Skip to content

Commit

Permalink
Merge branch 'fix-timeout-tests' into 267-and-268
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaSkriblovsky committed Aug 21, 2020
2 parents 25aa0ba + 55cda3f commit c64d9bf
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions tests/test_replicaset.py
Expand Up @@ -143,15 +143,13 @@ def test_SwitchToMasterOnConnect(self):

@defer.inlineCallbacks
def test_AutoReconnect(self):
self.patch(_Connection, 'maxDelay', 5)

try:
uri = "mongodb://localhost:{0}/?w={1}".format(self.ports[0], len(self.ports))
conn = ConnectionPool(uri)
conn = ConnectionPool(uri, max_delay=5)

yield conn.db.coll.insert({'x': 42}, safe=True)

yield self.__mongod[0].stop()
self.__mongod[0].kill(signal.SIGSTOP)

while True:
try:
Expand All @@ -162,14 +160,14 @@ def test_AutoReconnect(self):
pass

finally:
self.__mongod[0].kill(signal.SIGCONT)
yield conn.disconnect()
self.flushLoggedErrors(AutoReconnect)

@defer.inlineCallbacks
def test_AutoReconnect_from_primary_step_down(self):
self.patch(_Connection, 'maxDelay', 5)
uri = "mongodb://localhost:{0}/?w={1}".format(self.ports[0], len(self.ports))
conn = ConnectionPool(uri)
conn = ConnectionPool(uri, max_delay=5)

# this will force primary to step down, triggering an AutoReconnect that bubbles up
# through the connection pool to the client
Expand All @@ -180,15 +178,13 @@ def test_AutoReconnect_from_primary_step_down(self):

@defer.inlineCallbacks
def test_find_with_timeout(self):
self.patch(_Connection, 'maxDelay', 5)

try:
uri = "mongodb://localhost:{0}/?w={1}".format(self.ports[0], len(self.ports))
conn = ConnectionPool(uri, initial_delay=3)
conn = ConnectionPool(uri, retry_delay=3, max_delay=5)

yield conn.db.coll.insert({'x': 42}, safe=True)

yield self.__mongod[0].stop()
self.__mongod[0].kill(signal.SIGSTOP)

while True:
try:
Expand All @@ -200,20 +196,19 @@ def test_find_with_timeout(self):
pass

finally:
self.__mongod[0].kill(signal.SIGCONT)
yield conn.disconnect()
self.flushLoggedErrors(AutoReconnect)

@defer.inlineCallbacks
def test_find_with_deadline(self):
self.patch(_Connection, 'maxDelay', 5)

try:
uri = "mongodb://localhost:{0}/?w={1}".format(self.ports[0], len(self.ports))
conn = ConnectionPool(uri, initial_delay=3)
conn = ConnectionPool(uri, retry_delay=3, max_delay=5)

yield conn.db.coll.insert({'x': 42}, safe=True)

yield self.__mongod[0].stop()
self.__mongod[0].kill(signal.SIGSTOP)

while True:
try:
Expand All @@ -225,20 +220,19 @@ def test_find_with_deadline(self):
pass

finally:
self.__mongod[0].kill(signal.SIGCONT)
yield conn.disconnect()
self.flushLoggedErrors(AutoReconnect)

@defer.inlineCallbacks
def test_TimeExceeded_insert(self):
self.patch(_Connection, 'maxDelay', 5)

try:
uri = "mongodb://localhost:{0}/?w={1}".format(self.ports[0], len(self.ports))
conn = ConnectionPool(uri, initial_delay=3)
conn = ConnectionPool(uri, retry_delay=3, max_delay=5)

yield conn.db.coll.insert({'x': 42}, safe=True)

yield self.__mongod[0].stop()
self.__mongod[0].kill(signal.SIGSTOP)

while True:
try:
Expand All @@ -250,6 +244,7 @@ def test_TimeExceeded_insert(self):
pass

finally:
self.__mongod[0].kill(signal.SIGCONT)
yield conn.disconnect()
self.flushLoggedErrors(AutoReconnect)

Expand Down

0 comments on commit c64d9bf

Please sign in to comment.