• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python replica_sets.ReplicaSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mongo_orchestration.replica_sets.ReplicaSet的典型用法代码示例。如果您正苦于以下问题:Python ReplicaSet类的具体用法?Python ReplicaSet怎么用?Python ReplicaSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ReplicaSet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_member_id_to_host

 def test_member_id_to_host(self):
     self.repl_cfg = {'members': [{}, {}]}
     self.repl = ReplicaSet(self.repl_cfg)
     members = self.repl.config['members']
     for member in members:
         host = self.repl.member_id_to_host(member['_id'])
         self.assertEqual(member['host'], host)
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:7,代码来源:test_replica_sets.py


示例2: test_host2id

 def test_host2id(self):
     self.repl_cfg = {'members': [{}, {}]}
     self.repl = ReplicaSet(self.repl_cfg)
     members = self.repl.config['members']
     for member in members:
         self.assertEqual(member['_id'],
                          self.repl.host2id(member['host']))
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:7,代码来源:test_replica_sets.py


示例3: test_len

 def test_len(self):
     self.repl = ReplicaSet(self.repl_cfg)
     self.assertTrue(len(self.repl) == len(self.repl_cfg['members']))
     self.repl.member_del(3)
     self.assertTrue(len(self.repl) == len(self.repl_cfg['members']) - 1)
     self.repl.repl_member_add({'rsParams': {'arbiterOnly': True}})
     self.assertTrue(len(self.repl) == len(self.repl_cfg['members']))
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:7,代码来源:test_replica_sets.py


示例4: test_member_del_no_reconfig

 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)
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:7,代码来源:test_replica_sets.py


示例5: test_scram_with_ssl

    def test_scram_with_ssl(self):
        member_params = {'procParams': {'clusterAuthMode': 'x509'}}
        self.repl_cfg = {
            'login': 'luke',
            'password': 'ekul',
            'members': [member_params, member_params],
            'sslParams': {
                'sslCAFile': certificate('ca.pem'),
                'sslPEMKeyFile': certificate('server.pem'),
                'sslMode': 'requireSSL',
                'sslClusterFile': certificate('cluster_cert.pem'),
                'sslAllowInvalidCertificates': True
            }
        }
        # Should not raise an Exception.
        self.repl = ReplicaSet(self.repl_cfg)

        # Should create the user we requested. No raise on authenticate.
        client = pymongo.MongoClient(
            self.repl.primary(), ssl_certfile=certificate('client.pem'),
            ssl_cert_reqs=ssl.CERT_NONE)
        client.admin.authenticate('luke', 'ekul')
        # This should be the only user.
        self.assertEqual(len(client.admin.command('usersInfo')['users']), 1)
        self.assertFalse(client['$external'].command('usersInfo')['users'])
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:25,代码来源:test_replica_sets.py


示例6: test_member_info_auth_uri

 def test_member_info_auth_uri(self):
     member_params = {
         'procParams': {
             'clusterAuthMode': 'x509',
             'setParameter': {'authenticationMechanisms': 'MONGODB-X509'}
         }
     }
     self.repl_cfg = {
         'login': TEST_SUBJECT,
         'authSource': '$external',
         'members': [member_params, member_params],
         'sslParams': {
             'sslCAFile': certificate('ca.pem'),
             'sslPEMKeyFile': certificate('server.pem'),
             'sslMode': 'requireSSL',
             'sslClusterFile': certificate('cluster_cert.pem'),
             'sslAllowInvalidCertificates': True
         }
     }
     self.repl = ReplicaSet(self.repl_cfg)
     for i in range(len(self.repl)):
         member = self.repl.member_info(i)
         self.assertIn('mongodb_auth_uri', member)
         uri = member['mongodb_auth_uri']
         host = Servers().hostname(member['server_id'])
         self.assertIn(host, uri)
         self.assertIn(TEST_SUBJECT, uri)
         self.assertIn('authSource=$external', uri)
         self.assertIn('authMechanism=MONGODB-X509', uri)
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:29,代码来源:test_replica_sets.py


示例7: test_wait_while_reachable

 def test_wait_while_reachable(self):
     self.repl_cfg = {'members': [{}, {}]}
     self.repl = ReplicaSet(self.repl_cfg)
     servers = [member['host'] for member in self.repl.members()]
     self.assertTrue(self.repl.wait_while_reachable(servers, timeout=10))
     self.repl.member_command(1, 'stop')
     self.assertFalse(self.repl.wait_while_reachable(servers, timeout=10))
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:7,代码来源:test_replica_sets.py


示例8: test_mongodb_auth_uri

    def test_mongodb_auth_uri(self):
        if SERVER_VERSION < (2, 4):
            raise SkipTest("Need to be able to set 'authenticationMechanisms' "
                           "parameter to test.")

        member_params = {
            'procParams': {
                'clusterAuthMode': 'x509',
                'setParameter': {'authenticationMechanisms': 'MONGODB-X509'}
            }
        }
        self.repl_cfg = {
            'login': TEST_SUBJECT,
            'authSource': '$external',
            'members': [member_params, member_params],
            'sslParams': {
                'sslCAFile': certificate('ca.pem'),
                'sslPEMKeyFile': certificate('server.pem'),
                'sslMode': 'requireSSL',
                'sslClusterFile': certificate('cluster_cert.pem'),
                'sslAllowInvalidCertificates': True
            }
        }
        self.repl = ReplicaSet(self.repl_cfg)

        self.assertIn('mongodb_auth_uri', self.repl.info())
        repl_auth_uri = self.repl.info()['mongodb_auth_uri']
        hosts = ','.join(m['host'] for m in self.repl.members())
        self.assertIn(hosts, repl_auth_uri)
        self.assertIn(TEST_SUBJECT, repl_auth_uri)
        self.assertIn('authSource=$external', repl_auth_uri)
        self.assertIn('authMechanism=MONGODB-X509', repl_auth_uri)
        replset_param = 'replicaSet=' + self.repl.repl_id
        self.assertIn(replset_param, repl_auth_uri)
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:34,代码来源:test_replica_sets.py


示例9: test_repl_member_add

 def test_repl_member_add(self):
     self.repl_cfg = {'members': [{}, {}]}
     self.repl = ReplicaSet(self.repl_cfg)
     member_id = self.repl.repl_member_add({"rsParams": {"priority": 0, "hidden": True}})
     self.assertTrue(member_id >= 0)
     member = [item for item in self.repl.config['members'] if item['_id'] == member_id][0]
     self.assertTrue(member['hidden'])
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:7,代码来源:test_replica_sets.py


示例10: test_member_update

 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))
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:7,代码来源:test_replica_sets.py


示例11: test_member_info

 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)
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:8,代码来源:test_replica_sets.py


示例12: test_run_command

 def test_run_command(self):
     self.repl_cfg = {'members': [{}, {}]}
     self.repl = ReplicaSet(self.repl_cfg)
     self.assertEqual(self.repl.run_command("rs.status()", is_eval=True)['ok'], 1)
     result = self.repl.run_command('serverStatus', arg=None, is_eval=False, member_id=0)['repl']
     for key in ('me', 'ismaster', 'setName', 'primary', 'hosts'):
         self.assertTrue(key in result)
     self.assertEqual(self.repl.run_command(command="replSetGetStatus", is_eval=False)['ok'], 1)
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:8,代码来源:test_replica_sets.py


示例13: test_repl_update

 def test_repl_update(self):
     self.repl_cfg = {'members': [{}, {}, {'rsParams': {'priority': 0, 'hidden': True}}]}
     self.repl = ReplicaSet(self.repl_cfg)
     config = self.repl.config
     config['members'][1]['priority'] = 0
     config['members'][1]['hidden'] = True
     self.assertTrue(self.repl.repl_update(config))
     self.assertTrue(self.repl.config['members'][1]['hidden'])
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:8,代码来源:test_replica_sets.py


示例14: test_connection

 def test_connection(self):
     self.repl_cfg = {'members': [{}, {}]}
     self.repl = ReplicaSet(self.repl_cfg)
     _id = 1
     hostname = self.repl.member_id_to_host(_id)
     self.assertTrue(self.repl.connection(timeout=5))
     self.assertTrue(self.repl.connection(hostname=hostname, timeout=5))
     self.repl.member_command(_id, 'stop')
     self.assertRaises(pymongo.errors.AutoReconnect, lambda: self.repl.connection(hostname=hostname, timeout=5))
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:9,代码来源:test_replica_sets.py


示例15: test_members

 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'])
     members2 = sorted(self.repl.members(), key=lambda item: item['_id'])
     self.assertEqual(len(members1), len(members2))
     for i in range(len(members1)):
         self.assertEqual(members1[i]['host'], members2[i]['host'])
         self.assertEqual(members1[i]['_id'], members2[i]['_id'])
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:9,代码来源:test_replica_sets.py


示例16: test_compare_servers_passives

    def test_compare_servers_passives(self):
        self.repl = ReplicaSet(self.repl_cfg)
        self.repl.repl_member_add({"rsParams": {"priority": 0}})
        self.repl.repl_member_add({})
        servers = self.repl.servers()
        passives = self.repl.passives()
        for item in servers:
            self.assertTrue(item not in passives)

        for item in passives:
            self.assertTrue(item not in servers)
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:11,代码来源:test_replica_sets.py


示例17: test_member_command

 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'])
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:11,代码来源:test_replica_sets.py


示例18: test_member_create

 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)
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:11,代码来源:test_replica_sets.py


示例19: test_auth_arbiter_member_info

 def test_auth_arbiter_member_info(self):
     self.repl = ReplicaSet({'members': [
         {}, {'rsParams': {'arbiterOnly': True}}]})
     info = self.repl.member_info(1)
     for key in ('procInfo', 'mongodb_uri', 'statuses', 'rsInfo'):
         self.assertIn(key, info)
     rs_info = info['rsInfo']
     for key in ('primary', 'secondary', 'arbiterOnly'):
         self.assertIn(key, rs_info)
     self.assertFalse(rs_info['primary'])
     self.assertFalse(rs_info['secondary'])
     self.assertTrue(rs_info['arbiterOnly'])
开发者ID:TylerBrock,项目名称:mongo-orchestration,代码行数:12,代码来源:test_replica_sets.py


示例20: test_info

 def test_info(self):
     self.repl_cfg = {'members': [{}, {}]}
     self.repl = ReplicaSet(self.repl_cfg)
     cfg = self.repl.config
     info = self.repl.info()
     self.assertEqual(info['auth_key'], self.repl.auth_key)
     self.assertEqual(info['id'], self.repl.repl_id)
     self.assertEqual(len(info['members']), len(cfg['members']))
     members1 = sorted(cfg['members'], key=lambda item: item['_id'])
     members2 = sorted(info['members'], key=lambda item: item['_id'])
     for i in range(len(members1)):
         self.assertEqual(members1[i]['_id'], members2[i]['_id'])
         self.assertEqual(members1[i]['host'], members2[i]['host'])
开发者ID:10gen,项目名称:mongo-orchestration,代码行数:13,代码来源:test_replica_sets.py



注:本文中的mongo_orchestration.replica_sets.ReplicaSet类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python servers.Server类代码示例发布时间:2022-05-27
下一篇:
Python util.retry_until_ok函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap