Exemple #1
0
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)
Exemple #2
0
def main():
    path = os.path.dirname(sys.argv[0])
    if not path:
        path = '.'
    os.chdir(path)
    retval = True
    try:
        srv = TarantoolServer()
        srv.script = 'shared/box.lua'
        srv.start()
        test_cwd = os.path.dirname(srv.vardir)
        cmd = compile_cmd('tarantool-tcp')
        print('Running ' + repr(cmd))
        proc = subprocess.Popen(cmd, shell=True, cwd=test_cwd)
        if (proc.wait() != 0):
            retval = False
    except Exception as e:
        print e
        pass
    finally:
        pass

    try:
        srv = TarantoolServer(unix = True)
        srv.script = 'shared/box.lua'
        srv.start()
        test_cwd = os.path.dirname(srv.vardir)
        cmd = compile_cmd('tarantool-unix')
        print('Running ' + repr(cmd))
        proc = subprocess.Popen(cmd, shell=True, cwd=test_cwd)
        proc.wait()
        if (proc.wait() != 0):
            retval = False
    except Exception as e:
        print e
        pass
    finally:
        pass

    if (retval):
        print "Everything is OK"
    else:
        print "FAILED"

    return (-1 if not retval else 0)
Exemple #3
0
def main():
    path = os.path.dirname(sys.argv[0])
    if not path:
        path = '.'
    os.chdir(path)
    srv = None
    srv = TarantoolServer()
    srv.script = 'tests/shared/box.lua'
    srv.start()
    test_dir_path = os.path.abspath(os.path.join(os.getcwd(), 'tests'))
    test_cwd = os.path.dirname(srv.vardir)
    test_lib_path = ""
    try:
        shutil.copy('tests/shared/phpunit.xml', test_cwd)
        if 'global' in sys.argv:
            cmd = 'phpunit -v'
        else:
            test_lib_path = os.path.join(test_dir_path, 'phpunit.phar')
            shutil.copy('tests/shared/php.ini', test_cwd)
            shutil.copy('modules/tarantool.so', test_cwd)
            os.environ['PATH'] += os.pathsep + test_dir_path
            cmd = 'php -c php.ini {0}'.format(test_lib_path)
        print('Running ' + repr(cmd))
        version = read_popen('php-config --version').strip(' \n\t') + '.'
        version1 = read_popen('php-config --extension-dir').strip(' \n\t')
        version += ' ' + ('With' if version1.find('non-zts') == -1 else 'Without') + ' ZTS'
        version += ' ' + ('With' if version1.find('no-debug') == -1 else 'Without') + ' Debug'
        print('Running against ' + version)
        proc = subprocess.Popen(cmd, shell=True, cwd=test_cwd)
        cmd_stat = proc.wait()
        if (cmd_stat in [245, 139] and 'global' not in sys.argv):
            proc = subprocess.Popen(build_gdb_cmd(test_lib_path), shell=True, cwd=test_cwd)
    finally:
        del srv
        a = [
                os.path.join(test_cwd, 'php.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)
Exemple #4
0
def run_test(name, unix = False):
    retval = True

    try:
        srv = TarantoolServer(unix = unix)
        srv.script = 'shared/box.lua'
        srv.start()
        test_cwd = os.path.dirname(srv.vardir)
        cmd = compile_cmd(name)
        print('Running ' + repr(cmd))
        proc = subprocess.Popen(cmd, shell=True, cwd=test_cwd)
        if (proc.wait() != 0):
            retval = False
    except Exception as e:
        print e
        pass
    finally:
        pass

    return retval
Exemple #5
0
# 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/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 '-------------------------------------------------------------'
print 'Modify data to change LSN and check box.info'
Exemple #6
0
# Cleanup
server.stop()
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('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_id = replica.get_param('id')
replica_uuid = replica.get_param('uuid')
sys.stdout.push_filter(replica_uuid, '<replica uuid>')

replica.admin('box.info.id == %d' % replica_id)
replica.admin('not box.info.ro')
replica.admin('box.info.lsn == 0')
replica.admin('box.info.vclock[%d] == nil' % replica_id)

print '-------------------------------------------------------------'
print 'Modify data to bump LSN and check box.info'
print '-------------------------------------------------------------'
Exemple #7
0
# master server
master = server
master_id = master.get_param("id")
master.admin("box.schema.user.grant('guest', 'replication')")

print("-------------------------------------------------------------")
print("gh-484: JOIN doesn't save data to snapshot with TREE index")
print("-------------------------------------------------------------")

master.admin("space = box.schema.space.create('test', {id =  42})")
master.admin("index = space:create_index('primary', { type = 'tree'})")

master.admin("for k = 1, 9 do space:insert{k, k*k} end")

replica = TarantoolServer(server.ini)
replica.script = "replication-py/replica.lua"
replica.vardir = server.vardir
replica.rpl_master = master
replica.deploy()
replica.admin("box.space.test:select()")

replica.restart()
replica.admin("box.space.test:select()")
replica.stop()
replica.cleanup()

print("-------------------------------------------------------------")
print("replica test 2 (must be ok)")
print("-------------------------------------------------------------")

master.restart()
Exemple #8
0
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")
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);\")")
master.admin("ffi.C.sophia_schedule() >= 0")
Exemple #10
0
# master server
master = server
master.admin("fiber = require('fiber')")
master.admin("box.schema.user.grant('guest', 'replication')")
master.admin("box.schema.user.grant('guest', 'execute', 'universe')")

print '----------------------------------------------------------------------'
print 'Bootstrap replicas'
print '----------------------------------------------------------------------'

# Start replicas
master.id = master.get_param('id')
cluster = [master]
for i in range(REPLICA_N - 1):
    server = TarantoolServer(server.ini)
    server.script = 'replication-py/replica.lua'
    server.vardir = os.path.join(server.vardir, 'replica', str(master.id + i))
    server.rpl_master = master
    server.deploy()
    # Wait replica to fully bootstrap.
    # Otherwise can get ACCESS_DENIED error.
    cluster.append(server)

# Make a list of servers
sources = []
for server in cluster:
    sources.append(
        yaml.safe_load(server.admin('box.cfg.listen', silent=True))[0])
    server.id = server.get_param('id')

print 'done'
# master server
master = server
master_id = master.get_param('id')
master.admin("box.schema.user.grant('guest', 'replication')")

print '-------------------------------------------------------------'
print 'gh-484: JOIN doesn\'t save data to snapshot with TREE index'
print '-------------------------------------------------------------'

master.admin("space = box.schema.space.create('test', {id =  42})")
master.admin("index = space:create_index('primary', { type = 'tree'})")

master.admin('for k = 1, 9 do space:insert{k, k*k} end')

replica = TarantoolServer(server.ini)
replica.script = 'replication-py/replica.lua'
replica.vardir = server.vardir  #os.path.join(server.vardir, 'replica')
replica.rpl_master = master
replica.deploy()
replica.admin('box.space.test:select()')

replica.restart()
replica.admin('box.space.test:select()')
replica.stop()
replica.cleanup()

print '-------------------------------------------------------------'
print 'replica test 2 (must be ok)'
print '-------------------------------------------------------------'

master.restart()
Exemple #12
0
import os
import re
import time

from lib.tarantool_server import TarantoolServer

# master server
master = server
master.admin("box.schema.user.grant('guest', 'read,write,execute', 'universe')")

# replica server
replica = TarantoolServer()
replica.script = "replication/replica.lua"
replica.rpl_master = master
replica.vardir = os.path.join(master.vardir, 'replica')
replica.deploy()

replica.get_param('node')

cycles = 0
status = replica.admin.execute_no_reconnect("box.info.status", True)
while (re.search(r'replica/.*/(connecting|connected)\n', status) == None and cycles < 500):
    time.sleep(0.01)
    status = replica.admin.execute_no_reconnect("box.info.status", True)
    cycles += 1
print(re.search(r'replica/.*/(connecting|connected)\n', status) != None)

master.stop()
cycles = 0

while (re.search(r'replica/.*/(connecting|failed)\n', status) == None and cycles < 500):
Exemple #13
0
import os
import re
import time

from lib.tarantool_server import TarantoolServer

# master server
master = server
master.admin(
    "box.schema.user.grant('guest', 'read,write,execute', 'universe')")

# replica server
replica = TarantoolServer()
replica.script = "replication/replica.lua"
replica.rpl_master = master
replica.vardir = os.path.join(master.vardir, 'replica')
replica.deploy()

replica.get_param('node')

cycles = 0
status = replica.admin.execute_no_reconnect("box.info.status", True)
while (re.search(r'replica/.*/(connecting|connected)\n', status) == None
       and cycles < 500):
    time.sleep(0.01)
    status = replica.admin.execute_no_reconnect("box.info.status", True)
    cycles += 1
print(re.search(r'replica/.*/(connecting|connected)\n', status) != None)

master.stop()
cycles = 0
Exemple #14
0
# Cleanup
server.stop()
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("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_id = replica.get_param("id")
replica_uuid = replica.get_param("uuid")
sys.stdout.push_filter(replica_uuid, "<replica uuid>")

replica.admin("box.info.id == {}".format(replica_id))
replica.admin("not box.info.ro")
replica.admin("box.info.lsn == 0")
replica.admin("box.info.vclock[{}] == nil".format(replica_id))

print("-------------------------------------------------------------")
print("Modify data to bump LSN and check box.info")
print("-------------------------------------------------------------")
Exemple #15
0
# master server
master = server
# Re-deploy server to cleanup Sophia data
master.stop()
master.cleanup()
master.deploy()
master.admin("box.schema.user.create('%s', { password = '******'})" % (LOGIN, PASSWORD))
master.admin("box.schema.user.grant('%s', 'read,write,execute', 'universe')" % LOGIN)
master.iproto.py_con.authenticate(LOGIN, PASSWORD)
master.uri = '%s:%s@%s' % (LOGIN, PASSWORD, master.iproto.uri)
os.putenv('MASTER', master.uri)

# replica server
replica = TarantoolServer()
replica.script = "replication-py/replica.lua"
replica.vardir = server.vardir #os.path.join(server.vardir, 'replica')
replica.deploy()
replica.admin("while box.info.server.id == 0 do require('fiber').sleep(0.01) end")
replica.uri = '%s:%s@%s' % (LOGIN, PASSWORD, replica.iproto.uri)
replica.admin("while box.space['_priv']:len() < 1 do require('fiber').sleep(0.01) end")
replica.iproto.py_con.authenticate(LOGIN, PASSWORD)

for engine in engines:
    master.admin("s = box.schema.space.create('%s', { engine = '%s'})" % (engine, engine))
    master.admin("index = s:create_index('primary', {type = 'tree'})")

### gh-343: replica.cc must not add login and password to proc title
#status = replica.get_param("status")
#host_port = "%s:%s" % master.iproto.uri
#m = re.search(r'replica/(.*)/.*', status)
Exemple #16
0
import os
from glob import iglob as glob
from lib.tarantool_server import TarantoolServer

# 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 #os.path.join(server.vardir, 'replica')
replica.rpl_master = master
replica.deploy()
replica.wait_lsn(master_id, master.get_lsn(master_id))
replica_id = replica.get_param('server')['id']
replica.admin('box.info.server.id')
replica.admin('box.info.server.ro')
replica.admin('box.info.server.lsn')
replica.stop()

print '-------------------------------------------------------------'
print 'replica is read-only until receive self server_id in _cluster'
print '-------------------------------------------------------------'

# Remove xlog retrived by SUBSCRIBE
filename = str(0).zfill(20) + ".xlog"
wal = os.path.join(os.path.join(replica.vardir, replica.name), filename)
os.remove(wal)
Exemple #17
0
import os
from glob import iglob as glob
from lib.tarantool_server import TarantoolServer

# 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/replica.lua'
replica.vardir = server.vardir #os.path.join(server.vardir, 'replica')
replica.rpl_master = master
replica.deploy()
replica.wait_lsn(master_id, master.get_lsn(master_id))
replica_id = replica.get_param('server')['id']
replica.admin('box.info.server.id')
replica.admin('box.info.server.ro')
replica.admin('box.info.server.lsn')
replica.stop()

print '-------------------------------------------------------------'
print 'replica is read-only until receive self server_id in _cluster'
print '-------------------------------------------------------------'

# Remove xlog retrived by SUBSCRIBE
filename = str(0).zfill(20) + ".xlog"
wal = os.path.join(os.path.join(replica.vardir, replica.name), filename)
os.remove(wal)
Exemple #18
0
# Cleanup
server.stop()
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('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_id = replica.get_param('id')
replica_uuid = replica.get_param('uuid')
sys.stdout.push_filter(replica_uuid, '<replica uuid>')

replica.admin('box.info.id == %d' % replica_id)
replica.admin('not box.info.ro')
replica.admin('box.info.lsn == 0')
replica.admin('box.info.vclock[%d] == nil' % replica_id)

print '-------------------------------------------------------------'
print 'Modify data to bump LSN and check box.info'
print '-------------------------------------------------------------'
Exemple #19
0
def check_connection(con):
    try:
        s = con.space('test')
        print(s.select())
    except NetworkError:
        print('NetworkError !')
    except Exception as e:
        print(e)


# Start instances
master = server
cluster = [master]
for i in range(INSTANCE_N):
    server = TarantoolServer(server.ini)
    server.script = 'cluster-py/instance%d.lua' % (i+1)
    server.vardir = os.path.join(server.vardir, 'instance', str(i))
    server.deploy()
    server.admin("box.schema.user.grant('guest', 'read,write,execute', 'universe')")
    server.admin("_ = box.schema.space.create('test')")
    server.admin("_ = box.space.test:create_index('primary')")
    server.admin("box.space.test:insert{%d, %s}" % (1, i), silent = True)
    cluster.append(server)

# Make a list of servers
sources = []
for server in cluster[1:]:
    sources.append(yaml.safe_load(server.admin('box.cfg.listen', silent=True))[0])

addrs = []
for addr in sources:
Exemple #20
0
master = server
master.admin("fiber = require('fiber')")
master.admin("box.schema.user.grant('guest', 'replication')")
master.admin("box.schema.user.grant('guest', 'execute', 'universe')")

print '----------------------------------------------------------------------'
print 'Bootstrap replicas'
print '----------------------------------------------------------------------'

# Start replicas
master.id = master.get_param('server')['id']
master_lsn = master.get_lsn(master.id)
cluster = [ master ]
for i in range(REPLICA_N - 1):
    server = TarantoolServer(server.ini)
    server.script = 'replication/replica.lua'
    server.vardir = os.path.join(server.vardir, 'replica', str(master.id + i))
    server.rpl_master = master
    server.deploy()
    # Wait replica to fully bootstrap.
    # Otherwise can get ACCESS_DENIED error.
    server.wait_lsn(master.id, master_lsn)
    cluster.append(server)

# Make a list of servers
sources = []
for server in cluster:
    sources.append(yaml.load(server.admin('box.cfg.listen', silent = True))[0])
    server.id = server.get_param('server')['id']

print 'done'
Exemple #21
0
# 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 '-------------------------------------------------------------'
print 'Modify data to change LSN and check box.info'
Exemple #22
0
import os
import sys
import re
import yaml
from lib.tarantool_server import TarantoolServer

server = TarantoolServer(server.ini)
server.script = 'long_run/lua/finalizers.lua'
server.vardir = os.path.join(server.vardir, 'finalizers')
try:
    server.deploy()
except:
    print "Expected error:", sys.exc_info()[0]
else:
    print "Error! exception did not occur"


Exemple #23
0
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)
Exemple #24
0
# master server
master = server
master.admin("fiber = require('fiber')")
master.admin("box.schema.user.grant('guest', 'replication')")
master.admin("box.schema.user.grant('guest', 'execute', 'universe')")

print("----------------------------------------------------------------------")
print("Bootstrap replicas")
print("----------------------------------------------------------------------")

# Start replicas
master.id = master.get_param("id")
cluster = [ master ]
for i in range(REPLICA_N - 1):
    server = TarantoolServer(server.ini)
    server.script = "replication-py/replica.lua"
    server.vardir = os.path.join(server.vardir, "replica", str(master.id + i))
    server.rpl_master = master
    server.deploy()
    # Wait replica to fully bootstrap.
    # Otherwise can get ACCESS_DENIED error.
    cluster.append(server)

# Make a list of servers
sources = []
for server in cluster:
    sources.append(yaml.safe_load(server.admin("box.cfg.listen", silent = True))[0])
    server.id = server.get_param("id")

print("done")