Skip to content

Commit

Permalink
Fixes for integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Shrews committed Nov 28, 2022
1 parent 567c00e commit 909003b
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions test/integration/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_blank_execution_environment(cli, runtime, ee_tag, tmp_path, data_dir):
bc = tmp_path
ee_def = data_dir / 'blank' / 'execution-environment.yml'
cli(
f'ansible-builder build -c {bc} -f {ee_def} -t {ee_tag} --container-runtime {runtime}'
f'ansible-builder build --no-cache -c {bc} -f {ee_def} -t {ee_tag} --container-runtime {runtime}'
)
result = cli(f'{runtime} run --rm {ee_tag} echo "This is a simple test"')
assert 'This is a simple test' in result.stdout, result.stdout
Expand All @@ -42,7 +42,7 @@ def test_multiple_tags(cli, runtime, ee_tag, tmp_path, data_dir):
bc = tmp_path
ee_def = data_dir / 'blank' / 'execution-environment.yml'
cli(
f'ansible-builder build -c {bc} -f {ee_def} -t {ee_tag} -t testmultitags --container-runtime {runtime}'
f'ansible-builder build --no-cache -c {bc} -f {ee_def} -t {ee_tag} -t testmultitags --container-runtime {runtime}'
)
result = cli(f'{runtime} run --rm {ee_tag} echo "test: test_multiple_tags 1"')
assert 'test: test_multiple_tags 1' in result.stdout, result.stdout
Expand All @@ -56,7 +56,7 @@ def test_multiple_tags(cli, runtime, ee_tag, tmp_path, data_dir):
def test_user_system_requirement(cli, runtime, ee_tag, tmp_path, data_dir):
bc = tmp_path
ee_def = data_dir / 'subversion' / 'execution-environment.yml'
command = f'ansible-builder build -c {bc} -f {ee_def} -t {ee_tag} --container-runtime {runtime}'
command = f'ansible-builder build --no-cache -c {bc} -f {ee_def} -t {ee_tag} --container-runtime {runtime}'
cli(command)
result = cli(
f'{runtime} run --rm {ee_tag} svn --help'
Expand All @@ -69,7 +69,7 @@ def test_collection_system_requirement(cli, runtime, ee_tag, tmp_path, data_dir)
bc = tmp_path
ee_def = data_dir / 'ansible.posix.at' / 'execution-environment.yml'
cli(
f'ansible-builder build -c {bc} -f {ee_def} -t {ee_tag} --container-runtime {runtime} -v3'
f'ansible-builder build --no-cache -c {bc} -f {ee_def} -t {ee_tag} --container-runtime {runtime} -v3'
)
result = cli(
f'{runtime} run --rm {ee_tag} at -V'
Expand All @@ -81,7 +81,7 @@ def test_collection_system_requirement(cli, runtime, ee_tag, tmp_path, data_dir)
def test_user_python_requirement(cli, runtime, ee_tag, tmp_path, data_dir):
bc = tmp_path
ee_def = data_dir / 'pip' / 'execution-environment.yml'
command = f'ansible-builder build -c {bc} -f {ee_def} -t {ee_tag} --container-runtime {runtime}'
command = f'ansible-builder build --no-cache -c {bc} -f {ee_def} -t {ee_tag} --container-runtime {runtime}'
cli(command)
result = cli(
f'{runtime} run --rm {ee_tag} pip3 show awxkit'
Expand All @@ -98,7 +98,7 @@ def test_user_python_requirement(cli, runtime, ee_tag, tmp_path, data_dir):
def test_python_git_requirement(cli, runtime, ee_tag, tmp_path, data_dir):
bc = tmp_path
ee_def = data_dir / 'needs_git' / 'execution-environment.yml'
command = f'ansible-builder build -c {bc} -f {ee_def} -t {ee_tag} --container-runtime {runtime}'
command = f'ansible-builder build --no-cache -c {bc} -f {ee_def} -t {ee_tag} --container-runtime {runtime}'
cli(command)
result = cli(f'{runtime} run --rm {ee_tag} pip3 freeze')
assert 'flask' in result.stdout.lower(), result.stdout
Expand All @@ -112,7 +112,7 @@ def test_prepended_steps(cli, runtime, ee_tag, tmp_path, data_dir):
bc = tmp_path
ee_def = data_dir / 'prepend_steps' / 'execution-environment.yml'
cli(
f'ansible-builder build -c {bc} -f {ee_def} -t {ee_tag} --container-runtime {runtime}'
f'ansible-builder build --no-cache -c {bc} -f {ee_def} -t {ee_tag} --container-runtime {runtime}'
)

_file = 'Dockerfile' if runtime == 'docker' else 'Containerfile'
Expand All @@ -128,7 +128,7 @@ def test_build_args_basic(cli, runtime, ee_tag, tmp_path, data_dir):
bc = tmp_path
ee_def = data_dir / 'build_args' / 'execution-environment.yml'
result = cli(
f'ansible-builder build -c {bc} -f {ee_def} -t {ee_tag} --container-runtime {runtime} --build-arg FOO=bar -v3'
f'ansible-builder build --no-cache -c {bc} -f {ee_def} -t {ee_tag} --container-runtime {runtime} --build-arg FOO=bar -v3'
)
assert 'FOO=bar' in result.stdout

Expand All @@ -142,7 +142,7 @@ def test_build_args_from_environment(cli, runtime, ee_tag, tmp_path, data_dir):
ee_def = data_dir / 'build_args' / 'execution-environment.yml'
os.environ['FOO'] = 'secretsecret'
result = cli(
f'ansible-builder build -c {bc} -f {ee_def} -t {ee_tag} --container-runtime {runtime} --build-arg FOO -v3'
f'ansible-builder build --no-cache -c {bc} -f {ee_def} -t {ee_tag} --container-runtime {runtime} --build-arg FOO -v3'
)
assert 'secretsecret' in result.stdout

Expand All @@ -154,18 +154,19 @@ def test_base_image_build_arg(cli, runtime, ee_tag, tmp_path, data_dir):
os.environ['FOO'] = 'secretsecret'

# Build with custom image tag, then use that as input to --build-arg EE_BASE_IMAGE
cli(f'ansible-builder build -c {bc} -f {ee_def} -t {ee_tag}-custom --container-runtime {runtime} -v3')
cli(f'ansible-builder build -c {bc} -f {ee_def} -t {ee_tag}-custom '
cli(f'ansible-builder build --no-cache -c {bc} -f {ee_def} -t {ee_tag}-custom --container-runtime {runtime} -v3')
cli(f'ansible-builder build --no-cache -c {bc} -f {ee_def} -t {ee_tag}-custom '
f'--container-runtime {runtime} --build-arg EE_BASE_IMAGE={ee_tag}-custom -v3')
result = cli(f"{runtime} run {ee_tag}-custom cat /base_image")

result = cli(f"{runtime} run --rm {ee_tag}-custom cat /base_image")
assert f"{ee_tag}-custom" in result.stdout


@pytest.mark.test_all_runtimes
@pytest.mark.xfail(reason='Unreliable on podman')
def test_has_pytz(cli, runtime, data_dir, ee_tag, tmp_path):
ee_def = data_dir / 'pytz' / 'execution-environment.yml'
cli(f'ansible-builder build -c {tmp_path} -f {ee_def} -t {ee_tag} --container-runtime {runtime} -v 3')
cli(f'ansible-builder build --no-cache -c {tmp_path} -f {ee_def} -t {ee_tag} --container-runtime {runtime} -v 3')
result = cli(f'{runtime} run --rm {ee_tag} pip3 show pytz')

assert 'World timezone definitions, modern and historical' in result.stdout
Expand Down Expand Up @@ -197,7 +198,7 @@ def test_collection_verification_off(cli, runtime, data_dir, ee_tag, tmp_path):
Test that, by default, collection verification is off via the env var.
"""
ee_def = data_dir / 'ansible.posix.at' / 'execution-environment.yml'
result = cli(f'ansible-builder build -c {tmp_path} -f {ee_def} -t {ee_tag} --container-runtime {runtime} -v 3')
result = cli(f'ansible-builder build --no-cache -c {tmp_path} -f {ee_def} -t {ee_tag} --container-runtime {runtime} -v 3')
assert "RUN ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy" in result.stdout


Expand All @@ -211,7 +212,8 @@ def test_collection_verification_on(cli, runtime, data_dir, ee_tag, tmp_path):
ee_def = data_dir / 'ansible.posix.at' / 'execution-environment.yml'

# ansible-galaxy might error (older Ansible), but that should be ok
result = cli(f'ansible-builder build --galaxy-keyring {keyring} -c {tmp_path} -f {ee_def} -t {ee_tag} --container-runtime {runtime} -v 3', allow_error=True)
result = cli(f'ansible-builder build --no-cache --galaxy-keyring {keyring} -c {tmp_path} -f {ee_def} -t {ee_tag} --container-runtime {runtime} -v 3',
allow_error=True)

keyring_copy = tmp_path / constants.user_content_subfolder / constants.default_keyring_name
assert keyring_copy.exists()
Expand All @@ -224,15 +226,15 @@ def test_collection_verification_on(cli, runtime, data_dir, ee_tag, tmp_path):
@pytest.mark.test_all_runtimes
def test_galaxy_signing_extra_args(cli, runtime, data_dir, ee_tag, tmp_path):
"""
Test that all extr asigning args for gpg are passed into the container file.
Test that all extra signing args for gpg are passed into the container file.
"""
pytest.xfail("failing configuration (but should work)")

keyring = tmp_path / "mykeyring.gpg"
keyring.touch()
ee_def = data_dir / 'ansible.posix.at' / 'execution-environment.yml'

result = cli(f'ansible-builder build -c {tmp_path} -f {ee_def} -t {ee_tag} --container-runtime {runtime} -v 3 '
result = cli(f'ansible-builder build --no-cache -c {tmp_path} -f {ee_def} -t {ee_tag} --container-runtime {runtime} -v 3 '
f'--galaxy-keyring {keyring} --galaxy-ignore-signature-status-code 500 '
f'--galaxy-required-valid-signature-count 3', allow_error=True)

Expand Down

0 comments on commit 909003b

Please sign in to comment.