Skip to content

Commit ae65692

Browse files
committed
fix(unittests): fix test_return_closed/defunct_*
recent fixes to avoid race in stop/failing connection d0751e6 cdeb396 start faling a few unittests that wasn't mocking the corret function to work properly
1 parent f5d2d40 commit ae65692

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/unit/test_host_connection_pool.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def test_return_defunct_connection(self):
144144
pool.borrow_connection(timeout=0.01)
145145
conn.is_defunct = True
146146
session.cluster.signal_connection_failure.return_value = False
147+
host.signal_connection_failure.return_value = False
147148
pool.return_connection(conn)
148149

149150
# the connection should be closed a new creation scheduled
@@ -165,16 +166,18 @@ def test_return_defunct_connection_on_down_host(self):
165166
pool.borrow_connection(timeout=0.01)
166167
conn.is_defunct = True
167168
session.cluster.signal_connection_failure.return_value = True
169+
host.signal_connection_failure.return_value = True
168170
pool.return_connection(conn)
169171

170172
# the connection should be closed a new creation scheduled
171-
self.assertTrue(session.cluster.signal_connection_failure.call_args)
172173
self.assertTrue(conn.close.call_args)
173174
if self.PoolImpl is HostConnection:
174175
# on shard aware implementation we use submit function regardless
176+
self.assertTrue(host.signal_connection_failure.call_args)
175177
self.assertTrue(session.submit.called)
176178
else:
177179
self.assertFalse(session.submit.called)
180+
self.assertTrue(session.cluster.signal_connection_failure.call_args)
178181
self.assertTrue(pool.is_shutdown)
179182

180183
def test_return_closed_connection(self):
@@ -190,6 +193,7 @@ def test_return_closed_connection(self):
190193
pool.borrow_connection(timeout=0.01)
191194
conn.is_closed = True
192195
session.cluster.signal_connection_failure.return_value = False
196+
host.signal_connection_failure.return_value = False
193197
pool.return_connection(conn)
194198

195199
# a new creation should be scheduled

0 commit comments

Comments
 (0)