Skip to content

Fix errata contenthost - #20825

Merged
vsedmik merged 5 commits into
SatelliteQE:masterfrom
vsedmik:fix-errata-contenthost
Feb 23, 2026
Merged

Fix errata contenthost#20825
vsedmik merged 5 commits into
SatelliteQE:masterfrom
vsedmik:fix-errata-contenthost

Conversation

@vsedmik

@vsedmik vsedmik commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Problem Statement

The legacy "Content host" page has been removed as part of SAT-37927 but some errata UI tests were left behind, trying to reach removed contenthost property, views and entities.

Solution

Use "All hosts page" instead where possible, remove what is "Content host" page related.

Related Issues

https://issues.redhat.com/browse/SAT-42273

PRT test Cases example

trigger: test-robottelo
pytest: tests/foreman/ui/test_errata.py -k 'content_host_errata_search_commands or apply_for_all_hosts or show_count_on_host_pages'

Summary by Sourcery

Update errata UI tests to use the new All Hosts / Host UI instead of the removed legacy Content Host page and adjust expectations accordingly.

Bug Fixes:

  • Relax applicability task count assertion to avoid relying on an extra task created by legacy content host flows.
  • Align errata search and display assertions with the current Host UI fields and values, replacing outdated expectations tied to the legacy Content Host page.

Enhancements:

  • Refactor errata application and verification flows in tests to use the new host UI APIs for searching hosts, applying errata, and checking packages.
  • Remove obsolete tests and assertions that depended on the legacy Content Host previous-environment errata view.

@vsedmik vsedmik self-assigned this Feb 19, 2026
@vsedmik
vsedmik requested a review from a team as a code owner February 19, 2026 13:43
@vsedmik vsedmik added CherryPick PR needs CherryPick to previous branches 6.19.z labels Feb 19, 2026
@sourcery-ai

sourcery-ai Bot commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

This PR updates UI errata tests to stop using the removed legacy Content Host UI in favor of the new Hosts/All Hosts and Host details pages, adjusts expectations to match the new UI’s data model, and removes an obsolete test that depended on the legacy page.

File-Level Changes

Change Details Files
Switch errata application and package inspection flows from legacy content host UI helpers to new host UI helpers and task polling.
  • Replace session.contenthost.install_errata usage with session.host_new.apply_erratas plus explicit task polling via wait_for_tasks.
  • Update package verification to use session.host_new.get_packages and assert on Installed version rather than Installed Package.
  • Pre-navigate to All Hosts via session.host_new.search before applying errata to ensure a clean UI state for each host.
  • Relax applicability task count assertion from an exact num_hosts+1 to a non-zero length to account for new behavior.
tests/foreman/ui/test_errata.py
Remove tests and assertions that rely on the legacy Content Host page and update remaining tests’ docstrings and steps to only refer to the new Hosts UI.
  • Delete test_positive_content_host_previous_env which depended on the legacy Content Hosts Errata tab and environment dropdown.
  • Trim test_positive_show_count_on_host_pages to only validate errata counts via the new Host Errata page, removing legacy contenthost table checks.
  • Update test docstrings and step descriptions to remove references to legacy Content Host navigation and describe only Hosts -> All Hosts flows.
tests/foreman/ui/test_errata.py
Migrate errata- and RPM-related search tests from session.contenthost.* helpers to session.host/session.host_new APIs and align assertions with the new errata table schema.
  • Change host-level errata and RPM searches from session.contenthost.search to session.host.search with equivalent search queries.
  • Replace session.contenthost.search_errata with session.host_new.get_errata_table using a search filter on errata_id.
  • Adjust errata table assertions to check Errata, Type, and Synopsis fields using the new labels and values (e.g. Security/Bugfix instead of former advisory strings).
tests/foreman/ui/test_errata.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@vsedmik

vsedmik commented Feb 19, 2026

Copy link
Copy Markdown
Contributor Author
trigger: test-robottelo
pytest: tests/foreman/ui/test_errata.py -k 'content_host_errata_search_commands or apply_for_all_hosts or show_count_on_host_pages'

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • In test_positive_apply_for_all_hosts, changing the task assertion from len(applicability_tasks) == num_hosts + 1 to > 0 significantly weakens the guarantee; consider asserting against an expected minimum/exact number of tasks derived from num_hosts to keep the test meaningful while still accommodating the new UI behavior.
  • In the updated host errata/package checks (e.g., asserting '5.21-1.noarch' and using settings.repos.yum_6.errata[...]), consider centralizing these expected versions/labels in shared constants/fixtures so that UI or content changes don’t require editing multiple hard-coded strings in tests.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `test_positive_apply_for_all_hosts`, changing the task assertion from `len(applicability_tasks) == num_hosts + 1` to `> 0` significantly weakens the guarantee; consider asserting against an expected minimum/exact number of tasks derived from `num_hosts` to keep the test meaningful while still accommodating the new UI behavior.
- In the updated host errata/package checks (e.g., asserting `'5.21-1.noarch'` and using `settings.repos.yum_6.errata[...]`), consider centralizing these expected versions/labels in shared constants/fixtures so that UI or content changes don’t require editing multiple hard-coded strings in tests.

## Individual Comments

### Comment 1
<location> `tests/foreman/ui/test_errata.py:947` </location>
<code_context>
                 max_tries=30,
             )
-            assert len(applicability_tasks) == num_hosts + 1
+            assert len(applicability_tasks) > 0
             # found updated kangaroo package in each host
             updated_version = '0.2-1.noarch'
</code_context>

<issue_to_address>
**issue (testing):** The new assertion on `applicability_tasks` is weaker and may no longer guarantee that all expected tasks ran

Changing from `len(applicability_tasks) == num_hosts + 1` to `> 0` means the test can pass even if far fewer tasks are created than intended, weakening its ability to catch regressions. If the exact count is no longer stable, consider asserting a meaningful lower bound tied to `num_hosts` (e.g. `>= num_hosts`) or otherwise encoding the new, specific expectation so the test still verifies the intended behavior rather than just the presence of any tasks.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread tests/foreman/ui/test_errata.py

@chris1984 chris1984 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK, pending PRT

@Satellite-QE

Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 14399
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/ui/test_errata.py -k content_host_errata_search_commands or apply_for_all_hosts or show_count_on_host_pages --external-logging
Test Result : ========= 5 passed, 24 deselected, 220 warnings in 3246.00s (0:54:05) ==========

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label Feb 19, 2026
Comment thread tests/foreman/ui/test_errata.py Outdated
# updated walrus package found for each host
assert packages_rows[0]['Installed Package'] == FAKE_2_CUSTOM_PACKAGE
assert len(packages_rows) == 1
assert packages_rows[0]['Installed version'] == '5.21-1.noarch'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of hardcoding this assertion here, can't we use FAKE_2_CUSTOM_PACKAGE_NAME to fetch this version from FAKE_2_CUSTOM_PACKAGE?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do something like

assert packages_rows[0]['Installed version'] == FAKE_2_CUSTOM_PACKAGE.split('-', 1)[1]

which would be less readable, though.

Comment thread tests/foreman/ui/test_errata.py Outdated
session.location.select(loc_name=DEFAULT_LOC)
# Search for hosts needing RHSA security errata
result = session.contenthost.search('errata_status = security_needed')
result = session.host.search('errata_status = security_needed')

@Gauravtalreja1 Gauravtalreja1 Feb 20, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use session.host_new.* here and below, instead of legacy host UI?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

session.host runs via new UI already, so host_new should work too. Let's try it.

@Satellite-QE Satellite-QE removed the PRT-Passed Indicates that latest PRT run is passed for the PR label Feb 23, 2026
@vsedmik

vsedmik commented Feb 23, 2026

Copy link
Copy Markdown
Contributor Author
trigger: test-robottelo
pytest: tests/foreman/ui/test_errata.py -k content_host_errata_search_commands

@Satellite-QE

Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 14410
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/ui/test_errata.py -k content_host_errata_search_commands --external-logging
Test Result : ========== 1 passed, 28 deselected, 17 warnings in 1183.89s (0:19:43) ==========

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label Feb 23, 2026

@vijaysawant vijaysawant left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

@vsedmik vsedmik added the AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing label Feb 23, 2026
@vsedmik
vsedmik merged commit 3653f9b into SatelliteQE:master Feb 23, 2026
13 checks passed
github-actions Bot pushed a commit that referenced this pull request Feb 23, 2026
* 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)
@vsedmik
vsedmik deleted the fix-errata-contenthost branch February 23, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.19.z AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing CherryPick PR needs CherryPick to previous branches PRT-Passed Indicates that latest PRT run is passed for the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants