本文整理汇总了Python中utils.vtclient2函数的典型用法代码示例。如果您正苦于以下问题:Python vtclient2函数的具体用法?Python vtclient2怎么用?Python vtclient2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtclient2函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _check_rows_schema_diff
def _check_rows_schema_diff(self, driver):
out, err = utils.vtclient2(0, "/test_nj/test_keyspace/master", "select * from vt_select_test", driver=driver, verbose=False, raise_on_error=False)
if "column[0] name mismatch: id != msg" not in err and \
"column[0] name mismatch: msg != id" not in err:
logging.error("vtclient2 returned:\n%s\n%s", out, err)
self.fail('wrong vtclient2 output, missing "name mismatch" of some kind')
logging.debug("_check_rows_schema_diff:\n%s\n%s", out, err)
开发者ID:Eter365,项目名称:vitess,代码行数:7,代码来源:sharded.py
示例2: _check_rows
def _check_rows(self, to_look_for, driver="vtdb"):
out, err = utils.vtclient2(0, "/test_nj/test_keyspace/master", "select id, msg from vt_select_test", driver=driver, verbose=True)
for pattern in to_look_for:
if pattern not in err:
logging.error("vtclient2 returned:\n%s\n%s", out, err)
self.fail('wrong vtclient2 output, missing: ' + pattern)
logging.debug("_check_rows:\n%s\n%s", out, err)
开发者ID:Eter365,项目名称:vitess,代码行数:7,代码来源:sharded.py
示例3: check_rows_schema_diff
def check_rows_schema_diff(driver):
out, err = utils.vtclient2(0, "/test_nj/test_keyspace/master", "select * from vt_select_test", driver=driver, verbose=False, raise_on_error=False)
if "column[0] name mismatch: id != msg" not in err and \
"column[0] name mismatch: msg != id" not in err:
print "vtclient2 returned:"
print out
print err
raise utils.TestError('wrong vtclient2 output, missing "name mismatch" of some kind')
if utils.options.verbose:
print out, err
开发者ID:ShawnShoper,项目名称:WeShare,代码行数:10,代码来源:sharded.py
示例4: check_rows
def check_rows(to_look_for, driver="vtdb"):
out, err = utils.vtclient2(0, "/test_nj/test_keyspace/master", "select id, msg from vt_select_test", driver=driver, verbose=True)
for pattern in to_look_for:
if pattern not in err:
print "vtclient2 returned:"
print out
print err
raise utils.TestError('wrong vtclient2 output, missing: ' + pattern)
if utils.options.verbose:
print out, err
开发者ID:ShawnShoper,项目名称:WeShare,代码行数:10,代码来源:sharded.py
示例5: vquery
def vquery(self, query, path="", user=None, password=None, driver=None, verbose=False, raise_on_error=True):
return utils.vtclient2(
self.port,
path,
query,
user=user,
password=password,
driver=driver,
verbose=verbose,
raise_on_error=raise_on_error,
)
开发者ID:jekey,项目名称:vitess,代码行数:11,代码来源:tablet.py
示例6: test_sharding
def test_sharding(self):
shard_0_master.init_tablet("master", "test_keyspace", "-80")
shard_0_replica.init_tablet("replica", "test_keyspace", "-80")
shard_1_master.init_tablet("master", "test_keyspace", "80-")
shard_1_replica.init_tablet("replica", "test_keyspace", "80-")
utils.run_vtctl("RebuildShardGraph /zk/global/vt/keyspaces/test_keyspace/shards/*", auto_log=True)
utils.run_vtctl("RebuildKeyspaceGraph /zk/global/vt/keyspaces/*", auto_log=True)
# run checks now before we start the tablets
utils.validate_topology()
# create databases
shard_0_master.create_db("vt_test_keyspace")
shard_0_replica.create_db("vt_test_keyspace")
shard_1_master.create_db("vt_test_keyspace")
shard_1_replica.create_db("vt_test_keyspace")
# start the tablets
shard_0_master.start_vttablet()
shard_0_replica.start_vttablet()
shard_1_master.start_vttablet()
shard_1_replica.start_vttablet()
# apply the schema on the first shard through vtctl, so all tablets
# are the same (replication is not enabled yet, so allow_replication=false
# is just there to be tested)
utils.run_vtctl(
[
"ApplySchema",
"-stop-replication",
"-sql=" + create_vt_select_test.replace("\n", ""),
shard_0_master.tablet_alias,
]
)
utils.run_vtctl(
[
"ApplySchema",
"-stop-replication",
"-sql=" + create_vt_select_test.replace("\n", ""),
shard_0_replica.tablet_alias,
]
)
# start zkocc, we'll use it later
zkocc_server = utils.zkocc_start()
for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
t.reset_replication()
utils.run_vtctl("ReparentShard -force test_keyspace/-80 " + shard_0_master.tablet_alias, auto_log=True)
utils.run_vtctl("ReparentShard -force test_keyspace/80- " + shard_1_master.tablet_alias, auto_log=True)
# apply the schema on the second shard using a simple schema upgrade
utils.run_vtctl(
[
"ApplySchemaShard",
"-simple",
"-sql=" + create_vt_select_test_reverse.replace("\n", ""),
"test_keyspace/80-",
]
)
# insert some values directly (db is RO after minority reparent)
# FIXME(alainjobart) these values don't match the shard map
utils.run_vtctl("SetReadWrite " + shard_0_master.tablet_alias)
utils.run_vtctl("SetReadWrite " + shard_1_master.tablet_alias)
shard_0_master.mquery(
"vt_test_keyspace", "insert into vt_select_test (id, msg) values (1, 'test 1')", write=True
)
shard_1_master.mquery(
"vt_test_keyspace", "insert into vt_select_test (id, msg) values (10, 'test 10')", write=True
)
utils.validate_topology(ping_tablets=True)
utils.pause("Before the sql scatter query")
# note the order of the rows is not guaranteed, as the go routines
# doing the work can go out of order
self._check_rows(["Index\tid\tmsg", "1\ttest 1", "10\ttest 10"])
# write a value, re-read them all
utils.vtclient2(
3803,
"/test_nj/test_keyspace/master",
"insert into vt_select_test (id, msg) values (:keyspace_id, 'test 2')",
bindvars='{"keyspace_id": 2}',
driver="vtdb",
verbose=True,
)
self._check_rows(["Index\tid\tmsg", "1\ttest 1", "2\ttest 2", "10\ttest 10"])
# make sure the '2' value was written on first shard
rows = shard_0_master.mquery("vt_test_keyspace", "select id, msg from vt_select_test order by id")
self.assertEqual(rows, ((1, "test 1"), (2, "test 2")), "wrong mysql_query output: %s" % str(rows))
utils.pause("After db writes")
#.........这里部分代码省略.........
开发者ID:CERN-Stage-3,项目名称:vitess,代码行数:101,代码来源:sharded.py
示例7: test_sharding
def test_sharding(self):
shard_0_master.init_tablet( 'master', 'test_keyspace', '-80')
shard_0_replica.init_tablet('replica', 'test_keyspace', '-80')
shard_1_master.init_tablet( 'master', 'test_keyspace', '80-')
shard_1_replica.init_tablet('replica', 'test_keyspace', '80-')
utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace'], auto_log=True)
# run checks now before we start the tablets
utils.validate_topology()
# create databases, start the tablets, wait for them to start
for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
t.create_db('vt_test_keyspace')
t.start_vttablet(wait_for_state=None)
for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
t.wait_for_vttablet_state('SERVING')
# apply the schema on the first shard through vtctl, so all tablets
# are the same (replication is not enabled yet, so allow_replication=false
# is just there to be tested)
utils.run_vtctl(['ApplySchema',
'-stop-replication',
'-sql=' + create_vt_select_test.replace("\n", ""),
shard_0_master.tablet_alias])
utils.run_vtctl(['ApplySchema',
'-stop-replication',
'-sql=' + create_vt_select_test.replace("\n", ""),
shard_0_replica.tablet_alias])
# start vtgate, we'll use it later
vtgate_server, vtgate_port = utils.vtgate_start()
for t in [shard_0_master, shard_0_replica, shard_1_master, shard_1_replica]:
t.reset_replication()
utils.run_vtctl(['InitShardMaster', 'test_keyspace/-80',
shard_0_master.tablet_alias], auto_log=True)
utils.run_vtctl(['InitShardMaster', 'test_keyspace/80-',
shard_1_master.tablet_alias], auto_log=True)
# apply the schema on the second shard using a simple schema upgrade
utils.run_vtctl(['ApplySchemaShard',
'-simple',
'-sql=' + create_vt_select_test_reverse.replace("\n", ""),
'test_keyspace/80-'])
# insert some values directly (db is RO after minority reparent)
# FIXME(alainjobart) these values don't match the shard map
utils.run_vtctl(['SetReadWrite', shard_0_master.tablet_alias])
utils.run_vtctl(['SetReadWrite', shard_1_master.tablet_alias])
shard_0_master.mquery('vt_test_keyspace', "insert into vt_select_test (id, msg) values (1, 'test 1')", write=True)
shard_1_master.mquery('vt_test_keyspace', "insert into vt_select_test (id, msg) values (10, 'test 10')", write=True)
utils.validate_topology(ping_tablets=True)
utils.pause("Before the sql scatter query")
# note the order of the rows is not guaranteed, as the go routines
# doing the work can go out of order
self._check_rows(["Index\tid\tmsg",
"1\ttest 1",
"10\ttest 10"])
# write a value, re-read them all
utils.vtclient2(3803, "/test_nj/test_keyspace/master", "insert into vt_select_test (id, msg) values (:keyspace_id, 'test 2')", bindvars='{"keyspace_id": 2}', driver="vtdb", verbose=True)
self._check_rows(["Index\tid\tmsg",
"1\ttest 1",
"2\ttest 2",
"10\ttest 10"])
# make sure the '2' value was written on first shard
rows = shard_0_master.mquery('vt_test_keyspace', "select id, msg from vt_select_test order by id")
self.assertEqual(rows, ((1, 'test 1'), (2, 'test 2'), ),
'wrong mysql_query output: %s' % str(rows))
utils.pause("After db writes")
# now use various topo servers and streaming or both for the same query
self._check_rows(["Index\tid\tmsg",
"1\ttest 1",
"2\ttest 2",
"10\ttest 10"],
driver="vtdb-streaming")
if environment.topo_server().flavor() == 'zookeeper':
self._check_rows(["Index\tid\tmsg",
"1\ttest 1",
"2\ttest 2",
"10\ttest 10"],
driver="vtdb-zk")
self._check_rows(["Index\tid\tmsg",
"1\ttest 1",
"2\ttest 2",
"10\ttest 10"],
driver="vtdb-zk-streaming")
# make sure the schema checking works
self._check_rows_schema_diff("vtdb")
if environment.topo_server().flavor() == 'zookeeper':
self._check_rows_schema_diff("vtdb-zk")
#.........这里部分代码省略.........
开发者ID:Eter365,项目名称:vitess,代码行数:101,代码来源:sharded.py
注:本文中的utils.vtclient2函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论