Skip to content

Commit

Permalink
[Comp Eval] Fixing tests and adding support for errata install by sea…
Browse files Browse the repository at this point in the history
…rch (#14975)

* Fixing tests and adding errata by search

* removing max_tries

* updating pytest mark

* fixing other tests

* fixing docstring

* Moving errataname search

* removing location selection

* Adding sub man repo command

* updating erratum

* updating search rate and max tries
  • Loading branch information
ColeHiggins2 authored May 22, 2024
1 parent fe65df5 commit 2a52b85
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 6 deletions.
87 changes: 84 additions & 3 deletions tests/foreman/api/test_reporttemplates.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def test_negative_create_report_without_name(module_target_sat):


@pytest.mark.tier2
@pytest.mark.rhel_ver_match(r'^(?!6$)\d+$')
@pytest.mark.rhel_ver_match('[^6]')
@pytest.mark.no_containers
def test_positive_applied_errata(
function_org, function_location, function_lce, rhel_contenthost, target_sat
Expand Down Expand Up @@ -459,6 +459,87 @@ 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_by_search(
function_org, function_lce, rhel_contenthost, target_sat
):
"""Generate an Applied Errata report
:id: 0f7d2772-47a4-4215-b555-dd8ee675372f
:setup: A Host with some applied errata.
:steps:
1. Generate an Applied Errata report
:expectedresults: A report is generated with all applied errata listed
:CaseImportance: Medium
"""
activation_key = target_sat.api.ActivationKey(
environment=function_lce, organization=function_org
).create()
cv = target_sat.api.ContentView(organization=function_org).create()
ERRATUM_ID = str(settings.repos.yum_6.errata[2])
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,
}
)
errata_name = (
target_sat.api.Errata()
.search(query={'search': f'errata_id="{ERRATUM_ID}"'})[0]
.read()
.description
)
result = rhel_contenthost.register(function_org, None, 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
rhel_contenthost.execute('subscription-manager repos')
task_id = target_sat.api.JobInvocation().run(
data={
'feature': 'katello_errata_install_by_search',
'inputs': {'Errata search query': errata_name},
'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=20,
poll_timeout=2500,
)
rt = (
target_sat.api.ReportTemplate()
.search(query={'search': 'name="Host - Applied Errata"'})[0]
.read()
)
res = rt.generate(
data={
'organization_id': function_org.id,
'report_format': 'json',
'input_values': {
'Filter Errata Type': 'all',
'Include Last Reboot': 'no',
'Status': 'all',
},
}
)
assert res[0]['erratum_id'] == ERRATUM_ID
assert res[0]['issued']


@pytest.mark.tier2
@pytest.mark.stubbed
def test_positive_generate_nonblocking():
Expand Down Expand Up @@ -738,7 +819,7 @@ def test_positive_generate_job_report(setup_content, module_target_sat, content_

@pytest.mark.tier2
@pytest.mark.no_containers
@pytest.mark.rhel_ver_match(r'^(?!6$)\d+$')
@pytest.mark.rhel_ver_match('[^6]')
def test_positive_installable_errata(
target_sat, function_org, function_lce, function_location, rhel_contenthost
):
Expand Down Expand Up @@ -852,7 +933,7 @@ def test_positive_installable_errata(


@pytest.mark.tier2
@pytest.mark.rhel_ver_match(r'^(?!6$)\d+$')
@pytest.mark.rhel_ver_match('[^6]')
def test_positive_installed_products(
target_sat,
rhel_contenthost,
Expand Down
14 changes: 11 additions & 3 deletions tests/foreman/cli/test_reporttemplates.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def test_positive_end_to_end_crud_and_list(target_sat):
list - at least two report templates
info - some report template
update - some report template that is not locked
clone - some report template
delete - some report template that is not locked
:steps:
Expand All @@ -161,11 +162,12 @@ def test_positive_end_to_end_crud_and_list(target_sat):
2. hammer report-template list ...
3. hammer report-template info ...
4. hammer report-template update ... # change some value
5. hammer report-template delete ...
5. hammer report-template clone ...
6. hammer report-template delete ...
:expectedresults: Report is created, report templates are listed,
data about report template is showed,
report template is updated, and deleted.
report template is updated, report template is cloned, and deleted.
:CaseImportance: Critical
"""
Expand Down Expand Up @@ -193,6 +195,12 @@ def test_positive_end_to_end_crud_and_list(target_sat):
rt_list = target_sat.cli.ReportTemplate.list()
assert name not in [rt['name'] for rt in rt_list]

# clone
clone_name = gen_alpha()
target_sat.cli.ReportTemplate.clone({'id': report_template['id'], 'new-name': clone_name})
clone_list = target_sat.cli.ReportTemplate.list()
assert clone_name in [rt['name'] for rt in clone_list]

# delete tmp
target_sat.cli.ReportTemplate.delete({'name': tmp_report_template['name']})
with pytest.raises(CLIReturnCodeError):
Expand Down Expand Up @@ -679,7 +687,7 @@ def test_positive_generate_with_name_and_org(module_target_sat):
result = module_target_sat.cli.ReportTemplate.generate(
{'name': 'Host - Statuses', 'organization': DEFAULT_ORG}
)

assert 'RHEL lifecycle' in result
assert host['name'] in [item.split(',')[0] for item in result.split('\n')]


Expand Down

0 comments on commit 2a52b85

Please sign in to comment.