Skip to content

Commit

Permalink
Merge branch 'master' into JacobCallahan-broker-05
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauravtalreja1 authored Jun 6, 2024
2 parents 3cfa9ee + f19655d commit bb0df25
Show file tree
Hide file tree
Showing 50 changed files with 992 additions and 1,245 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
/tests/foreman/api/test_subscription.py @SatelliteQE/phoenix
/tests/foreman/api/test_syncplan.py @SatelliteQE/phoenix
/tests/foreman/cli/test_activationkey.py @SatelliteQE/phoenix
/tests/foreman/cli/test_artifacts.py @SatelliteQE/phoenix
/tests/foreman/cli/test_capsulecontent.py @SatelliteQE/phoenix
/tests/foreman/cli/test_contentaccess.py @SatelliteQE/phoenix
/tests/foreman/cli/test_contentcredentials.py @SatelliteQE/phoenix
Expand Down
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ updates:
schedule:
interval: "daily"
labels:
- '6.16.z'
- "CherryPick"
- "dependencies"
- "6.15.z"
- "6.14.z"
- "6.13.z"
- "6.12.z"

# Maintain dependencies for our GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
labels:
- '6.16.z'
- "CherryPick"
- "dependencies"
- "6.15.z"
- "6.14.z"
- "6.13.z"
- "6.12.z"
2 changes: 1 addition & 1 deletion .github/dependency_tests.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
broker[docker,podman,hussh]: "tests/foreman/ -k 'test_host_registration_end_to_end or test_positive_erratum_applicability or test_positive_upload_content'"
deepdiff: "tests/foreman/endtoend/test_api_endtoend.py -k 'test_positive_get_links'"
dynaconf[vault]: "tests/foreman/api/test_ldapauthsource.py -k 'test_positive_endtoend'"
manifester: "tests/foreman/api/test_subscription.py -k 'test_positive_create_after_refresh'"
manifester: "tests/foreman/cli/test_contentview.py -k 'test_positive_promote_rh_content'"
navmazing: "tests/foreman/ui/test_repository.py -k 'test_positive_create_as_non_admin_user'"
pyotp: "tests/foreman/ui/test_ldap_authentication.py -k 'test_positive_login_user_password_otp'"
pytest-xdist: "tests/foreman/ -n 3 -m 'build_sanity'"
Expand Down
4 changes: 2 additions & 2 deletions .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.4.5
rev: v0.4.7
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.2
rev: v8.18.3
hooks:
- id: gitleaks
5 changes: 5 additions & 0 deletions conf/jira.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ JIRA:
URL: https://issues.redhat.com
# Provide api_key to access Jira REST API
API_KEY: replace-with-jira-api-key
COMMENT_TYPE: group
COMMENT_VISIBILITY: "Red Hat Employee"
ENABLE_COMMENT: false
# Comment only if jira is in one of the following state
ISSUE_STATUS: ["Review", "Release Pending"]
2 changes: 1 addition & 1 deletion conf/robottelo.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ROBOTTELO:
RUN_ONE_DATAPOINT: false
# Satellite version supported by this branch
# UNDR version is used for some URL composition
SATELLITE_VERSION: "6.16"
SATELLITE_VERSION: "6.17"
# The Base OS RHEL Version(x.y) where the satellite would be installed
RHEL_VERSION: "8.9"
# Dynaconf and Dynaconf hooks related options
Expand Down
2 changes: 2 additions & 0 deletions conf/subscription.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ SUBSCRIPTION:
RHN_PASSWORD:
# subscription pool id
RHN_POOLID:
# lifecycle API url
LIFECYCLE_API_URL:
10 changes: 0 additions & 10 deletions conf/vlan.yaml.template

This file was deleted.

5 changes: 3 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'pytest_plugins.requirements.update_requirements',
'pytest_plugins.sanity_plugin',
'pytest_plugins.video_cleanup',
'pytest_plugins.jira_comments',
'pytest_plugins.capsule_n-minus',
# Fixtures
'pytest_fixtures.core.broker',
Expand Down Expand Up @@ -79,9 +80,9 @@
def pytest_runtest_makereport(item, call):
# execute all other hooks to obtain the report object
outcome = yield
rep = outcome.get_result()
report = outcome.get_result()

# set a report attribute for each phase of a call, which can
# be "setup", "call", "teardown"

setattr(item, "rep_" + rep.when, rep)
setattr(item, "report_" + report.when, report)
11 changes: 0 additions & 11 deletions pytest_fixtures/component/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,3 @@ def discovery_location(module_location, module_target_sat):
discovery_loc = module_target_sat.update_setting('discovery_location', module_location.name)
yield module_location
module_target_sat.update_setting('discovery_location', discovery_loc)


@pytest.fixture(scope='module')
def provisioning_env(module_target_sat, discovery_org, discovery_location):
# Build PXE default template to get default PXE file
module_target_sat.cli.ProvisioningTemplate().build_pxe_default()
return module_target_sat.api_factory.configure_provisioning(
org=discovery_org,
loc=discovery_location,
os=f'Redhat {module_target_sat.cli_factory.RHELRepository().repo_data["version"]}',
)
3 changes: 2 additions & 1 deletion pytest_fixtures/component/http_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ def setup_http_proxy(request, module_manifest_org, target_sat):
yield http_proxy, request.param
target_sat.update_setting('content_default_http_proxy', content_proxy_value)
target_sat.update_setting('http_proxy', general_proxy_value)
http_proxy.delete()
if http_proxy:
http_proxy.delete()
92 changes: 92 additions & 0 deletions pytest_plugins/jira_comments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
from collections import defaultdict
import os

import pytest

from robottelo.config import settings
from robottelo.logging import logger
from robottelo.utils.issue_handlers.jira import add_comment_on_jira


def pytest_addoption(parser):
"""Add --jira-comments option to report test results on the Jira issue."""
help_comment = (
'Report/Comment test results on Jira issues. '
'Test results marked with "Verifies" or "BlockedBy" doc fields will be commented on the corresponding Jira issues. '
'Note: To prevent accidental use, users must set ENABLE_COMMENT to true in the jira.yaml configuration file.'
)
parser.addoption(
'--jira-comments',
action='store_true',
default=False,
help=help_comment,
)


def pytest_configure(config):
"""Register jira_comments markers to avoid warnings."""
config.addinivalue_line('markers', 'jira_comments: Add test result comment on Jira issue.')
pytest.jira_comments = config.getoption('jira_comments')


def update_issue_to_tests_map(item, marker, test_result):
"""If the test has Verifies or BlockedBy doc field,
an issue to tests mapping will be added/updated in config.issue_to_tests_map
for each test run with outcome of the test.
"""
if marker:
for issue in marker.args[0]:
item.config.issue_to_tests_map[issue].append(
{'nodeid': item.nodeid, 'outcome': test_result}
)


@pytest.hookimpl(trylast=True, hookwrapper=True)
def pytest_runtest_makereport(item, call):
"""Create jira issue to test result mapping. Used for commenting result on Jira."""
outcome = yield
verifies_marker = item.get_closest_marker('verifies_issues')
blocked_by_marker = item.get_closest_marker('blocked_by')
enable_jira_comments = item.config.getoption('jira_comments')
if (
settings.jira.enable_comment
and enable_jira_comments
and (verifies_marker or blocked_by_marker)
):
report = outcome.get_result()
if report.when == 'teardown':
test_result = (
'passed'
if (
item.report_setup.passed
and item.report_call.passed
and report.outcome == 'passed'
)
else 'failed'
)
if not hasattr(item.config, 'issue_to_tests_map'):
item.config.issue_to_tests_map = defaultdict(list)
# Update issue_to_tests_map for Verifies testimony marker
update_issue_to_tests_map(item, verifies_marker, test_result)
# Update issue_to_tests_map for BlockedBy testimony marker
update_issue_to_tests_map(item, blocked_by_marker, test_result)


def pytest_sessionfinish(session, exitstatus):
"""Add test result comment to related Jira issues."""
if hasattr(session.config, 'issue_to_tests_map'):
user = os.environ.get('USER')
build_url = os.environ.get('BUILD_URL')
for issue in session.config.issue_to_tests_map:
comment_body = (
f'This is an automated comment from job/user: {build_url if build_url else user} for a Robottelo test run.\n'
f'Satellite/Capsule: {settings.server.version.release} Snap: {settings.server.version.snap} \n'
f'Result for tests linked with issue: {issue} \n'
)
for item in session.config.issue_to_tests_map[issue]:
comment_body += f'{item["nodeid"]} : {item["outcome"]} \n'
try:
add_comment_on_jira(issue, comment_body)
except Exception as e:
# Handle any errors in adding comments to Jira
logger.warning(f'Failed to add comment to Jira issue {issue}: {e}')
10 changes: 5 additions & 5 deletions pytest_plugins/metadata_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def handle_verification_issues(item, verifies_marker, verifies_issues):
verifies_args = verifies_marker.args[0]
if all(issue not in verifies_issues for issue in verifies_args):
log_and_deselect(item, '--verifies-issues')
return False
return False
return True


Expand Down Expand Up @@ -163,8 +163,8 @@ def pytest_collection_modifyitems(items, config):

# split the option string and handle no option, single option, multiple
# config.getoption(default) doesn't work like you think it does, hence or ''
importance = [i for i in (config.getoption('importance') or '').split(',') if i != '']
component = [c for c in (config.getoption('component') or '').split(',') if c != '']
importance = [i.lower() for i in (config.getoption('importance') or '').split(',') if i != '']
component = [c.lower() for c in (config.getoption('component') or '').split(',') if c != '']
team = [a.lower() for a in (config.getoption('team') or '').split(',') if a != '']
verifies_issues = config.getoption('verifies_issues')
blocked_by = config.getoption('blocked_by')
Expand Down Expand Up @@ -192,10 +192,10 @@ def pytest_collection_modifyitems(items, config):
# only add the mark if it hasn't already been applied at a lower scope
doc_component = component_regex.findall(docstring)
if doc_component and 'component' not in item_mark_names:
item.add_marker(pytest.mark.component(doc_component[0]))
item.add_marker(pytest.mark.component(doc_component[0].lower()))
doc_importance = importance_regex.findall(docstring)
if doc_importance and 'importance' not in item_mark_names:
item.add_marker(pytest.mark.importance(doc_importance[0]))
item.add_marker(pytest.mark.importance(doc_importance[0].lower()))
doc_team = team_regex.findall(docstring)
if doc_team and 'team' not in item_mark_names:
item.add_marker(pytest.mark.team(doc_team[0].lower()))
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
apypie==0.4.0
betelgeuse==1.11.0
broker[docker,podman,hussh]==0.5.0
cryptography==42.0.7
cryptography==42.0.8
deepdiff==7.0.1
dynaconf[vault]==3.2.5
fauxfactory==3.1.1
jinja2==3.1.4
manifester==0.0.14
manifester==0.2.3
navmazing==1.2.2
productmd==1.38
pyotp==2.9.0
python-box==7.1.1
pytest==8.2.1
pytest==8.2.2
pytest-order==1.2.1
pytest-services==2.2.1
pytest-mock==3.14.0
Expand All @@ -22,7 +22,7 @@ pytest-xdist==3.6.1
pytest-fixturecollection==0.1.2
pytest-ibutsu==2.2.4
PyYAML==6.0.1
requests==2.32.2
requests==2.32.3
tenacity==8.3.0
testimony==2.4.0
wait-for==1.2.0
Expand Down
6 changes: 6 additions & 0 deletions robottelo/cli/contentview.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ def version_republish_repositories(cls, options):
cls.command_sub = 'version republish-repositories'
return cls.execute(cls._construct_command(options), ignore_stderr=True)

@classmethod
def version_verify_checksum(cls, options):
"""Verify checksum of repository contents in the content view version."""
cls.command_sub = 'version verify-checksum'
return cls.execute(cls._construct_command(options), ignore_stderr=True)

@classmethod
def remove_from_environment(cls, options=None):
"""Remove content-view from an environment"""
Expand Down
25 changes: 10 additions & 15 deletions robottelo/cli/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
synchronize Sync a repository
update Update a product
update-proxy Updates an HTTP Proxy for a product
verify-checksum Verify checksum for one or more products
"""

from robottelo.cli.base import Base
Expand All @@ -34,22 +35,14 @@ class Product(Base):

@classmethod
def remove_sync_plan(cls, options=None):
"""
Delete assignment sync plan and product.
"""

"""Delete assignment sync plan and product."""
cls.command_sub = 'remove-sync-plan'

return cls.execute(cls._construct_command(options))

@classmethod
def set_sync_plan(cls, options=None):
"""
Assign sync plan to product.
"""

"""Assign sync plan to product."""
cls.command_sub = 'set-sync-plan'

return cls.execute(cls._construct_command(options))

@classmethod
Expand All @@ -60,10 +53,12 @@ def synchronize(cls, options=None):

@classmethod
def update_proxy(cls, options=None):
"""
Assign Http Proxy to products.
"""

"""Assign Http Proxy to products."""
cls.command_sub = 'update-proxy'

return cls.execute(cls._construct_command(options))

@classmethod
def verify_checksum(cls, options=None):
"""Verify checksum for one or more products."""
cls.command_sub = 'verify-checksum'
return cls.execute(cls._construct_command(options), ignore_stderr=True)
13 changes: 13 additions & 0 deletions robottelo/cli/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
synchronize Sync a repository
update Update a repository
upload-content Upload content into the repository
verify-checksum Verify checksum of repository contents
"""

from robottelo.cli.base import Base
Expand Down Expand Up @@ -78,3 +79,15 @@ def upload_content(cls, options):
"""Upload content to repository."""
cls.command_sub = 'upload-content'
return cls.execute(cls._construct_command(options), output_format='csv', ignore_stderr=True)

@classmethod
def reclaim_space(cls, options):
"""Remove disk space from a synced repository"""
cls.command_sub = 'reclaim-space'
return cls.execute(cls._construct_command(options), output_format='csv', ignore_stderr=True)

@classmethod
def verify_checksum(cls, options):
"""Verify checksum of repository contents."""
cls.command_sub = 'verify-checksum'
return cls.execute(cls._construct_command(options), ignore_stderr=True)
9 changes: 9 additions & 0 deletions robottelo/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ def get_url():
return urlunsplit((scheme, hostname, '', '', ''))


def admin_nailgun_config():
"""Return a NailGun configuration file constructed from default admin user credentials.
:return: ``nailgun.config.ServerConfig`` object, populated from admin user credentials.
"""
return ServerConfig(get_url(), get_credentials(), verify=settings.server.verify_ca)


def user_nailgun_config(username=None, password=None):
"""Return a NailGun configuration file constructed from default values.
Expand Down
Loading

0 comments on commit bb0df25

Please sign in to comment.