本文整理汇总了Python中lib.tarantool_server.TarantoolServer.stop方法的典型用法代码示例。如果您正苦于以下问题:Python TarantoolServer.stop方法的具体用法?Python TarantoolServer.stop怎么用?Python TarantoolServer.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.tarantool_server.TarantoolServer
的用法示例。
在下文中一共展示了TarantoolServer.stop方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import stop [as 别名]
print """
# Insert 10 tuples to hot_standby
"""
for i in range(id, id + 10):
hot_standby_sql("insert into t0 values (%d, 'the tuple %d')" % (i, i))
print """
# Select 10 tuples from hot_standby
"""
for i in range(id, id + 10):
hot_standby_sql("select * from t0 where k0 = %d" % i)
print """
# Select 10 tuples from replica
"""
replica.wait_lsn(21)
for i in range(id, id + 10):
replica_sql("select * from t0 where k0 = %d" % i)
# Cleanup.
hot_standby.stop()
hot_standby.cleanup(True)
replica.stop()
replica.cleanup(True)
server.deploy(self.suite_ini["config"])
# vim: syntax=python
示例2: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import stop [as 别名]
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)
# Start replica without master
server.stop()
replica.start()
replica.admin('box.cfg{replication_source = ""}')
示例3:
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import stop [as 别名]
print 'inserted %d records' % ROW_N
print
print 'Synchronize'
for server1 in cluster:
for server2 in cluster:
server1.wait_lsn(server2.id, server2.get_lsn(server2.id))
print 'server', server.id, 'done'
print 'done'
print
print 'Check data'
for server in cluster:
cnt = yaml.load(server.admin("box.space.test:len()", silent = True))[0]
print 'server', server.id, 'is', cnt == ROW_N and 'ok' or 'not ok'
print 'Done'
print
print
print '----------------------------------------------------------------------'
print 'Cleanup'
print '----------------------------------------------------------------------'
for server in cluster:
server.stop()
print 'server', server.id, 'done'
print
master.cleanup()
master.deploy()
示例4: TestSuite_Schema
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import stop [as 别名]
#.........这里部分代码省略.........
self.assertEqual(index.space.name, '_space')
self.assertEqual(index.iid, 2)
self.assertEqual(index.name, 'name')
self.assertEqual(len(index.parts), 1)
def test_05_02_index_name___number(self):
self.con.flush_schema()
index = self.sch.get_index('_index', 0)
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', 2)
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', 0)
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', 2)
self.assertEqual(index.space.name, '_space')
self.assertEqual(index.iid, 2)
self.assertEqual(index.name, 'name')
self.assertEqual(len(index.parts), 1)
def test_05_03_index_number_name__(self):
self.con.flush_schema()
index = self.sch.get_index(288, '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(288, '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(280, '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(280, 'name')
self.assertEqual(index.space.name, '_space')
self.assertEqual(index.iid, 2)
self.assertEqual(index.name, 'name')
self.assertEqual(len(index.parts), 1)
def test_05_04_index_number_number(self):
self.con.flush_schema()
index = self.sch.get_index(288, 0)
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(288, 2)
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(280, 0)
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(280, 2)
self.assertEqual(index.space.name, '_space')
self.assertEqual(index.iid, 2)
self.assertEqual(index.name, 'name')
self.assertEqual(len(index.parts), 1)
def test_06_index_cached(self):
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', 2)
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(280, '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(280, 2)
self.assertEqual(index.space.name, '_space')
self.assertEqual(index.iid, 2)
self.assertEqual(index.name, 'name')
self.assertEqual(len(index.parts), 1)
@classmethod
def tearDownClass(self):
self.srv.stop()
self.srv.clean()
示例5: TestSuite_Schema
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import stop [as 别名]
#.........这里部分代码省略.........
self.assertEqual(index.space.name, "_space")
self.assertEqual(index.iid, 2)
self.assertEqual(index.name, "name")
self.assertEqual(len(index.parts), 1)
def test_05_02_index_name___number(self):
self.con.flush_schema()
index = self.sch.get_index("_index", 0)
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", 2)
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", 0)
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", 2)
self.assertEqual(index.space.name, "_space")
self.assertEqual(index.iid, 2)
self.assertEqual(index.name, "name")
self.assertEqual(len(index.parts), 1)
def test_05_03_index_number_name__(self):
self.con.flush_schema()
index = self.sch.get_index(288, "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(288, "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(280, "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(280, "name")
self.assertEqual(index.space.name, "_space")
self.assertEqual(index.iid, 2)
self.assertEqual(index.name, "name")
self.assertEqual(len(index.parts), 1)
def test_05_04_index_number_number(self):
self.con.flush_schema()
index = self.sch.get_index(288, 0)
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(288, 2)
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(280, 0)
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(280, 2)
self.assertEqual(index.space.name, "_space")
self.assertEqual(index.iid, 2)
self.assertEqual(index.name, "name")
self.assertEqual(len(index.parts), 1)
def test_06_index_cached(self):
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", 2)
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(280, "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(280, 2)
self.assertEqual(index.space.name, "_space")
self.assertEqual(index.iid, 2)
self.assertEqual(index.name, "name")
self.assertEqual(len(index.parts), 1)
@classmethod
def tearDownClass(self):
self.srv.stop()
self.srv.clean()
示例6: Request
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import stop [as 别名]
#.........这里部分代码省略.........
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,
'(39, .*)'):
self.assertEqual(self.con.replace('space_1', [2, 2]), [[2, 2, 'tuple_2']])
def test_05_ping(self):
# Simple ping test
# * No exceptions are raised
# * Ping time > 0
self.assertTrue(self.con.ping() > 0)
self.assertEqual(self.con.ping(notime=True), "Success")
def test_06_update(self):
self.assertEqual(self.con.update('space_1', (2,), [('+', 1, 3)]),
[[2, 5, 'tuple_3']])
self.assertEqual(self.con.update('space_1', (2,), [('-', 1, 3)]),
[[2, 2, 'tuple_3']])
self.assertEqual(self.con.update('space_1', (2,), [(':', 2, 3, 2, 'lalal')]),
[[2, 2, 'tuplalal_3']])
self.assertEqual(self.con.update('space_1', (2,), [('!', 2, '1')]),
[[2, 2, '1', 'tuplalal_3']])
self.assertEqual(self.con.update('space_1', (2,), [('!', 2, 'oingo, boingo')]),
[[2, 2, 'oingo, boingo', '1', 'tuplalal_3']])
self.assertEqual(self.con.update('space_1', (2,), [('#', 2, 2)]),
[[2, 2, 'tuplalal_3']])
def test_07_call(self):
self.assertEqual(self.con.call('json.decode', '[123, 234, 345]'), [[123, 234, 345]])
self.assertEqual(self.con.call('json.decode', ['[123, 234, 345]']), [[123, 234, 345]])
self.assertEqual(self.con.call('json.decode', ('[123, 234, 345]',)), [[123, 234, 345]])
with self.assertRaisesRegexp(tarantool.DatabaseError,
'(32, .*)'):
self.con.call('json.decode')
with self.assertRaisesRegexp(tarantool.DatabaseError,
'(22, .*)'):
self.con.call('json.decode', '{"hello": "world"}')
ans = self.con.call('fiber.time')
self.assertEqual(len(ans), 1)
self.assertEqual(len(ans[0]), 1)
self.assertIsInstance(ans[0][0], float)
ans = self.con.call('fiber.time64')
self.assertEqual(len(ans), 1)
self.assertEqual(len(ans[0]), 1)
self.assertIsInstance(ans[0][0], (int, long))
ans = self.con.call('uuid.str')
self.assertEqual(len(ans), 1)
self.assertEqual(len(ans[0]), 1)
self.assertIsInstance(ans[0][0], str)
# ans = self.con.call('uuid.hex')
# self.assertEqual(len(ans), 1)
# self.assertEqual(len(ans[0]), 1)
# self.assertIsInstance(ans[0][0], str)
# with self.assertRaisesRegexp(tarantool.DatabaseError,
# '(12345, \'lol, error\')'):
# self.con.call('box.error', [12345, 'lol, error'])
self.assertEqual(self.con.call('box.tuple.new', [1, 2, 3, 'fld_1']), [[1, 2, 3, 'fld_1']])
self.assertEqual(self.con.call('box.tuple.new', 'fld_1'), [['fld_1']])
@classmethod
def tearDownClass(self):
self.srv.stop()
self.srv.clean()
示例7: Supervisor
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import stop [as 别名]
class Supervisor(object):
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 find_tests(self):
self.tests += [Parallel_PythonTest(k) \
for k in sorted(glob.glob(os.path.join(self.suite_path, "*.test.py" )))]
def take_rand(self):
if self.count != 0:
for test in self.tests:
sql = self.server.sql.clone()
admin = self.server.admin.clone()
yield [test, [sql, admin]]
else:
while True:
sql = self.server.sql.clone()
admin = self.server.admin.clone()
yield [random.choice(self.tests), [sql, admin]]
def run_all(self):
self.find_tests()
if self.count != 0:
self.tests *= self.count
random.shuffle(self.tests)
self.pool = GopherPool(processes = self.jobs)
self.iterator = self.pool.run()
self.filler = self.pool.fill(self.take_rand())
try:
self.server.cleanup()
logger.info("Tarantool.Instance > Server cleaned up")
logger.info("Tarantool.Instance > Server's path: %s", self.server.binary)
self.server.deploy()
logger.info("Tarantool.Instance > Server deployed")
try:
while True:
self.filler.next()
logger.debug("BigBrother.run > Jobs filled %d %d" %
(self.pool.queuein.qsize(), self.pool.queueout.qsize()))
while True:
try:
logger.debug("BigBrother.run > waiting for task")
task = self.iterator.next(1)
logger.debug("BigBrother.run > took task")
if task is None:
logger.info('>>>> Test return NONE')
continue
stat = task.get_status()
if stat.status != 3:
logger.info('>>>> Test %s finished' % repr(task.name))
else:
logger.error('>>>> Test %s failed with %s (%s)' %
(repr(task.name), stat.message, stat.reject))
except (QueueEmpty, StopIteration):
break
except StopIteration:
pass
finally:
self.server.stop()
logger.info("Tarantool.Instance > Server stopped")