Skip to content

Commit

Permalink
Update Platform tests that have hard coded content host versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Griffin-Sullivan committed Mar 8, 2024
1 parent 22180e7 commit d05812d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 27 deletions.
15 changes: 13 additions & 2 deletions pytest_fixtures/core/contenthosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ def rhel_contenthost(request):
yield host


@pytest.fixture(scope='module')
def module_rhel_contenthost(request):
"""A function-level fixture that provides a content host object parametrized"""
# Request should be parametrized through pytest_fixtures.fixture_markers
# unpack params dict
with Broker(**host_conf(request), host_class=ContentHost) as host:
yield host


@pytest.fixture(params=[{'rhel_version': '7'}])
def rhel7_contenthost(request):
"""A function-level fixture that provides a rhel7 content host object"""
Expand Down Expand Up @@ -268,8 +277,10 @@ def sat_upgrade_chost():
def custom_host(request):
"""A rhel content host that passes custom host config through request.param"""
deploy_args = request.param
# if 'deploy_rhel_version' is not set, let's default to RHEL 8
deploy_args['deploy_rhel_version'] = deploy_args.get('deploy_rhel_version', '8')
# if 'deploy_rhel_version' is not set, let's default to what's in server.yaml
deploy_args['deploy_rhel_version'] = deploy_args.get(
'deploy_rhel_version', settings.server.version.rhel_version
)
deploy_args['workflow'] = 'deploy-rhel'
with Broker(**deploy_args, host_class=Satellite) as host:
yield host
58 changes: 36 additions & 22 deletions tests/foreman/destructive/test_capsule_loadbalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,47 @@


@pytest.fixture(scope='module')
def content_for_client(module_target_sat, module_org, module_lce, module_cv, module_ak):
def content_for_client(request, module_target_sat, module_org, module_lce, module_cv, module_ak):
"""Setup content to be used by haproxy and client
:return: Activation key, client lifecycle environment(used by setup_capsules())
"""
module_target_sat.cli_factory.setup_org_for_a_custom_repo(
{
'url': settings.repos.RHEL7_OS,
'organization-id': module_org.id,
'content-view-id': module_cv.id,
'lifecycle-environment-id': module_lce.id,
'activationkey-id': module_ak.id,
}
)
rhel_ver = settings.content_host.default_rhel_version
if rhel_ver > 7:
for repo in eval(f'settings.repos.RHEL{rhel_ver}_OS'):
module_target_sat.cli_factory.setup_org_for_a_custom_repo(
{
'url': repo,
'organization-id': module_org.id,
'content-view-id': module_cv.id,
'lifecycle-environment-id': module_lce.id,
'activationkey-id': module_ak.id,
}
)
else:
module_target_sat.cli_factory.setup_org_for_a_custom_repo(
{
'url': eval(f'settings.repos.RHEL{rhel_ver}_OS'),
'organization-id': module_org.id,
'content-view-id': module_cv.id,
'lifecycle-environment-id': module_lce.id,
'activationkey-id': module_ak.id,
}
)
return {'client_ak': module_ak, 'client_lce': module_lce}


@pytest.fixture(scope='module')
def setup_capsules(
module_org,
rhel7_contenthost_module,
module_rhel_contenthost,
module_lb_capsule,
module_target_sat,
content_for_client,
):
"""Install capsules with loadbalancer options"""
extra_cert_var = {'foreman-proxy-cname': rhel7_contenthost_module.hostname}
extra_installer_var = {'certs-cname': rhel7_contenthost_module.hostname}
extra_cert_var = {'foreman-proxy-cname': module_rhel_contenthost.hostname}
extra_installer_var = {'certs-cname': module_rhel_contenthost.hostname}

for capsule in module_lb_capsule:
capsule.register_to_cdn()
Expand Down Expand Up @@ -92,13 +105,13 @@ def setup_capsules(
@pytest.fixture(scope='module')
def setup_haproxy(
module_org,
rhel7_contenthost_module,
module_rhel_contenthost,
content_for_client,
module_target_sat,
setup_capsules,
):
"""Install and configure haproxy and setup logging"""
haproxy = rhel7_contenthost_module
haproxy = module_rhel_contenthost
# Using same AK for haproxy just for packages
haproxy_ak = content_for_client['client_ak']
haproxy.execute('firewall-cmd --add-service RH-Satellite-6-capsule')
Expand Down Expand Up @@ -171,8 +184,9 @@ def loadbalancer_setup(

@pytest.mark.e2e
@pytest.mark.tier1
@pytest.mark.rhel_ver_list([settings.content_host.default_rhel_version])
def test_loadbalancer_install_package(
loadbalancer_setup, setup_capsules, rhel7_contenthost, module_org, module_location, request
loadbalancer_setup, setup_capsules, rhel_contenthost, module_org, module_location, request
):
r"""Install packages on a content host regardless of the registered capsule being available
Expand All @@ -192,7 +206,7 @@ def test_loadbalancer_install_package(
"""
# Register content host
result = rhel7_contenthost.register(
result = rhel_contenthost.register(
org=module_org,
loc=module_location,
activation_keys=loadbalancer_setup['content_for_client']['client_ak'].name,
Expand All @@ -202,15 +216,15 @@ def test_loadbalancer_install_package(
assert result.status == 0, f'Failed to register host: {result.stderr}'

# Try package installation
result = rhel7_contenthost.execute('yum install -y tree')
result = rhel_contenthost.execute('yum install -y tree')
assert result.status == 0

hosts = loadbalancer_setup['module_target_sat'].cli.Host.list(
{'organization-id': loadbalancer_setup['module_org'].id}
)
assert rhel7_contenthost.hostname in [host['name'] for host in hosts]
assert rhel_contenthost.hostname in [host['name'] for host in hosts]

result = rhel7_contenthost.execute('rpm -qa | grep katello-ca-consumer')
result = rhel_contenthost.execute('rpm -qa | grep katello-ca-consumer')

# Find which capsule the host is registered to since it's RoundRobin
# The following also asserts the above result
Expand All @@ -221,14 +235,14 @@ def test_loadbalancer_install_package(
)

# Remove the packages from the client
result = rhel7_contenthost.execute('yum remove -y tree')
result = rhel_contenthost.execute('yum remove -y tree')
assert result.status == 0

# Power off the capsule that the client is registered to
registered_to_capsule.power_control(state=VmState.STOPPED, ensure=True)

# Try package installation again
result = rhel7_contenthost.execute('yum install -y tree')
result = rhel_contenthost.execute('yum install -y tree')
assert result.status == 0

@request.addfinalizer
Expand Down
15 changes: 12 additions & 3 deletions tests/foreman/maintain/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,14 @@ def test_positive_repositories_validate(sat_maintain):
@pytest.mark.parametrize(
'custom_host',
[
{'deploy_rhel_version': '8', 'deploy_flavor': 'satqe-ssd.disk.xxxl'},
{'deploy_rhel_version': '8', 'deploy_flavor': 'satqe-ssd.standard.std'},
{
'deploy_rhel_version': settings.server.version.rhel_version,
'deploy_flavor': 'satqe-ssd.disk.xxxl',
},
{
'deploy_rhel_version': settings.server.version.rhel_version,
'deploy_flavor': 'satqe-ssd.standard.std',
},
],
ids=['default', 'medium'],
indirect=True,
Expand All @@ -118,6 +124,7 @@ def test_negative_pre_upgrade_tuning_profile_check(request, custom_host):
:expectedresults: Pre-upgrade check fails.
"""
profile = request.node.callspec.id
rhel_major = settings.server.version.rhel_version[0]
sat_version = ".".join(settings.server.version.release.split('.')[0:2])
# Register to CDN for RHEL8 repos, download and enable last y stream's ohsnap repos,
# and enable the satellite module and install it on the host
Expand All @@ -126,7 +133,9 @@ def test_negative_pre_upgrade_tuning_profile_check(request, custom_host):
SATELLITE_VERSION if sat_version == 'stream' else sat_version
)
custom_host.download_repofile(product='satellite', release=last_y_stream)
custom_host.execute('dnf -y module enable satellite:el8 && dnf -y install satellite')
custom_host.execute(
f'dnf -y module enable satellite:el{rhel_major} && dnf -y install satellite'
)
# Install with development tuning profile to get around installer checks
custom_host.execute(
'satellite-installer --scenario satellite --tuning development',
Expand Down

0 comments on commit d05812d

Please sign in to comment.