]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Add an extra step to pool test_sync
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 28 Jun 2020 02:57:52 +0000 (22:57 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 28 Jun 2020 02:57:52 +0000 (22:57 -0400)
Have observed CI failure with windows where not all
three connections got pulled out at the same time here
as the threads got serialized.  make sure all three
connections get used.

Change-Id: Ic2f7c7de1069358d95035f90c725c7dddd4f34d4

test/engine/test_pool.py

index 370536ce97bb8819c79f24e9e3807841c2f88923..278a6cada1dfefbdebdb75c1f6640b4017645de9 100644 (file)
@@ -699,6 +699,13 @@ class PoolFirstConnectSyncTest(PoolTestBase):
                 time.sleep(0.02)
 
         threads = []
+
+        # what we're trying to do here is have concurrent use of
+        # all three pooled connections at once, and the thing we want
+        # to test is that first_connect() finishes completely before
+        # any of the connections get returned.   so first_connect()
+        # sleeps for one second, then pings the mock.  the threads should
+        # not have made it to the "checkout() event for that one second.
         for i in range(5):
             th = threading.Thread(target=checkout)
             th.start()
@@ -706,6 +713,15 @@ class PoolFirstConnectSyncTest(PoolTestBase):
         for th in threads:
             th.join(join_timeout)
 
+        # there is a very unlikely condition observed in CI on windows
+        # where even though we have five threads above all calling upon the
+        # pool, we didn't get concurrent use of all three connections, two
+        # connections were enough.  so here we purposely just check out
+        # all three at once just to get a consistent test result.
+        make_sure_all_three_are_connected = [pool.connect() for i in range(3)]
+        for conn in make_sure_all_three_are_connected:
+            conn.close()
+
         eq_(
             evt.mock_calls,
             [