Skip to content

Commit

Permalink
Merge branch 'master' into master-SAT-28695-insights-client-ansible-host
Browse files Browse the repository at this point in the history
  • Loading branch information
damoore044 authored Dec 4, 2024
2 parents 374517a + 809029d commit d8561a6
Show file tree
Hide file tree
Showing 14 changed files with 202 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
- id: check-yaml
- id: debug-statements
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.4
rev: v0.8.1
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
1 change: 1 addition & 0 deletions conf/fam.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ FAM:
auth_source_ldap_attr_login: uid
auth_source_ldap_groups_base: cn=groups,cn=accounts,dc=example,dc=com
external_usergroup_name: "admins"
default_auth_source_ldap_account_password: password

COMPUTE_PROFILE:
libvirt:
Expand Down
3 changes: 3 additions & 0 deletions conf/repos.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ REPOS:
RHEL9_OS:
BASEOS: replace-with-rhel9-os-baseos-http-link
APPSTREAM: replace-with-rhel9-os-appstream-http-link
RHEL10_OS:
BASEOS: replace-with-rhel10-os-baseos-http-link
APPSTREAM: replace-with-rhel10-os-appstream-http-link
RHEL7_OPTIONAL: replace-with-rhel7-optional-url
RHEL7_EXTRAS: replace-with-rhel7-extras-url
# If capsule and satellite tools repositories available related packages will
Expand Down
2 changes: 1 addition & 1 deletion pytest_fixtures/component/leapp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

RHEL7_VER = '7.9'
RHEL8_VER = '8.10'
RHEL9_VER = '9.4'
RHEL9_VER = '9.5'

RHEL_REPOS = {
'rhel7_server': {
Expand Down
2 changes: 1 addition & 1 deletion requirements-optional.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ruff==0.8.1

# For generating documentation.
sphinx==8.1.3
sphinx-autoapi==3.3.3
sphinx-autoapi==3.4.0

# For 'manage' interactive shell
manage==0.1.15
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ navmazing==1.2.2
productmd==1.42
pyotp==2.9.0
python-box==7.2.0
pytest==8.3.3
pytest==8.3.4
pytest-order==1.3.0
pytest-services==2.2.1
pytest-mock==3.14.0
pytest-reportportal==5.4.5
pytest-reportportal==5.4.6
pytest-xdist==3.6.1
pytest-fixturecollection==0.1.2
pytest-ibutsu==2.2.4
Expand All @@ -26,7 +26,7 @@ requests==2.32.3
tenacity==9.0.0
testimony==2.4.0
wait-for==1.2.0
wrapanapi==3.6.1
wrapanapi

# Get airgun, nailgun and upgrade from master
airgun @ git+https://github.com/SatelliteQE/airgun.git@master#egg=airgun
Expand Down
3 changes: 2 additions & 1 deletion robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,13 +1105,14 @@ def configure_insights_client(
:param register: Whether to register client to insights
:return: None
"""
# Red Hat Insights requires RHEL 6/7/8/9 repo and it is not
# Red Hat Insights requires RHEL OS repos and it is not
# possible to sync the repo during the tests, Adding repo file.
distro_repo_map = {
'rhel6': settings.repos.rhel6_os,
'rhel7': settings.repos.rhel7_os,
'rhel8': settings.repos.rhel8_os,
'rhel9': settings.repos.rhel9_os,
'rhel10': settings.repos.rhel10_os,
}
rhel_repo = distro_repo_map.get(rhel_distro)

Expand Down
42 changes: 42 additions & 0 deletions tests/foreman/api/test_rhcloud_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,45 @@ def test_include_parameter_tags_setting(
if tag['key'] == 'host_collection':
assert tag['value'] == f'"{host_col_name}"'
break


@pytest.mark.e2e
@pytest.mark.tier3
def test_rhcloud_scheduled_insights_sync(
rhcloud_manifest_org,
rhcloud_registered_hosts,
module_target_sat,
):
"""Verify that triggering the InsightsScheduledSync job in Satellite succeeds with no errors
:id: 59f66062-2865-4cca-82bb-8d0501fd40f1
:steps:
1. Prepare machine and upload its data to Insights
2. Sync inventory status using RH Cloud plugin api
3. Trigger the InsightsScheduledSync job manually
4. Assert job succeeds
:expectedresults:
1. Manually triggering the InsightsScheduledSync job succeeds with no errors.
:Verifies: SAT-22626
:CaseAutomation: Automated
"""
org = rhcloud_manifest_org
virtual_host, baremetal_host = rhcloud_registered_hosts
# Generate report
module_target_sat.generate_inventory_report(org)
# Sync inventory status
inventory_sync = module_target_sat.sync_inventory_status(org)
task_output = module_target_sat.api.ForemanTask().search(
query={'search': f'id = {inventory_sync["task"]["id"]}'}
)
# Assert that both hosts are synced successfully
assert task_output[0].output['host_statuses']['sync'] == 2
result = module_target_sat.execute(
"foreman-rake console SATELLITE_RH_CLOUD_REQUESTS_DELAY=0 <<< 'ForemanTasks.sync_task(InsightsCloud::Async::InsightsScheduledSync)'"
)
assert 'success' in result.stdout
assert result.status == 0
2 changes: 1 addition & 1 deletion tests/foreman/cli/test_leapp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

RHEL7_VER = '7.9'
RHEL8_VER = '8.10'
RHEL9_VER = '9.4'
RHEL9_VER = '9.5'


@pytest.mark.e2e
Expand Down
2 changes: 1 addition & 1 deletion tests/foreman/cli/test_remoteexecution.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ def test_positive_time_expressions(self, rex_contenthost, target_sat):
"""
client = rex_contenthost
today = datetime.today()
hour = datetime.utcnow().hour
hour = datetime.now().hour
last_day_of_month = monthrange(today.year, today.month)[1]
# cronline uses https://github.com/floraison/fugit
fugit_expressions = [
Expand Down
18 changes: 8 additions & 10 deletions tests/foreman/maintain/test_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
from robottelo.utils.installer import InstallerCommand

upstream_url = {
'foreman_repo': 'https://yum.theforeman.org/releases/nightly/el8/x86_64/',
'puppet_repo': 'https://yum.puppetlabs.com/puppet/el/8/x86_64/',
'fedorapeople_repo': (
'https://fedorapeople.org/groups/katello/releases/yum/latest/candlepin/el7/x86_64/'
),
'foreman_repo': 'https://yum.theforeman.org/releases/nightly/el9/x86_64/',
'puppet_repo': 'https://yum.puppetlabs.com/puppet/el/9/x86_64/',
'katello_repo': 'https://yum.theforeman.org/katello/nightly/katello/el9/x86_64/',
}


Expand Down Expand Up @@ -215,14 +213,14 @@ def _finalize():
options={'label': 'check-upstream-repository', 'assumeyes': True}
)
assert result.status == 0
assert 'System has upstream foreman_repo,puppet_repo repositories enabled' in result.stdout
assert (
f"System has upstream {','.join(sorted([ name for name in upstream_url ]))} repositories enabled"
in result.stdout
)
assert 'FAIL' in result.stdout
for name in upstream_url:
result = sat_maintain.execute(f'cat /etc/yum.repos.d/{name}.repo')
if name == 'fedorapeople_repo':
assert 'enabled=1' in result.stdout
elif name in ['foreman_repo', 'puppet_repo']:
assert 'enabled=0' in result.stdout
assert 'enabled=0' in result.stdout


def test_positive_health_check_available_space(sat_maintain):
Expand Down
3 changes: 2 additions & 1 deletion tests/foreman/sys/test_katello_certs_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ class TestKatelloCertsCheck:
CA cert (a.k.a cacert.crt or rootCA.pem) can be used as bundle file.
"""

error_message = f"error 26 at 0 depth lookup: {'unsupported' if settings.repos.rhel_major_version == '8' else 'unsuitable'} certificate purpose"
invalid_inputs = [
(
{
'check': 'Checking CA bundle against the certificate file',
'message': 'error 26 at 0 depth lookup: unsupported certificate purpose',
'message': error_message,
},
'certs/invalid.crt',
'certs/invalid.key',
Expand Down
135 changes: 135 additions & 0 deletions tests/foreman/ui/test_capsulecontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"""

from datetime import datetime, timedelta

import pytest

from robottelo.config import settings
Expand Down Expand Up @@ -234,6 +236,139 @@ def test_positive_content_counts_for_mixed_cv(
assert 'content' not in details, 'Content still listed for removed LCEs'


@pytest.mark.parametrize('setting_update', ['automatic_content_count_updates=False'], indirect=True)
def test_positive_content_counts_granular_update(
module_target_sat, module_capsule_configured, setting_update, function_org, function_product
):
"""Verify that the capsule content counts can be updated separately for LCEs and CVs.
:id: 64f241f5-1766-4d11-95c7-f15633c10a80
:parametrized: yes
:verifies: SAT-28338
:BlockedBy: SAT-29679
:setup:
1. Satellite with registered external Capsule.
2. Disabled automatic content counts update.
:steps:
1. Create two LCEs, assign them to the Capsule.
2. Create and sync a repo, publish it in two CVs, promote both CVs to both LCEs.
3. Ensure no counts were calculated yet for both CVs, both LCEs.
4. Refresh counts for the first CV in the first LCE, check entity IDs in the Update task.
5. Ensure the counts were updated for the first CV and
the second CV stayed untouched, as well as the second LCE.
6. Refresh counts for the second LCE, check entity IDs in the Update task.
7. Ensure the counts were updated for the second LCE and
the second CV in the first LCE stayed untouched.
:expectedresults:
1. Content counts are updated only for the specific LCEs and CVs.
"""
wait_query = (
'label = Actions::Katello::ContentView::CapsuleSync OR '
'Actions::Katello::CapsuleContent::UpdateContentCounts'
)

# 1. Create two LCEs, assign them to the Capsule.
lce1 = module_target_sat.api.LifecycleEnvironment(organization=function_org).create()
lce2 = module_target_sat.api.LifecycleEnvironment(
organization=function_org, prior=lce1
).create()
module_capsule_configured.nailgun_capsule.content_add_lifecycle_environment(
data={'environment_id': [lce1.id, lce2.id]}
)

# 2. Create and sync a repo, publish it in two CVs, promote both CVs to both LCEs.
repo = module_target_sat.api.Repository(
product=function_product,
).create()
repo.sync()
repo = repo.read()
cvs = []
for _ in range(2):
cv = module_target_sat.api.ContentView(
organization=function_org, repository=[repo]
).create()
cv.publish()
cv = cv.read()
cv.version[0].promote(data={'environment_ids': [lce1.id, lce2.id]})
cvs.append(cv.read())
cv1, cv2 = cvs
module_target_sat.wait_for_tasks(search_query=wait_query, search_rate=5, max_tries=5)

empty_counts = [repo.name, 'N/A', 'N/A']
valid_counts = [
repo.name,
f'{repo.content_counts["rpm"]} Packages',
f'{repo.content_counts["erratum"]} Errata',
f'{repo.content_counts["package_group"]} Package groups',
]

with module_target_sat.ui_session() as session:
session.capsule.edit(
module_capsule_configured.hostname, add_organizations=[function_org.name]
)
session.organization.select(org_name=function_org.name)

# 3. Ensure no counts were calculated yet for both CVs, both LCEs.
details = session.capsule.read_details(module_capsule_configured.hostname)
assert all(
details['content'][lce.name][cv.name]['expanded_repo_details'][1] == empty_counts
for lce in [lce1, lce2]
for cv in cvs
), 'Expected "N/A" for content counts displayed'

# 4. Refresh counts for the first CV in the first LCE, check entity IDs in the Update task.
session.capsule.refresh_lce_counts(
module_capsule_configured.hostname, lce_name=lce1.name, cv_name=cv1.name
)
timestamp = (datetime.utcnow() - timedelta(seconds=1)).strftime('%Y-%m-%d %H:%M')
task = module_target_sat.api.ForemanTask().search(
query={
'search': f'label=Actions::Katello::CapsuleContent::UpdateContentCounts and started_at>="{timestamp}"'
}
)[0]
assert task.input['smart_proxy_id'] == module_capsule_configured.nailgun_capsule.id
assert task.input['environment_id'] == lce1.id
assert task.input['content_view_id'] == cv1.id

# 5. Ensure the counts were updated for the first CV and
# the second CV stayed untouched, as well as the second LCE.
details = session.capsule.read_details(module_capsule_configured.hostname)
assert details['content'][lce1.name][cv1.name]['expanded_repo_details'][1] == valid_counts
assert details['content'][lce1.name][cv2.name]['expanded_repo_details'][1] == empty_counts
assert all(
details['content'][lce2.name][cv.name]['expanded_repo_details'][1] == empty_counts
for cv in cvs
)

# 6. Refresh counts for the second LCE, check entity IDs in the Update task.
session.capsule.refresh_lce_counts(module_capsule_configured.hostname, lce_name=lce2.name)
timestamp = (datetime.utcnow() - timedelta(seconds=1)).strftime('%Y-%m-%d %H:%M')
task = module_target_sat.api.ForemanTask().search(
query={
'search': f'label=Actions::Katello::CapsuleContent::UpdateContentCounts and started_at>="{timestamp}"'
}
)[0]
assert task.input['smart_proxy_id'] == module_capsule_configured.nailgun_capsule.id
assert task.input['environment_id'] == lce2.id
assert not task.input['content_view_id']

# 7. Ensure the counts were updated for the second LCE and
# the second CV in the first LCE stayed untouched.
details = session.capsule.read_details(module_capsule_configured.hostname)
assert all(
details['content'][lce2.name][cv.name]['expanded_repo_details'][1] == valid_counts
for cv in cvs
)
assert details['content'][lce1.name][cv2.name]['expanded_repo_details'][1] == empty_counts


@pytest.mark.parametrize('setting_update', ['hide_reclaim_space_warning=False'], indirect=True)
def test_hide_reclaim_space_warning(module_target_sat, setting_update):
"""Verify the Reclaim space warning hiding via Settings works as expected.
Expand Down
2 changes: 1 addition & 1 deletion tests/foreman/ui/test_leapp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

RHEL7_VER = '7.9'
RHEL8_VER = '8.10'
RHEL9_VER = '9.4'
RHEL9_VER = '9.5'


@pytest.mark.tier3
Expand Down

0 comments on commit d8561a6

Please sign in to comment.