From d00201a031883de6eb00fbf75c626ef6e7119fc8 Mon Sep 17 00:00:00 2001 From: Santi Legaristi Date: Sat, 14 Nov 2026 00:01:31 +0100 Subject: [PATCH] test(crash): wait for the watcher instead of a fixed sleep (#47) --- tests/test_e2e_crash.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_e2e_crash.py b/tests/test_e2e_crash.py index 363b892..9236686 100644 --- a/tests/test_e2e_crash.py +++ b/tests/test_e2e_crash.py @@ -64,7 +64,11 @@ def test_write_abandoned_during_restore_is_not_executed(self): for i in range(200): # a journal long enough that restoring it outlasts the client's patience self.assertEqual(sqs("CreateQueue", {"QueueName": f"filler-{i}"})[0], 200) sh("docker", "kill", f"keepstack-{PORT}") - time.sleep(1.5) # the watcher is restoring the emulator now; writes wait + # A fixed sleep raced the watcher (#47): before it notices, writes hit the dead emulator and fail at once. + deadline = time.time() + 30 + while "the emulator stopped" not in self.ks("logs").stdout and time.time() < deadline: + time.sleep(0.2) + time.sleep(0.5) # the watcher is restoring the emulator now; writes wait with self.assertRaises((socket.timeout, TimeoutError), msg="restore finished too fast to test"): sqs("CreateQueue", {"QueueName": "abandoned"}, timeout=1) deadline = time.time() + 120