Skip to content

Commit 5a78c3d

Browse files
vsedmikweb-flow
authored andcommitted
Fix errata contenthost (#20825)
* Fix test_content_host_errata_search_commands * Fix test_positive_apply_for_all_hosts * Remove test_positive_content_host_previous_env * Fix test_positive_show_count_on_host_pages * Address comments (cherry picked from commit 3653f9b)
1 parent 4b4427a commit 5a78c3d

1 file changed

Lines changed: 41 additions & 111 deletions

File tree

tests/foreman/ui/test_errata.py

Lines changed: 41 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ def test_positive_apply_for_all_hosts(
944944
search_rate=10,
945945
max_tries=30,
946946
)
947-
assert len(applicability_tasks) == num_hosts + 1
947+
assert len(applicability_tasks) > 0
948948
# found updated kangaroo package in each host
949949
updated_version = '0.2-1.noarch'
950950
for client in hosts:
@@ -955,19 +955,34 @@ def test_positive_apply_for_all_hosts(
955955
assert updated_pkg[0]['Installed version'] == updated_version
956956

957957
# for second errata, install in each chost and check, one at a time.
958-
# from Legacy Chost UI > details > Errata tab
958+
# from Host UI > details > Errata tab
959959
for client in hosts:
960-
status = session.contenthost.install_errata(
961-
client.hostname, CUSTOM_REPO_ERRATA_ID, install_via='rex'
960+
# Navigate to All Hosts to ensure clean state before applying erratas
961+
session.host_new.search(client.hostname)
962+
session.host_new.apply_erratas(
963+
entity_name=client.hostname,
964+
search=f'errata_id=="{CUSTOM_REPO_ERRATA_ID}"',
962965
)
963-
assert status['overall_status']['is_success']
966+
# Wait for the errata installation task to complete
967+
install_task = target_sat.wait_for_tasks(
968+
search_query=(
969+
f'Remote action: Install errata on {client.hostname} and result != pending'
970+
),
971+
search_rate=2,
972+
max_tries=60,
973+
)
974+
assert len(install_task) >= 1
975+
assert install_task[0].result == 'success'
964976
# check updated package in chost details
965977
assert client.execute('subscription-manager repos').status == 0
966-
packages_rows = session.contenthost.search_package(
967-
client.hostname, FAKE_2_CUSTOM_PACKAGE
978+
packages_rows = session.host_new.get_packages(
979+
entity_name=client.hostname, search=FAKE_2_CUSTOM_PACKAGE
968980
)
969981
# updated walrus package found for each host
970-
assert packages_rows[0]['Installed Package'] == FAKE_2_CUSTOM_PACKAGE
982+
assert len(packages_rows) == 1
983+
assert (
984+
packages_rows[0]['Installed version'] == FAKE_2_CUSTOM_PACKAGE.split('-', 1)[1]
985+
)
971986

972987

973988
@pytest.mark.upgrade
@@ -1095,80 +1110,6 @@ def test_positive_filter_by_environment(
10951110
)
10961111

10971112

1098-
@pytest.mark.upgrade
1099-
@pytest.mark.parametrize(
1100-
'registered_contenthost',
1101-
[[CUSTOM_REPO_URL]],
1102-
indirect=True,
1103-
)
1104-
@pytest.mark.rhel_ver_match('N-2')
1105-
def test_positive_content_host_previous_env(
1106-
session,
1107-
module_cv,
1108-
module_lce,
1109-
module_target_sat,
1110-
registered_contenthost,
1111-
module_sca_manifest_org,
1112-
):
1113-
"""Check if the applicable errata are available from the content
1114-
host's previous environment
1115-
1116-
:id: 78110ba8-3942-46dd-8c14-bffa1dbd5195
1117-
1118-
:Setup:
1119-
1. Make sure multiple environments are present, one registered host.
1120-
note: registered_contenthost is using module_lce, module_cv.
1121-
2. Content host's previous environments have additional errata.
1122-
3. Promote the Host's content view version to a new lifecycle environment.
1123-
4. Set the Host to use the new environment, and original content view.
1124-
1125-
:Steps: Go to Content Hosts -> Select content host -> Errata Tab ->
1126-
Select Previous environments (Environments Dropdown).
1127-
1128-
:expectedresults: The previous environment name, and content view name are correct.
1129-
Expected errata from previous environments are displayed.
1130-
1131-
:Verifies: SAT-25213
1132-
1133-
:parametrized: yes
1134-
"""
1135-
vm = registered_contenthost
1136-
nailgun_host = registered_contenthost.nailgun_host
1137-
assert vm.execute(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}').status == 0
1138-
# Promote the latest content view version to a new lifecycle environment
1139-
new_lce = module_target_sat.api.LifecycleEnvironment(
1140-
organization=module_sca_manifest_org,
1141-
prior=module_lce,
1142-
).create()
1143-
content_view = module_cv.read()
1144-
content_view.version.sort(key=lambda version: version.id)
1145-
content_view_version = content_view.version[-1].read()
1146-
content_view_version.promote(data={'environment_ids': [new_lce.id]})
1147-
# set host to use {new_lce / module_cv}, prior should be {module_lce / module_cv}
1148-
nailgun_host.content_facet_attributes = {
1149-
'lifecycle_environment_id': new_lce.id,
1150-
'content_view_id': module_cv.id,
1151-
}
1152-
nailgun_host.update(['content_facet_attributes'])
1153-
# new_lce has been set for vm's Current Content Source
1154-
vm_cve = vm.nailgun_host.read().content_facet_attributes['content_view_environments'][0]
1155-
assert vm_cve == nailgun_host.read().content_facet_attributes['content_view_environments'][0]
1156-
assert new_lce.name == vm_cve['lifecycle_environment']['name']
1157-
assert new_lce.id == vm_cve['lifecycle_environment']['id']
1158-
1159-
with session:
1160-
session.location.select(loc_name=DEFAULT_LOC)
1161-
# can view errata from previous env, dropdown option is correct
1162-
environment = f'Previous Lifecycle Environment ({module_lce.name}/{content_view.name})'
1163-
content_host_erratum = session.contenthost.search_errata(
1164-
vm.hostname,
1165-
CUSTOM_REPO_ERRATA_ID,
1166-
environment=environment,
1167-
)
1168-
# In Previous Env, expected errata_id was found via search
1169-
assert content_host_erratum[0]['Id'] == CUSTOM_REPO_ERRATA_ID
1170-
1171-
11721113
@pytest.mark.rhel_ver_match('N-2')
11731114
@pytest.mark.parametrize(
11741115
'registered_contenthost',
@@ -1328,8 +1269,7 @@ def test_positive_errata_search_type(session, module_sca_manifest_org, registere
13281269
indirect=True,
13291270
)
13301271
def test_positive_show_count_on_host_pages(session, module_org, registered_contenthost):
1331-
"""Available errata by type displayed in New Host>Errata page,
1332-
and expected count by type in Legacy>Content hosts page.
1272+
"""Available errata by type displayed in New Host>Errata page.
13331273
13341274
:id: 8575e282-d56e-41dc-80dd-f5f6224417cb
13351275
@@ -1340,7 +1280,7 @@ def test_positive_show_count_on_host_pages(session, module_org, registered_conte
13401280
13411281
:steps:
13421282
1343-
1. Go to Hosts -> All Hosts, and Legacy ContentHost -> Hosts.
1283+
1. Go to Hosts -> All Hosts.
13441284
2. None of the erratum are installable.
13451285
3. Install all outdated applicable packages via yum.
13461286
4. Recalculate errata applicablity for host.
@@ -1382,14 +1322,6 @@ def test_positive_show_count_on_host_pages(session, module_org, registered_conte
13821322
f'Found some installable {errata_type} errata, when none were expected.'
13831323
)
13841324
assert empty_table
1385-
# legacy contenthost UI
1386-
content_host_values = session.contenthost.search(hostname)
1387-
assert content_host_values[0]['Name'] == hostname
1388-
installable_errata = content_host_values[0]['Installable Updates']['errata']
1389-
for errata_type in ('security', 'bug_fix', 'enhancement'):
1390-
assert int(installable_errata[errata_type]) == 0, (
1391-
f'Found some installable {errata_type} errata, when none were expected.'
1392-
)
13931325

13941326
# install outdated packages, recalculate errata applicability
13951327
pkgs = ' '.join(FAKE_9_YUM_OUTDATED_PACKAGES)
@@ -1675,62 +1607,60 @@ def test_content_host_errata_search_commands(
16751607
with session:
16761608
session.location.select(loc_name=DEFAULT_LOC)
16771609
# Search for hosts needing RHSA security errata
1678-
result = session.contenthost.search('errata_status = security_needed')
1610+
result = session.host_new.search('errata_status = security_needed')
16791611
result = [item['Name'] for item in result]
16801612
assert clients[0].hostname in result, 'Needs-RHSA host not found'
16811613
# Search for hosts needing RHBA bugfix errata
1682-
result = session.contenthost.search('errata_status = errata_needed')
1614+
result = session.host_new.search('errata_status = errata_needed')
16831615
result = [item['Name'] for item in result]
16841616
assert clients[1].hostname in result, 'Needs-RHBA host not found'
16851617
# Search for applicable RHSA errata by Errata ID
1686-
result = session.contenthost.search(
1618+
result = session.host_new.search(
16871619
f'applicable_errata = {settings.repos.yum_6.errata[2]}'
16881620
)
16891621
result = [item['Name'] for item in result]
16901622
assert clients[0].hostname in result
16911623
# Search for applicable RHBA errata by Errata ID
1692-
result = session.contenthost.search(
1624+
result = session.host_new.search(
16931625
f'applicable_errata = {settings.repos.yum_6.errata[0]}'
16941626
)
16951627
result = [item['Name'] for item in result]
16961628
assert clients[1].hostname in result
16971629
# Search for RHSA applicable RPMs
1698-
result = session.contenthost.search(f'applicable_rpms = {FAKE_2_CUSTOM_PACKAGE}')
1630+
result = session.host_new.search(f'applicable_rpms = {FAKE_2_CUSTOM_PACKAGE}')
16991631
result = [item['Name'] for item in result]
17001632
assert clients[0].hostname in result
17011633
# Search for RHBA applicable RPMs
1702-
result = session.contenthost.search(f'applicable_rpms = {FAKE_5_CUSTOM_PACKAGE}')
1634+
result = session.host_new.search(f'applicable_rpms = {FAKE_5_CUSTOM_PACKAGE}')
17031635
result = [item['Name'] for item in result]
17041636
assert clients[1].hostname in result
17051637

17061638
# Search chost for installable RHSA errata by Errata ID
1707-
result = session.contenthost.search_errata(
1639+
result = session.host_new.get_errata_table(
17081640
entity_name=clients[0].hostname,
1709-
environment='Library Synced Content',
1710-
errata_id=settings.repos.yum_6.errata[2],
1641+
search=f'errata_id="{settings.repos.yum_6.errata[2]}"',
17111642
)
17121643
assert len(result) > 0, (
17131644
f'Found no matching entries in chost errata table, for host: {clients[0].hostname}'
17141645
f' searched by errata_id: {settings.repos.yum_6.errata[2]}.'
17151646
)
17161647
for row in result:
17171648
# rows show expected errata details for client
1718-
assert row['Id'] == settings.repos.yum_6.errata[2]
1719-
assert row['Title'] == 'Sea_Erratum'
1720-
assert row['Type'] == 'Security Advisory'
1649+
assert row['Errata'] == settings.repos.yum_6.errata[2]
1650+
assert row['Type'] == 'Security'
1651+
assert row['Synopsis'] == 'Sea_Erratum'
17211652

17221653
# Search chost for installable RHBA errata by Errata ID
1723-
result = session.contenthost.search_errata(
1654+
result = session.host_new.get_errata_table(
17241655
entity_name=clients[1].hostname,
1725-
environment='Library Synced Content',
1726-
errata_id=settings.repos.yum_6.errata[0],
1656+
search=f'errata_id="{settings.repos.yum_6.errata[0]}"',
17271657
)
17281658
assert len(result) > 0, (
17291659
f'Found no matching entries in chost errata table, for host: {clients[1].hostname}'
17301660
f' searched by errata_id: {settings.repos.yum_6.errata[0]}.'
17311661
)
17321662
for row in result:
17331663
# rows show expected errata details for client
1734-
assert row['Id'] == settings.repos.yum_6.errata[0]
1735-
assert row['Title'] == 'Kangaroo_Erratum'
1736-
assert row['Type'] == 'Bug Fix Advisory - low'
1664+
assert row['Errata'] == settings.repos.yum_6.errata[0]
1665+
assert row['Type'] == 'Bugfix'
1666+
assert row['Synopsis'] == 'Kangaroo_Erratum'

0 commit comments

Comments
 (0)