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

[6.15.z] [Comp Eval] Updating to test on multiple hosts and fixing test failures #15014

Merged
Show file tree
Hide file tree
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
17 changes: 13 additions & 4 deletions robottelo/host_helpers/cli_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ def setup_org_for_a_custom_repo(self, options=None):
'repository-id': custom_repo['id'],
}

def _setup_org_for_a_rh_repo(self, options=None):
def _setup_org_for_a_rh_repo(self, options=None, force=False):
"""Sets up Org for the given Red Hat repository by:

1. Checks if organization and lifecycle environment were given, otherwise
Expand Down Expand Up @@ -792,7 +792,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': force,
}
)
except CLIReturnCodeError as err:
raise CLIFactoryError(
Expand Down Expand Up @@ -845,7 +850,11 @@ def _setup_org_for_a_rh_repo(self, options=None):
}

def setup_org_for_a_rh_repo(
self, options=None, force_manifest_upload=False, force_use_cdn=False
self,
options=None,
force_manifest_upload=False,
force_use_cdn=False,
force=False,
):
"""Wrapper above ``_setup_org_for_a_rh_repo`` to use custom downstream repo
instead of CDN's 'Satellite Capsule', 'Satellite Tools' and base OS repos if
Expand Down Expand Up @@ -874,7 +883,7 @@ def setup_org_for_a_rh_repo(
elif 'Satellite Capsule' in options.get('repository'):
custom_repo_url = settings.repos.capsule_repo
if force_use_cdn or settings.robottelo.cdn or not custom_repo_url:
return self._setup_org_for_a_rh_repo(options)
return self._setup_org_for_a_rh_repo(options, force)
options['url'] = custom_repo_url
result = self.setup_org_for_a_custom_repo(options)
if force_manifest_upload:
Expand Down
30 changes: 16 additions & 14 deletions tests/foreman/api/test_reporttemplates.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,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, module_target_sat, content_hosts):
"""Generate a report using the Job - Invocation Report template.

:id: 946c39db-3061-43d7-b922-1be61f0c7d93
Expand All @@ -686,32 +686,32 @@ 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.register(org, None, ak.name, module_target_sat)
host.add_rex_key(module_target_sat)
assert host.subscribed
# Run a Job on the Host
template_id = (
target_sat.api.JobTemplate()
module_target_sat.api.JobTemplate()
.search(query={'search': 'name="Run Command - Script Default"'})[0]
.id
)
job = target_sat.api.JobInvocation().run(
job = module_target_sat.api.JobInvocation().run(
synchronous=False,
data={
'job_template_id': template_id,
'inputs': {
'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
module_target_sat.wait_for_tasks(f'resource_type = JobInvocation and resource_id = {job["id"]}')
result = module_target_sat.api.JobInvocation(id=job['id']).read()
assert result.succeeded == 2
rt = (
target_sat.api.ReportTemplate()
module_target_sat.api.ReportTemplate()
.search(query={'search': 'name="Job - Invocation Report"'})[0]
.read()
)
Expand All @@ -722,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 '/root' in res[1]['stdout']


@pytest.mark.tier2
Expand Down
14 changes: 8 additions & 6 deletions tests/foreman/cli/test_reporttemplates.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,9 +746,10 @@ 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
module_sca_manifest_org, local_ak, local_subscription, rhel7_contenthost, target_sat
):
"""Generate an report using the Subscription - Entitlement Report template
in html, yaml, and csv format.
Expand All @@ -772,11 +773,11 @@ def test_positive_generate_entitlements_report_multiple_formats(
"""
client = rhel7_contenthost
client.install_katello_ca(target_sat)
client.register_contenthost(module_entitlement_manifest_org.label, local_ak['name'])
client.register_contenthost(module_sca_manifest_org.label, local_ak['name'])
assert client.subscribed
result_html = target_sat.cli.ReportTemplate.generate(
{
'organization': module_entitlement_manifest_org.name,
'organization': module_sca_manifest_org.name,
'name': 'Subscription - Entitlement Report',
'report-format': 'html',
'inputs': 'Days from Now=no limit',
Expand All @@ -786,7 +787,7 @@ def test_positive_generate_entitlements_report_multiple_formats(
assert local_subscription['name'] in result_html
result_yaml = target_sat.cli.ReportTemplate.generate(
{
'organization': module_entitlement_manifest_org.name,
'organization': module_sca_manifest_org.name,
'name': 'Subscription - Entitlement Report',
'report-format': 'yaml',
'inputs': 'Days from Now=no limit',
Expand All @@ -799,7 +800,7 @@ def test_positive_generate_entitlements_report_multiple_formats(
assert local_subscription['name'] in entry
result_csv = target_sat.cli.ReportTemplate.generate(
{
'organization': module_entitlement_manifest_org.name,
'organization': module_sca_manifest_org.name,
'name': 'Subscription - Entitlement Report',
'report-format': 'csv',
'inputs': 'Days from Now=no limit',
Expand Down Expand Up @@ -924,7 +925,8 @@ def test_positive_generate_hostpkgcompare(
'content-view-id': local_content_view['id'],
'lifecycle-environment-id': local_environment['id'],
'activationkey-id': local_ak['id'],
}
},
force=True,
)
target_sat.cli_factory.setup_org_for_a_custom_repo(
{
Expand Down
Loading