Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.14.z] Update Platform tests that have hard coded content host versions #14612

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 module-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 @@ -278,8 +287,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 content_host.yaml
deploy_args['deploy_rhel_version'] = deploy_args.get(
'deploy_rhel_version', settings.content_host.default_rhel_version
)
deploy_args['workflow'] = 'deploy-rhel'
with Broker(**deploy_args, host_class=Satellite) as host:
yield host
1 change: 1 addition & 0 deletions pytest_plugins/fixture_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

TARGET_FIXTURES = [
'rhel_contenthost',
'module_rhel_contenthost',
'content_hosts',
'module_provisioning_rhel_content',
'capsule_provisioning_rhel_content',
Expand Down
66 changes: 42 additions & 24 deletions tests/foreman/destructive/test_capsule_loadbalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import pytest
from wrapanapi import VmState

from robottelo import constants
from robottelo.config import settings
from robottelo.constants import CLIENT_PORT, DataFile
from robottelo.utils.installer import InstallerCommand
Expand All @@ -22,34 +23,50 @@


@pytest.fixture(scope='module')
def content_for_client(module_target_sat, module_org, module_lce, module_cv, module_ak):
def content_for_client(module_target_sat, module_sca_manifest_org, module_lce, module_cv):
"""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,
}
)
return {'client_ak': module_ak, 'client_lce': module_lce}
rhel_ver = settings.content_host.default_rhel_version
baseos = f'rhel{rhel_ver}_bos'
appstream = f'rhel{rhel_ver}_aps'

rh_repos = []
for repo in [baseos, appstream]:
synced_repo_id = module_target_sat.api_factory.enable_sync_redhat_repo(
constants.REPOS[repo], module_sca_manifest_org.id
)
repo = module_target_sat.api.Repository(id=synced_repo_id).read()
rh_repos.append(repo)

module_cv.repository = rh_repos
module_cv.update(['repository'])
module_cv.publish()
module_cv = module_cv.read()
cvv = module_cv.version[0]
cvv.promote(data={'environment_ids': module_lce.id})
module_cv = module_cv.read()
ak = module_target_sat.api.ActivationKey(
content_view=module_cv,
environment=module_lce,
organization=module_sca_manifest_org,
).create()

return {'client_ak': 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,20 +109,20 @@ 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')
haproxy.execute('firewall-cmd --runtime-to-permanent')
haproxy.install_katello_ca(module_target_sat)
haproxy.register_contenthost(module_org.label, haproxy_ak.name)
result = haproxy.execute('yum install haproxy policycoreutils-python -y')
result = haproxy.execute('yum install haproxy policycoreutils-python-utils -y')
assert result.status == 0
haproxy.execute('rm -f /etc/haproxy/haproxy.cfg')
haproxy.session.sftp_write(
Expand Down Expand Up @@ -171,8 +188,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 @@ -193,7 +211,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 @@ -203,15 +221,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 @@ -225,14 +243,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


Expand Down
17 changes: 13 additions & 4 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 @@ -122,15 +128,18 @@ def test_negative_pre_upgrade_tuning_profile_check(request, custom_host):
:expectedresults: Pre-upgrade check fails.
"""
profile = request.node.callspec.id
rhel_major = custom_host.os_version.major
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,
# Register to CDN for RHEL repos, download and enable last y stream's ohsnap repos,
# and enable the satellite module and install it on the host
custom_host.register_to_cdn()
last_y_stream = last_y_stream_version(
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
Loading