-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into nilclass-publish
- Loading branch information
Showing
38 changed files
with
715 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""Robottelo configuration migrations | ||
This module contains functions that are run after the configuration is loaded. Each function | ||
should be named `migration_<YYMMDD>_<description>` and accept two parameters: `settings` and | ||
`data`. `settings` is a `dynaconf` `Box` object containing the configuration. `data` is a | ||
`dict` that can be used to store settings that will be merged with the rest of the settings. | ||
The functions should not return anything. | ||
""" | ||
|
||
from packaging.version import Version | ||
|
||
from robottelo.logging import logger | ||
|
||
|
||
def migration_231129_deploy_workflow(settings, data): | ||
"""Migrates {server,capsule}.deploy_workflow to {server,capsule}.deploy_workflows""" | ||
for product_type in ['server', 'capsule']: | ||
# If the product_type has a deploy_workflow and it is a string, and | ||
# it does not have a deploy_workflows set | ||
if ( | ||
settings[product_type].get('deploy_workflow') | ||
and isinstance(settings[product_type].deploy_workflow, str) | ||
and not settings[product_type].get('deploy_workflows') | ||
): | ||
sat_rhel_version = settings[product_type].version.rhel_version | ||
data[product_type] = {} | ||
# Set the deploy_workflows to a dict with product and os keys | ||
# Get the OS workflow from the content_host config | ||
data[product_type].deploy_workflows = { | ||
'product': settings[product_type].deploy_workflow, | ||
'os': settings.content_host[ | ||
f'rhel{Version(str(sat_rhel_version)).major}' | ||
].vm.workflow, | ||
} | ||
logger.info( | ||
f'Migrated {product_type}.DEPLOY_WORKFLOW to {product_type}.DEPLOY_WORKFLOWS' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from urllib.parse import urlparse | ||
|
||
from box import Box | ||
from broker.hosts import Host | ||
import pytest | ||
|
||
from robottelo.config import settings | ||
from robottelo.logging import logger | ||
|
||
test_results = {} | ||
test_directories = [ | ||
'tests/foreman/destructive', | ||
'tests/foreman/ui', | ||
'tests/foreman/sanity', | ||
'tests/foreman/virtwho', | ||
] | ||
|
||
|
||
def _clean_video(session_id, test): | ||
logger.info(f"cleaning up video files for session: {session_id} and test: {test}") | ||
|
||
if settings.ui.grid_url and session_id: | ||
grid = urlparse(url=settings.ui.grid_url) | ||
infra_grid = Host(hostname=grid.hostname) | ||
infra_grid.execute(command=f'rm -rf /var/www/html/videos/{session_id}') | ||
logger.info(f"video cleanup for session {session_id} is complete") | ||
else: | ||
logger.warning("missing grid_url or session_id. unable to clean video files.") | ||
|
||
|
||
def pytest_addoption(parser): | ||
"""Custom pytest option to skip video cleanup on test success. | ||
Args: | ||
parser (object): The pytest command-line option parser. | ||
Options: | ||
--skip-video-cleanup: Skip video cleaning on test success (default: False). | ||
""" | ||
parser.addoption( | ||
"--skip-video-cleanup", | ||
action="store_true", | ||
default=False, | ||
help="Skip video cleaning on test success", | ||
) | ||
|
||
|
||
@pytest.hookimpl(tryfirst=True, hookwrapper=True) | ||
def pytest_runtest_makereport(item): | ||
"""Custom pytest hook to capture test outcomes and perform video cleanup. | ||
Note: | ||
This hook captures test results during 'call' and performs video cleanup | ||
during 'teardown' if the test passed and the '--skip-video-cleanup' option is not set. | ||
""" | ||
outcome = yield | ||
report = outcome.get_result() | ||
skip_video_cleanup = item.config.getoption("--skip-video-cleanup", False) | ||
|
||
if not skip_video_cleanup and any(directory in report.fspath for directory in test_directories): | ||
if report.when == "call": | ||
test_results[item.nodeid] = Box( | ||
{ | ||
'outcome': report.outcome, | ||
'duration': report.duration, | ||
'longrepr': str(report.longrepr), | ||
} | ||
) | ||
if report.when == "teardown": | ||
if item.nodeid in test_results: | ||
result_info = test_results[item.nodeid] | ||
if result_info.outcome == 'passed': | ||
session_id_tuple = next( | ||
(t for t in report.user_properties if t[0] == 'session_id'), None | ||
) | ||
session_id = session_id_tuple[1] if session_id_tuple else None | ||
_clean_video(session_id, item.nodeid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.