Skip to content

Commit

Permalink
Add test for fapolicyd installation
Browse files Browse the repository at this point in the history
  • Loading branch information
jameerpathan111 committed Dec 19, 2023
1 parent 21ddb7f commit 8b49310
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
7 changes: 6 additions & 1 deletion robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ def get_sat_rhel_version():
return Version(rhel_version)


def setup_capsule(satellite, capsule, org, registration_args=None, installation_args=None):
def setup_capsule(
satellite, capsule, org, registration_args=None, installation_args=None, enable_fapolicyd=False
):
"""Given satellite and capsule instances, run the commands needed to set up the capsule
Note: This does not perform content setup actions on the Satellite
Expand Down Expand Up @@ -152,6 +154,9 @@ def setup_capsule(satellite, capsule, org, registration_args=None, installation_
)
capsule.install_katello_ca(satellite)
capsule.register_contenthost(**registration_args)
if enable_fapolicyd:
capsule.execute('dnf -y install fapolicyd && systemctl enable --now fapolicyd').status == 0
capsule.execute('rpm -q foreman-proxy-fapolicyd').status == 0
return capsule.install(cmd_args)


Expand Down
35 changes: 28 additions & 7 deletions tests/foreman/installer/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1347,14 +1347,20 @@ def common_sat_install_assertions(satellite):
assert 'FAIL' not in result.stdout


def install_satellite(satellite, installer_args):
def install_satellite(satellite, installer_args, enable_fapolicyd=False):
# Register for RHEL8 repos, get Ohsnap repofile, and enable and download satellite
satellite.register_to_cdn()
satellite.download_repofile(
product='satellite',
release=settings.server.version.release,
snap=settings.server.version.snap,
)
if enable_fapolicyd:
satellite.execute(
'dnf -y install fapolicyd && systemctl enable --now fapolicyd'
).status == 0
satellite.execute('rpm -q foreman-fapolicyd').status == 0
satellite.execute('rpm -q foreman-proxy-fapolicyd').status == 0
satellite.execute('dnf -y module enable satellite:el8 && dnf -y install satellite')
# Configure Satellite firewall to open communication
satellite.execute(
Expand All @@ -1380,24 +1386,33 @@ def sat_default_install(module_sat_ready_rhels):


@pytest.fixture(scope='module')
def sat_non_default_install(module_sat_ready_rhels):
def sat_non_default_install(request, module_sat_ready_rhels):
"""Install Satellite with various options"""
enable_fapolicyd = False
if hasattr(request, 'param'):
enable_fapolicyd = request.param
installer_args = [
'scenario satellite',
f'foreman-initial-admin-password {settings.server.admin_password}',
'foreman-rails-cache-store type:file',
'foreman-proxy-content-pulpcore-hide-guarded-distributions false',
]
install_satellite(module_sat_ready_rhels[1], installer_args)
install_satellite(module_sat_ready_rhels[1], installer_args, enable_fapolicyd=enable_fapolicyd)
yield module_sat_ready_rhels[1]
common_sat_install_assertions(module_sat_ready_rhels[1])


@pytest.mark.e2e
@pytest.mark.tier1
@pytest.mark.pit_client
def test_capsule_installation(sat_default_install, cap_ready_rhel, default_org):
"""Run a basic Capsule installation
@pytest.mark.parametrize(
"enable_fapolicyd",
[True, False],
indirect=True,
ids=['fapolicyd_enabled', 'fapolicyd_disabled'],
)
def test_capsule_installation(sat_default_install, cap_ready_rhel, default_org, enable_fapolicyd):
"""Run a basic Capsule installation w/ and w/o fapolicyd
:id: 64fa85b6-96e6-4fea-bea4-a30539d59e65
Expand Down Expand Up @@ -1428,7 +1443,7 @@ def test_capsule_installation(sat_default_install, cap_ready_rhel, default_org):
org = sat_default_install.api.Organization().search(query={'search': f'name="{DEFAULT_ORG}"'})[
0
]
setup_capsule(sat_default_install, cap_ready_rhel, org)
setup_capsule(sat_default_install, cap_ready_rhel, org, enable_fapolicyd=enable_fapolicyd)
assert sat_default_install.api.Capsule().search(
query={'search': f'name={cap_ready_rhel.hostname}'}
)[0]
Expand Down Expand Up @@ -1461,8 +1476,14 @@ def test_capsule_installation(sat_default_install, cap_ready_rhel, default_org):

@pytest.mark.e2e
@pytest.mark.tier1
@pytest.mark.parametrize(
"sat_non_default_install",
[True, False],
indirect=True,
ids=['fapolicyd_enabled', 'fapolicyd_disabled'],
)
def test_foreman_rails_cache_store(sat_non_default_install):
"""Test foreman-rails-cache-store option
"""Test foreman-rails-cache-store option. Also tests installation w/ and w/o fapolicyd.
:id: 379a2fe8-1085-4a7f-8ac3-24c421412f12
Expand Down

0 comments on commit 8b49310

Please sign in to comment.