fix APIv2 python attach test flake

The test was added in commit 1424f0958f, 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 <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2023-01-25 14:10:09 +01:00
parent c35e74f4cc
commit 9904fbed33
No known key found for this signature in database
GPG Key ID: EB145DD938A3CAF2
1 changed files with 13 additions and 0 deletions

View File

@ -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"