Skip to content

Commit

Permalink
Merge branch 'master' into cv-ui-version-table
Browse files Browse the repository at this point in the history
  • Loading branch information
sambible authored May 10, 2024
2 parents b500e5b + cdf898a commit 4285a24
Show file tree
Hide file tree
Showing 23 changed files with 119 additions and 65 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
exclude: tests/foreman/data/
- id: check-yaml
- id: debug-statements
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.1
rev: v0.4.3
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -28,6 +28,6 @@ repos:
types: [text]
require_serial: true
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.0
rev: v8.18.2
hooks:
- id: gitleaks
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pytest-fixturecollection==0.1.2
pytest-ibutsu==2.2.4
PyYAML==6.0.1
requests==2.31.0
tenacity==8.2.3
tenacity==8.3.0
testimony==2.4.0
wait-for==1.2.0
wrapanapi==3.6.0
Expand Down
19 changes: 4 additions & 15 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@
from box import Box
from nailgun import entities


# String Color codes
class Colored(Box):
YELLOW = '\033[1;33m'
REDLIGHT = '\033[3;31m'
REDDARK = '\033[1;31m'
GREEN = '\033[1;32m'
WHITELIGHT = '\033[1;30m'
RESET = '\033[0m'


# This should be updated after each version branch
SATELLITE_VERSION = "6.16"
SATELLITE_OS_VERSION = "8"
Expand Down Expand Up @@ -555,16 +544,16 @@ class Colored(Box):
},
'rhel9_bos': {
'id': 'rhel-9-for-x86_64-baseos-kickstart',
'name': 'Red Hat Enterprise Linux 9 for x86_64 - BaseOS Kickstart 9.3',
'version': '9.3',
'name': 'Red Hat Enterprise Linux 9 for x86_64 - BaseOS Kickstart 9.4',
'version': '9.4',
'reposet': REPOSET['kickstart']['rhel9_bos'],
'product': PRDS['rhel9'],
'distro': 'rhel9',
},
'rhel9_aps': {
'id': 'rhel-9-for-x86_64-appstream-kickstart',
'name': 'Red Hat Enterprise Linux 9 for x86_64 - AppStream Kickstart 9.3',
'version': '9.3',
'name': 'Red Hat Enterprise Linux 9 for x86_64 - AppStream Kickstart 9.4',
'version': '9.4',
'reposet': REPOSET['kickstart']['rhel9_aps'],
'product': PRDS['rhel9'],
'distro': 'rhel9',
Expand Down
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
5 changes: 4 additions & 1 deletion robottelo/utils/vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ def exec_vault_command(self, command: str, **kwargs):
logger.error(f"Error! {self.HELP_TEXT}")
sys.exit(1)
if vcommand.stderr:
if 'Error revoking token' in verror:
if 'no such host' in verror:
logger.error("The Vault host is not reachable, check network availability.")
sys.exit()
elif 'Error revoking token' in verror:
logger.info("Token is alredy revoked!")
elif 'Error looking up token' in verror:
logger.info("Vault is not logged in!")
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
2 changes: 1 addition & 1 deletion tests/foreman/cli/test_computeresource_libvirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_positive_list(libvirt_url, module_target_sat):
)
assert comp_res['name']
result_list = module_target_sat.cli.ComputeResource.list(
{'search': 'name=%s' % comp_res['name']}
{'search': 'name={}'.format(comp_res['name'])}
)
assert len(result_list) > 0
result = module_target_sat.cli.ComputeResource.exists(search=('name', comp_res['name']))
Expand Down
51 changes: 42 additions & 9 deletions tests/foreman/cli/test_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,13 @@ def test_positive_crud_interface_by_id(target_sat, default_location, default_org

mac = gen_mac(multicast=False)
host = target_sat.cli_factory.make_fake_host({'domain-id': domain.id})
number_of_interfaces = len(target_sat.cliHostInterface.list({'host-id': host['id']}))
number_of_interfaces = len(target_sat.cli.HostInterface.list({'host-id': host['id']}))

target_sat.cliHostInterface.create(
target_sat.cli.HostInterface.create(
{'host-id': host['id'], 'domain-id': domain.id, 'mac': mac, 'type': 'interface'}
)
host = target_sat.cli.Host.info({'id': host['id']})
host_interface = target_sat.cliHostInterface.info(
host_interface = target_sat.cli.HostInterface.info(
{
'host-id': host['id'],
'id': [ni for ni in host['network-interfaces'] if ni['mac-address'] == mac][0]['id'],
Expand All @@ -375,22 +375,22 @@ def test_positive_crud_interface_by_id(target_sat, default_location, default_org
assert host_interface['domain'] == domain.name
assert host_interface['mac-address'] == mac
assert (
len(target_sat.cliHostInterface.list({'host-id': host['id']})) == number_of_interfaces + 1
len(target_sat.cli.HostInterface.list({'host-id': host['id']})) == number_of_interfaces + 1
)

new_domain = target_sat.api.Domain(
location=[default_location], organization=[default_org]
).create()
new_mac = gen_mac(multicast=False)
target_sat.cliHostInterface.update(
target_sat.cli.HostInterface.update(
{
'host-id': host['id'],
'id': host_interface['id'],
'domain-id': new_domain.id,
'mac': new_mac,
}
)
host_interface = target_sat.cliHostInterface.info(
host_interface = target_sat.cli.HostInterface.info(
{
'host-id': host['id'],
'id': [ni for ni in host['network-interfaces'] if ni['mac-address'] == mac][0]['id'],
Expand All @@ -399,10 +399,10 @@ def test_positive_crud_interface_by_id(target_sat, default_location, default_org
assert host_interface['domain'] == new_domain.name
assert host_interface['mac-address'] == new_mac

target_sat.cliHostInterface.delete({'host-id': host['id'], 'id': host_interface['id']})
assert len(target_sat.cliHostInterface.list({'host-id': host['id']})) == number_of_interfaces
target_sat.cli.HostInterface.delete({'host-id': host['id'], 'id': host_interface['id']})
assert len(target_sat.cli.HostInterface.list({'host-id': host['id']})) == number_of_interfaces
with pytest.raises(CLIReturnCodeError):
target_sat.cliHostInterface.info({'host-id': host['id'], 'id': host_interface['id']})
target_sat.cli.HostInterface.info({'host-id': host['id'], 'id': host_interface['id']})


@pytest.mark.cli_host_create
Expand Down Expand Up @@ -2699,3 +2699,36 @@ def test_positive_create_and_update_with_content_source(
target_sat.cli.Capsule.content_synchronize({'name': module_capsule_configured.hostname})
assert rhel_contenthost.execute(f'dnf -y install {package}').status == 0
assert rhel_contenthost.execute(f'rpm -q {package}').status == 0


@pytest.mark.cli_host_create
@pytest.mark.tier2
def test_positive_create_host_with_lifecycle_environment_name(
module_lce,
module_org,
module_promoted_cv,
module_target_sat,
):
"""Attempt to create a host with lifecycle-environment name specified
:id: 7445ad21-538f-4357-8bd1-9676d2478633
:BZ: 2106256
:expectedresults: Host is created with no errors
:customerscenario: true
:CaseImportance: Medium
"""
found_host = False
new_host = module_target_sat.cli_factory.make_fake_host(
{
'content-view-id': module_promoted_cv.id,
'lifecycle-environment': module_lce.name,
'organization-id': module_org.id,
}
)
hosts = module_target_sat.cli.Host.list({'organization-id': module_org.id})
found_host = any(new_host.name in i.values() for i in hosts)
assert found_host, 'Assertion failed: host not found'
6 changes: 4 additions & 2 deletions tests/foreman/cli/test_leapp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:Team: Rocket
:CaseImportance: High
:CaseImportance: Critical
:CaseAutomation: Automated
Expand All @@ -25,7 +25,7 @@

RHEL7_VER = '7.9'
RHEL8_VER = '8.9'
RHEL9_VER = '9.3'
RHEL9_VER = '9.4'

RHEL_REPOS = {
'rhel7_server': {
Expand Down Expand Up @@ -219,6 +219,7 @@ def precondition_check_upgrade_and_install_leapp_tool(custom_leapp_host):
)


@pytest.mark.e2e
@pytest.mark.skip_if_open('SAT-24023')
@pytest.mark.parametrize(
'upgrade_path',
Expand Down Expand Up @@ -300,6 +301,7 @@ def test_leapp_upgrade_rhel(
assert new_ver == upgrade_path['target_version']


@pytest.mark.e2e
@pytest.mark.skip_if_open('SAT-24023')
@pytest.mark.parametrize(
'upgrade_path',
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
1 change: 1 addition & 0 deletions tests/foreman/ui/test_computeprofiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import pytest


@pytest.mark.e2e
@pytest.mark.tier2
@pytest.mark.upgrade
def test_positive_end_to_end(session, module_location, module_org, module_target_sat):
Expand Down
Loading

0 comments on commit 4285a24

Please sign in to comment.