Skip to content

Commit

Permalink
Move target script tests from pulp to integration test suite (#696)
Browse files Browse the repository at this point in the history
Move tests of the target scripts into the active CI integration tests.
  • Loading branch information
Shrews authored Jul 25, 2024
1 parent 469f92c commit 9b9d88f
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 62 deletions.
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.

0 comments on commit 9b9d88f

Please sign in to comment.