Skip to content

Commit 7e922a9

Browse files
test: enhance worker startup logs test (#1230)
Improve `test_worker_startup_logs` to not rely on an arbitrary time.sleep and increase the time window since it seems in CI sometimes fails because the command does not have time enough to start. Signed-off-by: Alex <[email protected]>
1 parent 0748535 commit 7e922a9

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

tests/integration/test_logging.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,31 @@ def test_worker_startup_logs():
2626
Test that starting workers produce the expected startup message.
2727
"""
2828
command = ["aap-eda-manage", "rqworker", "--help"]
29+
timeout = 10
2930
process = subprocess.Popen(
3031
command,
3132
stdout=subprocess.PIPE,
3233
stderr=subprocess.PIPE,
3334
text=True,
35+
bufsize=1,
36+
universal_newlines=True,
3437
)
3538

36-
time.sleep(3)
39+
expected_message = "Starting eda-server"
40+
found = False
41+
start_time = time.time()
42+
43+
while time.time() - start_time < timeout:
44+
line = process.stderr.readline()
45+
if expected_message in line:
46+
found = True
47+
break
48+
3749
process.terminate()
3850
stdout, stderr = process.communicate(timeout=3)
3951

40-
assert "Starting eda-server" in stderr
52+
error_message = (
53+
f"Expected message '{expected_message}' "
54+
f"not found in stderr output: {stderr}"
55+
)
56+
assert found, error_message

0 commit comments

Comments
 (0)