Skip to content

Commit ac07e0f

Browse files
authored
PYTHON-2447 Fix race in CMAP maxConnecting test (#529)
1 parent 5625860 commit ac07e0f

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

test/cmap/pool-checkout-maxConnecting-is-enforced.json

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,31 @@
3030
"name": "start",
3131
"target": "thread1"
3232
},
33-
{
34-
"name": "checkOut",
35-
"thread": "thread1"
36-
},
3733
{
3834
"name": "start",
3935
"target": "thread2"
4036
},
4137
{
42-
"name": "wait",
43-
"thread": "thread2",
44-
"ms": 100
38+
"name": "start",
39+
"target": "thread3"
4540
},
4641
{
4742
"name": "checkOut",
48-
"thread": "thread2"
43+
"thread": "thread1"
4944
},
5045
{
51-
"name": "start",
52-
"target": "thread3"
46+
"name": "waitForEvent",
47+
"event": "ConnectionCreated",
48+
"count": 1
5349
},
5450
{
5551
"name": "wait",
56-
"thread": "thread3",
5752
"ms": 100
5853
},
54+
{
55+
"name": "checkOut",
56+
"thread": "thread2"
57+
},
5958
{
6059
"name": "checkOut",
6160
"thread": "thread3"

test/test_cmap.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ def check_events(self, events, ignore):
172172
"""Check the events of a test."""
173173
actual_events = self.actual_events(ignore)
174174
for actual, expected in zip(actual_events, events):
175+
self.logs.append('Checking event actual: %r vs expected: %r' % (
176+
actual, expected))
175177
self.check_event(actual, expected)
176178

177179
if len(events) > len(actual_events):
@@ -196,6 +198,7 @@ def set_fail_point(self, command_args):
196198

197199
def run_scenario(self, scenario_def, test):
198200
"""Run a CMAP spec test."""
201+
self.logs = []
199202
self.assertEqual(scenario_def['version'], 1)
200203
self.assertIn(scenario_def['style'], ['unit', 'integration'])
201204
self.listener = CMAPListener()
@@ -240,8 +243,7 @@ def cleanup():
240243
self.check_events(test['events'], test['ignore'])
241244
except Exception:
242245
# Print the events after a test failure.
243-
print()
244-
print('Failed test: %r' % (test['description'],))
246+
print('\nFailed test: %r' % (test['description'],))
245247
print('Operations:')
246248
for op in self._ops:
247249
print(op)
@@ -252,6 +254,9 @@ def cleanup():
252254
print('Events:')
253255
for event in self.listener.events:
254256
print(event)
257+
print('Log:')
258+
for log in self.logs:
259+
print(log)
255260
raise
256261

257262
POOL_OPTIONS = {

0 commit comments

Comments
 (0)