diff --git a/tests/core/test_vault_bad_keys.py b/tests/core/test_vault_bad_keys.py index 8274351e..1ff8df96 100644 --- a/tests/core/test_vault_bad_keys.py +++ b/tests/core/test_vault_bad_keys.py @@ -232,14 +232,17 @@ def test_retry_takes_the_next_parallel_answer_without_a_new_request(tmp_path: Pa from tests.core.test_vaults_lookup import FakeVault local = SQLite("local", tmp_path / "local.db") - fast = FakeVault("fast", BAD, delay=0.01) - slow = FakeVault("slow", GOOD, delay=0.2) + # the fast answer must land after the slow query has started, or the pool shutdown cancels + # the slow query before it runs and it never reaches candidates; a loaded CI runner can take + # tens of milliseconds to start the second worker thread + fast = FakeVault("fast", BAD, delay=0.1) + slow = FakeVault("slow", GOOD, delay=0.3) vaults = Vaults("SVC") vaults.vaults = [local, fast, slow] assert vaults.get_key(KID) == (BAD, fast) vaults.flag_bad_key(KID, BAD) - time.sleep(0.4) # the slow answer lands in candidates after the first call returned + time.sleep(0.5) # the slow answer lands in candidates after the first call returned assert vaults.get_key(KID) == (GOOD, slow) assert fast.calls == 1 and slow.calls == 1