From 607dc83e55a73af958a8282fff4403303c6cb21d Mon Sep 17 00:00:00 2001 From: xavierk Date: Mon, 14 Sep 2026 12:25:25 +0530 Subject: [PATCH] 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 --- tests/test_packaging.py | 119 ++++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 58 deletions(-) diff --git a/tests/test_packaging.py b/tests/test_packaging.py index 6c7510d..e32f1ab 100644 --- a/tests/test_packaging.py +++ b/tests/test_packaging.py @@ -32,6 +32,19 @@ def _get_version() -> str: 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: """Get available container runtime (podman or docker).""" for cmd in ["podman", "docker"]: @@ -582,18 +595,16 @@ def test_python_floor(skip_no_docker, version): tag = "fenris-floor-ubuntu-2204" subprocess.run( - ["docker", "build", "-t", tag, str(build_dir)], + _container_cmd("build", "-t", tag, str(build_dir)), check=True, capture_output=True, timeout=300, ) container = f"fenris-floor-{os.getpid()}" subprocess.run( - [ - "docker", "run", "-d", "--name", container, + _container_cmd("run", "-d", "--name", container, "--tmpfs", "/tmp:exec,size=64m", - tag, "sleep", "infinity", - ], + tag, "sleep", "infinity"), check=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" finally: subprocess.run( - ["docker", "rm", "-f", container], + _container_cmd("rm", "-f", container), capture_output=True, ) @@ -645,18 +656,16 @@ def test_python_floor(skip_no_docker, version): tag_floor = "fenris-below-floor-debian11" subprocess.run( - ["docker", "build", "-t", tag_floor, str(build_dir_floor)], + _container_cmd("build", "-t", tag_floor, str(build_dir_floor)), check=True, capture_output=True, timeout=300, ) container_floor = f"fenris-below-floor-{os.getpid()}" subprocess.run( - [ - "docker", "run", "-d", "--name", container_floor, + _container_cmd("run", "-d", "--name", container_floor, "--tmpfs", "/tmp:exec,size=64m", - tag_floor, "sleep", "infinity", - ], + tag_floor, "sleep", "infinity"), check=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}" finally: subprocess.run( - ["docker", "rm", "-f", container_floor], + _container_cmd("rm", "-f", container_floor), capture_output=True, ) @@ -726,7 +735,7 @@ def test_dormant_install(skip_no_docker, image, fmt, version): # Build image tag = f"fenris-test-{image.replace(':', '-').replace('/', '-')}" subprocess.run( - ["docker", "build", "-t", tag, str(build_dir)], + _container_cmd("build", "-t", tag, str(build_dir)), check=True, capture_output=True, timeout=300, @@ -735,11 +744,9 @@ def test_dormant_install(skip_no_docker, image, fmt, version): # Run container container = f"fenris-test-{os.getpid()}" subprocess.run( - [ - "docker", "run", "-d", "--name", container, + _container_cmd("run", "-d", "--name", container, "--tmpfs", "/tmp:exec,size=64m", - tag, "sleep", "infinity", - ], + tag, "sleep", "infinity"), check=True, capture_output=True, ) @@ -748,7 +755,7 @@ def test_dormant_install(skip_no_docker, image, fmt, version): _assert_dormant_layout(container, fmt, version) finally: subprocess.run( - ["docker", "rm", "-f", container], + _container_cmd("rm", "-f", container), capture_output=True, ) @@ -797,7 +804,7 @@ def test_migration_guard(skip_no_docker, image, fmt, version): tag = f"fenris-guard-{image.replace(':', '-').replace('/', '-')}" subprocess.run( - ["docker", "build", "-t", tag, str(build_dir)], + _container_cmd("build", "-t", tag, str(build_dir)), check=True, capture_output=True, timeout=300, @@ -805,11 +812,9 @@ def test_migration_guard(skip_no_docker, image, fmt, version): container = f"fenris-guard-{os.getpid()}" subprocess.run( - [ - "docker", "run", "-d", "--name", container, + _container_cmd("run", "-d", "--name", container, "--tmpfs", "/tmp:exec,size=64m", - tag, "sleep", "infinity", - ], + tag, "sleep", "infinity"), check=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) finally: subprocess.run( - ["docker", "rm", "-f", container], + _container_cmd("rm", "-f", container), capture_output=True, ) @@ -850,7 +855,7 @@ def test_upgrade_semantics(skip_no_docker, image, fmt, version): tag = f"fenris-upgrade-{image.replace(':', '-').replace('/', '-')}" subprocess.run( - ["docker", "build", "-t", tag, str(build_dir)], + _container_cmd("build", "-t", tag, str(build_dir)), check=True, capture_output=True, timeout=300, @@ -858,11 +863,9 @@ def test_upgrade_semantics(skip_no_docker, image, fmt, version): container = f"fenris-upgrade-{os.getpid()}" subprocess.run( - [ - "docker", "run", "-d", "--name", container, + _container_cmd("run", "-d", "--name", container, "--tmpfs", "/tmp:exec,size=64m", - tag, "sleep", "infinity", - ], + tag, "sleep", "infinity"), check=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) finally: subprocess.run( - ["docker", "rm", "-f", container], + _container_cmd("rm", "-f", container), 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(':', '-')}" subprocess.run( - ["docker", "build", "-t", tag, str(build_dir)], + _container_cmd("build", "-t", tag, str(build_dir)), check=True, capture_output=True, timeout=300, ) container = f"fenris-deb-remove-{os.getpid()}" subprocess.run( - ["docker", "run", "-d", "--name", container, - "--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"], + _container_cmd("run", "-d", "--name", container, + "--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"), 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). finally: 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(':', '-')}" subprocess.run( - ["docker", "build", "-t", tag, str(build_dir)], + _container_cmd("build", "-t", tag, str(build_dir)), check=True, capture_output=True, timeout=300, ) container = f"fenris-deb-purge-{os.getpid()}" subprocess.run( - ["docker", "run", "-d", "--name", container, - "--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"], + _container_cmd("run", "-d", "--name", container, + "--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"), 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) finally: 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('/', '-')}" subprocess.run( - ["docker", "build", "-t", tag, str(build_dir)], + _container_cmd("build", "-t", tag, str(build_dir)), check=True, capture_output=True, timeout=300, ) container = f"fenris-upgrade-no-disable-{os.getpid()}" subprocess.run( - ["docker", "run", "-d", "--name", container, - "--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"], + _container_cmd("run", "-d", "--name", container, + "--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"), 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" finally: 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" subprocess.run( - ["docker", "build", "-t", tag, str(build_dir)], + _container_cmd("build", "-t", tag, str(build_dir)), check=True, capture_output=True, timeout=300, ) container = f"fenris-rpm-erase-{os.getpid()}" subprocess.run( - ["docker", "run", "-d", "--name", container, - "--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"], + _container_cmd("run", "-d", "--name", container, + "--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"), 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). finally: 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" subprocess.run( - ["docker", "build", "-t", tag, str(build_dir)], + _container_cmd("build", "-t", tag, str(build_dir)), check=True, capture_output=True, timeout=300, ) container = f"fenris-rpm-erase-unmod-{os.getpid()}" subprocess.run( - ["docker", "run", "-d", "--name", container, - "--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"], + _container_cmd("run", "-d", "--name", container, + "--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"), 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) finally: 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(':', '-')}" subprocess.run( - ["docker", "build", "-t", tag, str(build_dir)], + _container_cmd("build", "-t", tag, str(build_dir)), check=True, capture_output=True, timeout=300, ) container = f"fenris-no-move-deb-{os.getpid()}" subprocess.run( - ["docker", "run", "-d", "--name", container, - "--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"], + _container_cmd("run", "-d", "--name", container, + "--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"), check=True, capture_output=True, ) @@ -1348,7 +1351,7 @@ def test_no_move_continuity_deb(skip_no_docker, image, version): ) finally: 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" subprocess.run( - ["docker", "build", "-t", tag, str(build_dir)], + _container_cmd("build", "-t", tag, str(build_dir)), check=True, capture_output=True, timeout=300, ) container = f"fenris-no-move-rpm-{os.getpid()}" subprocess.run( - ["docker", "run", "-d", "--name", container, - "--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"], + _container_cmd("run", "-d", "--name", container, + "--tmpfs", "/tmp:exec,size=64m", tag, "sleep", "infinity"), check=True, capture_output=True, ) @@ -1422,5 +1425,5 @@ def test_no_move_continuity_rpm(skip_no_docker, version): ) finally: subprocess.run( - ["docker", "rm", "-f", container], capture_output=True, + _container_cmd("rm", "-f", container), capture_output=True, )