From 9904fbed33a5daf6ba7cb2b2b90c8e5e3472e8f5 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Wed, 25 Jan 2023 14:10:09 +0100 Subject: [PATCH] fix APIv2 python attach test flake The test was added in commit 1424f0958f6f, it can flake because the attach test needs the message in the log. On slow CI systems this can take longer. Add a retry logic which checks the container log every second for up to 5 seconds. That should be plenty of time. Fixes #17204 Signed-off-by: Paul Holzinger --- test/apiv2/python/rest_api/test_v2_0_0_container.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/apiv2/python/rest_api/test_v2_0_0_container.py b/test/apiv2/python/rest_api/test_v2_0_0_container.py index 7cf4a8a8ec..15f6c36169 100644 --- a/test/apiv2/python/rest_api/test_v2_0_0_container.py +++ b/test/apiv2/python/rest_api/test_v2_0_0_container.py @@ -146,6 +146,19 @@ class ContainerTestCase(APITestCase): ) self.assertEqual(r.status_code, 204, r.text) + # wait for the log message to appear to avoid flakes on slow systems + # with the /attach?logs=true test below + for _ in range(5): + r = requests.get( + self.podman_url + + f"/v1.40/containers/{payload['Id']}/logs?stdout=true" + ) + self.assertIn(r.status_code, (101, 200), r.text) + if r.content == b"\x01\x00\x00\x00\x00\x00\x00\x07podman\n": + break + + time.sleep(1) + r = requests.post( self.podman_url + f"/v1.40/containers/{payload['Id']}/attach?logs=true&stream=false"