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

[SAT-30611] Test Applied Errata report by hostname #17702

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

damoore044
Copy link
Contributor

@damoore044 damoore044 commented Feb 27, 2025

Problem Statement

test_positive_applied_errata_for_specific_hosts covers SAT-30611 for report filtered by hostname,
but also reported was a perceived discrepancy with the date fields, I found we don't yet test the dates for the Hosts - Applied Errata ReportTemplate.

  • New coverage (nice-to-have) test_positive_applied_errata_by_install_date
    now tests the 'Since' and 'Up to' date fields.
  • ^ PRT is failing for this _install_date case in 6.17.z and Stream, will remove that and open in a separate PR so we can merge this bug's coverage. [Robottelo Applied Errata Report by Install Dates: 'Since' and 'Up to' #17713 ]

PRT

trigger: test-robottelo
pytest: tests/foreman/api/test_reporttemplates.py -k '_specific_hosts'

@damoore044 damoore044 added CherryPick PR needs CherryPick to previous branches Stream Introduced in or relating directly to Satellite Stream/Master 6.16.z Introduced in or relating directly to Satellite 6.16 6.17.z labels Feb 27, 2025
@damoore044 damoore044 self-assigned this Feb 27, 2025
@damoore044 damoore044 force-pushed the app_errata_report branch 3 times, most recently from f164549 to 06aa920 Compare February 27, 2025 00:56
@damoore044
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/api/test_reporttemplates.py::test_positive_applied_errata_for_specific_hosts tests/foreman/api/test_reporttemplates.py::test_positive_applied_errata_by_install_date

@damoore044 damoore044 force-pushed the app_errata_report branch 3 times, most recently from e99cd9b to 802109c Compare February 27, 2025 14:18
Copy link
Contributor

@jeremylenz jeremylenz left a comment

Choose a reason for hiding this comment

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

One wording nit, but tests LGTM! nice job :)

@damoore044
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/api/test_reporttemplates.py -k '_specific_hosts or _install_date'

@damoore044 damoore044 added the QETestCoverage Issues and PRs relating to a Satellite bug label Feb 27, 2025
@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 10342
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/api/test_reporttemplates.py -k _specific_hosts or _install_date --external-logging
Test Result : ==== 3 failed, 3 passed, 42 deselected, 838 warnings in 2889.51s (0:48:09) =====

@Satellite-QE Satellite-QE added the PRT-Failed Indicates that latest PRT run is failed for the PR label Feb 27, 2025
@damoore044
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/api/test_reporttemplates.py::test_positive_applied_errata_by_install_date

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 10346
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/api/test_reporttemplates.py::test_positive_applied_errata_by_install_date --external-logging
Test Result : ================= 3 failed, 278 warnings in 1759.86s (0:29:19) =================

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 10349
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/api/test_reporttemplates.py::test_positive_applied_errata_by_install_date --external-logging
Test Result : ================= 3 failed, 290 warnings in 1682.31s (0:28:02) =================

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 10350
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/api/test_reporttemplates.py::test_positive_applied_errata_by_install_date --external-logging
Test Result : ================= 3 failed, 290 warnings in 1752.04s (0:29:12) =================

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 10355
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/api/test_reporttemplates.py -k _specific_hosts --external-logging
Test Result : ========= 3 passed, 42 deselected, 675 warnings in 2789.95s (0:46:29) ==========

@Satellite-QE Satellite-QE added PRT-Passed Indicates that latest PRT run is passed for the PR and removed PRT-Failed Indicates that latest PRT run is failed for the PR labels Feb 28, 2025
Comment on lines 643 to 653
'feature': 'katello_errata_install',
'inputs': {'errata': str(RHSA_ERRATA)},
'targeting_type': 'static_query',
'search_query': f'name = {rhsa_host.hostname}',
'organization_id': module_org.id,
},
)['id']
# apply RHBA errata to the other host
rhba_task_id = module_target_sat.api.JobInvocation().run(
data={
'feature': 'katello_errata_install',
Copy link
Contributor

Choose a reason for hiding this comment

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

The web UI uses katello_errata_install_by_search. (katello_errata_install is from the old UI.)

katello_errata_install_by_search includes an errata search input. When you select all in the web UI, the errata search input (I think it's called "Errata filter"?) ends up as an empty string.

Before this fix, the magic comment in the rendered REX job template would have resolved to all errata in the system -- and that incorrect info would end up in the Applied Errata report.

After this fix, you should see only the host's applicable errata both in the rendered job template magic comment, and in the report.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Jeremy thanks for the re-review here, pushed a new commit to address these comments.
Please see the katello_errata_install_by_search REX job template invoked with
empty errata search query (" "). Right around Ln# 650

I also made dictionaries for the two host's info so loops can be used in each main step , rather than listing out every step twice for each host.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

.. the only thing that I have not yet figured out, how to get this 'magic comment' from the rendered job template.
@vsedmik @ColeHiggins2 any ideas?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure what that that 'magic comment' means. Let's find out.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's saved to the rendered job template here -->
https://github.com/Katello/katello/blob/f3444e8d6584dbaf66d8711cea75b2f52975b296/app/views/foreman/job_templates/install_errata_by_search_query.erb#L20-L21

Should be the exact errata IDs that result from the search query.

Copy link
Contributor

Choose a reason for hiding this comment

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

you could look for RESOLVED_ERRATA_IDS= in the template

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JacobCallahan Do you know of a way to read the rendered job template via API or CLI from the JobInvocation or its task?
Seems the only way we could find was via the Rendered job template preview in UI, but that sounds more like we should build a thorough rendered template preview testcase for UI, as would also need more Airgun work to accept inputs like hostname and Errata search query etc, outside of this PRs scope.
If not, I am already checking the task(s) invoked from the job and their status/outputs, would that be sufficient?

Copy link
Member

Choose a reason for hiding this comment

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

@damoore044 unfortunately, that's too component-specific for me to have an answer to. I'd recommend you check the api and see if that exists. If not, then there may be a way in the CLI.
Otherwise, we know some great Devs that might be able to provide a path!

@Satellite-QE Satellite-QE removed the PRT-Passed Indicates that latest PRT run is passed for the PR label Mar 4, 2025
@damoore044 damoore044 force-pushed the app_errata_report branch 2 times, most recently from a4e0d38 to 97217e1 Compare March 4, 2025 13:58
@damoore044
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/api/test_reporttemplates.py -k '_specific_hosts'

Copy link
Contributor

@vsedmik vsedmik left a comment

Choose a reason for hiding this comment

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

Looks good, just one small question, non-blocking.

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 10395
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/api/test_reporttemplates.py -k _specific_hosts --external-logging
Test Result : ========= 3 passed, 42 deselected, 1853 warnings in 9003.70s (2:30:03) =========

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label Mar 4, 2025
@Satellite-QE Satellite-QE removed the PRT-Passed Indicates that latest PRT run is passed for the PR label Mar 4, 2025
@damoore044
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/api/test_reporttemplates.py::test_positive_applied_errata_for_specific_hosts

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 10399
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/api/test_reporttemplates.py::test_positive_applied_errata_for_specific_hosts --external-logging
Test Result : ================ 3 passed, 1998 warnings in 8767.45s (2:26:07) =================

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label Mar 4, 2025
@Satellite-QE Satellite-QE removed the PRT-Passed Indicates that latest PRT run is passed for the PR label Mar 7, 2025
@damoore044
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/api/test_reporttemplates.py::test_positive_applied_errata_for_specific_hosts[rhel9-ipv4]

@damoore044
Copy link
Contributor Author

@chris1984 could you add co-pilot for review on this? thank you

@chris1984 chris1984 requested a review from Copilot March 7, 2025 19:27
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR adds new test coverage for the Hosts - Applied Errata Report Template by hostname and further validates the date fields with an additional test case.

  • Introduces a new test "test_positive_applied_errata_for_specific_hosts" to check report generation and errata filtering by hostname.
  • Adds a new constant "FAKE_9_YUM_OUTDATED_PACKAGES" to support the test setup for applied errata.

Reviewed Changes

File Description
tests/foreman/api/test_reporttemplates.py Adds new test coverage to validate errata reporting by hostname.

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

assert chost.execute('subscription-manager refresh').status == 0
assert chost.applicable_errata_count == 0
assert chost.applicable_package_count == 0
# job yieled only a single task for one host, success
Copy link
Preview

Copilot AI Mar 7, 2025

Choose a reason for hiding this comment

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

There is a spelling error in the comment on line 675; 'yieled' should be corrected to 'yielded'.

Suggested change
# job yieled only a single task for one host, success
# job yielded only a single task for one host, success

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 10446
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/api/test_reporttemplates.py::test_positive_applied_errata_for_specific_hosts[rhel9-ipv4] --external-logging
Test Result : ================= 1 passed, 16 warnings in 4818.11s (1:20:18) ==================

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.15.z Introduced in or relating directly to Satellite 6.15 6.16.z Introduced in or relating directly to Satellite 6.16 6.17.z CherryPick PR needs CherryPick to previous branches PRT-Passed Indicates that latest PRT run is passed for the PR QETestCoverage Issues and PRs relating to a Satellite bug Stream Introduced in or relating directly to Satellite Stream/Master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants