def module_init(): """ Called at import """ args = Options().args # Change the current working directory to where all test # collections are supposed to reside # If script executed with (python test-run.py) dirname is '' # so we need to make it . path = os.path.dirname(sys.argv[0]) if not path: path = '.' os.chdir(path) setenv() warn_unix_sockets_at_start(args.vardir) # always run with clean (non-existent) 'var' directory try: shutil.rmtree(args.vardir) except OSError: pass args.builddir = os.path.abspath(os.path.expanduser(args.builddir)) SOURCEDIR = os.path.dirname(os.getcwd()) BUILDDIR = args.builddir os.environ["SOURCEDIR"] = SOURCEDIR os.environ["BUILDDIR"] = BUILDDIR soext = sys.platform == 'darwin' and 'dylib' or 'so' os.environ["LUA_PATH"] = SOURCEDIR+"/?.lua;"+SOURCEDIR+"/?/init.lua;;" os.environ["LUA_CPATH"] = BUILDDIR+"/?."+soext+";;" TarantoolServer.find_exe(args.builddir) UnittestServer.find_exe(args.builddir)
def module_init(): """ Called at import """ args = Options().args # Change the current working directory to where all test # collections are supposed to reside # If script executed with (python test-run.py) dirname is '' # so we need to make it . path = os.path.dirname(sys.argv[0]) if not path: path = '.' os.chdir(path) setenv() warn_unix_sockets_at_start(args.vardir) # always run with clean (non-existent) 'var' directory try: shutil.rmtree(args.vardir) except OSError: pass args.builddir = os.path.abspath(os.path.expanduser(args.builddir)) SOURCEDIR = os.path.dirname(os.getcwd()) BUILDDIR = args.builddir os.environ["SOURCEDIR"] = SOURCEDIR os.environ["BUILDDIR"] = BUILDDIR soext = sys.platform == 'darwin' and 'dylib' or 'so' os.environ[ "LUA_PATH"] = SOURCEDIR + "/?.lua;" + SOURCEDIR + "/?/init.lua;;" os.environ["LUA_CPATH"] = BUILDDIR + "/?." + soext + ";;" TarantoolServer.find_exe(args.builddir) UnittestServer.find_exe(args.builddir)
def main(): options = Options() oldcwd = os.getcwd() # Change the current working directory to where all test # collections are supposed to reside # If script executed with (python test-run.py) dirname is '' # so we need to make it . path = os.path.dirname(sys.argv[0]) if not path: path = '.' os.chdir(path) setenv() failed_tests = [] try: TarantoolServer.find_exe(options.args.builddir) UnittestServer.find_exe(options.args.builddir) color_stdout("Started {0}\n".format(" ".join(sys.argv)), schema='tr_text') suite_names = options.args.suites if suite_names == []: for root, dirs, names in os.walk(os.getcwd()): if "suite.ini" in names: suite_names.append(os.path.basename(root)) if options.args.stress is None: suites = [TestSuite(suite_name, options.args) for suite_name in sorted(suite_names)] for suite in suites: failed_tests.extend(suite.run_all()) else: suite_names = [suite_name for suite_name in suite_names if suite_name.find(options.args.stress) != -1] suites = [Supervisor(suite_name, options.args) for suite_name in sorted(suite_names)] for suite in suites: suite.run_all() except RuntimeError as e: color_stdout("\nFatal error: %s. Execution aborted.\n" % e, schema='error') if options.args.gdb: time.sleep(100) return (-1) finally: os.chdir(oldcwd) if failed_tests and options.args.is_force: color_stdout("\n===== %d tests failed:\n" % len(failed_tests), schema='error') for test in failed_tests: color_stdout("----- %s\n" % test, schema='info') return (-1 if failed_tests else 0)
def main(): options = Options() oldcwd = os.getcwd() # Change the current working directory to where all test # collections are supposed to reside # If script executed with (python test-run.py) dirname is '' # so we need to make it . path = os.path.dirname(sys.argv[0]) if not path: path = '.' os.chdir(path) setenv() failed_tests = [] try: color_stdout("Started {}\n".format(" ".join(sys.argv)), schema='tr_text') suite_names = [] if options.args.suites != []: suite_names = options.args.suites else: for root, dirs, names in os.walk(os.getcwd()): if "suite.ini" in names: suite_names.append(os.path.basename(root)) suites = [TestSuite(suite_name, options.args) for suite_name in sorted(suite_names)] TarantoolServer.find_exe(options.args.builddir) UnittestServer.find_exe(options.args.builddir) for suite in suites: failed_tests.extend(suite.run_all()) except RuntimeError as e: color_stdout("\nFatal error: {0}. Execution aborted.\n".format(e), schema='error') if options.args.gdb: time.sleep(100) return (-1) finally: os.chdir(oldcwd) if failed_tests and options.args.is_force: color_stdout("\n===== {0} tests failed:".format(len(failed_tests))+"\n", schema='error') for test in failed_tests: color_stdout("----- "+test+"\n", schema='info') return (-1 if failed_tests else 0)
def module_init(): """ Called at import """ args = Options().args # Change the current working directory to where all test # collections are supposed to reside # If script executed with (python test-run.py) dirname is '' # so we need to make it . path = os.path.dirname(sys.argv[0]) if not path: path = '.' os.chdir(path) setenv() # Keep the PWD environment variable in sync with a current # working directory. It does not strictly necessary, just to # avoid any confusion. os.environ['PWD'] = os.getcwd() warn_unix_sockets_at_start(args.vardir) # always run with clean (non-existent) 'var' directory try: shutil.rmtree(args.vardir) except OSError: pass args.builddir = os.path.abspath(os.path.expanduser(args.builddir)) SOURCEDIR = os.path.dirname(os.getcwd()) BUILDDIR = args.builddir os.environ["SOURCEDIR"] = SOURCEDIR os.environ["BUILDDIR"] = BUILDDIR soext = sys.platform == 'darwin' and 'dylib' or 'so' os.environ[ "LUA_PATH"] = SOURCEDIR + "/?.lua;" + SOURCEDIR + "/?/init.lua;;" os.environ["LUA_CPATH"] = BUILDDIR + "/?." + soext + ";;" os.environ["REPLICATION_SYNC_TIMEOUT"] = str(args.replication_sync_timeout) os.environ['MEMTX_ALLOCATOR'] = args.memtx_allocator TarantoolServer.find_exe(args.builddir) UnittestServer.find_exe(args.builddir) AppServer.find_exe(args.builddir) Options().check_schema_upgrade_option(TarantoolServer.debug)
# encoding: utf-8 import os import time from lib.tarantool_server import TarantoolServer # master server master = server master_sql = master.sql # hot standby server hot_standby = TarantoolServer() hot_standby.deploy("replication/cfg/hot_standby.cfg", hot_standby.find_exe(self.args.builddir), os.path.join(self.args.vardir, "hot_standby"), need_init=False) hot_standby_sql = hot_standby.sql # replica server replica = TarantoolServer() replica.deploy("replication/cfg/replica.cfg", replica.find_exe(self.args.builddir), os.path.join(self.args.vardir, "replica")) replica_sql = replica.sql # Begin tuple id id = 1 print """ # Insert 10 tuples to master """ for i in range(id, id + 10):
import yaml from lib.memcached_connection import MemcachedConnection from lib.tarantool_server import TarantoolServer sonet = """The expense of spirit in a waste of shame Is lust in action; and till action, lust""".split('\n') master = server master_memcached = master.memcached replica = TarantoolServer() replica.deploy("replication/cfg/replica.cfg", replica.find_exe(self.args.builddir), os.path.join(self.args.vardir, "replica")) replica_memcached = replica.memcached ################################### def get_lsn(serv): serv_admin = serv.admin resp = serv_admin("box.info.lsn", silent=True) return yaml.load(resp)[0] def wait(serv_master = master, serv_replica = replica): lsn = get_lsn(serv_master) serv_replica.wait_lsn(lsn) return lsn def get_memcached_len(serv):