本文整理汇总了Python中mongo_orchestration.sharded_clusters.ShardedCluster.info方法的典型用法代码示例。如果您正苦于以下问题:Python ShardedCluster.info方法的具体用法?Python ShardedCluster.info怎么用?Python ShardedCluster.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mongo_orchestration.sharded_clusters.ShardedCluster
的用法示例。
在下文中一共展示了ShardedCluster.info方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ShardTestCase
# 需要导入模块: from mongo_orchestration.sharded_clusters import ShardedCluster [as 别名]
# 或者: from mongo_orchestration.sharded_clusters.ShardedCluster import info [as 别名]
#.........这里部分代码省略.........
self.assertEqual(len(self.sh.configsvrs), 1)
self.sh.cleanup()
config = {'configsvrs': [{}, {}, {}]}
self.sh = ShardedCluster(config)
self.assertEqual(len(self.sh.configsvrs), 3)
self.sh.cleanup()
def test_routers(self):
config = {}
self.sh = ShardedCluster(config)
self.assertEqual(len(self.sh.routers), 1)
self.sh.cleanup()
config = {'routers': [{}, {}, {}]}
self.sh = ShardedCluster(config)
self.assertEqual(len(self.sh.routers), 3)
self.sh.cleanup()
def test_members(self):
config = {}
self.sh = ShardedCluster(config)
self.assertEqual(len(self.sh.members), 0)
self.sh.cleanup()
config = {'shards': [{}, {}, {}]}
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()
示例2: ShardSSLTestCase
# 需要导入模块: from mongo_orchestration.sharded_clusters import ShardedCluster [as 别名]
# 或者: from mongo_orchestration.sharded_clusters.ShardedCluster import info [as 别名]
#.........这里部分代码省略.........
DEFAULT_SUBJECT, mechanism='MONGODB-X509')
# Should create the user we requested. No raise on authenticate.
client = pymongo.MongoClient(
host, ssl_certfile=certificate('client.pem'),
ssl_cert_reqs=ssl.CERT_NONE)
client['$external'].authenticate(TEST_SUBJECT, mechanism='MONGODB-X509')
def test_scram_with_ssl(self):
proc_params = {'procParams': {'clusterAuthMode': 'x509'}}
config = {
'login': 'luke',
'password': 'ekul',
'configsvrs': [{'clusterAuthMode': 'x509'}],
'routers': [{'clusterAuthMode': 'x509'}],
'shards': [{'shardParams': proc_params},
{'shardParams': {'members': [proc_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.sh = ShardedCluster(config)
time.sleep(1)
# Should create the user we requested. No raise on authenticate.
host = self.sh.router['hostname']
client = pymongo.MongoClient(
host, 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'])
def test_ssl(self):
config = {
'configsvrs': [{}],
'routers': [{}],
'shards': [{}, {'shardParams': {'members': [{}]}}],
'sslParams': {
'sslCAFile': certificate('ca.pem'),
'sslPEMKeyFile': certificate('server.pem'),
'sslMode': 'requireSSL',
'sslClusterFile': certificate('cluster_cert.pem'),
'sslAllowInvalidCertificates': True
}
}
# Should not raise an Exception.
self.sh = ShardedCluster(config)
# Server should require SSL.
host = self.sh.router['hostname']
with self.assertRaises(pymongo.errors.ConnectionFailure):
connected(pymongo.MongoClient(host))
# This shouldn't raise.
connected(
pymongo.MongoClient(host, ssl_certfile=certificate('client.pem'),
ssl_cert_reqs=ssl.CERT_NONE))
def test_mongodb_auth_uri(self):
if SERVER_VERSION < (2, 4):
raise SkipTest("Need to be able to set 'authenticationMechanisms' "
"parameter to test.")
shard_params = {
'shardParams': {
'procParams': {
'clusterAuthMode': 'x509',
'setParameter': {'authenticationMechanisms': 'MONGODB-X509'}
}
}
}
config = {
'login': TEST_SUBJECT,
'authSource': '$external',
'configsvrs': [{'clusterAuthMode': 'x509'}],
'routers': [{'clusterAuthMode': 'x509'}],
'shards': [shard_params, shard_params],
'sslParams': {
'sslCAFile': certificate('ca.pem'),
'sslPEMKeyFile': certificate('server.pem'),
'sslMode': 'requireSSL',
'sslClusterFile': certificate('cluster_cert.pem'),
'sslAllowInvalidCertificates': True
}
}
self.sh = ShardedCluster(config)
self.assertIn('mongodb_auth_uri', self.sh.info())
auth_uri = self.sh.info()['mongodb_auth_uri']
hosts = ','.join(r['hostname'] for r in self.sh.routers)
self.assertIn(hosts, auth_uri)
self.assertIn(TEST_SUBJECT, auth_uri)
self.assertIn('authSource=$external', auth_uri)
self.assertIn('authMechanism=MONGODB-X509', auth_uri)
示例3: ShardTestCase
# 需要导入模块: from mongo_orchestration.sharded_clusters import ShardedCluster [as 别名]
# 或者: from mongo_orchestration.sharded_clusters.ShardedCluster import info [as 别名]
#.........这里部分代码省略.........
self.assertEqual(len(self.sh.configsvrs), 1)
self.sh.cleanup()
config = {'configsvrs': [{}, {}, {}]}
self.sh = ShardedCluster(config)
self.assertEqual(len(self.sh.configsvrs), 3)
self.sh.cleanup()
def test_routers(self):
config = {}
self.sh = ShardedCluster(config)
self.assertEqual(len(self.sh.routers), 1)
self.sh.cleanup()
config = {'routers': [{}, {}, {}]}
self.sh = ShardedCluster(config)
self.assertEqual(len(self.sh.routers), 3)
self.sh.cleanup()
def test_members(self):
config = {}
self.sh = ShardedCluster(config)
self.assertEqual(len(self.sh.members), 0)
self.sh.cleanup()
config = {'shards': [{}, {}, {}]}
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()