From eacbde553a785a548dbe9825ea43708c5f9abaed Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Thu, 25 Jul 2024 11:50:57 -0400 Subject: [PATCH] Move target script tests from pulp to integration test suite (#696) Move tests of the target scripts into the active CI integration tests. (cherry picked from commit 9b9d88f45c327b0b751c2338289904f17ed26719) --- .../v3/check_ansible/ee-missing-ansible.yml | 6 +-- .../v3/check_ansible/ee-missing-runner.yml | 6 +-- test/data/v3/check_ansible/ee-skip.yml | 8 +-- test/integration/test_build.py | 50 +++++++++++++++++++ test/pulp_integration/test_v3.py | 48 ------------------ 5 files changed, 56 insertions(+), 62 deletions(-) delete mode 100644 test/pulp_integration/test_v3.py diff --git a/test/data/v3/check_ansible/ee-missing-ansible.yml b/test/data/v3/check_ansible/ee-missing-ansible.yml index f77ca939..9fd73fc3 100644 --- a/test/data/v3/check_ansible/ee-missing-ansible.yml +++ b/test/data/v3/check_ansible/ee-missing-ansible.yml @@ -3,13 +3,11 @@ version: 3 images: base_image: - name: localhost:8080/testrepo/ubi-minimal:latest + name: quay.io/centos/centos:stream9 dependencies: ansible_runner: package_pip: ansible-runner - python_interpreter: - package_system: python3 options: - package_manager_path: /usr/bin/microdnf + package_manager_path: /bin/true diff --git a/test/data/v3/check_ansible/ee-missing-runner.yml b/test/data/v3/check_ansible/ee-missing-runner.yml index 66d54ed0..c8316754 100644 --- a/test/data/v3/check_ansible/ee-missing-runner.yml +++ b/test/data/v3/check_ansible/ee-missing-runner.yml @@ -3,13 +3,11 @@ version: 3 images: base_image: - name: localhost:8080/testrepo/ubi-minimal:latest + name: quay.io/centos/centos:stream9 dependencies: ansible_core: package_pip: ansible-core - python_interpreter: - package_system: python3 options: - package_manager_path: /usr/bin/microdnf + package_manager_path: /bin/true diff --git a/test/data/v3/check_ansible/ee-skip.yml b/test/data/v3/check_ansible/ee-skip.yml index 27ce28c3..da6b8e92 100644 --- a/test/data/v3/check_ansible/ee-skip.yml +++ b/test/data/v3/check_ansible/ee-skip.yml @@ -3,12 +3,8 @@ version: 3 images: base_image: - name: localhost:8080/testrepo/ubi-minimal:latest - -dependencies: - python_interpreter: - package_system: python3 + name: quay.io/centos/centos:stream9 options: skip_ansible_check: True - package_manager_path: /usr/bin/microdnf + package_manager_path: /bin/true diff --git a/test/integration/test_build.py b/test/integration/test_build.py index 2e6b70ee..b134a1a8 100644 --- a/test/integration/test_build.py +++ b/test/integration/test_build.py @@ -1,4 +1,5 @@ import os +import subprocess # Need to call this directly for multiple tag testing from test.conftest import delete_image @@ -298,3 +299,52 @@ def test_empty_galaxy_requirements(cli, runtime, data_dir, ee_tag, tmp_path): allow_error=True) assert result.rc == 0 + + +@pytest.mark.test_all_runtimes +def test_ansible_check_is_skipped(cli, runtime, ee_tag, data_dir, tmp_path): + """ + Test that the check_ansible script is skipped will NOT cause build failure. + """ + ee_def = data_dir / 'v3' / 'check_ansible' / 'ee-skip.yml' + + result = cli( + f'ansible-builder build --no-cache -c {tmp_path} -f {ee_def} -t {ee_tag} ' + f'--container-runtime={runtime} -v3' + ) + + assert result.rc == 0 + + +@pytest.mark.test_all_runtimes +def test_missing_ansible(cli, runtime, ee_tag, data_dir, tmp_path): + """ + Test that the check_ansible script will cause build failure if + ansible-core is not installed. + """ + ee_def = data_dir / 'v3' / 'check_ansible' / 'ee-missing-ansible.yml' + + with pytest.raises(subprocess.CalledProcessError) as einfo: + cli( + f'ansible-builder build -c {tmp_path} -f {ee_def} -t {ee_tag} ' + f'--container-runtime={runtime} -v3' + ) + + assert "ERROR - Missing Ansible installation" in einfo.value.stdout + + +@pytest.mark.test_all_runtimes +def test_missing_runner(cli, runtime, ee_tag, data_dir, tmp_path): + """ + Test that the check_ansible script will cause build failure if + ansible-runner is not installed. + """ + ee_def = data_dir / 'v3' / 'check_ansible' / 'ee-missing-runner.yml' + + with pytest.raises(subprocess.CalledProcessError) as einfo: + cli( + f'ansible-builder build -c {tmp_path} -f {ee_def} -t {ee_tag} ' + f'--container-runtime={runtime} -v3' + ) + + assert "ERROR - Missing Ansible Runner installation" in einfo.value.stdout diff --git a/test/pulp_integration/test_v3.py b/test/pulp_integration/test_v3.py deleted file mode 100644 index 916cceb8..00000000 --- a/test/pulp_integration/test_v3.py +++ /dev/null @@ -1,48 +0,0 @@ -import subprocess -import pytest - - -class TestV3: - - def test_ansible_check_is_skipped(self, cli, tmp_path, data_dir, podman_ee_tag): - """ - Test that the check_ansible script is skipped will NOT cause build failure. - """ - ee_def = data_dir / 'v3' / 'check_ansible' / 'ee-skip.yml' - - result = cli( - f'ansible-builder build -c {tmp_path} -f {ee_def} -t {podman_ee_tag} ' - f'--container-runtime=podman -v3' - ) - - assert result.rc == 0 - - def test_missing_ansible(self, cli, tmp_path, data_dir, podman_ee_tag): - """ - Test that the check_ansible script will cause build failure if - ansible-core is not installed. - """ - ee_def = data_dir / 'v3' / 'check_ansible' / 'ee-missing-ansible.yml' - - with pytest.raises(subprocess.CalledProcessError) as einfo: - cli( - f'ansible-builder build -c {tmp_path} -f {ee_def} -t {podman_ee_tag} ' - f'--container-runtime=podman -v3' - ) - - assert "ERROR - Missing Ansible installation" in einfo.value.stdout - - def test_missing_runner(self, cli, tmp_path, data_dir, podman_ee_tag): - """ - Test that the check_ansible script will cause build failure if - ansible-runner is not installed. - """ - ee_def = data_dir / 'v3' / 'check_ansible' / 'ee-missing-runner.yml' - - with pytest.raises(subprocess.CalledProcessError) as einfo: - cli( - f'ansible-builder build -c {tmp_path} -f {ee_def} -t {podman_ee_tag} ' - f'--container-runtime=podman -v3' - ) - - assert "ERROR - Missing Ansible Runner installation" in einfo.value.stdout