From ebe8bc5d4d465a1719b48411c5c1dc708b2d497c Mon Sep 17 00:00:00 2001 From: Cole Higgins Date: Tue, 9 Apr 2024 14:51:46 -0400 Subject: [PATCH] Updating tests to use many hosts and fixing sca --- robottelo/host_helpers/cli_factory.py | 7 ++++++- tests/foreman/api/test_reporttemplates.py | 21 ++++++++++++--------- tests/foreman/cli/test_reporttemplates.py | 1 + 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/robottelo/host_helpers/cli_factory.py b/robottelo/host_helpers/cli_factory.py index 30a28d57479..d5441f223e5 100644 --- a/robottelo/host_helpers/cli_factory.py +++ b/robottelo/host_helpers/cli_factory.py @@ -793,7 +793,12 @@ def _setup_org_for_a_rh_repo(self, options=None): # Promote version1 to next env try: self._satellite.cli.ContentView.version_promote( - {'id': cvv['id'], 'organization-id': org_id, 'to-lifecycle-environment-id': env_id} + { + 'id': cvv['id'], + 'organization-id': org_id, + 'to-lifecycle-environment-id': env_id, + 'force': True, + } ) except CLIReturnCodeError as err: raise CLIFactoryError( diff --git a/tests/foreman/api/test_reporttemplates.py b/tests/foreman/api/test_reporttemplates.py index a0c79506cf3..bfc3029ed2d 100644 --- a/tests/foreman/api/test_reporttemplates.py +++ b/tests/foreman/api/test_reporttemplates.py @@ -666,7 +666,7 @@ def test_positive_schedule_entitlements_report(setup_content, target_sat): @pytest.mark.no_containers @pytest.mark.tier3 -def test_positive_generate_job_report(setup_content, target_sat, rhel7_contenthost): +def test_positive_generate_job_report(setup_content, target_sat, content_hosts): """Generate a report using the Job - Invocation Report template. :id: 946c39db-3061-43d7-b922-1be61f0c7d93 @@ -685,11 +685,12 @@ def test_positive_generate_job_report(setup_content, target_sat, rhel7_contentho :customerscenario: true """ ak, org = setup_content - rhel7_contenthost.install_katello_ca(target_sat) - rhel7_contenthost.register_contenthost(org.label, ak.name) - rhel7_contenthost.add_rex_key(target_sat) - assert rhel7_contenthost.subscribed - # Run a Job on the Host + for host in content_hosts: + host.install_katello_ca(target_sat) + host.register_contenthost(org.label, ak.name) + host.add_rex_key(target_sat) + assert host.subscribed + # Run a Job on the Host template_id = ( target_sat.api.JobTemplate() .search(query={'search': 'name="Run Command - Script Default"'})[0] @@ -703,12 +704,12 @@ def test_positive_generate_job_report(setup_content, target_sat, rhel7_contentho 'command': 'pwd', }, 'targeting_type': 'static_query', - 'search_query': f'name = {rhel7_contenthost.hostname}', + 'search_query': f'name ^ ({content_hosts[0].hostname} && {content_hosts[1].hostname}', }, ) target_sat.wait_for_tasks(f'resource_type = JobInvocation and resource_id = {job["id"]}') result = target_sat.api.JobInvocation(id=job['id']).read() - assert result.succeeded == 1 + assert result.succeeded == 2 rt = ( target_sat.api.ReportTemplate() .search(query={'search': 'name="Job - Invocation Report"'})[0] @@ -721,8 +722,10 @@ def test_positive_generate_job_report(setup_content, target_sat, rhel7_contentho 'input_values': {"job_id": job["id"]}, } ) - assert res[0]['Host'] == rhel7_contenthost.hostname + assert res[0]['Host'] == content_hosts[0].hostname + assert res[1]['Host'] == content_hosts[1].hostname assert '/root' in res[0]['stdout'] + assert res[1]['stdout'] @pytest.mark.tier2 diff --git a/tests/foreman/cli/test_reporttemplates.py b/tests/foreman/cli/test_reporttemplates.py index 9c9bcf0e5a6..06ab74910bd 100644 --- a/tests/foreman/cli/test_reporttemplates.py +++ b/tests/foreman/cli/test_reporttemplates.py @@ -745,6 +745,7 @@ def test_positive_generate_ansible_template(module_target_sat): assert host['name'] in [item.split(',')[1] for item in report_data.split('\n') if len(item) > 0] +@pytest.mark.no_containers @pytest.mark.tier3 def test_positive_generate_entitlements_report_multiple_formats( module_entitlement_manifest_org, local_ak, local_subscription, rhel7_contenthost, target_sat