Skip to content

Commit

Permalink
fix APIv2 python attach test flake
Browse files Browse the repository at this point in the history
The test was added in commit 1424f09, 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>
  • Loading branch information
Luap99 committed Jan 25, 2023
1 parent c35e74f commit 9904fbe
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/apiv2/python/rest_api/test_v2_0_0_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ def test_attach(self):
)
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"
Expand Down

0 comments on commit 9904fbe

Please sign in to comment.