Skip to content

Commit

Permalink
Merge branch 'subscription-entitlement-default' of github.com:sambibl…
Browse files Browse the repository at this point in the history
…e/robottelo into subscription-entitlement-default
  • Loading branch information
sambible committed Jan 16, 2024
2 parents 8168fba + 6088c5d commit 70969db
Show file tree
Hide file tree
Showing 36 changed files with 545 additions and 101 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto_assignment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
if: "!contains(github.event.pull_request.labels.*.name, 'Auto_Cherry_Picked')"
runs-on: ubuntu-latest
steps:
- uses: kentaro-m/[email protected].5
- uses: kentaro-m/[email protected].6
with:
configuration-path: ".github/auto_assign.yml"
2 changes: 1 addition & 1 deletion .github/workflows/auto_cherry_pick_merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- id: automerge
name: Auto merge of cherry-picked PRs.
uses: "pascalgn/[email protected].0"
uses: "pascalgn/[email protected].2"
env:
GITHUB_TOKEN: "${{ secrets.CHERRYPICK_PAT }}"
MERGE_LABELS: "AutoMerge_Cherry_Picked, Auto_Cherry_Picked"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:

- id: automerge
name: Auto merge of dependabot PRs.
uses: "pascalgn/[email protected].0"
uses: "pascalgn/[email protected].2"
env:
GITHUB_TOKEN: "${{ secrets.CHERRYPICK_PAT }}"
MERGE_LABELS: "dependencies"
Expand Down
4 changes: 3 additions & 1 deletion conf/ui.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ UI:
WEBDRIVER: chrome
# Binary location for selected wedriver (not needed if using saucelabs)
WEBDRIVER_BINARY: /usr/bin/chromedriver

RECORD_VIDEO: false
GRID_URL: http://infra-grid.example.com:4444
# Web_Kaifuku Settings (checkout https://github.com/RonnyPfannschmidt/webdriver_kaifuku)
WEBKAIFUKU:
webdriver: chrome/remote
webdriver_options:
command_executor: http://localhost:4444/wd/hub
desired_capabilities:
se:recordVideo: '@jinja {{ this.ui.record_video }}'
browserName: chrome
chromeOptions:
args:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ select = [
]

ignore = [
"B019", # lru_cache can lead to memory leaks - acceptable tradeoff
"E501", # line too long - handled by black
"PT004", # pytest underscrore prefix for non-return fixtures
"PT005", # pytest no underscrore prefix for return fixtures
Expand Down
2 changes: 1 addition & 1 deletion pytest_fixtures/component/provisioning_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def module_sync_kickstart_content(
"""
repo_names = []
tasks = []
rhel_ver = request.param
rhel_ver = request.param['rhel_version']
if int(rhel_ver) <= 7:
repo_names.append(f'rhel{rhel_ver}')
else:
Expand Down
21 changes: 15 additions & 6 deletions pytest_fixtures/component/virtwho_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
deploy_configure_by_command,
deploy_configure_by_script,
get_configure_command,
get_configure_command_option,
get_guest_info,
)

Expand Down Expand Up @@ -271,21 +272,29 @@ def deploy_type_cli(
form_data_cli,
virtwho_config_cli,
target_sat,
default_location,
):
deploy_type = request.param.lower()
assert virtwho_config_cli['status'] == 'No Report Yet'
if "id" in deploy_type:
command = get_configure_command(virtwho_config_cli['id'], org_module.name)
hypervisor_name, guest_name = deploy_configure_by_command(
command, form_data_cli['hypervisor-type'], debug=True, org=org_module.label
)
elif "script" in deploy_type:
if 'script' in deploy_type:
script = target_sat.cli.VirtWhoConfig.fetch(
{'id': virtwho_config_cli['id']}, output_format='base'
)
hypervisor_name, guest_name = deploy_configure_by_script(
script, form_data_cli['hypervisor-type'], debug=True, org=org_module.label
)
elif deploy_type == 'organization-title':
virtwho_config_cli['organization-title'] = org_module.title
elif deploy_type == 'location-id':
virtwho_config_cli['location-id'] = default_location.id
if deploy_type in ['id', 'name', 'organization-title', 'location-id']:
if 'id' in deploy_type:
command = get_configure_command(virtwho_config_cli['id'], org_module.name)
else:
command = get_configure_command_option(deploy_type, virtwho_config_cli, org_module.name)
hypervisor_name, guest_name = deploy_configure_by_command(
command, form_data_cli['hypervisor-type'], debug=True, org=org_module.label
)
return hypervisor_name, guest_name


Expand Down
1 change: 1 addition & 0 deletions pytest_plugins/fixture_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'content_hosts',
'module_provisioning_rhel_content',
'capsule_provisioning_rhel_content',
'module_sync_kickstart_content',
'rex_contenthost',
]

Expand Down
20 changes: 12 additions & 8 deletions pytest_plugins/video_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@


def _clean_video(session_id, test):
logger.info(f"cleaning up video files for session: {session_id} and test: {test}")
if settings.ui.record_video:
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.")
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):
Expand Down Expand Up @@ -67,6 +68,9 @@ def pytest_runtest_makereport(item):
if item.nodeid in test_results:
result_info = test_results[item.nodeid]
if result_info.outcome == 'passed':
report.user_properties = [
(key, value) for key, value in report.user_properties if key != 'video_url'
]
session_id_tuple = next(
(t for t in report.user_properties if t[0] == 'session_id'), None
)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cryptography==41.0.7
deepdiff==6.7.1
dynaconf[vault]==3.2.4
fauxfactory==3.1.0
jinja2==3.1.2
jinja2==3.1.3
manifester==0.0.14
navmazing==1.2.2
productmd==1.38
Expand Down
2 changes: 1 addition & 1 deletion robottelo/cli/content_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ContentExport(Base):
command_requires_org = True

@classmethod
def list(cls, output_format='json', options=None):
def list(cls, options=None, output_format='json'):
"""
List previous exports
"""
Expand Down
17 changes: 16 additions & 1 deletion robottelo/cli/hammer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,26 @@ def _normalize_obj(obj):
return obj


def is_csv(output):
"""Verifies if the output string is eligible for converting into CSV"""
sniffer = csv.Sniffer()
try:
sniffer.sniff(output)
return True
except csv.Error:
return False


def parse_csv(output):
"""Parse CSV output from Hammer CLI and convert it to python dictionary."""
# ignore warning about puppet and ostree deprecation
output.replace('Puppet and OSTree will no longer be supported in Katello 3.16\n', '')
reader = csv.reader(output.splitlines())
is_rex = True if 'Job invocation' in output else False
# Validate if the output is eligible for CSV conversions else return as it is
if not is_csv(output) and not is_rex:
return output
output = output.splitlines()[0:2] if is_rex else output.splitlines()
reader = csv.reader(output)
# Generate the key names, spaces will be converted to dashes "-"
keys = [_normalize(header) for header in next(reader)]
# For each entry, create a dict mapping each key with each value
Expand Down
2 changes: 1 addition & 1 deletion robottelo/cli/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def synchronize(cls, options, return_raw_response=None, timeout=3600000):
cls.command_sub = 'synchronize'
return cls.execute(
cls._construct_command(options),
output_format='csv',
output_format='base',
ignore_stderr=True,
return_raw_response=return_raw_response,
timeout=timeout,
Expand Down
5 changes: 2 additions & 3 deletions robottelo/host_helpers/cli_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
example: my_satellite.cli_factory.make_org()
"""
import datetime
from functools import partial
from functools import lru_cache, partial
import inspect
import os
from os import chmod
Expand All @@ -14,7 +14,6 @@
from time import sleep

from box import Box
from cachetools import cachedmethod
from fauxfactory import (
gen_alpha,
gen_alphanumeric,
Expand Down Expand Up @@ -295,7 +294,7 @@ def _evaluate_functions(self, iterable):
if not key.startswith('_')
}

@cachedmethod
@lru_cache
def _find_entity_class(self, entity_name):
entity_name = entity_name.replace('_', '').lower()
for name, class_obj in self._satellite.cli.__dict__.items():
Expand Down
6 changes: 3 additions & 3 deletions robottelo/host_helpers/satellite_mixins.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import contextlib
from functools import lru_cache
import io
import os
import random
import re

from cachetools import cachedmethod
import requests

from robottelo.cli.proxy import CapsuleTunnelError
Expand Down Expand Up @@ -235,7 +235,7 @@ def available_capsule_port(self):
:rtype: int
"""
port_pool_range = settings.fake_capsules.port_range
if isinstance(port_pool_range, list):
if isinstance(port_pool_range, str):
port_pool_range = tuple(port_pool_range.split('-'))
if isinstance(port_pool_range, tuple) and len(port_pool_range) == 2:
port_pool = range(int(port_pool_range[0]), int(port_pool_range[1]))
Expand Down Expand Up @@ -358,6 +358,6 @@ def api_factory(self):
self._api_factory = APIFactory(self)
return self._api_factory

@cachedmethod
@lru_cache
def ui_factory(self, session):
return UIFactory(self, session=session)
11 changes: 5 additions & 6 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from box import Box
from broker import Broker
from broker.hosts import Host
from cachetools import cachedmethod
from dynaconf.vendor.box.exceptions import BoxKeyError
from fauxfactory import gen_alpha, gen_string
from manifester import Manifester
Expand Down Expand Up @@ -1857,10 +1856,10 @@ def get_caller():
except Exception:
raise
finally:
video_url = settings.ui.grid_url.replace(
':4444', f'/videos/{ui_session.ui_session_id}.mp4'
)
if self.record_property is not None and settings.ui.record_video:
video_url = settings.ui.grid_url.replace(
':4444', f'/videos/{ui_session.ui_session_id}/video.mp4'
)
self.record_property('video_url', video_url)
self.record_property('session_id', ui_session.ui_session_id)

Expand Down Expand Up @@ -2283,7 +2282,7 @@ def get_rhsso_client_id(self):
break
return client_id

@cachedmethod
@lru_cache
def get_rhsso_user_details(self, username):
"""Getter method to receive the user id"""
result = self.execute(
Expand All @@ -2292,7 +2291,7 @@ def get_rhsso_user_details(self, username):
result_json = json.loads(result.stdout)
return result_json[0]

@cachedmethod
@lru_cache
def get_rhsso_groups_details(self, group_name):
"""Getter method to receive the group id"""
result = self.execute(f"{KEY_CLOAK_CLI} get groups -r {settings.rhsso.realm}")
Expand Down
17 changes: 16 additions & 1 deletion robottelo/utils/virtwho.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def virtwho_package_locked():
assert "Packages are locked" in result[1]


def create_http_proxy(org, name=None, url=None, http_type='https'):
def create_http_proxy(org, location, name=None, url=None, http_type='https'):
"""
Creat a new http-proxy with attributes.
:param name: Name of the proxy
Expand All @@ -524,5 +524,20 @@ def create_http_proxy(org, name=None, url=None, http_type='https'):
name=http_proxy_name,
url=http_proxy_url,
organization=[org.id],
location=[location.id],
).create()
return http_proxy.url, http_proxy.name, http_proxy.id


def get_configure_command_option(deploy_type, args, org=DEFAULT_ORG):
"""Return the deploy command line based on option.
:param str option: the unique id of the configure file you have created.
:param str org: the satellite organization name.
"""
username, password = Base._get_username_password()
if deploy_type == 'location-id':
return f"hammer -u {username} -p {password} virt-who-config deploy --id {args['id']} --location-id '{args['location-id']}' "
elif deploy_type == 'organization-title':
return f"hammer -u {username} -p {password} virt-who-config deploy --id {args['id']} --organization-title '{args['organization-title']}' "
elif deploy_type == 'name':
return f"hammer -u {username} -p {password} virt-who-config deploy --name {args['name']} --organization '{org}' "
8 changes: 4 additions & 4 deletions tests/foreman/api/test_discoveredhost.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def test_positive_provision_pxe_host(
mac = provisioning_host._broker_args['provisioning_nic_mac_addr']
wait_for(
lambda: sat.api.DiscoveredHost().search(query={'mac': mac}) != [],
timeout=600,
timeout=1500,
delay=40,
)
discovered_host = sat.api.DiscoveredHost().search(query={'mac': mac})[0]
Expand Down Expand Up @@ -251,7 +251,7 @@ def test_positive_provision_pxe_less_host(
mac = pxeless_discovery_host._broker_args['provisioning_nic_mac_addr']
wait_for(
lambda: sat.api.DiscoveredHost().search(query={'mac': mac}) != [],
timeout=600,
timeout=1500,
delay=40,
)
discovered_host = sat.api.DiscoveredHost().search(query={'mac': mac})[0]
Expand Down Expand Up @@ -386,7 +386,7 @@ def test_positive_reboot_pxe_host(
mac = provisioning_host._broker_args['provisioning_nic_mac_addr']
wait_for(
lambda: sat.api.DiscoveredHost().search(query={'mac': mac}) != [],
timeout=240,
timeout=1500,
delay=20,
)

Expand Down Expand Up @@ -432,7 +432,7 @@ def test_positive_reboot_all_pxe_hosts(
mac = host._broker_args['provisioning_nic_mac_addr']
wait_for(
lambda: sat.api.DiscoveredHost().search(query={'mac': mac}) != [], # noqa: B023
timeout=240,
timeout=1500,
delay=20,
)
discovered_host = sat.api.DiscoveredHost().search(query={'mac': mac})[0]
Expand Down
1 change: 1 addition & 0 deletions tests/foreman/api/test_provisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ def test_rhel_pxe_provisioning_fips_enabled(

@pytest.mark.e2e
@pytest.mark.parametrize('pxe_loader', ['bios', 'uefi'], indirect=True)
@pytest.mark.on_premises_provisioning
@pytest.mark.rhel_ver_match('[^6]')
def test_capsule_pxe_provisioning(
request,
Expand Down
Loading

0 comments on commit 70969db

Please sign in to comment.