From d9503c8f65b6ae1c9aadf4a7a87e0a4840b46f38 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Wed, 10 Apr 2024 09:33:34 -0400 Subject: [PATCH] [6.15.z] Coverage of BZ#2245081 ansible callback on capsule (#14723) --- pytest_fixtures/core/sat_cap_factory.py | 12 +++++++++ tests/foreman/installer/test_installer.py | 31 +++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/pytest_fixtures/core/sat_cap_factory.py b/pytest_fixtures/core/sat_cap_factory.py index 0c23b1ee4d2..3cfebdee160 100644 --- a/pytest_fixtures/core/sat_cap_factory.py +++ b/pytest_fixtures/core/sat_cap_factory.py @@ -250,6 +250,18 @@ def module_lb_capsule(retry_limit=3, delay=300, **broker_args): Broker(hosts=cap_hosts.out).checkin() +@pytest.fixture(scope='module') +def module_capsule_configured_ansible(module_capsule_configured): + """Configure the capsule instance with Ansible feature enabled""" + result = module_capsule_configured.install( + cmd_args=[ + 'enable-foreman-proxy-plugin-ansible', + ] + ) + assert result.status == 0, 'Installer failed to enable ansible plugin.' + return module_capsule_configured + + @pytest.fixture(scope='module') def module_capsule_configured_async_ssh(module_capsule_configured): """Configure the capsule instance with the satellite from settings.server.hostname, diff --git a/tests/foreman/installer/test_installer.py b/tests/foreman/installer/test_installer.py index da64593642e..f57647f23b8 100644 --- a/tests/foreman/installer/test_installer.py +++ b/tests/foreman/installer/test_installer.py @@ -1777,6 +1777,37 @@ def test_installer_cap_pub_directory_accessibility(capsule_configured): assert 'Success!' in command_output.stdout +def test_installer_capsule_with_enabled_ansible(module_capsule_configured_ansible): + """Enables Ansible feature on external Capsule and checks the callback is set correctly + + :id: d60c475e-f4e7-11ee-af8a-98fa9b11ac24 + + :steps: + 1. Have a Satellite with external Capsule integrated + 2. Enable Ansible feature on external Capsule + 3. Check the ansible callback plugin on external Capsule + + :expectedresults: + Ansible callback plugin is overridden to "redhat.satellite.foreman" + + :CaseImportance: High + + :BZ: 2245081 + + :customerscenario: true + """ + ansible_env = '/etc/foreman-proxy/ansible.env' + downstream_callback = 'redhat.satellite.foreman' + callback_whitelist = module_capsule_configured_ansible.execute( + f"awk -F= '/ANSIBLE_CALLBACK_WHITELIST/{{print$2}}' {ansible_env}" + ) + assert callback_whitelist.stdout.strip('" \n') == downstream_callback + callbacks_enabled = module_capsule_configured_ansible.execute( + f"awk -F= '/ANSIBLE_CALLBACKS_ENABLED/{{print$2}}' {ansible_env}" + ) + assert callbacks_enabled.stdout.strip('" \n') == downstream_callback + + @pytest.mark.tier1 @pytest.mark.build_sanity @pytest.mark.first_sanity