本文整理汇总了Python中lib.tarantool_server.TarantoolServer.start方法的典型用法代码示例。如果您正苦于以下问题:Python TarantoolServer.start方法的具体用法?Python TarantoolServer.start怎么用?Python TarantoolServer.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.tarantool_server.TarantoolServer
的用法示例。
在下文中一共展示了TarantoolServer.start方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import start [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 start [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 start [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 start [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: str
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import start [as 别名]
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)
# Start replica without master
server.stop()
replica.start()
replica.admin('box.cfg{replication_source = ""}')
# Check that replica in read-only mode
replica.admin('box.info.server.id')
replica.admin('box.info.server.ro')
replica.admin('box.info.server.lsn')
replica.admin('space = box.schema.space.create("ro")')
replica.admin('box.info.vclock[%d]' % replica_id)
replica.stop()
replica.cleanup(True)
server.deploy()
示例6:
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import start [as 别名]
os.remove(wal)
# Start replica without master
server.stop()
# #1075: Box.once should wait before the server enters RW mode
#
# We expect the replica to get blocked in box.cfg{}, hence wait = False.
# Since neither xlog files nor master are available, the replica waits
# indefinitely.
#
# Note: replica monitors _cluster table, synchronized via replication.
# The replica enters RW mode once it discovers that according to
# _cluster table it had joined the cluster. Never happens in this
# particular test case.
replica.start(wait = False)
replica.admin('box.cfg{replication_source = ""}')
# Check that replica in read-only mode
replica.admin('box.info.server.id')
replica.admin('box.info.server.ro')
replica.admin('box.info.server.lsn')
replica.admin('space = box.schema.space.create("ro")')
replica.admin('box.info.vclock[%d]' % replica_id)
# Check that box.cfg didn't return yet
replica.admin('box_cfg_done')
replica.stop()
replica.cleanup(True)
server.deploy()
示例7: TestSuite_Schema
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import start [as 别名]
class TestSuite_Schema(unittest.TestCase):
@classmethod
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 test_00_authenticate(self):
self.assertIsNone(self.srv.admin("box.schema.user.create('test', { password = 'test' })"))
self.assertIsNone(self.srv.admin("box.schema.user.grant('test', 'read,write', 'space', '_space')"))
self.assertIsNone(self.srv.admin("box.schema.user.grant('test', 'read,write', 'space', '_index')"))
self.assertEqual(self.con.authenticate('test', 'test')._data, None)
def test_01_space_bad(self):
with self.assertRaisesRegexp(tarantool.SchemaError,
'There\'s no space.*'):
self.sch.get_space(0)
with self.assertRaisesRegexp(tarantool.SchemaError,
'There\'s no space.*'):
self.sch.get_space(0)
with self.assertRaisesRegexp(tarantool.SchemaError,
'There\'s no space.*'):
self.sch.get_space('bad_name')
def test_02_index_bad(self):
with self.assertRaisesRegexp(tarantool.SchemaError,
'There\'s no space.*'):
self.sch.get_index(0, 'primary')
with self.assertRaisesRegexp(tarantool.SchemaError,
'There\'s no space.*'):
self.sch.get_index('bad_space', 'primary')
with self.assertRaisesRegexp(tarantool.SchemaError,
'There\'s no index.*'):
self.sch.get_index(280, 'bad_index')
with self.assertRaisesRegexp(tarantool.SchemaError,
'There\'s no index.*'):
self.sch.get_index(280, 'bad_index')
with self.assertRaisesRegexp(tarantool.SchemaError,
'There\'s no index.*'):
self.sch.get_index(280, 3)
def test_03_01_space_name__(self):
self.con.flush_schema()
space = self.sch.get_space('_schema')
self.assertEqual(space.sid, 272)
self.assertEqual(space.name, '_schema')
self.assertEqual(space.arity, 1)
space = self.sch.get_space('_space')
self.assertEqual(space.sid, 280)
self.assertEqual(space.name, '_space')
self.assertEqual(space.arity, 1)
space = self.sch.get_space('_index')
self.assertEqual(space.sid, 288)
self.assertEqual(space.name, '_index')
self.assertEqual(space.arity, 1)
def test_03_02_space_number(self):
self.con.flush_schema()
space = self.sch.get_space(272)
self.assertEqual(space.sid, 272)
self.assertEqual(space.name, '_schema')
self.assertEqual(space.arity, 1)
space = self.sch.get_space(280)
self.assertEqual(space.sid, 280)
self.assertEqual(space.name, '_space')
self.assertEqual(space.arity, 1)
space = self.sch.get_space(288)
self.assertEqual(space.sid, 288)
self.assertEqual(space.name, '_index')
self.assertEqual(space.arity, 1)
def test_04_space_cached(self):
space = self.sch.get_space('_schema')
self.assertEqual(space.sid, 272)
self.assertEqual(space.name, '_schema')
self.assertEqual(space.arity, 1)
space = self.sch.get_space('_space')
self.assertEqual(space.sid, 280)
self.assertEqual(space.name, '_space')
self.assertEqual(space.arity, 1)
space = self.sch.get_space('_index')
self.assertEqual(space.sid, 288)
self.assertEqual(space.name, '_index')
self.assertEqual(space.arity, 1)
def test_05_01_index_name___name__(self):
self.con.flush_schema()
index = self.sch.get_index('_index', 'primary')
self.assertEqual(index.space.name, '_index')
self.assertEqual(index.iid, 0)
self.assertEqual(index.name, 'primary')
self.assertEqual(len(index.parts), 2)
index = self.sch.get_index('_index', 'name')
self.assertEqual(index.space.name, '_index')
self.assertEqual(index.iid, 2)
self.assertEqual(index.name, 'name')
#.........这里部分代码省略.........
示例8: TestSuite_Schema
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import start [as 别名]
class TestSuite_Schema(unittest.TestCase):
@classmethod
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 test_00_authenticate(self):
self.assertIsNone(self.srv.admin("box.schema.user.create('test', { password = 'test' })"))
self.assertIsNone(self.srv.admin("box.schema.user.grant('test', 'read,write', 'space', '_space')"))
self.assertIsNone(self.srv.admin("box.schema.user.grant('test', 'read,write', 'space', '_index')"))
self.assertEqual(self.con.authenticate("test", "test")._data, None)
def test_01_space_bad(self):
with self.assertRaisesRegexp(tarantool.SchemaError, "There's no space.*"):
self.sch.get_space(0)
with self.assertRaisesRegexp(tarantool.SchemaError, "There's no space.*"):
self.sch.get_space(0)
with self.assertRaisesRegexp(tarantool.SchemaError, "There's no space.*"):
self.sch.get_space("bad_name")
def test_02_index_bad(self):
with self.assertRaisesRegexp(tarantool.SchemaError, "There's no space.*"):
self.sch.get_index(0, "primary")
with self.assertRaisesRegexp(tarantool.SchemaError, "There's no space.*"):
self.sch.get_index("bad_space", "primary")
with self.assertRaisesRegexp(tarantool.SchemaError, "There's no index.*"):
self.sch.get_index(280, "bad_index")
with self.assertRaisesRegexp(tarantool.SchemaError, "There's no index.*"):
self.sch.get_index(280, "bad_index")
with self.assertRaisesRegexp(tarantool.SchemaError, "There's no index.*"):
self.sch.get_index(280, 3)
def test_03_01_space_name__(self):
self.con.flush_schema()
space = self.sch.get_space("_schema")
self.assertEqual(space.sid, 272)
self.assertEqual(space.name, "_schema")
self.assertEqual(space.arity, 1)
space = self.sch.get_space("_space")
self.assertEqual(space.sid, 280)
self.assertEqual(space.name, "_space")
self.assertEqual(space.arity, 1)
space = self.sch.get_space("_index")
self.assertEqual(space.sid, 288)
self.assertEqual(space.name, "_index")
self.assertEqual(space.arity, 1)
def test_03_02_space_number(self):
self.con.flush_schema()
space = self.sch.get_space(272)
self.assertEqual(space.sid, 272)
self.assertEqual(space.name, "_schema")
self.assertEqual(space.arity, 1)
space = self.sch.get_space(280)
self.assertEqual(space.sid, 280)
self.assertEqual(space.name, "_space")
self.assertEqual(space.arity, 1)
space = self.sch.get_space(288)
self.assertEqual(space.sid, 288)
self.assertEqual(space.name, "_index")
self.assertEqual(space.arity, 1)
def test_04_space_cached(self):
space = self.sch.get_space("_schema")
self.assertEqual(space.sid, 272)
self.assertEqual(space.name, "_schema")
self.assertEqual(space.arity, 1)
space = self.sch.get_space("_space")
self.assertEqual(space.sid, 280)
self.assertEqual(space.name, "_space")
self.assertEqual(space.arity, 1)
space = self.sch.get_space("_index")
self.assertEqual(space.sid, 288)
self.assertEqual(space.name, "_index")
self.assertEqual(space.arity, 1)
def test_05_01_index_name___name__(self):
self.con.flush_schema()
index = self.sch.get_index("_index", "primary")
self.assertEqual(index.space.name, "_index")
self.assertEqual(index.iid, 0)
self.assertEqual(index.name, "primary")
self.assertEqual(len(index.parts), 2)
index = self.sch.get_index("_index", "name")
self.assertEqual(index.space.name, "_index")
self.assertEqual(index.iid, 2)
self.assertEqual(index.name, "name")
self.assertEqual(len(index.parts), 2)
index = self.sch.get_index("_space", "primary")
self.assertEqual(index.space.name, "_space")
self.assertEqual(index.iid, 0)
self.assertEqual(index.name, "primary")
self.assertEqual(len(index.parts), 1)
index = self.sch.get_index("_space", "name")
self.assertEqual(index.space.name, "_space")
#.........这里部分代码省略.........
示例9: Request
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import start [as 别名]
class Request(unittest.TestCase):
@classmethod
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 test_00_00_authenticate(self):
self.assertIsNone(self.srv.admin("box.schema.user.create('test', { password = 'test' })"))
self.assertIsNone(self.srv.admin("box.schema.user.grant('test', 'execute,read,write', 'universe')"))
self.assertEqual(self.con.authenticate('test', 'test')._data, None)
def test_00_01_space_created(self):
# Check that space is created in setUpClass
self.assertEqual(self.space_created[1], 'created')
def test_00_02_fill_space(self):
# Fill space with values
for i in xrange(1, 500):
self.assertEqual(
self.con.insert('space_1', [i, i%5, 'tuple_'+str(i)])[0],
[i, i%5, 'tuple_'+str(i)]
)
def test_00_03_answer_repr(self):
repr_str = \
'''- [1, 1, tuple_1]
'''
self.assertEqual(repr(self.con.select('space_1', 1)), repr_str)
def test_02_select(self):
# Check that select with different keys are Ok. (With and without index names)
self.assertEqual(self.con.select('space_1', 20), [[20, 0, 'tuple_20']])
self.assertEqual(self.con.select('space_1', [21]), [[21, 1, 'tuple_21']])
self.assertEqual(self.con.select('space_1', [22], index='primary'), [[22, 2, 'tuple_22']])
self.assertEqual(self.con.select('space_1', [23], index='primary'), [[23, 3, 'tuple_23']])
# Check that Offset and Limit args are working fine.
self.assertEqual(self.con.select('space_1', [20], index='primary', limit=1), [[20, 0, 'tuple_20']])
# With other indexes too
self.assertEqual(
sorted(
self.con.select('space_1', [0], index='secondary', offset=3, limit=0),
key = lambda x: x[0]),
[]
)
self.assertEqual(
sorted(
self.con.select('space_1', [0], index='secondary', offset=3, limit=1),
key = lambda x: x[0]),
[[110, 0, 'tuple_110']]
)
self.assertEqual(
sorted(
self.con.select('space_1', [0], index='secondary', offset=3, limit=2),
key = lambda x: x[0]),
[[110, 0, 'tuple_110'],\
[115, 0, 'tuple_115']]
)
select_req = self.con.select('space_1', [0], index='secondary')
self.assertEqual(len(select_req), 99)
for i in select_req:
self.assertTrue(not (i[0] % 5))
self.assertTrue(not i[1])
self.assertTrue(i[2] == 'tuple_' + str(i[0]))
# Check limit again.
self.assertEqual(len(self.con.select('space_1', [0, 'tuple_20'], index='secondary', limit=0)), 0)
self.assertEqual(len(self.con.select('space_1', [0], index='secondary', limit=0)), 0)
self.assertEqual(len(self.con.select('space_1', [0], index='secondary', limit=100)), 99)
self.assertEqual(len(self.con.select('space_1', [0], index='secondary', limit=50)), 50)
# TODO: Check iterator_types
def test_03_delete(self):
# Check that delete works fine
self.assertEqual(self.con.delete('space_1', 20), [[20, 0, 'tuple_20']])
self.assertEqual(self.con.delete('space_1', [20]), [])
self.assertEqual(self.con.select('space_1', [20], index='primary'), [])
# Check that <index_id> field has no meaning, yet.
with self.assertRaisesRegexp(tarantool.DatabaseError,
'(19, .*)'):
self.con.delete('space_1', [1, 'tuple_21'])
self.assertEqual(self.con.select('space_1', [21], index='primary'), [[21, 1, 'tuple_21']])
def test_04_replace(self):
# Check replace that is Ok.
self.assertEqual(self.con.replace('space_1', [2, 2, 'tuple_3']), [[2, 2, 'tuple_3']])
self.assertEqual(self.con.select('space_1', 2), [[2, 2, 'tuple_3']])
# Check replace that isn't Ok.
with self.assertRaisesRegexp(tarantool.DatabaseError,
#.........这里部分代码省略.........