本文整理汇总了Python中pymongo.mongo_replica_set_client.MongoReplicaSetClient类的典型用法代码示例。如果您正苦于以下问题:Python MongoReplicaSetClient类的具体用法?Python MongoReplicaSetClient怎么用?Python MongoReplicaSetClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MongoReplicaSetClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: TestMonitorRemovesRecoveringMember
class TestMonitorRemovesRecoveringMember(HATestCase):
# Members in STARTUP2 or RECOVERING states are shown in the primary's
# isMaster response, but aren't secondaries and shouldn't be read from.
# Verify that if a secondary goes into RECOVERING mode, the Monitor removes
# it from the set of readers.
def setUp(self):
members = [{}, {'priority': 0}, {'priority': 0}]
res = ha_tools.start_replica_set(members)
self.seed, self.name = res
def test_monitor_removes_recovering_member(self):
self.c = MongoReplicaSetClient(
self.seed, replicaSet=self.name, use_greenlets=use_greenlets)
secondaries = ha_tools.get_secondaries()
for mode in SECONDARY, SECONDARY_PREFERRED:
partitioned_secondaries = partition_nodes(secondaries)
utils.assertReadFromAll(self, self.c, partitioned_secondaries, mode)
secondary, recovering_secondary = secondaries
ha_tools.set_maintenance(recovering_secondary, True)
sleep(2 * MONITOR_INTERVAL)
for mode in SECONDARY, SECONDARY_PREFERRED:
# Don't read from recovering member
utils.assertReadFrom(self, self.c, _partition_node(secondary), mode)
def tearDown(self):
self.c.close()
super(TestMonitorRemovesRecoveringMember, self).tearDown()
开发者ID:nilnullzip,项目名称:mongo-python-driver,代码行数:32,代码来源:test_ha.py
示例2: test_get_default_database
def test_get_default_database(self):
host = one(self.hosts)
uri = "mongodb://%s:%d/foo?replicaSet=%s" % (
host[0], host[1], self.name)
c = MongoReplicaSetClient(uri, _connect=False)
self.assertEqual(Database(c, 'foo'), c.get_default_database())
开发者ID:MrMission,项目名称:spider,代码行数:7,代码来源:test_replica_set_client.py
示例3: test_alive
def test_alive(self):
client = self._get_client()
self.assertTrue(client.alive())
client = MongoReplicaSetClient("doesnt exist", replicaSet="rs", _connect=False)
self.assertFalse(client.alive())
开发者ID:distagon,项目名称:Taiwan_Stock_info,代码行数:7,代码来源:test_replica_set_client.py
示例4: TestPassiveAndHidden
class TestPassiveAndHidden(HATestCase):
def setUp(self):
members = [{},
{'priority': 0},
{'arbiterOnly': True},
{'priority': 0, 'hidden': True},
{'priority': 0, 'slaveDelay': 5}
]
res = ha_tools.start_replica_set(members)
self.seed, self.name = res
def test_passive_and_hidden(self):
self.c = MongoReplicaSetClient(
self.seed, replicaSet=self.name, use_greenlets=use_greenlets)
passives = ha_tools.get_passives()
passives = partition_nodes(passives)
self.assertEqual(self.c.secondaries, set(passives))
for mode in SECONDARY, SECONDARY_PREFERRED:
utils.assertReadFromAll(self, self.c, passives, mode)
ha_tools.kill_members(ha_tools.get_passives(), 2)
sleep(2 * MONITOR_INTERVAL)
utils.assertReadFrom(self, self.c, self.c.primary, SECONDARY_PREFERRED)
def tearDown(self):
self.c.close()
super(TestPassiveAndHidden, self).tearDown()
开发者ID:nilnullzip,项目名称:mongo-python-driver,代码行数:30,代码来源:test_ha.py
示例5: test_get_default_database_with_authsource
def test_get_default_database_with_authsource(self):
# Ensure we distinguish database name from authSource.
host = one(self.hosts)
uri = "mongodb://%s:%d/foo?replicaSet=%s&authSource=src" % (host[0], host[1], self.name)
c = MongoReplicaSetClient(uri, _connect=False)
self.assertEqual(Database(c, "foo"), c.get_default_database())
开发者ID:RockLi,项目名称:mongo-python-driver,代码行数:7,代码来源:test_replica_set_client.py
示例6: TestReplicaSetRequest
class TestReplicaSetRequest(HATestCase):
def setUp(self):
members = [{}, {}, {'arbiterOnly': True}]
res = ha_tools.start_replica_set(members)
self.c = MongoReplicaSetClient(res[0], replicaSet=res[1],
use_greenlets=use_greenlets,
auto_start_request=True)
def test_request_during_failover(self):
primary = _partition_node(ha_tools.get_primary())
secondary = _partition_node(ha_tools.get_random_secondary())
self.assertTrue(self.c.auto_start_request)
self.assertTrue(self.c.in_request())
rs_state = self.c._MongoReplicaSetClient__rs_state
primary_pool = rs_state.get(primary).pool
secondary_pool = rs_state.get(secondary).pool
# Trigger start_request on primary pool
utils.assertReadFrom(self, self.c, primary, PRIMARY)
self.assertTrue(primary_pool.in_request())
# Fail over
ha_tools.kill_primary()
sleep(5)
patience_seconds = 60
for _ in range(patience_seconds):
try:
if ha_tools.ha_tools_debug:
print 'Waiting for failover'
if ha_tools.get_primary():
# We have a new primary
break
except ConnectionFailure:
pass
sleep(1)
else:
self.fail("Problem with test: No new primary after %s seconds"
% patience_seconds)
try:
# Trigger start_request on secondary_pool, which is becoming new
# primary
self.c.test.test.find_one()
except AutoReconnect:
# We've noticed the failover now
pass
# The old secondary is now primary
utils.assertReadFrom(self, self.c, secondary, PRIMARY)
self.assertTrue(self.c.in_request())
self.assertTrue(secondary_pool.in_request())
def tearDown(self):
self.c.close()
super(TestReplicaSetRequest, self).tearDown()
开发者ID:1060460048,项目名称:mongo-python-driver,代码行数:59,代码来源:test_ha.py
示例7: _get_client
def _get_client(self, **kwargs):
kwargs.setdefault('connectTimeoutMS', 500)
# Assume there are no open mongods listening on a.com, b.com, ....
bad_seeds = ['%s.com' % chr(ord('a') + i) for i in range(5)]
seeds = ','.join(bad_seeds + [pair])
client = MongoReplicaSetClient(seeds, replicaSet=self.name, **kwargs)
# In case of a slow test machine.
client._refresh_timeout_sec = 30
return client
开发者ID:MrMission,项目名称:spider,代码行数:11,代码来源:test_replica_set_client.py
示例8: test_ipv6
def test_ipv6(self):
try:
client = MongoReplicaSetClient("[::1]:%d" % (port,),
replicaSet=self.name)
except:
# Either mongod was started without --ipv6
# or the OS doesn't support it (or both).
raise SkipTest("No IPv6")
# Try a few simple things
client = MongoReplicaSetClient("mongodb://[::1]:%d" % (port,),
replicaSet=self.name)
client = MongoReplicaSetClient("mongodb://[::1]:%d/?w=0;"
"replicaSet=%s" % (port, self.name))
client = MongoReplicaSetClient("[::1]:%d,localhost:"
"%d" % (port, port),
replicaSet=self.name)
client = MongoReplicaSetClient("localhost:%d,[::1]:"
"%d" % (port, port),
replicaSet=self.name)
client.pymongo_test.test.save({"dummy": u"object"})
client.pymongo_test_bernie.test.save({"dummy": u"object"})
dbs = client.database_names()
self.assertTrue("pymongo_test" in dbs)
self.assertTrue("pymongo_test_bernie" in dbs)
client.close()
开发者ID:MrMission,项目名称:spider,代码行数:27,代码来源:test_replica_set_client.py
示例9: TestReplicaSetAuth
class TestReplicaSetAuth(HATestCase):
def setUp(self):
members = [
{},
{'priority': 0},
{'priority': 0},
]
res = ha_tools.start_replica_set(members, auth=True)
self.c = MongoReplicaSetClient(res[0], replicaSet=res[1],
use_greenlets=use_greenlets)
# Add an admin user to enable auth
self.c.admin.add_user('admin', 'adminpass')
self.c.admin.authenticate('admin', 'adminpass')
self.db = self.c.pymongo_ha_auth
self.db.add_user('user', 'userpass')
self.c.admin.logout()
def test_auth_during_failover(self):
self.assertTrue(self.db.authenticate('user', 'userpass'))
self.assertTrue(self.db.foo.insert({'foo': 'bar'},
safe=True, w=3, wtimeout=3000))
self.db.logout()
self.assertRaises(OperationFailure, self.db.foo.find_one)
primary = self.c.primary
ha_tools.kill_members(['%s:%d' % primary], 2)
# Let monitor notice primary's gone
sleep(2 * MONITOR_INTERVAL)
self.assertFalse(primary == self.c.primary)
# Make sure we can still authenticate
self.assertTrue(self.db.authenticate('user', 'userpass'))
# And still query.
self.db.read_preference = PRIMARY_PREFERRED
self.assertEqual('bar', self.db.foo.find_one()['foo'])
def tearDown(self):
self.c.close()
super(TestReplicaSetAuth, self).tearDown()
开发者ID:1060460048,项目名称:mongo-python-driver,代码行数:43,代码来源:test_ha.py
示例10: test_alive
def test_alive(self):
primary = ha_tools.get_primary()
secondary = ha_tools.get_random_secondary()
primary_cx = MongoClient(primary, use_greenlets=use_greenlets)
secondary_cx = MongoClient(secondary, use_greenlets=use_greenlets)
rsc = MongoReplicaSetClient(
self.seed, replicaSet=self.name, use_greenlets=use_greenlets)
try:
self.assertTrue(primary_cx.alive())
self.assertTrue(secondary_cx.alive())
self.assertTrue(rsc.alive())
ha_tools.kill_primary()
time.sleep(0.5)
self.assertFalse(primary_cx.alive())
self.assertTrue(secondary_cx.alive())
self.assertFalse(rsc.alive())
ha_tools.kill_members([secondary], 2)
time.sleep(0.5)
self.assertFalse(primary_cx.alive())
self.assertFalse(secondary_cx.alive())
self.assertFalse(rsc.alive())
finally:
rsc.close()
开发者ID:nilnullzip,项目名称:mongo-python-driver,代码行数:28,代码来源:test_ha.py
示例11: test_passive_and_hidden
def test_passive_and_hidden(self):
self.c = MongoReplicaSetClient(
self.seed, replicaSet=self.name, use_greenlets=use_greenlets)
passives = ha_tools.get_passives()
passives = partition_nodes(passives)
self.assertEqual(self.c.secondaries, set(passives))
for mode in SECONDARY, SECONDARY_PREFERRED:
utils.assertReadFromAll(self, self.c, passives, mode)
ha_tools.kill_members(ha_tools.get_passives(), 2)
sleep(2 * MONITOR_INTERVAL)
utils.assertReadFrom(self, self.c, self.c.primary, SECONDARY_PREFERRED)
开发者ID:nilnullzip,项目名称:mongo-python-driver,代码行数:14,代码来源:test_ha.py
示例12: setUp
def setUp(self):
members = [
# primary
{'tags': {'dc': 'ny', 'name': 'primary'}},
# secondary
{'tags': {'dc': 'la', 'name': 'secondary'}, 'priority': 0},
# other_secondary
{'tags': {'dc': 'ny', 'name': 'other_secondary'}, 'priority': 0},
]
res = ha_tools.start_replica_set(members)
self.seed, self.name = res
primary = ha_tools.get_primary()
self.primary = _partition_node(primary)
self.primary_tags = ha_tools.get_tags(primary)
# Make sure priority worked
self.assertEqual('primary', self.primary_tags['name'])
self.primary_dc = {'dc': self.primary_tags['dc']}
secondaries = ha_tools.get_secondaries()
(secondary, ) = [
s for s in secondaries
if ha_tools.get_tags(s)['name'] == 'secondary']
self.secondary = _partition_node(secondary)
self.secondary_tags = ha_tools.get_tags(secondary)
self.secondary_dc = {'dc': self.secondary_tags['dc']}
(other_secondary, ) = [
s for s in secondaries
if ha_tools.get_tags(s)['name'] == 'other_secondary']
self.other_secondary = _partition_node(other_secondary)
self.other_secondary_tags = ha_tools.get_tags(other_secondary)
self.other_secondary_dc = {'dc': self.other_secondary_tags['dc']}
self.c = MongoReplicaSetClient(
self.seed, replicaSet=self.name, use_greenlets=use_greenlets)
self.db = self.c.pymongo_test
self.w = len(self.c.secondaries) + 1
self.db.test.remove({}, w=self.w)
self.db.test.insert(
[{'foo': i} for i in xrange(10)], w=self.w)
self.clear_ping_times()
开发者ID:nilnullzip,项目名称:mongo-python-driver,代码行数:50,代码来源:test_ha.py
示例13: TestLastErrorDefaults
class TestLastErrorDefaults(HATestCase):
def setUp(self):
members = [{}, {}]
res = ha_tools.start_replica_set(members)
self.seed, self.name = res
self.c = MongoReplicaSetClient(self.seed, replicaSet=self.name,
use_greenlets=use_greenlets)
def test_get_last_error_defaults(self):
if not version.at_least(self.c, (1, 9, 0)):
raise SkipTest("Need MongoDB >= 1.9.0 to test getLastErrorDefaults")
replset = self.c.local.system.replset.find_one()
settings = replset.get('settings', {})
# This should cause a WTimeoutError for every write command
settings['getLastErrorDefaults'] = {
'w': 3,
'wtimeout': 1
}
replset['settings'] = settings
replset['version'] = replset.get("version", 1) + 1
self.c.admin.command("replSetReconfig", replset)
self.assertRaises(WTimeoutError, self.c.pymongo_test.test.insert,
{'_id': 0})
self.assertRaises(WTimeoutError, self.c.pymongo_test.test.save,
{'_id': 0, "a": 5})
self.assertRaises(WTimeoutError, self.c.pymongo_test.test.update,
{'_id': 0}, {"$set": {"a": 10}})
self.assertRaises(WTimeoutError, self.c.pymongo_test.test.remove,
{'_id': 0})
def tearDown(self):
self.c.close()
super(TestLastErrorDefaults, self).tearDown()
开发者ID:1060460048,项目名称:mongo-python-driver,代码行数:37,代码来源:test_ha.py
示例14: test_monitor_removes_recovering_member
def test_monitor_removes_recovering_member(self):
self.c = MongoReplicaSetClient(
self.seed, replicaSet=self.name, use_greenlets=use_greenlets)
secondaries = ha_tools.get_secondaries()
for mode in SECONDARY, SECONDARY_PREFERRED:
partitioned_secondaries = partition_nodes(secondaries)
utils.assertReadFromAll(self, self.c, partitioned_secondaries, mode)
secondary, recovering_secondary = secondaries
ha_tools.set_maintenance(recovering_secondary, True)
sleep(2 * MONITOR_INTERVAL)
for mode in SECONDARY, SECONDARY_PREFERRED:
# Don't read from recovering member
utils.assertReadFrom(self, self.c, _partition_node(secondary), mode)
开发者ID:nilnullzip,项目名称:mongo-python-driver,代码行数:17,代码来源:test_ha.py
示例15: test_properties
def test_properties(self):
c = MongoReplicaSetClient(pair, replicaSet=self.name)
c.admin.command('ping')
self.assertEqual(c.primary, self.primary)
self.assertEqual(c.hosts, self.hosts)
self.assertEqual(c.arbiters, self.arbiters)
self.assertEqual(c.max_pool_size, 100)
self.assertEqual(c.document_class, dict)
self.assertEqual(c.tz_aware, False)
# Make sure MRSC's properties are copied to Database and Collection
for obj in c, c.pymongo_test, c.pymongo_test.test:
self.assertEqual(obj.read_preference, ReadPreference.PRIMARY)
self.assertEqual(obj.write_concern, {})
cursor = c.pymongo_test.test.find()
self.assertEqual(
ReadPreference.PRIMARY, cursor._Cursor__read_preference)
c.close()
tag_sets = [{'dc': 'la', 'rack': '2'}, {'foo': 'bar'}]
secondary = Secondary(tag_sets)
c = MongoReplicaSetClient(pair, replicaSet=self.name, max_pool_size=25,
document_class=SON, tz_aware=True,
read_preference=secondary,
acceptablelatencyms=77)
c.admin.command('ping')
self.assertEqual(c.primary, self.primary)
self.assertEqual(c.hosts, self.hosts)
self.assertEqual(c.arbiters, self.arbiters)
self.assertEqual(c.max_pool_size, 25)
self.assertEqual(c.document_class, SON)
self.assertEqual(c.tz_aware, True)
for obj in c, c.pymongo_test, c.pymongo_test.test:
self.assertEqual(obj.read_preference, secondary)
cursor = c.pymongo_test.test.find()
self.assertEqual(
secondary, cursor._Cursor__read_preference)
nearest = Nearest([{'dc': 'ny'}, {}])
cursor = c.pymongo_test.test.find(read_preference=nearest)
self.assertEqual(
nearest, cursor._Cursor__read_preference)
if version.at_least(c, (1, 7, 4)):
self.assertEqual(c.max_bson_size, 16777216)
else:
self.assertEqual(c.max_bson_size, 4194304)
c.close()
开发者ID:xowenx,项目名称:mongo-python-driver,代码行数:52,代码来源:test_replica_set_client.py
示例16: test_properties
def test_properties(self):
c = MongoReplicaSetClient(pair, replicaSet=self.name)
c.admin.command("ping")
self.assertEqual(c.primary, self.primary)
self.assertEqual(c.hosts, self.hosts)
self.assertEqual(c.arbiters, self.arbiters)
self.assertEqual(c.max_pool_size, 10)
self.assertEqual(c.document_class, dict)
self.assertEqual(c.tz_aware, False)
# Make sure MRSC's properties are copied to Database and Collection
for obj in c, c.pymongo_test, c.pymongo_test.test:
self.assertEqual(obj.read_preference, ReadPreference.PRIMARY)
self.assertEqual(obj.tag_sets, [{}])
self.assertEqual(obj.secondary_acceptable_latency_ms, 15)
self.assertEqual(obj.slave_okay, False)
self.assertEqual(obj.write_concern, {})
cursor = c.pymongo_test.test.find()
self.assertEqual(ReadPreference.PRIMARY, cursor._Cursor__read_preference)
self.assertEqual([{}], cursor._Cursor__tag_sets)
self.assertEqual(15, cursor._Cursor__secondary_acceptable_latency_ms)
self.assertEqual(False, cursor._Cursor__slave_okay)
c.close()
tag_sets = [{"dc": "la", "rack": "2"}, {"foo": "bar"}]
c = MongoReplicaSetClient(
pair,
replicaSet=self.name,
max_pool_size=25,
document_class=SON,
tz_aware=True,
slaveOk=False,
read_preference=ReadPreference.SECONDARY,
tag_sets=copy.deepcopy(tag_sets),
secondary_acceptable_latency_ms=77,
)
c.admin.command("ping")
self.assertEqual(c.primary, self.primary)
self.assertEqual(c.hosts, self.hosts)
self.assertEqual(c.arbiters, self.arbiters)
self.assertEqual(c.max_pool_size, 25)
self.assertEqual(c.document_class, SON)
self.assertEqual(c.tz_aware, True)
for obj in c, c.pymongo_test, c.pymongo_test.test:
self.assertEqual(obj.read_preference, ReadPreference.SECONDARY)
self.assertEqual(obj.tag_sets, tag_sets)
self.assertEqual(obj.secondary_acceptable_latency_ms, 77)
self.assertEqual(obj.slave_okay, False)
self.assertEqual(obj.safe, True)
cursor = c.pymongo_test.test.find()
self.assertEqual(ReadPreference.SECONDARY, cursor._Cursor__read_preference)
self.assertEqual(tag_sets, cursor._Cursor__tag_sets)
self.assertEqual(77, cursor._Cursor__secondary_acceptable_latency_ms)
self.assertEqual(False, cursor._Cursor__slave_okay)
cursor = c.pymongo_test.test.find(
read_preference=ReadPreference.NEAREST, tag_sets=[{"dc": "ny"}, {}], secondary_acceptable_latency_ms=123
)
self.assertEqual(ReadPreference.NEAREST, cursor._Cursor__read_preference)
self.assertEqual([{"dc": "ny"}, {}], cursor._Cursor__tag_sets)
self.assertEqual(123, cursor._Cursor__secondary_acceptable_latency_ms)
self.assertEqual(False, cursor._Cursor__slave_okay)
if version.at_least(c, (1, 7, 4)):
self.assertEqual(c.max_bson_size, 16777216)
else:
self.assertEqual(c.max_bson_size, 4194304)
c.close()
开发者ID:RockLi,项目名称:mongo-python-driver,代码行数:72,代码来源:test_replica_set_client.py
示例17: __init__
def __init__(self, hosts):
MockClientBase.__init__(self)
MongoReplicaSetClient.__init__(
self,
hosts,
replicaSet=MOCK_RS_NAME)
开发者ID:ArturFis,项目名称:mongo-python-driver,代码行数:6,代码来源:test_replica_set_reconfig.py
示例18: TestReadPreference
class TestReadPreference(HATestCase):
def setUp(self):
members = [
# primary
{'tags': {'dc': 'ny', 'name': 'primary'}},
# secondary
{'tags': {'dc': 'la', 'name': 'secondary'}, 'priority': 0},
# other_secondary
{'tags': {'dc': 'ny', 'name': 'other_secondary'}, 'priority': 0},
]
res = ha_tools.start_replica_set(members)
self.seed, self.name = res
primary = ha_tools.get_primary()
self.primary = _partition_node(primary)
self.primary_tags = ha_tools.get_tags(primary)
# Make sure priority worked
self.assertEqual('primary', self.primary_tags['name'])
self.primary_dc = {'dc': self.primary_tags['dc']}
secondaries = ha_tools.get_secondaries()
(secondary, ) = [
s for s in secondaries
if ha_tools.get_tags(s)['name'] == 'secondary']
self.secondary = _partition_node(secondary)
self.secondary_tags = ha_tools.get_tags(secondary)
self.secondary_dc = {'dc': self.secondary_tags['dc']}
(other_secondary, ) = [
s for s in secondaries
if ha_tools.get_tags(s)['name'] == 'other_secondary']
self.other_secondary = _partition_node(other_secondary)
self.other_secondary_tags = ha_tools.get_tags(other_secondary)
self.other_secondary_dc = {'dc': self.other_secondary_tags['dc']}
self.c = MongoReplicaSetClient(
self.seed, replicaSet=self.name, use_greenlets=use_greenlets)
self.db = self.c.pymongo_test
self.w = len(self.c.secondaries) + 1
self.db.test.remove({}, w=self.w)
self.db.test.insert(
[{'foo': i} for i in xrange(10)], w=self.w)
self.clear_ping_times()
def set_ping_time(self, host, ping_time_seconds):
Member._host_to_ping_time[host] = ping_time_seconds
def clear_ping_times(self):
Member._host_to_ping_time.clear()
def test_read_preference(self):
# We pass through four states:
#
# 1. A primary and two secondaries
# 2. Primary down
# 3. Primary up, one secondary down
# 4. Primary up, all secondaries down
#
# For each state, we verify the behavior of PRIMARY,
# PRIMARY_PREFERRED, SECONDARY, SECONDARY_PREFERRED, and NEAREST
c = MongoReplicaSetClient(
self.seed, replicaSet=self.name, use_greenlets=use_greenlets)
def assertReadFrom(member, *args, **kwargs):
utils.assertReadFrom(self, c, member, *args, **kwargs)
def assertReadFromAll(members, *args, **kwargs):
utils.assertReadFromAll(self, c, members, *args, **kwargs)
def unpartition_node(node):
host, port = node
return '%s:%s' % (host, port)
# To make the code terser, copy hosts into local scope
primary = self.primary
secondary = self.secondary
other_secondary = self.other_secondary
bad_tag = {'bad': 'tag'}
# 1. THREE MEMBERS UP -------------------------------------------------
# PRIMARY
assertReadFrom(primary, PRIMARY)
# PRIMARY_PREFERRED
# Trivial: mode and tags both match
assertReadFrom(primary, PRIMARY_PREFERRED, self.primary_dc)
# Secondary matches but not primary, choose primary
assertReadFrom(primary, PRIMARY_PREFERRED, self.secondary_dc)
# Chooses primary, ignoring tag sets
#.........这里部分代码省略.........
开发者ID:nilnullzip,项目名称:mongo-python-driver,代码行数:101,代码来源:test_ha.py
示例19: setUp
def setUp(self):
members = [{}, {}]
res = ha_tools.start_replica_set(members)
self.seed, self.name = res
self.c = MongoReplicaSetClient(self.seed, replicaSet=self.name,
use_greenlets=use_greenlets)
开发者ID:1060460048,项目名称:mongo-python-driver,代码行数:6,代码来源:test_ha.py
示例20: test_alive
def test_alive(self):
client = MongoReplicaSetClient(
'doesnt exist', replicaSet='rs', _connect=False)
self.assertFalse(client.alive())
开发者ID:ArturFis,项目名称:mongo-python-driver,代码行数:5,代码来源:test_replica_set_client.py
注:本文中的pymongo.mongo_replica_set_client.MongoReplicaSetClient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论