本文整理汇总了Python中lib.tarantool_server.TarantoolServer.script方法的典型用法代码示例。如果您正苦于以下问题:Python TarantoolServer.script方法的具体用法?Python TarantoolServer.script怎么用?Python TarantoolServer.script使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.tarantool_server.TarantoolServer
的用法示例。
在下文中一共展示了TarantoolServer.script方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import script [as 别名]
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)
示例2: main
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import script [as 别名]
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)
示例3: main
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import script [as 别名]
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)
示例4: run_test
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import script [as 别名]
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
示例5: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import script [as 别名]
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)
示例6: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import script [as 别名]
# 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'
示例7: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import script [as 别名]
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"
示例8: require
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import script [as 别名]
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'
示例9: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import script [as 别名]
# 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 '-------------------------------------------------------------'
示例10: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import script [as 别名]
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):
示例11: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import script [as 别名]
# 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 = '%s'})" % (LOGIN, PASSWORD))
master.admin("box.schema.user.grant('%s', 'read,write,execute', 'universe')" % LOGIN)
master.iproto.py_con.authenticate(LOGIN, PASSWORD)
master.uri = '%s:%[email protected]%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:%[email protected]%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)