[Tarantool-patches] [PATCH] Add option to specify snapshot version

Sergey Bronnikov sergeyb at tarantool.org
Mon Mar 23 11:45:13 MSK 2020


GitHub branch: https://github.com/tarantool/test-run/tree/ligurio/gh-4801-add-snapshot-option

Ticket: #4801
---
 lib/options.py          | 7 +++++++
 lib/tarantool_server.py | 9 +++++++++
 2 files changed, 16 insertions(+)

diff --git a/lib/options.py b/lib/options.py
index 8bacb4a..cce3835 100644
--- a/lib/options.py
+++ b/lib/options.py
@@ -201,6 +201,13 @@ class Options:
                 help="""Run the server under 'luacov'.
                 Default: false.""")
 
+        parser.add_argument(
+                "--snapshot-version",
+                dest='snapshot_version',
+                default=None,
+                help="""Version of Tarantool snapshot loaded before
+                testing.""")
+
         # XXX: We can use parser.parse_intermixed_args() on
         # Python 3.7 to understand commands like
         # ./test-run.py foo --exclude bar baz
diff --git a/lib/tarantool_server.py b/lib/tarantool_server.py
index fd102b9..09aee9c 100644
--- a/lib/tarantool_server.py
+++ b/lib/tarantool_server.py
@@ -32,6 +32,7 @@ from lib.utils import format_process
 from lib.utils import signame
 from lib.utils import warn_unix_socket
 from lib.utils import prefix_each_line
+from lib.options import Options
 from test import TestRunGreenlet, TestExecutionError
 
 
@@ -767,6 +768,14 @@ class TarantoolServer(Server):
                     if (e.errno == errno.ENOENT):
                         continue
                     raise
+
+        snapshot_basename = Options().args.snapshot_version
+        if snapshot_basename:
+            snapshot_name = '{}.snap'.format(snapshot_basename)
+            snapshot_path = os.path.join(self.testdir, 'static/snapshots', snapshot_name)
+            color_log("Copy snapshot: {}".format(snapshot_name))
+            os.mkdir(os.path.join(self.vardir, 'box'))
+            shutil.copy(snapshot_path, os.path.join(self.vardir, 'box/00000000000000000001.snap'))
         shutil.copy('.tarantoolctl', self.vardir)
         shutil.copy(os.path.join(self.TEST_RUN_DIR, 'test_run.lua'),
                     self.vardir)
-- 
2.23.0


-- 
sergeyb@


More information about the Tarantool-patches mailing list