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

[Customer Case] Applied Errata report with invalid errata #15378

Merged
Merged
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
76 changes: 76 additions & 0 deletions tests/foreman/api/test_reporttemplates.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,82 @@ def test_positive_applied_errata(
assert res[0]['issued']


@pytest.mark.tier2
@pytest.mark.rhel_ver_match('[^6]')
@pytest.mark.no_containers
def test_positive_applied_errata_report_with_invalid_errata(
function_org, function_location, function_lce, rhel_contenthost, target_sat
):
"""Generate an Applied Errata report after an invalid errata has been applied

:id: cf64f193-870d-4053-ae4b-28148424b2e2

:setup: A Host with some invalid applied errata.

:steps:

1. Apply invalid errata
2. Generate an Applied Errata report

:expectedresults: A report is generated without failures

:BZ: 2176368

:customerscenario: true
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"""
:customerscenario: true
"""

activation_key = target_sat.api.ActivationKey(
environment=function_lce, organization=function_org
).create()
cv = target_sat.api.ContentView(organization=function_org).create()
Comment on lines +481 to +484
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
activation_key = target_sat.api.ActivationKey(
environment=function_lce, organization=function_org
).create()
cv = target_sat.api.ContentView(organization=function_org).create()

We could probably use function_ak_with_cv fixture instead (and function_promoted_cv it uses inside).

Copy link
Member Author

Choose a reason for hiding this comment

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

Had some issues with lce using that fixture, Test was failing, Lets just keep it how it is

Copy link
Contributor

Choose a reason for hiding this comment

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

I have also found that fixture fails to setup as expected

target_sat.cli_factory.setup_org_for_a_custom_repo(
{
'url': settings.repos.yum_6.url,
'organization-id': function_org.id,
'content-view-id': cv.id,
'lifecycle-environment-id': function_lce.id,
'activationkey-id': activation_key.id,
}
)
result = rhel_contenthost.register(
function_org, function_location, activation_key.name, target_sat
)
assert f'The registered system name is: {rhel_contenthost.hostname}' in result.stdout
assert rhel_contenthost.subscribed
rhel_contenthost.execute(r'subscription-manager repos --enable \*')
assert rhel_contenthost.execute(f'yum install -y {FAKE_1_CUSTOM_PACKAGE}').status == 0
assert rhel_contenthost.execute(f'rpm -q {FAKE_1_CUSTOM_PACKAGE}').status == 0
task_id = target_sat.api.JobInvocation().run(
data={
'feature': 'katello_errata_install',
'inputs': {'errata': 'invalid-errata'},
'targeting_type': 'static_query',
'search_query': f'name = {rhel_contenthost.hostname}',
'organization_id': function_org.id,
},
)['id']
target_sat.wait_for_tasks(
search_query=(f'label = Actions::RemoteExecution::RunHostsJob and id = {task_id}'),
search_rate=15,
max_tries=10,
)
rt = (
target_sat.api.ReportTemplate()
.search(query={'search': 'name="Host - Applied Errata"'})[0]
.read()
)
rt.generate(
data={
'organization_id': function_org.id,
'report_format': 'json',
'input_values': {
'Filter Errata Type': 'all',
'Include Last Reboot': 'no',
'Status': 'all',
},
}
)

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think any other assertion can be implementated after generating errata report?

Copy link
Member Author

Choose a reason for hiding this comment

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

We talked about this in chat, There are not any good ways to make an assertion here. All we need to test is that this report is generated. A failing tests is a good enough indicator here


@pytest.mark.tier2
@pytest.mark.rhel_ver_match('[^6]')
@pytest.mark.no_containers
Expand Down