From 2da5e0cfbddd6bd5a6c1ad61baad0861894a4d48 Mon Sep 17 00:00:00 2001 From: Ben Banfield-Zanin Date: Wed, 6 Aug 2025 14:13:47 +0100 Subject: [PATCH] Don't block indefinitely waiting for a HAProxy logline. Retry after 1s waiting. --- newsfragments/655.internal.md | 1 + tests/integration/test_synapse.py | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 newsfragments/655.internal.md diff --git a/newsfragments/655.internal.md b/newsfragments/655.internal.md new file mode 100644 index 00000000..6198552f --- /dev/null +++ b/newsfragments/655.internal.md @@ -0,0 +1 @@ +CI: remove flakes in `test_routes_to_synapse_workers_correctly` by streaming logs from all HAProxy `Pods`, not just the current ones. diff --git a/tests/integration/test_synapse.py b/tests/integration/test_synapse.py index 64a3f1dd..771ac4a9 100644 --- a/tests/integration/test_synapse.py +++ b/tests/integration/test_synapse.py @@ -131,18 +131,22 @@ async def test_routes_to_synapse_workers_correctly( while True: # Given we've made at least one request, we know there should be something here and we can block for it - # We might have requests from a previous attempt and so we might not succeed first time - log_line = await logs_matching_path.get() + # However sometimes it appears that logs aren't emitted from HAProxy so don't block indefinitely + try: + log_line = await asyncio.wait_for(logs_matching_path.get(), timeout=1.0) + except TimeoutError: + print(f"No HAProxy logs relating to {path} emitted after 1s. Retrying") + break # Save off lines from any run we encounter, not just the current one if any([id in log_line for id in attempt_ids]): matching_lines.append(log_line) - if attempt_id in log_line and f"synapse-http-in synapse-{backend}" in log_line: - return - - if logs_matching_path.empty(): - break + if attempt_id in log_line: + if f"synapse-http-in synapse-{backend}" in log_line: + return + else: + print(f"Request for {path} routed elsewhere: {log_line}") attempts += 1 await asyncio.sleep(1)