def setUpClass(self): print ' SCHEMA '.center(70, '=') print '-' * 70 self.srv = TarantoolServer() self.srv.script = 'tests/suites/box.lua' self.srv.start() self.con = tarantool.Connection('localhost', self.srv.args['primary']) self.sch = self.con.schema
def __init__(self, suite_path, args): """Initialize a test suite: check that it exists and contains a syntactically correct configuration file. Then create a test instance for each found test.""" 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: raise RuntimeError("Suite %s doesn't exist" % repr(suite_path)) # read the suite config config = ConfigParser.ConfigParser() config.read(os.path.join(suite_path, "suite.ini")) self.ini.update(dict(config.items("default"))) self.ini.update(self.args.__dict__) self.multi_run = self.get_multirun_conf(suite_path) if self.args.stress is None and self.ini['core'] == 'stress': return for i in ["script"]: self.ini[i] = os.path.join(suite_path, self.ini[i]) if i in self.ini else None for i in ["disabled", "valgrind_disabled", "release_disabled"]: self.ini[i] = dict.fromkeys( self.ini[i].split()) if i in self.ini else dict() for i in ["lua_libs"]: self.ini[i] = map( lambda x: os.path.join(suite_path, x), dict.fromkeys(self.ini[i].split()) if i in self.ini else dict()) try: if self.ini['core'] in ['tarantool', 'stress']: self.server = TarantoolServer(self.ini) else: self.server = Server(self.ini) self.ini["server"] = self.server except Exception as e: print e raise RuntimeError("Unknown server: core = {0}".format( self.ini["core"])) color_stdout("Collecting tests in ", schema='ts_text') color_stdout(repr(suite_path), schema='path') color_stdout(": ", self.ini["description"], ".\n", schema='ts_text') self.server.find_tests(self, suite_path) color_stdout("Found ", str(len(self.tests)), " tests.\n", schema='path')
def setUpClass(self): print ' DML '.center(70, '=') print '-' * 70 self.srv = TarantoolServer() self.srv.script = 'tests/suites/box.lua' self.srv.start() self.con = tarantool.Connection('localhost', self.srv.args['primary']) self.adm = self.srv.admin self.space_created = self.adm("box.schema.create_space('space_1')") self.adm("box.space['space_1']:create_index('primary', {type = 'tree', parts = {1, 'num'}, unique = true})") self.adm("box.space['space_1']:create_index('secondary', {type = 'tree', parts = {2, 'num', 3, 'str'}, unique = true})") self.adm("json = require('json')") self.adm("fiber = require('fiber')") self.adm("uuid = require('uuid')")
def __init__(self, suite_path, args): self.args = args self.tests = [] self.suite_path = suite_path self.ini = { 'core': 'tarantool', 'script': os.path.join(suite_path, 'parallel.lua'), } # read suite config config = ConfigParser.ConfigParser() config.read(os.path.join(suite_path, "suite.ini")) self.ini.update(dict(config.items("default"))) self.ini.update(self.args.__dict__) self.jobs = int(self.ini.get('jobs', 1)) self.count = int(self.ini.get('count', 0)) for i in ["script"]: self.ini[i] = os.path.join(suite_path, self.ini[i]) if i in self.ini else None self.server = TarantoolServer(self.ini) self.pool = None self.iterator = None
def main(): path = os.path.dirname(sys.argv[0]) if not path: path = '.' os.chdir(path) if '--prepare' in sys.argv: prepare_env() exit(0) srv = None srv = TarantoolServer() srv.script = 'test/shared/box.lua' srv.start() test_dir_path = os.path.abspath(os.path.join(os.getcwd(), 'test')) test_cwd = os.path.dirname(srv.vardir) test_lib_path = "" try: shutil.copy('test/shared/phpunit.xml', test_cwd) cmd = '' test_lib_path = os.path.join(test_dir_path, 'phpunit.phar') shutil.copy('test/shared/tarantool.ini', test_cwd) shutil.copy('modules/tarantool.so', test_cwd) if '--flags' in sys.argv: os.environ['ZEND_DONT_UNLOAD_MODULES'] = '1' os.environ['USE_ZEND_ALLOC'] = '0' os.environ['MALLOC_CHECK_'] = '1' if '--valgrind' in sys.argv: cmd = cmd + 'valgrind --leak-check=full --log-file=php.out ' cmd = cmd + '--suppressions=test/shared/valgrind.sup ' cmd = cmd + '--keep-stacktraces=alloc-and-free --freelist-vol=2000000000 ' cmd = cmd + '--malloc-fill=0 --free-fill=0 ' cmd = cmd + '--num-callers=50 ' + find_php_bin() cmd = cmd + ' -c tarantool.ini {0}'.format(test_lib_path) elif '--gdb' in sys.argv: cmd = cmd + 'gdb {0} --ex '.format(find_php_bin()) cmd = cmd + '"set args -c tarantool.ini {0}"'.format(test_lib_path) elif '--strace' in sys.argv: cmd = cmd + 'strace ' + find_php_bin() cmd = cmd + ' -c tarantool.ini {0}'.format(test_lib_path) else: print find_php_bin() cmd = '{0} -c tarantool.ini {1}'.format(find_php_bin(), test_lib_path) print cmd print('Running ' + repr(cmd)) version = read_popen('php-config --version').strip(' \n\t') + '.' version1 = read_popen('php-config --extension-dir').strip(' \n\t') version += '\n' + ('With' if version1.find('non-zts') == -1 else 'Without') + ' ZTS' version += '\n' + ('With' if version1.find('no-debug') == -1 else 'Without') + ' Debug' print('Running against ' + version) proc = subprocess.Popen(cmd, shell=True, cwd=test_cwd) proc.wait() finally: a = [ os.path.join(test_cwd, 'tarantool.ini'), os.path.join(test_cwd, 'phpunit.xml'), os.path.join(test_cwd, 'tarantool.so'), ] for elem in a: if os.path.exists(elem): os.remove(elem)
from __future__ import print_function import os import sys import re import yaml from lib.tarantool_server import TarantoolServer server = TarantoolServer(server.ini) server.script = "long_run-py/lua/finalizers.lua" server.vardir = os.path.join(server.vardir, "finalizers") server.crash_expected = True try: server.deploy() except: print("Expected error:", sys.exc_info()[0]) else: print("Error! exception did not occur")
# Cleanup server.stop() server.script = script server.deploy() print '-------------------------------------------------------------' print 'Start a new replica and check box.info on the start' print '-------------------------------------------------------------' # master server master = server master_id = master.get_param('server')['id'] master.admin("box.schema.user.grant('guest', 'replication')") replica = TarantoolServer(server.ini) replica.script = 'replication-py/replica.lua' replica.vardir = server.vardir replica.rpl_master = master replica.deploy() replica.wait_lsn(master_id, master.get_lsn(master_id)) replica_id = replica.get_param('server')['id'] replica_uuid = replica.get_param('server')['uuid'] sys.stdout.push_filter(replica_uuid, '<replica uuid>') replica.admin('box.info.server.id == %d' % replica_id) replica.admin('not box.info.server.ro') replica.admin('box.info.server.lsn == 0') replica.admin('box.info.vclock[%d] == 0' % replica_id) print '-------------------------------------------------------------'
master.admin("box.schema.user.grant('guest', 'replication')") master.admin( "space = box.schema.space.create('test', { id = 99999, engine = \"sophia\" })" ) master.admin("index = space:create_index('primary', { type = 'tree'})") master.admin('for k = 1, 123 do space:insert{k, k*k} end') master.admin('box.snapshot()') lsn = master.get_lsn(master_id) print '-------------------------------------------------------------' print 'replica JOIN' print '-------------------------------------------------------------' # replica server replica = TarantoolServer(server.ini) replica.script = 'replication/replica.lua' replica.vardir = server.vardir #os.path.join(server.vardir,'replica') replica.rpl_master = master replica.deploy() replica.wait_lsn(master_id, lsn) replica.admin('box.space.test:select()') replica.stop() replica.cleanup(True) # remove space master.admin("space:drop()") master.admin('box.snapshot()') master.admin("ffi = require('ffi')") master.admin("ffi.cdef(\"int sophia_schedule(void);\")")
import sys import time 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
# 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):