Skip to content

Commit

Permalink
Merge branch 'master' into cv-warning
Browse files Browse the repository at this point in the history
  • Loading branch information
sambible authored Dec 12, 2024
2 parents 52d87c1 + f1ca32b commit c9e097d
Show file tree
Hide file tree
Showing 20 changed files with 147 additions and 140 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.8.1
rev: v0.8.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
2 changes: 1 addition & 1 deletion conf/jira.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ JIRA:
COMMENT_VISIBILITY: "Red Hat Employee"
ENABLE_COMMENT: false
# Comment only if jira is in one of the following state
ISSUE_STATUS: ["Review", "Release Pending"]
ISSUE_STATUS: ["Testing", "Release Pending"]
2 changes: 2 additions & 0 deletions conf/robottelo.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ ROBOTTELO:
SETTINGS:
GET_FRESH: true
IGNORE_VALIDATION_ERRORS: false
# Stage docs url
STAGE_DOCS_URL: https://docs.redhat.com
28 changes: 15 additions & 13 deletions pytest_fixtures/core/sat_cap_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,19 +364,18 @@ def installer_satellite(request):
# enable satellite repos
for repo in sat.SATELLITE_CDN_REPOS.values():
sat.enable_repo(repo, force=True)
elif settings.server.version.source == 'nightly':
sat.create_custom_repos(
satellite_repo=settings.repos.satellite_repo,
satmaintenance_repo=settings.repos.satmaintenance_repo,
)
else:
if settings.server.version.source == 'nightly':
sat.create_custom_repos(
satellite_repo=settings.repos.satellite_repo,
satmaintenance_repo=settings.repos.satmaintenance_repo,
)
else:
# get ohsnap repofile
sat.download_repofile(
product='satellite',
release=settings.server.version.release,
snap=settings.server.version.snap,
)
# get ohsnap repofile
sat.download_repofile(
product='satellite',
release=settings.server.version.release,
snap=settings.server.version.snap,
)

if settings.robottelo.rhel_source == "internal":
# disable rhel repos from cdn
Expand All @@ -386,7 +385,7 @@ def installer_satellite(request):

sat.install_satellite_or_capsule_package()
# Install Satellite
sat.execute(
installer_result = sat.execute(
InstallerCommand(
installer_args=[
'scenario satellite',
Expand All @@ -395,6 +394,9 @@ def installer_satellite(request):
).get_command(),
timeout='30m',
)
# exit code 0 means no changes, 2 means changes were applied succesfully
assert installer_result.status in (0, 2), installer_result.stdout

sat.enable_satellite_ipv6_http_proxy()
if 'sanity' in request.config.option.markexpr:
configure_nailgun()
Expand Down
19 changes: 7 additions & 12 deletions pytest_fixtures/core/xdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest

from robottelo.config import configure_airgun, configure_nailgun, settings
from robottelo.hosts import Capsule, Satellite
from robottelo.hosts import ContentHost, Satellite
from robottelo.logging import logger


Expand All @@ -17,17 +17,12 @@ def align_to_satellite(request, worker_id, satellite_factory):
settings.set("server.hostname", None)
yield
# Checkout Sanity Capsule finally
if settings.capsule.hostname:
sanity_cap = Capsule.get_host_by_hostname(settings.capsule.hostname)
sanity_cap.unregister()
Broker(hosts=[sanity_cap]).checkin()
# Checkout Sanity Satellite finally
if settings.server.hostname:
sanity_sat = Satellite(settings.server.hostname)
sanity_sat.unregister()
if settings.server.auto_checkin:
broker_sat = Satellite.get_host_by_hostname(sanity_sat.hostname)
Broker(hosts=[broker_sat]).checkin()
for host in [settings.capsule.hostname, settings.server.hostname]:
if host:
sanity_host = ContentHost.get_host_by_hostname(host)
if settings.server.auto_checkin:
sanity_host.unregister()
Broker(hosts=[sanity_host]).checkin()
else:
# clear any hostname that may have been previously set
settings.set("server.hostname", None)
Expand Down
4 changes: 2 additions & 2 deletions requirements-optional.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# For running tests and checking code quality using these modules.
pytest-cov==6.0.0
redis==5.2.0
redis==5.2.1
pre-commit==4.0.1
ruff==0.8.1
ruff==0.8.2

# For generating documentation.
sphinx==8.1.3
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ fauxfactory==3.1.1
jinja2==3.1.4
manifester==0.2.8
navmazing==1.2.2
productmd==1.42
productmd==1.43
pyotp==2.9.0
python-box==7.2.0
python-box==7.3.0
pytest==8.3.4
pytest-order==1.3.0
pytest-services==2.2.1
pytest-mock==3.14.0
pytest-reportportal==5.4.6
pytest-reportportal==5.4.7
pytest-xdist==3.6.1
pytest-fixturecollection==0.1.2
pytest-ibutsu==2.2.4
Expand Down
3 changes: 2 additions & 1 deletion robottelo/config/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
Validator('jira.comment_type', default="group"),
Validator('jira.comment_visibility', default="Red Hat Employee"),
Validator('jira.enable_comment', default=False),
Validator('jira.issue_status', default=["Review", "Release Pending"]),
Validator('jira.issue_status', default=["Testing", "Release Pending"]),
],
ldap=[
Validator(
Expand Down Expand Up @@ -321,6 +321,7 @@
Validator('remotedb.port', default=5432),
],
robottelo=[
Validator('robottelo.stage_docs_url', default='https://docs.redhat.com'),
Validator('robottelo.settings.ignore_validation_errors', is_type_of=bool, default=False),
Validator('robottelo.rhel_source', default='ga', is_in=['ga', 'internal']),
Validator(
Expand Down
12 changes: 10 additions & 2 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1830,8 +1830,16 @@
# Jira statuses used by Robottelo issue handler.
JIRA_TESTS_PASSED_LABEL = "tests-passed"
JIRA_TESTS_FAILED_LABEL = "tests-failed"
JIRA_OPEN_STATUSES = ("New", "Backlog", "Refinement", "To Do", "In Progress")
JIRA_ONQA_STATUS = "Review"
JIRA_OPEN_STATUSES = (
"New",
"Backlog",
"Refinement",
"To Do",
"In Progress",
"Review",
"Release Pending - Upstream",
)
JIRA_ONQA_STATUS = "Testing"
JIRA_CLOSED_STATUSES = ("Release Pending", "Closed")
JIRA_WONTFIX_RESOLUTIONS = "Obsolete"

Expand Down
11 changes: 8 additions & 3 deletions tests/foreman/api/test_multiple_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,15 @@ def test_positive_permission_read(self, target_sat):
class and name and resource_type fields are populated
:CaseImportance: Critical
:Verifies: SAT-29957
:BlockedBy: SAT-29957
"""
perm = target_sat.api.Permission().search(query={'per_page': '1'})[0]
assert perm.name
assert perm.resource_type
perms = target_sat.api.Permission().search(query={'per_page': '1'})
for perm in perms:
assert perm.name
assert perm.resource_type

@pytest.mark.tier1
def test_positive_media_read(self, target_sat):
Expand Down
6 changes: 3 additions & 3 deletions tests/foreman/api/test_provisioningtemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ def test_positive_template_check_rex_snippet(
assert f'chown -R {rex_user}: ~{rex_user}' in rex_snippet
assert f'chown -R {rex_user}: ~{rex_user}/.ssh' in rex_snippet
assert (
f'echo "{rex_user} ALL = (root) NOPASSWD : ALL" > /etc/sudoers.d/{rex_user}\necho "Defaults:{rex_user} !requiretty" >> /etc/sudoers.d/{rex_user}'
f'echo "{rex_user} ALL = (ALL) NOPASSWD : ALL" > /etc/sudoers.d/{rex_user}\necho "Defaults:{rex_user} !requiretty" >> /etc/sudoers.d/{rex_user}'
in rex_snippet
)
assert ssh_key in rex_snippet
Expand Down Expand Up @@ -646,8 +646,8 @@ def test_positive_template_check_rex_pull_mode_snippet(
pkg_manager = 'yum' if module_sync_kickstart_content.rhel_ver < 8 else 'dnf'
assert f'{pkg_manager} -y install foreman_ygg_worker' in rex_snippet
assert 'broker = ["mqtts://$SERVER_NAME:1883"]' in rex_snippet
assert 'systemctl try-restart yggdrasild' in rex_snippet
assert 'systemctl enable --now yggdrasild' in rex_snippet
assert 'systemctl try-restart $YGGDRASIL_SERVICE' in rex_snippet
assert 'systemctl enable --now $YGGDRASIL_SERVICE' in rex_snippet
assert 'yggdrasil status' in rex_snippet
assert 'Remote execution pull provider successfully configured!' in rex_snippet

Expand Down
2 changes: 2 additions & 0 deletions tests/foreman/api/test_rhcloud_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ def test_rhcloud_scheduled_insights_sync(
:Verifies: SAT-22626
:CaseAutomation: Automated
:customerscenario: true
"""
org = rhcloud_manifest_org
virtual_host, baremetal_host = rhcloud_registered_hosts
Expand Down
15 changes: 0 additions & 15 deletions tests/foreman/api/test_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,6 @@ def module_ak(module_sca_manifest_org, rh_repo, custom_repo, module_target_sat):
).create()


@pytest.mark.tier1
@pytest.mark.pit_server
def test_positive_create(module_sca_manifest, module_target_sat):
"""Upload a manifest.
:id: 6faf9d96-9b45-4bdc-afa9-ec3fbae83d41
:expectedresults: Manifest is uploaded successfully
:CaseImportance: Critical
"""
org = module_target_sat.api.Organization().create()
module_target_sat.upload_manifest(org.id, module_sca_manifest.content)


@pytest.mark.tier1
def test_positive_refresh(function_sca_manifest_org, request, target_sat):
"""Upload a manifest and refresh it afterwards.
Expand Down
34 changes: 34 additions & 0 deletions tests/foreman/cli/test_rhcloud_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,37 @@ def test_positive_generate_all_reports_job(target_sat):
assert task_output[0].result == "success"
finally:
target_sat.update_setting('allow_auto_inventory_upload', True)


@pytest.mark.rhel_ver_match('N-2')
def test_positive_register_insights_client_host(module_target_sat, rhel_insights_vm):
"""Check the below command executed successfully
command - insights-client --ansible-host=foo.example.com
:id: b578371e-ec36-42de-83fa-bcea6e027fe2
:setup:
1. Enable, sync RHEL BaseOS and AppStream repositories
2. Create CV, Publish/promote and create AK for host registration
3. Register host to satellite, Setup Insights is Yes (Override), Install insights-client
:steps:
2. Test connection of insights client
3. execute insight client command given in the description
:expectedresults: Command executed successfully
:Verifies: SAT-28695
:customerscenario: true
:CaseAutomation: Automated
"""
# Test connection of insights client
assert rhel_insights_vm.execute('insights-client --test-connection').status == 0

# Execute insight client command
output = rhel_insights_vm.execute(f'insights-client --ansible-host={rhel_insights_vm.hostname}')
assert output.status == 0
assert 'Ansible hostname updated' in output.stdout
5 changes: 4 additions & 1 deletion tests/foreman/destructive/test_ldapauthsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ def test_rhsso_login_using_hammer(
result = module_target_sat.cli.Auth.with_user(
username=settings.rhsso.rhsso_user, password=settings.rhsso.rhsso_password
).status()
assert f"Session exists, currently logged in as '{settings.rhsso.rhsso_user}'." in result
assert (
f"Session exists, currently logged in as '{settings.rhsso.rhsso_user}'."
in result[0]['message']
)
task_list = module_target_sat.cli.Task.with_user(
username=settings.rhsso.rhsso_user, password=settings.rhsso.rhsso_password
).list()
Expand Down
10 changes: 5 additions & 5 deletions tests/foreman/installer/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,22 @@ def common_sat_install_assertions(satellite):
result = satellite.execute(
r'journalctl --quiet --no-pager --boot --priority err -u "dynflow-sidekiq*" -u "foreman-proxy" -u "foreman" -u "httpd" -u "postgresql" -u "pulpcore-api" -u "pulpcore-content" -u "pulpcore-worker*" -u "redis" -u "tomcat"'
)
assert len(result.stdout) == 0
assert not result.stdout
# no errors in /var/log/foreman/production.log
result = satellite.execute(r'grep --context=100 -E "\[E\|" /var/log/foreman/production.log')
if not is_open('SAT-21086'):
assert len(result.stdout) == 0
assert not result.stdout
# no errors/failures in /var/log/foreman-installer/satellite.log
result = satellite.execute(
r'grep "\[ERROR" --context=100 /var/log/foreman-installer/satellite.log'
)
assert len(result.stdout) == 0
assert not result.stdout
# no errors/failures in /var/log/httpd/*
result = satellite.execute(r'grep -iR "error" /var/log/httpd/*')
assert len(result.stdout) == 0
assert not result.stdout
# no errors/failures in /var/log/candlepin/*
result = satellite.execute(r'grep -iR "error" /var/log/candlepin/*')
assert len(result.stdout) == 0
assert not result.stdout

httpd_log = satellite.execute('journalctl --unit=httpd')
assert "WARNING" not in httpd_log.stdout
Expand Down
35 changes: 33 additions & 2 deletions tests/foreman/ui/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,28 @@ def test_positive_assign_ansible_role_variable_on_host(
module_org,
module_location,
):
"""Verify ansible variable is added to the role and attached to the host.
"""Verify ansible variable is added to the role and attached to the host and delete updated value in variable
:id: 7ec4fe19-5a08-4b10-bb4e-7327dd68699a
:BZ: 2170727
:Verifies: SAT-23109
:customerscenario: true
:steps:
1. Create an Ansible variable with array type and set the default value.
2. Enable both 'Merge Overrides' and 'Merge Default'.
3. Add the variable to a role and attach the role to the host.
4. Verify that ansible role and variable is added to the host.
5. Override the variable value.
6. Reset the overridden value to the original value.
:expectedresults: The role and variable is successfully added to the host.
:expectedresults:
1. The role and variable is successfully added to the host.
2. The overridden value in the variable was successfully deleted, and the default value remains unchanged.
"""

@request.addfinalizer
Expand Down Expand Up @@ -229,6 +236,30 @@ def _finalize():
(v['Name'], v['Ansible role'], v['Type'], v['Value']) for v in variable_table
]

new_key = gen_string('alpha')
session.ansiblevariables.create_with_overrides(
{
'key': new_key,
'ansible_role': SELECTED_ROLE[0],
'override': 'true',
'parameter_type': parameter_type,
'default_value': default_value,
}
)
new_value = '["test update"]'
# Update the value in a variable.
session.host_new.update_variable_value(rhel_contenthost.hostname, new_key, new_value)
update_value = session.host_new.read_variable_value(rhel_contenthost.hostname, new_key)
assert new_value in update_value

# Revert the updated value to its default state.
session.host_new.del_variable_value(rhel_contenthost.hostname)
reset_variable_value = session.host_new.read_variable_value(
rhel_contenthost.hostname, new_key
)
assert new_value not in reset_variable_value
assert default_value in reset_variable_value

@pytest.mark.tier3
@pytest.mark.parametrize('setting_update', ['ansible_roles_to_ignore'], indirect=True)
def test_positive_ansible_roles_ignore_list(self, target_sat, setting_update):
Expand Down
Loading

0 comments on commit c9e097d

Please sign in to comment.