From ac07e0f4e22e2f52ec9a3305dbaa81449e6516d8 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Mon, 7 Dec 2020 08:59:33 -1000 Subject: [PATCH] PYTHON-2447 Fix race in CMAP maxConnecting test (#529) --- ...ol-checkout-maxConnecting-is-enforced.json | 27 +++++++++---------- test/test_cmap.py | 9 +++++-- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/test/cmap/pool-checkout-maxConnecting-is-enforced.json b/test/cmap/pool-checkout-maxConnecting-is-enforced.json index 358e0801b..4b67b73ad 100644 --- a/test/cmap/pool-checkout-maxConnecting-is-enforced.json +++ b/test/cmap/pool-checkout-maxConnecting-is-enforced.json @@ -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" diff --git a/test/test_cmap.py b/test/test_cmap.py index 95de866f1..ef40d07bf 100644 --- a/test/test_cmap.py +++ b/test/test_cmap.py @@ -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 = {