本文整理汇总了Python中mongo_orchestration.replica_sets.ReplicaSet.member_update方法的典型用法代码示例。如果您正苦于以下问题:Python ReplicaSet.member_update方法的具体用法?Python ReplicaSet.member_update怎么用?Python ReplicaSet.member_update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mongo_orchestration.replica_sets.ReplicaSet
的用法示例。
在下文中一共展示了ReplicaSet.member_update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ReplicaSetTestCase
# 需要导入模块: from mongo_orchestration.replica_sets import ReplicaSet [as 别名]
# 或者: from mongo_orchestration.replica_sets.ReplicaSet import member_update [as 别名]
#.........这里部分代码省略.........
self.repl_cfg = {'members': [{}, {}]}
self.repl = ReplicaSet(self.repl_cfg)
config = self.repl.config
self.assertTrue('_id' in config)
self.assertTrue('members' in config)
def test_member_create(self):
self.repl_cfg = {'members': [{}, {}]}
self.repl = ReplicaSet(self.repl_cfg)
result = self.repl.member_create({}, 13)
self.assertTrue('host' in result)
self.assertTrue('_id' in result)
h_id = Servers().host_to_server_id(result['host'])
h_info = Servers().info(h_id)
self.assertIn(result['host'], h_info['mongodb_uri'])
self.assertTrue(h_info['procInfo']['alive'])
Servers().remove(h_id)
def test_member_del(self):
self.repl_cfg = {'members': [{}, {}, {}]}
self.repl = ReplicaSet(self.repl_cfg)
m_count = len(self.repl.config['members'])
self.assertTrue(self.repl.member_del(2))
self.assertEqual(len(self.repl.config['members']), m_count - 1)
def test_member_del_no_reconfig(self):
self.repl_cfg = {'members': [{}, {}, {}]}
self.repl = ReplicaSet(self.repl_cfg)
m_count = len(self.repl.config['members'])
self.assertTrue(self.repl.member_del(2, reconfig=False))
self.assertEqual(len(self.repl.config['members']), m_count)
self.repl.server_map.pop(2)
def test_member_update(self):
self.repl = ReplicaSet(self.repl_cfg)
member = [item for item in self.repl.config['members'] if item['_id'] == 2][0]
self.assertTrue(member.get('hidden', False))
self.assertTrue(self.repl.member_update(2, {"rsParams": {"priority": 1, "hidden": False}}))
member = [item for item in self.repl.config['members'] if item['_id'] == 2][0]
self.assertFalse(member.get('hidden', False))
def test_member_info(self):
self.repl_cfg = {'members': [{}, {}]}
self.repl = ReplicaSet(self.repl_cfg)
member = [item for item in self.repl.config['members'] if item['_id'] == 1][0]
result = self.repl.member_info(1)
self.assertTrue(result['procInfo']['alive'])
self.assertIn(member['host'], result['mongodb_uri'])
self.assertTrue(len(result['rsInfo']) > 0)
def test_member_command(self):
self.repl_cfg = {'members': [{}, {}]}
self.repl = ReplicaSet(self.repl_cfg)
_id = 1
self.assertTrue(self.repl.member_info(_id)['procInfo']['alive'])
self.repl.member_command(_id, 'stop')
self.assertFalse(self.repl.member_info(_id)['procInfo']['alive'])
self.repl.member_command(_id, 'start')
self.assertTrue(self.repl.member_info(_id)['procInfo']['alive'])
self.repl.member_command(_id, 'restart')
self.assertTrue(self.repl.member_info(_id)['procInfo']['alive'])
def test_members(self):
self.repl_cfg = {'members': [{}, {}]}
self.repl = ReplicaSet(self.repl_cfg)
members1 = sorted(self.repl.config['members'], key=lambda item: item['_id'])