diff --git a/test/test_build.py b/test/test_build.py index fbf1f60f..052be0f3 100644 --- a/test/test_build.py +++ b/test/test_build.py @@ -416,6 +416,9 @@ def build_images(shared_tmpdir, build_container, request, force_aws_upload, gpg_ ] cmd.extend(signed_image_args) + # Pull the signed image + testutil.pull_container(container_ref, tls_verify=False) + cmd.extend([ *creds_args, build_container, @@ -424,8 +427,8 @@ def build_images(shared_tmpdir, build_container, request, force_aws_upload, gpg_ *upload_args, *target_arch_args, *tc.bib_rootfs_args(), - "--tls-verify=false" if tc.sign else "--tls-verify=true", f"--use-librepo={tc.use_librepo}", + *tc.bib_rootfs_args() ]) # print the build command for easier tracing diff --git a/test/test_manifest.py b/test/test_manifest.py index 746f9461..32fb90ef 100644 --- a/test/test_manifest.py +++ b/test/test_manifest.py @@ -7,8 +7,8 @@ import textwrap import pytest -import testutil +import testutil from containerbuild import build_container_fixture # pylint: disable=unused-import from containerbuild import make_container from testcases import gen_testcases @@ -69,6 +69,8 @@ def test_iso_manifest_smoke(build_container, tc): @pytest.mark.parametrize("tc", gen_testcases("manifest")) def test_manifest_disksize(tmp_path, build_container, tc): + testutil.pull_container(tc.container_ref, tc.target_arch) + # create derrived container with 6G silly file to ensure that # bib doubles the size to 12G+ cntf_path = tmp_path / "Containerfile" @@ -114,6 +116,8 @@ def test_manifest_local_checks_containers_storage_errors(build_container): @pytest.mark.parametrize("tc", gen_testcases("manifest")) def test_manifest_local_checks_containers_storage_works(tmp_path, build_container, tc): + testutil.pull_container(tc.container_ref, tc.target_arch) + cntf_path = tmp_path / "Containerfile" cntf_path.write_text(textwrap.dedent(f"""\n FROM {tc.container_ref} @@ -360,6 +364,8 @@ def find_image_anaconda_stage(manifest_str): @pytest.mark.parametrize("tc", gen_testcases("anaconda-iso")) def test_manifest_anaconda_module_customizations(tmpdir_factory, build_container, tc): + testutil.pull_container(tc.container_ref, tc.target_arch) + cfg = { "customizations": { "installer": { @@ -384,8 +390,6 @@ def test_manifest_anaconda_module_customizations(tmpdir_factory, build_container config_json_path = output_path / "config.json" config_json_path.write_text(json.dumps(cfg), encoding="utf-8") - testutil.pull_container(tc.container_ref, tc.target_arch) - output = subprocess.check_output([ *testutil.podman_run_common, "-v", f"{output_path}:/output", @@ -548,6 +552,7 @@ def find_grub2_iso_stage_from(manifest_str): def test_manifest_fips_customization(tmp_path, build_container): container_ref = "quay.io/centos-bootc/centos-bootc:stream9" + testutil.pull_container(container_ref) config = { "customizations": { @@ -582,6 +587,7 @@ def find_bootc_install_to_fs_stage_from(manifest_str): def test_manifest_disk_customization_lvm(tmp_path, build_container): container_ref = "quay.io/centos-bootc/centos-bootc:stream9" + testutil.pull_container(container_ref) config = { "customizations": { @@ -606,6 +612,7 @@ def test_manifest_disk_customization_lvm(tmp_path, build_container): with config_path.open("w") as config_file: json.dump(config, config_file) + testutil.pull_container(container_ref) output = subprocess.check_output([ *testutil.podman_run_common, "-v", f"{config_path}:/config.json:ro", @@ -641,6 +648,7 @@ def test_manifest_disk_customization_btrfs(tmp_path, build_container): with config_path.open("w") as config_file: json.dump(config, config_file) + testutil.pull_container(container_ref) output = subprocess.check_output([ *testutil.podman_run_common, "-v", f"{config_path}:/config.json:ro", @@ -681,6 +689,7 @@ def test_manifest_disk_customization_swap(tmp_path, build_container): with config_path.open("w") as config_file: json.dump(config, config_file) + testutil.pull_container(container_ref) output = subprocess.check_output([ *testutil.podman_run_common, "-v", f"{config_path}:/config.json:ro", @@ -725,6 +734,7 @@ def test_manifest_disk_customization_lvm_swap(tmp_path, build_container): with config_path.open("w") as config_file: json.dump(config, config_file) + testutil.pull_container(container_ref) output = subprocess.check_output([ *testutil.podman_run_common, "-v", f"{config_path}:/config.json:ro", @@ -754,6 +764,7 @@ def test_manifest_disk_customization_lvm_swap(tmp_path, build_container): def test_iso_manifest_use_librepo(build_container, use_librepo): # no need to parameterize this test, --use-librepo behaves same for all containers container_ref = "quay.io/centos-bootc/centos-bootc:stream9" + testutil.pull_container(container_ref) output = subprocess.check_output([ *testutil.podman_run_common, diff --git a/test/test_progress.py b/test/test_progress.py index d83cad97..2caa0eaf 100644 --- a/test/test_progress.py +++ b/test/test_progress.py @@ -1,5 +1,6 @@ import subprocess +import testutil # pylint: disable=unused-import,duplicate-code from test_opts import container_storage_fixture from containerbuild import build_container_fixture, build_fake_container_fixture @@ -10,8 +11,7 @@ def test_progress_debug(tmp_path, build_fake_container): output_path.mkdir(exist_ok=True) cmdline = [ - "podman", "run", "--rm", - "--privileged", + *testutil.podman_run_common, build_fake_container, "build", "--progress=debug", @@ -27,19 +27,21 @@ def test_progress_debug(tmp_path, build_fake_container): def test_progress_term_works_without_tty(tmp_path, build_fake_container): + container_ref = "quay.io/centos-bootc/centos-bootc:stream9" + testutil.pull_container(container_ref) + output_path = tmp_path / "output" output_path.mkdir(exist_ok=True) cmdline = [ - "podman", "run", "--rm", + *testutil.podman_run_common, # note that "-t" is missing here - "--privileged", build_fake_container, "build", # explicitly selecting term progress works even when there is no tty # (i.e. we just need ansi terminal support) "--progress=term", - "quay.io/centos-bootc/centos-bootc:stream9", + container_ref, ] res = subprocess.run(cmdline, capture_output=True, text=True, check=False) assert res.returncode == 0 @@ -51,10 +53,9 @@ def test_progress_term_autoselect(tmp_path, build_fake_container): output_path.mkdir(exist_ok=True) cmdline = [ - "podman", "run", "--rm", + *testutil.podman_run_common, # we have a terminal "-t", - "--privileged", build_fake_container, "build", # note that we do not select a --progress here so auto-select is used diff --git a/test/testutil.py b/test/testutil.py index 1cdbcaa7..2d574579 100644 --- a/test/testutil.py +++ b/test/testutil.py @@ -215,7 +215,7 @@ def get_ip_from_default_route(): return default_route.split()[8] -def pull_container(container_ref, target_arch=""): +def pull_container(container_ref, target_arch="", tls_verify=True): if target_arch == "": target_arch = platform.machine() @@ -225,5 +225,6 @@ def pull_container(container_ref, target_arch=""): subprocess.run([ "podman", "pull", "--arch", target_arch, + "--tls-verify" if tls_verify else "--tls-verify=false", container_ref, ], check=True)