Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move target script tests from pulp to integration test suite (#696) #697

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions test/data/v3/check_ansible/ee-missing-ansible.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 2 additions & 4 deletions test/data/v3/check_ansible/ee-missing-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 2 additions & 6 deletions test/data/v3/check_ansible/ee-skip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
50 changes: 50 additions & 0 deletions test/integration/test_build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import subprocess

# Need to call this directly for multiple tag testing
from test.conftest import delete_image
Expand Down Expand Up @@ -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
48 changes: 0 additions & 48 deletions test/pulp_integration/test_v3.py

This file was deleted.

Loading