Skip to content

Commit ee23dd1

Browse files
mayeuthenryiii
authored andcommitted
fix(test): implement retry for test_container_removed
The test is flaky on some platforms. Implement retry rather than just skip.
1 parent 55037e9 commit ee23dd1

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

unit_test/oci_container_test.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import subprocess
99
import sys
1010
import textwrap
11+
import time
1112
from contextlib import nullcontext
1213
from pathlib import Path, PurePath, PurePosixPath
1314

@@ -138,33 +139,39 @@ def test_cwd(container_engine):
138139
assert container.call(["pwd"], capture_output=True, cwd="/opt") == "/opt\n"
139140

140141

141-
@pytest.mark.skipif(
142-
pm == "s390x" and detect_ci_provider() == CIProvider.travis_ci,
143-
reason="test is flaky on this platform, see https://github.com/pypa/cibuildwheel/pull/1961#issuecomment-2334678966",
144-
)
145142
def test_container_removed(container_engine):
143+
# test is flaky on some platforms, implement retry for 5 second
144+
timeout = 50 # * 100 ms = 5s
146145
with OCIContainer(
147146
engine=container_engine, image=DEFAULT_IMAGE, oci_platform=DEFAULT_OCI_PLATFORM
148147
) as container:
148+
assert container.name is not None
149+
container_name = container.name
150+
for _ in range(timeout):
151+
docker_containers_listing = subprocess.run(
152+
f"{container.engine.name} container ls",
153+
shell=True,
154+
check=True,
155+
stdout=subprocess.PIPE,
156+
text=True,
157+
).stdout
158+
if container_name in docker_containers_listing:
159+
break
160+
time.sleep(0.1)
161+
assert container_name in docker_containers_listing
162+
163+
for _ in range(timeout):
149164
docker_containers_listing = subprocess.run(
150165
f"{container.engine.name} container ls",
151166
shell=True,
152167
check=True,
153168
stdout=subprocess.PIPE,
154169
text=True,
155170
).stdout
156-
assert container.name is not None
157-
assert container.name in docker_containers_listing
158-
old_container_name = container.name
159-
160-
docker_containers_listing = subprocess.run(
161-
f"{container.engine.name} container ls",
162-
shell=True,
163-
check=True,
164-
stdout=subprocess.PIPE,
165-
text=True,
166-
).stdout
167-
assert old_container_name not in docker_containers_listing
171+
if container_name not in docker_containers_listing:
172+
break
173+
time.sleep(0.1)
174+
assert container_name not in docker_containers_listing
168175

169176

170177
def test_large_environment(container_engine):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy