Skip to content

Commit bc776a7

Browse files
committed
tests: make the udocker tests less flaky by logging into the Docker Hub if credentials are provided.
1 parent e1e1ab3 commit bc776a7

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

tests/test_udocker.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ def udocker(tmp_path_factory: TempPathFactory) -> str:
3030
["tar", "--strip-components=1", "-xzvf", "udocker-tarball.tgz"],
3131
["./udocker/udocker", "install"],
3232
]
33+
if "UDOCKER_USER" in os.environ and "UDOCKER_PASS" in os.environ:
34+
install_cmds.append(
35+
[
36+
"./udocker/udocker",
37+
"login",
38+
f"--username={os.environ['UDOCKER_USER']}",
39+
f"--password={os.environ['UDOCKER_PASS']}",
40+
]
41+
)
42+
install_cmds.append(["./udocker/udocker", "pull", "debian:stable-slim"])
3343

3444
test_environ["UDOCKER_DIR"] = os.path.join(docker_install_dir, ".udocker")
3545
test_environ["HOME"] = docker_install_dir
@@ -78,10 +88,11 @@ def test_udocker_usage_should_not_write_cid_file(udocker: str, tmp_path: Path) -
7888
)
7989
def test_udocker_should_display_memory_usage(udocker: str, tmp_path: Path) -> None:
8090
"""Confirm that memory ussage is logged even with udocker."""
91+
print(udocker)
8192
with working_directory(tmp_path):
8293
error_code, stdout, stderr = get_main_output(
8394
[
84-
"--enable-ext",
95+
"--enable-ext", "--timestamps", "--debug",
8596
"--default-container=debian:stable-slim",
8697
"--user-space-docker-cmd=" + udocker,
8798
get_data("tests/wf/timelimit.cwl"),
@@ -91,7 +102,7 @@ def test_udocker_should_display_memory_usage(udocker: str, tmp_path: Path) -> No
91102
)
92103

93104
assert "completed success" in stderr, stderr
94-
assert "Max memory" in stderr, stderr
105+
assert "Max memory" in stderr or "Could not collect memory usage, job ended before monitoring began." in stderr, stderr
95106

96107

97108
@pytest.mark.skipif(not LINUX, reason="LINUX only")

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ passenv =
4141
PROOT_NO_SECCOMP
4242
APPTAINER_TMPDIR
4343
SINGULARITY_FAKEROOT
44+
UDOCKER_*
4445

4546
extras =
4647
py3{10,11,12,13,14}-unit: deps

0 commit comments

Comments
 (0)