chore: complete podman support in packaging tests
Replace all hardcoded docker commands with _container_cmd() helper function that auto-detects podman or docker runtime. Note: test_python_floor fails because Debian 11 (bullseye) has reached end-of-life and its security repository URLs return 404. This is a test infrastructure issue, not a code issue. Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
This commit is contained in:
co-authored by
CommandCodeBot
parent
d6fa94001c
commit
607dc83e55
+61
-58
@@ -32,6 +32,19 @@ def _get_version() -> str:
|
|||||||
return get_version()
|
return get_version()
|
||||||
|
|
||||||
|
|
||||||
|
def _get_container_runtime() -> str:
|
||||||
|
"""Get available container runtime (podman or docker)."""
|
||||||
|
for cmd in ["podman", "docker"]:
|
||||||
|
try:
|
||||||
|
r = subprocess.run([cmd, "info"], capture_output=True, timeout=10)
|
||||||
|
if r.returncode == 0:
|
||||||
|
return cmd
|
||||||
|
except (FileNotFoundError, subprocess.TimeoutExpired):
|
||||||
|
continue
|
||||||
|
return "docker" # fallback
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _get_container_runtime() -> str:
|
def _get_container_runtime() -> str:
|
||||||
"""Get available container runtime (podman or docker)."""
|
"""Get available container runtime (podman or docker)."""
|
||||||
for cmd in ["podman", "docker"]:
|
for cmd in ["podman", "docker"]:
|
||||||
@@ -582,18 +595,16 @@ def test_python_floor(skip_no_docker, version):
|
|||||||
|
|
||||||
tag = "fenris-floor-ubuntu-2204"
|
tag = "fenris-floor-ubuntu-2204"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "build", "-t", tag, str(build_dir)],
|
_container_cmd("build", "-t", tag, str(build_dir)),
|
||||||
check=True,
|
check=True,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
timeout=300,
|
timeout=300,
|
||||||
)
|
)
|
||||||
container = f"fenris-floor-{os.getpid()}"
|
container = f"fenris-floor-{os.getpid()}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
[
|
_container_cmd("run", "-d", "--name", container,
|
||||||
"docker", "run", "-d", "--name", container,
|
|
||||||
"--tmpfs", "/tmp:exec,size=64m",
|
"--tmpfs", "/tmp:exec,size=64m",
|
||||||
tag, "sleep", "infinity",
|
tag, "sleep", "infinity"),
|
||||||
],
|
|
||||||
check=True,
|
check=True,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
)
|
)
|
||||||
@@ -622,7 +633,7 @@ def test_python_floor(skip_no_docker, version):
|
|||||||
assert rc == 0, "fenris not on PATH after floor-met install"
|
assert rc == 0, "fenris not on PATH after floor-met install"
|
||||||
finally:
|
finally:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "rm", "-f", container],
|
_container_cmd("rm", "-f", container),
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -645,18 +656,16 @@ def test_python_floor(skip_no_docker, version):
|
|||||||
|
|
||||||
tag_floor = "fenris-below-floor-debian11"
|
tag_floor = "fenris-below-floor-debian11"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "build", "-t", tag_floor, str(build_dir_floor)],
|
_container_cmd("build", "-t", tag_floor, str(build_dir_floor)),
|
||||||
check=True,
|
check=True,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
timeout=300,
|
timeout=300,
|
||||||
)
|
)
|
||||||
container_floor = f"fenris-below-floor-{os.getpid()}"
|
container_floor = f"fenris-below-floor-{os.getpid()}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
[
|
_container_cmd("run", "-d", "--name", container_floor,
|
||||||
"docker", "run", "-d", "--name", container_floor,
|
|
||||||
"--tmpfs", "/tmp:exec,size=64m",
|
"--tmpfs", "/tmp:exec,size=64m",
|
||||||
tag_floor, "sleep", "infinity",
|
tag_floor, "sleep", "infinity"),
|
||||||
],
|
|
||||||
check=True,
|
check=True,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
)
|
)
|
||||||
@@ -691,7 +700,7 @@ def test_python_floor(skip_no_docker, version):
|
|||||||
f"Package should not be configured below Python floor: {out}"
|
f"Package should not be configured below Python floor: {out}"
|
||||||
finally:
|
finally:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "rm", "-f", container_floor],
|
_container_cmd("rm", "-f", container_floor),
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -726,7 +735,7 @@ def test_dormant_install(skip_no_docker, image, fmt, version):
|
|||||||
# Build image
|
# Build image
|
||||||
tag = f"fenris-test-{image.replace(':', '-').replace('/', '-')}"
|
tag = f"fenris-test-{image.replace(':', '-').replace('/', '-')}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "build", "-t", tag, str(build_dir)],
|
_container_cmd("build", "-t", tag, str(build_dir)),
|
||||||
check=True,
|
check=True,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
timeout=300,
|
timeout=300,
|
||||||
@@ -735,11 +744,9 @@ def test_dormant_install(skip_no_docker, image, fmt, version):
|
|||||||
# Run container
|
# Run container
|
||||||
container = f"fenris-test-{os.getpid()}"
|
container = f"fenris-test-{os.getpid()}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
[
|
_container_cmd("run", "-d", "--name", container,
|
||||||
"docker", "run", "-d", "--name", container,
|
|
||||||
"--tmpfs", "/tmp:exec,size=64m",
|
"--tmpfs", "/tmp:exec,size=64m",
|
||||||
tag, "sleep", "infinity",
|
tag, "sleep", "infinity"),
|
||||||
],
|
|
||||||
check=True,
|
check=True,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
)
|
)
|
||||||
@@ -748,7 +755,7 @@ def test_dormant_install(skip_no_docker, image, fmt, version):
|
|||||||
_assert_dormant_layout(container, fmt, version)
|
_assert_dormant_layout(container, fmt, version)
|
||||||
finally:
|
finally:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "rm", "-f", container],
|
_container_cmd("rm", "-f", container),
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -797,7 +804,7 @@ def test_migration_guard(skip_no_docker, image, fmt, version):
|
|||||||
|
|
||||||
tag = f"fenris-guard-{image.replace(':', '-').replace('/', '-')}"
|
tag = f"fenris-guard-{image.replace(':', '-').replace('/', '-')}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "build", "-t", tag, str(build_dir)],
|
_container_cmd("build", "-t", tag, str(build_dir)),
|
||||||
check=True,
|
check=True,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
timeout=300,
|
timeout=300,
|
||||||
@@ -805,11 +812,9 @@ def test_migration_guard(skip_no_docker, image, fmt, version):
|
|||||||
|
|
||||||
container = f"fenris-guard-{os.getpid()}"
|
container = f"fenris-guard-{os.getpid()}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
[
|
_container_cmd("run", "-d", "--name", container,
|
||||||
"docker", "run", "-d", "--name", container,
|
|
||||||
"--tmpfs", "/tmp:exec,size=64m",
|
"--tmpfs", "/tmp:exec,size=64m",
|
||||||
tag, "sleep", "infinity",
|
tag, "sleep", "infinity"),
|
||||||
],
|
|
||||||
check=True,
|
check=True,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
)
|
)
|
||||||
@@ -818,7 +823,7 @@ def test_migration_guard(skip_no_docker, image, fmt, version):
|
|||||||
_assert_migration_guard(container, fmt, pkg_name)
|
_assert_migration_guard(container, fmt, pkg_name)
|
||||||
finally:
|
finally:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "rm", "-f", container],
|
_container_cmd("rm", "-f", container),
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -850,7 +855,7 @@ def test_upgrade_semantics(skip_no_docker, image, fmt, version):
|
|||||||
|
|
||||||
tag = f"fenris-upgrade-{image.replace(':', '-').replace('/', '-')}"
|
tag = f"fenris-upgrade-{image.replace(':', '-').replace('/', '-')}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "build", "-t", tag, str(build_dir)],
|
_container_cmd("build", "-t", tag, str(build_dir)),
|
||||||
check=True,
|
check=True,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
timeout=300,
|
timeout=300,
|
||||||
@@ -858,11 +863,9 @@ def test_upgrade_semantics(skip_no_docker, image, fmt, version):
|
|||||||
|
|
||||||
container = f"fenris-upgrade-{os.getpid()}"
|
container = f"fenris-upgrade-{os.getpid()}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
[
|
_container_cmd("run", "-d", "--name", container,
|
||||||
"docker", "run", "-d", "--name", container,
|
|
||||||
"--tmpfs", "/tmp:exec,size=64m",
|
"--tmpfs", "/tmp:exec,size=64m",
|
||||||
tag, "sleep", "infinity",
|
tag, "sleep", "infinity"),
|
||||||
],
|
|
||||||
check=True,
|
check=True,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
)
|
)
|
||||||
@@ -875,7 +878,7 @@ def test_upgrade_semantics(skip_no_docker, image, fmt, version):
|
|||||||
_assert_rpm_upgrade_full(container, pkg_name)
|
_assert_rpm_upgrade_full(container, pkg_name)
|
||||||
finally:
|
finally:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "rm", "-f", container],
|
_container_cmd("rm", "-f", container),
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -904,14 +907,14 @@ def test_deb_remove_preserves_config_and_store(skip_no_docker, image, version):
|
|||||||
|
|
||||||
tag = f"fenris-deb-remove-{image.replace(':', '-')}"
|
tag = f"fenris-deb-remove-{image.replace(':', '-')}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "build", "-t", tag, str(build_dir)],
|
_container_cmd("build", "-t", tag, str(build_dir)),
|
||||||
check=True, capture_output=True, timeout=300,
|
check=True, capture_output=True, timeout=300,
|
||||||
)
|
)
|
||||||
|
|
||||||
container = f"fenris-deb-remove-{os.getpid()}"
|
container = f"fenris-deb-remove-{os.getpid()}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "run", "-d", "--name", container,
|
_container_cmd("run", "-d", "--name", container,
|
||||||
"--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"],
|
"--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"),
|
||||||
check=True, capture_output=True,
|
check=True, capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -926,7 +929,7 @@ def test_deb_remove_preserves_config_and_store(skip_no_docker, image, version):
|
|||||||
# test_upgrade_semantics (criterion 4: removal scripts are no-ops).
|
# test_upgrade_semantics (criterion 4: removal scripts are no-ops).
|
||||||
finally:
|
finally:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "rm", "-f", container], capture_output=True,
|
_container_cmd("rm", "-f", container), capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -950,14 +953,14 @@ def test_deb_purge_removes_everything(skip_no_docker, image, version):
|
|||||||
|
|
||||||
tag = f"fenris-deb-purge-{image.replace(':', '-')}"
|
tag = f"fenris-deb-purge-{image.replace(':', '-')}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "build", "-t", tag, str(build_dir)],
|
_container_cmd("build", "-t", tag, str(build_dir)),
|
||||||
check=True, capture_output=True, timeout=300,
|
check=True, capture_output=True, timeout=300,
|
||||||
)
|
)
|
||||||
|
|
||||||
container = f"fenris-deb-purge-{os.getpid()}"
|
container = f"fenris-deb-purge-{os.getpid()}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "run", "-d", "--name", container,
|
_container_cmd("run", "-d", "--name", container,
|
||||||
"--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"],
|
"--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"),
|
||||||
check=True, capture_output=True,
|
check=True, capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -969,7 +972,7 @@ def test_deb_purge_removes_everything(skip_no_docker, image, version):
|
|||||||
_assert_package_files_removed(container)
|
_assert_package_files_removed(container)
|
||||||
finally:
|
finally:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "rm", "-f", container], capture_output=True,
|
_container_cmd("rm", "-f", container), capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -998,14 +1001,14 @@ def test_sanctioned_disable_skipped_on_upgrade(skip_no_docker, image, fmt,
|
|||||||
|
|
||||||
tag = f"fenris-upgrade-no-disable-{image.replace(':', '-').replace('/', '-')}"
|
tag = f"fenris-upgrade-no-disable-{image.replace(':', '-').replace('/', '-')}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "build", "-t", tag, str(build_dir)],
|
_container_cmd("build", "-t", tag, str(build_dir)),
|
||||||
check=True, capture_output=True, timeout=300,
|
check=True, capture_output=True, timeout=300,
|
||||||
)
|
)
|
||||||
|
|
||||||
container = f"fenris-upgrade-no-disable-{os.getpid()}"
|
container = f"fenris-upgrade-no-disable-{os.getpid()}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "run", "-d", "--name", container,
|
_container_cmd("run", "-d", "--name", container,
|
||||||
"--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"],
|
"--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"),
|
||||||
check=True, capture_output=True,
|
check=True, capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1065,7 +1068,7 @@ def test_sanctioned_disable_skipped_on_upgrade(skip_no_docker, image, fmt,
|
|||||||
assert rc == 0, "Helper removed during upgrade"
|
assert rc == 0, "Helper removed during upgrade"
|
||||||
finally:
|
finally:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "rm", "-f", container], capture_output=True,
|
_container_cmd("rm", "-f", container), capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -1088,14 +1091,14 @@ def test_rpm_erase_modified_config_preserved(skip_no_docker, version):
|
|||||||
|
|
||||||
tag = "fenris-rpm-erase-mod"
|
tag = "fenris-rpm-erase-mod"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "build", "-t", tag, str(build_dir)],
|
_container_cmd("build", "-t", tag, str(build_dir)),
|
||||||
check=True, capture_output=True, timeout=300,
|
check=True, capture_output=True, timeout=300,
|
||||||
)
|
)
|
||||||
|
|
||||||
container = f"fenris-rpm-erase-{os.getpid()}"
|
container = f"fenris-rpm-erase-{os.getpid()}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "run", "-d", "--name", container,
|
_container_cmd("run", "-d", "--name", container,
|
||||||
"--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"],
|
"--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"),
|
||||||
check=True, capture_output=True,
|
check=True, capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1121,7 +1124,7 @@ def test_rpm_erase_modified_config_preserved(skip_no_docker, version):
|
|||||||
# test_upgrade_semantics (criterion 4: removal scripts are no-ops).
|
# test_upgrade_semantics (criterion 4: removal scripts are no-ops).
|
||||||
finally:
|
finally:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "rm", "-f", container], capture_output=True,
|
_container_cmd("rm", "-f", container), capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -1144,14 +1147,14 @@ def test_rpm_erase_unmodified_config_removed(skip_no_docker, version):
|
|||||||
|
|
||||||
tag = "fenris-rpm-erase-unmod"
|
tag = "fenris-rpm-erase-unmod"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "build", "-t", tag, str(build_dir)],
|
_container_cmd("build", "-t", tag, str(build_dir)),
|
||||||
check=True, capture_output=True, timeout=300,
|
check=True, capture_output=True, timeout=300,
|
||||||
)
|
)
|
||||||
|
|
||||||
container = f"fenris-rpm-erase-unmod-{os.getpid()}"
|
container = f"fenris-rpm-erase-unmod-{os.getpid()}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "run", "-d", "--name", container,
|
_container_cmd("run", "-d", "--name", container,
|
||||||
"--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"],
|
"--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"),
|
||||||
check=True, capture_output=True,
|
check=True, capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1169,7 +1172,7 @@ def test_rpm_erase_unmodified_config_removed(skip_no_docker, version):
|
|||||||
_assert_package_files_removed(container)
|
_assert_package_files_removed(container)
|
||||||
finally:
|
finally:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "rm", "-f", container], capture_output=True,
|
_container_cmd("rm", "-f", container), capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -1300,14 +1303,14 @@ def test_no_move_continuity_deb(skip_no_docker, image, version):
|
|||||||
|
|
||||||
tag = f"fenris-no-move-deb-{image.replace(':', '-')}"
|
tag = f"fenris-no-move-deb-{image.replace(':', '-')}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "build", "-t", tag, str(build_dir)],
|
_container_cmd("build", "-t", tag, str(build_dir)),
|
||||||
check=True, capture_output=True, timeout=300,
|
check=True, capture_output=True, timeout=300,
|
||||||
)
|
)
|
||||||
|
|
||||||
container = f"fenris-no-move-deb-{os.getpid()}"
|
container = f"fenris-no-move-deb-{os.getpid()}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "run", "-d", "--name", container,
|
_container_cmd("run", "-d", "--name", container,
|
||||||
"--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"],
|
"--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"),
|
||||||
check=True, capture_output=True,
|
check=True, capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1348,7 +1351,7 @@ def test_no_move_continuity_deb(skip_no_docker, image, version):
|
|||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "rm", "-f", container], capture_output=True,
|
_container_cmd("rm", "-f", container), capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -1375,14 +1378,14 @@ def test_no_move_continuity_rpm(skip_no_docker, version):
|
|||||||
|
|
||||||
tag = "fenris-no-move-rpm"
|
tag = "fenris-no-move-rpm"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "build", "-t", tag, str(build_dir)],
|
_container_cmd("build", "-t", tag, str(build_dir)),
|
||||||
check=True, capture_output=True, timeout=300,
|
check=True, capture_output=True, timeout=300,
|
||||||
)
|
)
|
||||||
|
|
||||||
container = f"fenris-no-move-rpm-{os.getpid()}"
|
container = f"fenris-no-move-rpm-{os.getpid()}"
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "run", "-d", "--name", container,
|
_container_cmd("run", "-d", "--name", container,
|
||||||
"--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"],
|
"--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"),
|
||||||
check=True, capture_output=True,
|
check=True, capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1422,5 +1425,5 @@ def test_no_move_continuity_rpm(skip_no_docker, version):
|
|||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["docker", "rm", "-f", container], capture_output=True,
|
_container_cmd("rm", "-f", container), capture_output=True,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user