本文整理汇总了Python中mongo_orchestration.sharded_clusters.ShardedCluster.router_command方法的典型用法代码示例。如果您正苦于以下问题:Python ShardedCluster.router_command方法的具体用法?Python ShardedCluster.router_command怎么用?Python ShardedCluster.router_command使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mongo_orchestration.sharded_clusters.ShardedCluster
的用法示例。
在下文中一共展示了ShardedCluster.router_command方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ShardTestCase
# 需要导入模块: from mongo_orchestration.sharded_clusters import ShardedCluster [as 别名]
# 或者: from mongo_orchestration.sharded_clusters.ShardedCluster import router_command [as 别名]
#.........这里部分代码省略.........
self.sh = ShardedCluster(config)
self.assertEqual(len(self.sh.members), 3)
self.sh.cleanup()
def test_router(self):
config = {}
self.sh = ShardedCluster(config)
self.assertTrue(Servers().info(self.sh.router['id'])['statuses']['mongos'])
self.sh.cleanup()
config = {'routers': [{}, {}, {}]}
self.sh = ShardedCluster(config)
routers = self.sh.routers
hostname = routers[1]['hostname']
_id = routers[1]['id']
# stop routers 0 and 2
Servers().command(routers[0]['id'], 'stop')
Servers().command(routers[2]['id'], 'stop')
router = self.sh.router
self.assertEqual(router['id'], _id)
self.assertEqual(router['hostname'], hostname)
self.sh.cleanup()
def test_router_add(self):
config = {}
self.sh = ShardedCluster(config)
self.assertEqual(len(self.sh.routers), 1)
self.sh.router_add({})
self.assertEqual(len(self.sh.routers), 2)
self.sh.router_add({})
self.assertEqual(len(self.sh.routers), 3)
self.sh.cleanup()
def test_router_command(self):
config = {'shards': [{}, {}]}
self.sh = ShardedCluster(config)
result = self.sh.router_command('listShards', is_eval=False)
self.assertEqual(result['ok'], 1)
self.sh.cleanup()
def test_member_add(self):
config = {}
self.sh = ShardedCluster(config)
self.assertEqual(len(self.sh.members), 0)
result = self.sh.member_add('test1', {})
self.assertTrue(result.get('isServer', False))
self.assertEqual(result['id'], 'test1')
self.assertEqual(len(self.sh.members), 1)
result = self.sh.member_add('test2', {'id': 'rs1', 'members': [{}, {}]})
self.assertFalse(result.get('isServer', False))
self.assertTrue(result.get('isReplicaSet', False))
self.assertEqual(result['id'], 'test2')
self.assertEqual(len(self.sh.members), 2)
self.sh.cleanup()
def test_member_info(self):
config = {'shards': [{'id': 'member1'}, {'id': 'sh-rs-01', 'shardParams': {'id': 'rs1', 'members': [{}, {}]}}]}
self.sh = ShardedCluster(config)
info = self.sh.member_info('member1')
self.assertEqual(info['id'], 'member1')
self.assertTrue(info['isServer'])
self.assertTrue('_id' in info)
info = self.sh.member_info('sh-rs-01')
示例2: ShardTestCase
# 需要导入模块: from mongo_orchestration.sharded_clusters import ShardedCluster [as 别名]
# 或者: from mongo_orchestration.sharded_clusters.ShardedCluster import router_command [as 别名]
#.........这里部分代码省略.........
self.sh = ShardedCluster(config)
self.assertEqual(len(self.sh.members), 3)
self.sh.cleanup()
def test_router(self):
config = {}
self.sh = ShardedCluster(config)
self.assertTrue(Servers().info(self.sh.router['id'])['statuses']['mongos'])
self.sh.cleanup()
config = {'routers': [{}, {}, {}]}
self.sh = ShardedCluster(config)
routers = self.sh.routers
hostname = routers[1]['hostname']
_id = routers[1]['id']
# stop routers 0 and 2
Servers().command(routers[0]['id'], 'stop')
Servers().command(routers[2]['id'], 'stop')
router = self.sh.router
self.assertEqual(router['id'], _id)
self.assertEqual(router['hostname'], hostname)
self.sh.cleanup()
def test_router_add(self):
config = {}
self.sh = ShardedCluster(config)
self.assertEqual(len(self.sh.routers), 1)
self.sh.router_add({})
self.assertEqual(len(self.sh.routers), 2)
self.sh.router_add({})
self.assertEqual(len(self.sh.routers), 3)
self.sh.cleanup()
def test_router_command(self):
config = {'shards': [{}, {}]}
self.sh = ShardedCluster(config)
result = self.sh.router_command('listShards', is_eval=False)
self.assertEqual(result['ok'], 1)
self.sh.cleanup()
def test_member_add(self):
config = {}
self.sh = ShardedCluster(config)
self.assertEqual(len(self.sh.members), 0)
result = self.sh.member_add('test1', {})
self.assertTrue(result.get('isServer', False))
self.assertEqual(result['id'], 'test1')
self.assertEqual(len(self.sh.members), 1)
result = self.sh.member_add('test2', {'id': 'rs1', 'members': [{}, {}]})
self.assertFalse(result.get('isServer', False))
self.assertTrue(result.get('isReplicaSet', False))
self.assertEqual(result['id'], 'test2')
self.assertEqual(len(self.sh.members), 2)
self.sh.cleanup()
def test_member_info(self):
config = {'shards': [{'id': 'member1'}, {'id': 'sh-rs-01', 'shardParams': {'id': 'rs1', 'members': [{}, {}]}}]}
self.sh = ShardedCluster(config)
info = self.sh.member_info('member1')
self.assertEqual(info['id'], 'member1')
self.assertTrue(info['isServer'])
self.assertTrue('_id' in info)
info = self.sh.member_info('sh-rs-01')