本文整理汇总了Python中lib.tarantool_server.TarantoolServer.admin方法的典型用法代码示例。如果您正苦于以下问题:Python TarantoolServer.admin方法的具体用法?Python TarantoolServer.admin怎么用?Python TarantoolServer.admin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.tarantool_server.TarantoolServer
的用法示例。
在下文中一共展示了TarantoolServer.admin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import admin [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
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'
print '-------------------------------------------------------------'
replica.admin('box.space._schema:insert{"test", 48}')
replica.admin('box.info.server.lsn == 1')
replica.admin('box.info.vclock[%d] == 1' % replica_id)
print '-------------------------------------------------------------'
print 'Unregister replica and check box.info'
print '-------------------------------------------------------------'
# gh-527: update vclock on delete from box.space._cluster'
示例2: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import admin [as 别名]
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)
# Start replica without master
server.stop()
示例3: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import admin [as 别名]
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 = 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")
示例4: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import admin [as 别名]
master.admin('for k = 1, 9 do space:insert{k, k*k} end')
for k in glob.glob(os.path.join(master.vardir, '*.xlog')):
os.unlink(k)
print '-------------------------------------------------------------'
print 'replica test 1 (no such space)'
print '-------------------------------------------------------------'
replica = TarantoolServer(server.ini)
replica.cfgfile_source = 'replication/cfg/replica.cfg'
replica.vardir = os.path.join(server.vardir, 'replica')
replica.rpl_master = master
replica.deploy()
replica.admin('box.space.test')
replica.stop()
replica.cleanup(True)
master.admin('box.snapshot()')
master.restart()
master.admin('for k = 10, 19 do box.space[42]:insert{k, k*k*k} end')
lsn = master.get_param('lsn')
print '-------------------------------------------------------------'
print 'replica test 2 (must be ok)'
print '-------------------------------------------------------------'
replica = TarantoolServer(server.ini)
replica.cfgfile_source = 'replication/cfg/replica.cfg'
replica.vardir = os.path.join(server.vardir, 'replica')
示例5: range
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import admin [as 别名]
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'
print '----------------------------------------------------------------------'
print 'Make a full mesh'
print '----------------------------------------------------------------------'
# Connect each server to each other to make full mesh
for server in cluster:
server.iproto.py_con.eval("box.cfg { replication_source = ... }", [sources])
# Wait connections to establish
for server in cluster:
for server2 in cluster:
示例6: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import admin [as 别名]
# 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.space._schema:insert{"test", 48}')
replica.admin('box.info.server.id')
replica.admin('box.info.server.ro')
replica.admin('box.info.server.lsn') # 1
replica.admin('box.info.vclock[%d]' % replica_id)
master.admin('box.space._cluster:delete{%d}' % replica_id)
replica.wait_lsn(master_id, master.get_lsn(master_id))
replica.admin('box.info.server.id')
replica.admin('box.info.server.ro')
replica.admin('box.info.server.lsn') # -1
replica.admin('box.info.vclock[%d]' % replica_id)
# replica is read-only
replica.admin('box.space._schema:replace{"test", 48}')
示例7: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import admin [as 别名]
# 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 '-------------------------------------------------------------'
replica.admin('box.space._schema:insert{"test", 48}')
replica.admin('box.info.lsn == 1')
replica.admin('box.info.vclock[%d] == 1' % replica_id)
print '-------------------------------------------------------------'
print 'Connect master to replica'
print '-------------------------------------------------------------'
replication_source = yaml.safe_load(replica.admin('box.cfg.listen', silent = True))[0]
示例8:
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import admin [as 别名]
replica.vardir = server.vardir #os.path.join(server.vardir, 'replica')
replica.rpl_master = master
# #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 xlog files on master were deleted, they aren't delivered,
# and replica waits indefinitely.
#
# Note: replica waits for a log entry indicating that this very replica
# joined the cluster. Once the entry is fetched we assume that the
# replica is relatively up to date and enter RW mode. Never happens in
# this particular test case.
replica.deploy(wait = False)
replica.admin('box.space.test')
replica.admin('box_cfg_done') # blocked in box.cfg it should be
replica.stop()
replica.cleanup(True)
print '-------------------------------------------------------------'
print 'replica JOIN'
print '-------------------------------------------------------------'
master.admin('box.snapshot()')
master.restart()
replica.deploy()
replica.wait_lsn(master_id, master.get_lsn(master_id))
示例9: TestSuite_Schema
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import admin [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")
#.........这里部分代码省略.........
示例10: TestSuite_Schema
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import admin [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')
#.........这里部分代码省略.........
示例11: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import admin [as 别名]
for k in glob.glob(os.path.join(master.vardir, '*.xlog')):
os.unlink(k)
print '-------------------------------------------------------------'
print 'replica test 1 (must be failed)'
print '-------------------------------------------------------------'
replica = TarantoolServer()
replica.deploy("replication/cfg/replica.cfg",
replica.find_exe(self.args.builddir),
os.path.join(self.args.vardir, "replica"),
need_init=False)
for i in range(1, 10):
replica.admin('box.select(42, 0, %d)' % i)
replica.stop()
replica.cleanup(True)
master.admin('box.snapshot()')
master.restart()
master.admin('for k = 10, 19 do box.insert(42, k, k*k*k) end')
print '-------------------------------------------------------------'
print 'replica test 2 (must be ok)'
print '-------------------------------------------------------------'
replica = TarantoolServer()
replica.deploy("replication/cfg/replica.cfg",
replica.find_exe(self.args.builddir),
示例12: TarantoolServer
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import admin [as 别名]
# master server
master = server
master.admin("box.schema.user.create('%s', { password = '%s'})" % (LOGIN, PASSWORD))
master.admin("box.schema.user.grant('%s', 'read,write,execute', 'universe')" % LOGIN)
master.sql.py_con.authenticate(LOGIN, PASSWORD)
master.uri = '%s:%[email protected]%s:%s' % (LOGIN, PASSWORD, HOST, master.sql.port)
os.putenv('MASTER_PORT', master.uri)
# replica server
replica = TarantoolServer()
replica.script = "replication/replica.lua"
replica.vardir = os.path.join(server.vardir, 'replica')
replica.deploy()
replica.uri = '%s:%[email protected]%s:%s' % (LOGIN, PASSWORD, HOST, replica.sql.port)
replica.admin("while box.space['_priv']:len() < 1 do require('fiber').sleep(0.01) end")
replica.sql.py_con.authenticate(LOGIN, PASSWORD)
master.admin("s = box.schema.create_space('tweedledum', {id = 0})")
master.admin("s:create_index('primary', {type = 'hash'})")
## gh-343: replica.cc must not add login and password to proc title
status = replica.get_param("status")
host_port = "%s:%s" % (HOST, master.sql.port)
m = re.search(r'replica/(.*)/.*', status)
if not m or m.group(1) != host_port:
print 'invalid box.info.status', status, 'expected host:port', host_port
master_id = master.get_param('node')['id']
replica_id = replica.get_param('node')['id']
示例13: Request
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import admin [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,
#.........这里部分代码省略.........
示例14: range
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import admin [as 别名]
_server.wait_lsn(lsn)
for i in range(begin, end):
_server.sql("select * from t0 where k0 = %d" % i)
# master server
master = server
cfgfile_bkp = server.cfgfile_source
# replica server
replica = TarantoolServer()
replica.rpl_master = master
replica.cfgfile_source = "replication/cfg/replica.cfg"
replica.vardir = os.path.join(server.vardir, 'replica')
replica.deploy()
master.admin("box.schema.user.grant('guest', 'read,write,execute', 'universe')")
replica.admin("while box.space['_priv']:len() < 1 do box.fiber.sleep(0.01) end")
master.admin("s = box.schema.create_space('tweedledum', {id = 0})")
master.admin("s:create_index('primary', {type = 'hash'})")
id = ID_BEGIN
for i in range(REPEAT):
print "test %d iteration" % i
# insert to master
insert_tuples(master, id, id + ID_STEP)
# select from replica
select_tuples(replica, id, id + ID_STEP, master.get_param("lsn"))
id += ID_STEP
# insert to master
insert_tuples(master, id, id + ID_STEP)
# select from replica
示例15: select_tuples
# 需要导入模块: from lib.tarantool_server import TarantoolServer [as 别名]
# 或者: from lib.tarantool_server.TarantoolServer import admin [as 别名]
def select_tuples(_server, begin, end):
for i in range(begin, end):
_server.sql("select * from t0 where k0 = %d" % i)
# master server
master = server
# replica server
replica = TarantoolServer()
replica.script = "replication/replica.lua"
replica.rpl_master = master
replica.vardir = os.path.join(server.vardir, 'replica')
replica.deploy()
master.admin("box.schema.user.grant('guest', 'read,write,execute', 'universe')")
replica.admin("while box.space['_priv']:len() < 1 do box.fiber.sleep(0.01) end")
master.admin("s = box.schema.create_space('tweedledum', {id = 0})")
master.admin("s:create_index('primary', {type = 'hash'})")
master_uuid = master.get_param('node')
replica_uuid = replica.get_param('node')
id = ID_BEGIN
for i in range(REPEAT):
print "test %d iteration" % i
# insert to master
insert_tuples(master, id, id + ID_STEP)
# select from replica
replica.wait_lsn(master_uuid, master.get_lsn(master_uuid))
select_tuples(replica, id, id + ID_STEP)