Skip to content

Commit 8b54d4b

Browse files
committed
fix race conditions in threaded tests
Add extra time for threads to catch up in slower runs, ensure the dictionary ordering used by worker is deterministic. Change-Id: I1013a69116ebdcbe64d7c6dfae12ca791256aebf
1 parent c509164 commit 8b54d4b

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

sqlalchemy_collectd/client/tests/test_worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def start_loop():
6060

6161
# now wait, it will hit the SystemExit and exit.
6262
# if it times out, we failed.
63-
worker._WORKER_THREAD.join(1)
63+
worker._WORKER_THREAD.join(5)
6464

6565
# see that it did what we asked.
6666
self.assertEqual(

sqlalchemy_collectd/client/worker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import collections
12
import logging
23
import os
34
import threading
@@ -9,7 +10,7 @@
910
_WORKER_THREAD = None
1011
_PID = os.getpid()
1112

12-
_collection_targets = {}
13+
_collection_targets = collections.OrderedDict()
1314

1415

1516
def _check_threads_started():

sqlalchemy_collectd/server/tests/test_listener.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def receive():
3030
with mock.patch.object(listener, "log") as mock_logger:
3131
listener.listen(mock.Mock(receive=receive))
3232

33-
listener.listen_thread.join(1)
33+
listener.listen_thread.join(5)
3434

3535
# call "five" doesn't happen because we should have exited
3636
self.assertEqual(

0 commit comments

Comments
 (0)