diff --git a/test/box/bad_trigger.result b/test/box/bad_trigger.result index c2001b19334fa31545d6ec3d299917e272b4ab5b..2cbea1b12f7dbce2dd4ffdee9918376813c49467 100644 --- a/test/box/bad_trigger.result +++ b/test/box/bad_trigger.result @@ -1,11 +1,14 @@ + # # if on_connect() trigger raises an exception, the connection is dropped # + type(box.session.on_connect(function() nosuchfunction() end)) --- - nil ... -disconnected +Exception raised + type(box.session.on_connect(nil)) --- - function diff --git a/test/box/bad_trigger.test.py b/test/box/bad_trigger.test.py index 714659a8fa4dcab64756234b16724778ef67b6ed..3e6f851caed34f9bd7dbb7ed84746b82609ba1c8 100644 --- a/test/box/bad_trigger.test.py +++ b/test/box/bad_trigger.test.py @@ -1,7 +1,9 @@ from lib.box_connection import BoxConnection -print """ # +print """ + # # if on_connect() trigger raises an exception, the connection is dropped - # """ + # + """ admin("type(box.session.on_connect(function() nosuchfunction() end))") con1 = BoxConnection('localhost', server.primary_port) @@ -9,7 +11,7 @@ try: con1.execute("select * from t0 where k0=0") con1.execute("select * from t0 where k0=0") except Exception as e: - print "disconnected" + print "Exception raised\n" # Clean-up admin("type(box.session.on_connect(nil))") diff --git a/test/box/configuration.test.py b/test/box/configuration.test.py index a7688d2fc7014f2e85bb5dbe24e0a45f80e7dd9e..c7335d399700e974ff46f42707e35cb09b23e329 100644 --- a/test/box/configuration.test.py +++ b/test/box/configuration.test.py @@ -1,6 +1,3 @@ -# encoding: utf-8 -# - import os import sys import shutil @@ -27,12 +24,9 @@ server.stop() server.deploy("box/tarantool_scriptdir.cfg") admin("print_config()") - # restore default server server.stop() shutil.rmtree(script_dir_path, True) server.deploy(self.suite_ini["config"]) sys.stdout.pop_filter() - -# vim: syntax=python diff --git a/test/box/session.result b/test/box/session.result index f9f2ec25ba2fa0bd96ad8a9f983c2d875b6704b4..f8cb1a0206901a92963e8181f8444d71df1641aa 100644 --- a/test/box/session.result +++ b/test/box/session.result @@ -61,7 +61,7 @@ box.session.on_disconnect(function() end) --- - null ... --- check it''s possible to reset these triggers +-- check it's possible to reset these triggers type(box.session.on_connect(function() error('hear') end)) --- - function @@ -138,23 +138,22 @@ box.session.on_disconnect(dec) active_connections = 0 --- ... -default con1 ---# create connection con1 to default ---# set connection con1 +--# create connection con_one to default active_connections --- - 1 ... -default con2 ---# create connection con2 to default ---# set connection con2 +--# create connection con_two to default active_connections --- - 2 ... ---# drop connection con1 ---# drop connection con2 ---# set connection default +--# drop connection con_one +--# drop connection con_two +active_connections +--- +- 0 +... type(box.session.on_connect(nil)) --- - function @@ -172,14 +171,14 @@ box.session.on_disconnect(function() box.delete(0, box.session.id()) end) --- - null ... -default con3 ---# create connection con3 to default ---# set connection con3 +--# create connection con_three to default +--# set connection con_three box.unpack('i', box.select(0, 0, box.session.id())[0]) == box.session.id() --- - true ... ---# drop connection con3 +--# set connection default +--# drop connection con_three -- cleanup type(box.session.on_connect(nil)) --- diff --git a/test/box/session.test.lua b/test/box/session.test.lua index d129e488aff5e643a1883442a62fd05427643c76..a61cc3d0a2963aac84fde3062e5641a2085e42c7 100644 --- a/test/box/session.test.lua +++ b/test/box/session.test.lua @@ -20,7 +20,7 @@ box.session.peer() == box.session.peer(box.session.id()) box.session.on_connect(function() end) box.session.on_disconnect(function() end) --- check it''s possible to reset these triggers +-- check it's possible to reset these triggers type(box.session.on_connect(function() error('hear') end)) type(box.session.on_disconnect(function() error('hear') end)) @@ -49,16 +49,14 @@ function dec() active_connections = active_connections - 1 end box.session.on_connect(inc) box.session.on_disconnect(dec) active_connections = 0 ---# create connection con1 to default ---# set connection con1 +--# create connection con_one to default active_connections ---# create connection con2 to default ---# set connection con2 +--# create connection con_two to default +active_connections +--# drop connection con_one +--# drop connection con_two active_connections ---# drop connection con1 ---# drop connection con2 ---# set connection default type(box.session.on_connect(nil)) type(box.session.on_disconnect(nil)) @@ -66,10 +64,11 @@ type(box.session.on_disconnect(nil)) box.session.on_connect(function() box.insert(0, box.session.id()) end) box.session.on_disconnect(function() box.delete(0, box.session.id()) end) ---# create connection con3 to default ---# set connection con3 +--# create connection con_three to default +--# set connection con_three box.unpack('i', box.select(0, 0, box.session.id())[0]) == box.session.id() ---# drop connection con3 +--# set connection default +--# drop connection con_three -- cleanup type(box.session.on_connect(nil)) diff --git a/test/lib/tarantool_server.py b/test/lib/tarantool_server.py index fdb92d7c966060e085c09f5356a54f3886a56d39..1761ee7320967549ec60f5831d2241919ef6b5f4 100644 --- a/test/lib/tarantool_server.py +++ b/test/lib/tarantool_server.py @@ -132,7 +132,7 @@ class LuaTest(FuncTest): elif matched2.group(1) == 'deploy': name = matched2.group(2) if name in self.suite_ini['servers']: - self.suite_ini['servers'][name].deploy() + self.suite_ini['servers'][name].deploy(silent=True) else: raise LuaPreprocessorException("Wrong server name: " + name) elif matched2.group(1) == 'reconfigure': @@ -171,10 +171,10 @@ class LuaTest(FuncTest): if matched3.group(1) == 'create': namecon, name = re.match("(.*)\s+to\s+(.*)", matched3.group(2)).groups() self.suite_ini['connections'][namecon] = AdminConnection('localhost', self.suite_ini['servers'][name].port) - print name, namecon + self.suite_ini['connections'][namecon].connect() elif matched3.group(1) == 'drop': name = matched3.group(2) - if name in self.suite_ini['connections'] and not self.suite_ini['connections'] is curcon: + if name in self.suite_ini['connections']: self.suite_ini['connections'][name].disconnect() self.suite_ini['connections'].pop(name) else: @@ -271,7 +271,8 @@ class TarantoolServer(Server): '*.inprogress', '*.cfg', '*.sup', - '*.lua'] + '*.lua', + '*.pid'] self.process = None self.config = None self.vardir = None diff --git a/test/lib/test_suite.py b/test/lib/test_suite.py index 73e2245adaae1e5e6b39f32a6ba2334e1a1c6dc7..62282d91fdf46f1e2072a78a06acaf735c565d50 100644 --- a/test/lib/test_suite.py +++ b/test/lib/test_suite.py @@ -215,7 +215,7 @@ class TestSuite: self.args = args self.tests = [] self.ini = {} - + self.suite_path = suite_path self.ini["core"] = "tarantool" if os.access(suite_path, os.F_OK) == False: @@ -280,33 +280,34 @@ class TestSuite: print "TEST".ljust(48), "RESULT" print shortsep failed_tests = [] + try: + for test in self.tests: + sys.stdout.write(test.name.ljust(48)) + # for better diagnostics in case of a long-running test + sys.stdout.flush() + + test_name = os.path.basename(test.name) + + if (test_name in self.ini["disabled"] + or not self.server.debug and test_name in self.ini["release_disabled"] + or self.args.valgrind and test_name in self.ini["valgrind_disabled"]): + print "[ disabled ]" + else: + test.run(self.server) + if not test.passed(): + failed_tests.append(test.name) + finally: + print '\n', shortsep + self.server.stop(silent=False) + self.server.cleanup() - for test in self.tests: - sys.stdout.write(test.name.ljust(48)) - # for better diagnostics in case of a long-running test - sys.stdout.flush() - - test_name = os.path.basename(test.name) - - if (test_name in self.ini["disabled"] - or not self.server.debug and test_name in self.ini["release_disabled"] - or self.args.valgrind and test_name in self.ini["valgrind_disabled"]): - print "[ disabled ]" - else: - test.run(self.server) - if not test.passed(): - failed_tests.append(test.name) - - print shortsep if failed_tests: print "Failed {0} tests: {1}.".format(len(failed_tests), ", ".join(failed_tests)) - self.server.stop(silent=False) - self.server.cleanup() if self.args.valgrind and check_valgrind_log(self.server.valgrind_log): print " Error! There were warnings/errors in valgrind log file:" print_tail_n(self.server.valgrind_log, 20) - return 1 - return len(failed_tests) + return ['valgrind error in ' + self.suite_path] + return failed_tests diff --git a/test/replication/consistent.result b/test/replication/consistent.result index ffc30b8bfef7549e038f55f4202cb1514268eb02..d70a9d1e5c69a3fefc318d35867db0e5ab7af6f5 100644 --- a/test/replication/consistent.result +++ b/test/replication/consistent.result @@ -20,9 +20,12 @@ function _insert(_begin, _end, msg) end; --- ... +begin_lsn = box.info.lsn; +--- +... function _select(_begin, _end) a = {} - while box.info.lsn < _end + 3 do + while box.info.lsn < begin_lsn + _end do box.fiber.sleep(0.001) end for i = _begin, _end do diff --git a/test/replication/consistent.test.lua b/test/replication/consistent.test.lua index 75e4db9ad002cc45de5300dcd37a0432502ffee3..bca123f762b72f00e582065be3e98f4e13486c3d 100644 --- a/test/replication/consistent.test.lua +++ b/test/replication/consistent.test.lua @@ -14,9 +14,11 @@ function _insert(_begin, _end, msg) return unpack(a) end; +begin_lsn = box.info.lsn; + function _select(_begin, _end) a = {} - while box.info.lsn < _end + 3 do + while box.info.lsn < begin_lsn + _end do box.fiber.sleep(0.001) end for i = _begin, _end do diff --git a/test/replication/hot_standby.result b/test/replication/hot_standby.result index d522395ba3b01fc2f14694dcd17a731253cff4c1..b6d1767f74304dc3a0a710505794fed9a9f47465 100644 --- a/test/replication/hot_standby.result +++ b/test/replication/hot_standby.result @@ -2,14 +2,6 @@ --# create server replica with configuration='replication/cfg/replica.cfg' --# start server hot_standby --# start server replica -box.replace(box.schema.SPACE_ID, 0, 0, 'tweedledum') ---- -- [0, 0, 'tweedledum'] -... -box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') ---- -- [0, 0, 'primary', 1752392040, 1, 1, 0, 'num'] -... --# setopt delimiter ';' --# set connection default, hot_standby, replica function _insert(_begin, _end) @@ -30,15 +22,27 @@ function _select(_begin, _end) end; --- ... -function _wait_lsn(_lsn) - while box.info.lsn < _lsn do +begin_lsn = box.info.lsn; +--- +... +function _wait_lsn(_lsnd) + while box.info.lsn < _lsnd + begin_lsn do box.fiber.sleep(0.001) end + begin_lsn = begin_lsn + _lsnd end; --- ... --# setopt delimiter '' --# set connection default +box.replace(box.schema.SPACE_ID, 0, 0, 'tweedledum') +--- +- [0, 0, 'tweedledum'] +... +box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') +--- +- [0, 0, 'primary', 1752392040, 1, 1, 0, 'num'] +... _insert(1, 10) --- - [1, 'the tuple 1'] @@ -66,7 +70,7 @@ _select(1, 10) - [10, 'the tuple 10'] ... --# set connection replica -_wait_lsn(13) +_wait_lsn(12) --- ... _select(1, 10) @@ -122,10 +126,22 @@ _select(11, 20) - [20, 'the tuple 20'] ... --# set connection replica -_wait_lsn(23) +_wait_lsn(12) --- ... _select(11, 20) +--- +- [11, 'the tuple 11'] +- [12, 'the tuple 12'] +- [13, 'the tuple 13'] +- [14, 'the tuple 14'] +- [15, 'the tuple 15'] +- [16, 'the tuple 16'] +- [17, 'the tuple 17'] +- [18, 'the tuple 18'] +- [19, 'the tuple 19'] +- [20, 'the tuple 20'] +... --# stop server hot_standby --# stop server replica --# cleanup server hot_standby diff --git a/test/replication/hot_standby.test.lua b/test/replication/hot_standby.test.lua index 388879c340c90a3be5a4c5309c9956da4651759a..61cf50258bdf70a402116d5c6846978acaad7a4f 100644 --- a/test/replication/hot_standby.test.lua +++ b/test/replication/hot_standby.test.lua @@ -2,8 +2,6 @@ --# create server replica with configuration='replication/cfg/replica.cfg' --# start server hot_standby --# start server replica -box.replace(box.schema.SPACE_ID, 0, 0, 'tweedledum') -box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') --# setopt delimiter ';' --# set connection default, hot_standby, replica @@ -21,18 +19,23 @@ function _select(_begin, _end) end return unpack(a) end; -function _wait_lsn(_lsn) - while box.info.lsn < _lsn do +begin_lsn = box.info.lsn; +function _wait_lsn(_lsnd) + while box.info.lsn < _lsnd + begin_lsn do box.fiber.sleep(0.001) end + begin_lsn = begin_lsn + _lsnd end; --# setopt delimiter '' --# set connection default +box.replace(box.schema.SPACE_ID, 0, 0, 'tweedledum') +box.replace(box.schema.INDEX_ID, 0, 0, 'primary', 'hash', 1, 1, 0, 'num') + _insert(1, 10) _select(1, 10) --# set connection replica -_wait_lsn(13) +_wait_lsn(12) _select(1, 10) --# stop server default @@ -46,7 +49,7 @@ _insert(11, 20) _select(11, 20) --# set connection replica -_wait_lsn(23) +_wait_lsn(12) _select(11, 20) --# stop server hot_standby diff --git a/test/test-run.py b/test/test-run.py index b6f0961919573753d36824a3ff103420b39dadf5..f085dc32b4e1cf951c485bf7ad160f69bd1c9963 100755 --- a/test/test-run.py +++ b/test/test-run.py @@ -164,7 +164,7 @@ def main(): path = '.' os.chdir(path) - failed_tests = 0 + failed_tests = [] try: print "Started", " ".join(sys.argv) @@ -179,7 +179,7 @@ def main(): suites = [TestSuite(suite_name, options.args) for suite_name in sorted(suite_names)] for suite in suites: - failed_tests += suite.run_all() + failed_tests.extend(suite.run_all()) except RuntimeError as e: print "\nFatal error: {0}. Execution aborted.".format(e) if options.args.gdb: @@ -188,7 +188,12 @@ def main(): finally: os.chdir(oldcwd) - return -failed_tests + if failed_tests and options.args.is_force: + print '\n===== %d tests failed:' % len(failed_tests) + for test in failed_tests: + print "----- %s" % test + + return (-1 if failed_tests else 0) if __name__ == "__main__": exit(main())