PYTHON-2447 Fix race in CMAP maxConnecting test (#529)

This commit is contained in:
Shane Harvey 2020-12-07 08:59:33 -10:00 committed by GitHub
parent 5625860688
commit ac07e0f4e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 16 deletions

View File

@ -30,32 +30,31 @@
"name": "start",
"target": "thread1"
},
{
"name": "checkOut",
"thread": "thread1"
},
{
"name": "start",
"target": "thread2"
},
{
"name": "wait",
"thread": "thread2",
"ms": 100
},
{
"name": "checkOut",
"thread": "thread2"
},
{
"name": "start",
"target": "thread3"
},
{
"name": "checkOut",
"thread": "thread1"
},
{
"name": "waitForEvent",
"event": "ConnectionCreated",
"count": 1
},
{
"name": "wait",
"thread": "thread3",
"ms": 100
},
{
"name": "checkOut",
"thread": "thread2"
},
{
"name": "checkOut",
"thread": "thread3"

View File

@ -172,6 +172,8 @@ class TestCMAP(IntegrationTest):
"""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):
@ -196,6 +198,7 @@ class TestCMAP(IntegrationTest):
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()
@ -240,8 +243,7 @@ class TestCMAP(IntegrationTest):
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)
@ -252,6 +254,9 @@ class TestCMAP(IntegrationTest):
print('Events:')
for event in self.listener.events:
print(event)
print('Log:')
for log in self.logs:
print(log)
raise
POOL_OPTIONS = {