From e654a7c2a33ff0e89c10ec9f18717908dd6b73ab Mon Sep 17 00:00:00 2001 From: Konstantin Osipov <kostja@tarantool.org> Date: Sat, 31 Aug 2013 01:27:12 +0400 Subject: [PATCH] Convert snapshot.test to the new format. --- test/box/snapshot.result | 27 ++++++++++++++++++--------- test/box/snapshot.test.py | 22 ++++++++++++---------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/test/box/snapshot.result b/test/box/snapshot.result index 08cb03f6ef..6d6114c50b 100644 --- a/test/box/snapshot.result +++ b/test/box/snapshot.result @@ -1,26 +1,34 @@ +box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum') +--- +- [0, 0, 'tweedledum'] +... +box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') +--- +- [0, 0, 'primary', 1752392040, 1, 1, 0, 'num'] +... # # A test case for: http://bugs.launchpad.net/bugs/686411 -# Check that 'save snapshot' does not overwrite a snapshot +# Check that 'box.snapshot()' does not overwrite a snapshot # file that already exists. Verify also that any other # error that happens when saving snapshot is propagated # to the caller. insert into t0 values (1, 'first tuple') Insert OK, 1 row affected -save snapshot +box.snapshot() --- -ok +- ok ... -save snapshot +box.snapshot() --- -fail: can't save snapshot, errno 17 (File exists) +- error: can't save snapshot, errno 17 (File exists) ... insert into t0 values (2, 'second tuple') Insert OK, 1 row affected # Make 'var' directory read-only. -save snapshot +box.snapshot() --- -fail: can't save snapshot, errno 13 (Permission denied) +- error: can't save snapshot, errno 13 (Permission denied) ... delete from t0 where k0 = 1 Delete OK, 1 row affected @@ -36,5 +44,6 @@ Delete OK, 1 row affected insert into t0 values (1, 'Test tuple') Insert OK, 1 row affected Snapshot exists. -delete from t0 where k0=1 -Delete OK, 1 row affected +box.space[0]:drop() +--- +... diff --git a/test/box/snapshot.test.py b/test/box/snapshot.test.py index 0be0b92a06..4e2d02db3b 100644 --- a/test/box/snapshot.test.py +++ b/test/box/snapshot.test.py @@ -3,22 +3,25 @@ import yaml import time from signal import SIGUSR1 +admin("box.insert(box.schema.SPACE_ID, 0, 0, 'tweedledum')") +admin("box.insert(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num')") + print """# # A test case for: http://bugs.launchpad.net/bugs/686411 -# Check that 'save snapshot' does not overwrite a snapshot +# Check that 'box.snapshot()' does not overwrite a snapshot # file that already exists. Verify also that any other # error that happens when saving snapshot is propagated # to the caller. """ sql("insert into t0 values (1, 'first tuple')") -admin("save snapshot") +admin("box.snapshot()") # In absence of data modifications, two consecutive -# 'save snapshot' statements will try to write +# 'box.snapshot()' statements will try to write # into the same file, since file name is based # on LSN. # Don't allow to overwrite snapshots. -admin("save snapshot") +admin("box.snapshot()") # # Increment LSN sql("insert into t0 values (2, 'second tuple')") @@ -26,7 +29,7 @@ sql("insert into t0 values (2, 'second tuple')") # Check for other errors, e.g. "Permission denied". print "# Make 'var' directory read-only." os.chmod(vardir, 0555) -admin("save snapshot") +admin("box.snapshot()") # cleanup os.chmod(vardir, 0755) @@ -44,11 +47,10 @@ print """ sql("insert into t0 values (1, 'Test tuple')") -result = admin("show info", silent=True) -info = yaml.load(result)["info"] +pid = int(yaml.load(admin("box.info.pid", silent=True))[0]) +lsn = yaml.load(admin("box.info.lsn", silent=True))[0] -pid = info["pid"] -snapshot = str(info["lsn"]).zfill(20) + ".snap" +snapshot = str(lsn).zfill(20) + ".snap" snapshot = os.path.join(vardir, snapshot) iteration = 0 @@ -66,6 +68,6 @@ if iteration == 0 or iteration >= MAX_ITERATIONS: else: print "Snapshot exists." -sql("delete from t0 where k0=1") +admin("box.space[0]:drop()") # vim: syntax=python spell -- GitLab