Skip to content

PYTHON-2447 Fix race in CMAP maxConnecting test #529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions test/cmap/pool-checkout-maxConnecting-is-enforced.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,31 @@
"name": "start",
"target": "thread1"
},
{
"name": "checkOut",
"thread": "thread1"
},
{
"name": "start",
"target": "thread2"
},
{
"name": "wait",
"thread": "thread2",
"ms": 100
"name": "start",
"target": "thread3"
},
{
"name": "checkOut",
"thread": "thread2"
"thread": "thread1"
},
{
"name": "start",
"target": "thread3"
"name": "waitForEvent",
"event": "ConnectionCreated",
"count": 1
},
{
"name": "wait",
"thread": "thread3",
"ms": 100
},
{
"name": "checkOut",
"thread": "thread2"
},
{
"name": "checkOut",
"thread": "thread3"
Expand Down
9 changes: 7 additions & 2 deletions test/test_cmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ def check_events(self, events, ignore):
"""Check the events of a test."""
actual_events = self.actual_events(ignore)
for actual, expected in zip(actual_events, events):
self.logs.append('Checking event actual: %r vs expected: %r' % (
actual, expected))
self.check_event(actual, expected)

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

def run_scenario(self, scenario_def, test):
"""Run a CMAP spec test."""
self.logs = []
self.assertEqual(scenario_def['version'], 1)
self.assertIn(scenario_def['style'], ['unit', 'integration'])
self.listener = CMAPListener()
Expand Down Expand Up @@ -240,8 +243,7 @@ def cleanup():
self.check_events(test['events'], test['ignore'])
except Exception:
# Print the events after a test failure.
print()
print('Failed test: %r' % (test['description'],))
print('\nFailed test: %r' % (test['description'],))
print('Operations:')
for op in self._ops:
print(op)
Expand All @@ -252,6 +254,9 @@ def cleanup():
print('Events:')
for event in self.listener.events:
print(event)
print('Log:')
for log in self.logs:
print(log)
raise

POOL_OPTIONS = {
Expand Down