Skip to content

Commit

Permalink
lce passed to register_contenthost
Browse files Browse the repository at this point in the history
  • Loading branch information
damoore044 committed Oct 5, 2023
1 parent bd2ae89 commit b6edaaa
Showing 1 changed file with 11 additions and 29 deletions.
40 changes: 11 additions & 29 deletions tests/foreman/api/test_errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,28 +75,13 @@ def custom_repo(module_org, module_lce, module_cv, activation_key):
)


def _install_package(
module_org, clients, host_ids, package_name, via_ssh=True, rpm_package_name=None
):
"""Install package via SSH CLI if via_ssh is True, otherwise
install via http api: PUT /api/v2/hosts/bulk/install_content
"""
if via_ssh:
for client in clients:
result = client.run(f'yum install -y {package_name}')
assert result.status == 0
result = client.run(f'rpm -q {package_name}')
assert result.status == 0
else:
entities.Host().install_content(
data={
'organization_id': module_org.id,
'included': {'ids': host_ids},
'content_type': 'package',
'content': [package_name],
}
)
_validate_package_installed(clients, rpm_package_name)
def _install_package(clients, package_name):
"""Install package via SSH"""
for client in clients:
result = client.run(f'yum install -y {package_name}')
assert result.status == 0
result = client.run(f'rpm -q {package_name}')
assert result.status == 0


def _validate_package_installed(hosts, package_name, expected_installed=True, timeout=240):
Expand Down Expand Up @@ -250,20 +235,17 @@ def test_positive_install_multiple_in_host(
}
)
rhel_contenthost.install_katello_ca(module_target_sat)
rhel_contenthost.register_contenthost(function_org.name, activation_key.name)
rhel_contenthost.register_contenthost(function_org.name, activation_key.name, function_lce.name)
rhel_contenthost.run(r'subscription-manager repos --enable \*')
rhel_contenthost.install_katello_ca(module_target_sat)

assert rhel_contenthost.subscribed
host = rhel_contenthost.nailgun_host
for package in constants.FAKE_9_YUM_OUTDATED_PACKAGES:
_install_package(
function_org, clients=[rhel_contenthost], host_ids=[host.id], package_name=package
)
_install_package(clients=[rhel_contenthost], package_name=package)
applicable_errata_count = rhel_contenthost.applicable_errata_count
assert applicable_errata_count > 1
rhel_contenthost.add_rex_key(satellite=module_target_sat)
for errata in settings.repos.yum_9.errata[1:4]:
for errata in settings.repos.yum_9.errata:
task_id = module_target_sat.api.JobInvocation().run(
data={
'feature': 'katello_errata_install',
Expand Down

0 comments on commit b6edaaa

Please sign in to comment.