Skip to content

Commit

Permalink
Merge branch 'master' into katello-ca-crt
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamsg199 authored Aug 9, 2024
2 parents 71f8853 + d0308ee commit 66838c3
Show file tree
Hide file tree
Showing 51 changed files with 405 additions and 407 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dependency_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
id: yaml
uses: mikefarah/yq@master
with:
cmd: yq e '.["${{ steps.metadata.outputs.dependency-names }}"]' ./.github/dependency_tests.yaml
cmd: yq eval '.["${{ steps.metadata.outputs.dependency-names }}"]' ./.github/dependency_tests.yaml

- name: Add the PRT Comment
if: steps.yaml.outputs.result != 'null'
Expand Down
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ tests/foreman/pytest.ini
/conf/*.conf
!/conf/supportability.yaml

# I don't know where those 2 files come from
# but they are always there.
full_upgrade
upgrade_highlights

#Robottelo artifact
screenshots/
tmp/
Expand Down
4 changes: 2 additions & 2 deletions pytest_fixtures/component/rh_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def rhcloud_registered_hosts(
vm.configure_rhai_client(
satellite=module_target_sat,
activation_key=rhcloud_activation_key.name,
org=rhcloud_manifest_org.label,
org=rhcloud_manifest_org,
rhel_distro=f"rhel{vm.os_version.major}",
)
assert vm.subscribed
Expand All @@ -54,7 +54,7 @@ def rhel_insights_vm(
rhel_contenthost.configure_rhai_client(
satellite=module_target_sat,
activation_key=rhcloud_activation_key.name,
org=rhcloud_manifest_org.label,
org=rhcloud_manifest_org,
rhel_distro=f"rhel{rhel_contenthost.os_version.major}",
)
# Generate report
Expand Down
6 changes: 6 additions & 0 deletions pytest_plugins/metadata_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ def pytest_collection_modifyitems(items, config):
sat_version = settings.server.version.get('release')
snap_version = settings.server.version.get('snap', '')

# Satellite Network Type on which tests are running on
satellite_network_type = 'ipv6' if settings.server.is_ipv6 else 'ipv4'

# 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.lower() for i in (config.getoption('importance') or '').split(',') if i != '']
Expand Down Expand Up @@ -224,6 +227,9 @@ def pytest_collection_modifyitems(items, config):
item.user_properties.append(("SatelliteVersion", sat_version))
item.user_properties.append(("SnapVersion", snap_version))

# Network Type user property
item.user_properties.append(("SatelliteNetworkType", satellite_network_type))

# exit early if no filters were passed
if importance or component or team:
# Filter test collection based on CLI options for filtering
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

apypie==0.4.0
betelgeuse==1.11.0
broker[docker,podman,hussh]==0.5.2
broker[docker,podman,hussh]==0.5.3
cryptography==43.0.0
deepdiff==7.0.1
dynaconf[vault]==3.2.6
Expand All @@ -21,7 +21,7 @@ pytest-reportportal==5.4.1
pytest-xdist==3.6.1
pytest-fixturecollection==0.1.2
pytest-ibutsu==2.2.4
PyYAML==6.0.1
PyYAML==6.0.2
requests==2.32.3
tenacity==9.0.0
testimony==2.4.0
Expand Down
2 changes: 1 addition & 1 deletion robottelo/host_helpers/contenthost_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def get_facts(self):
if result.status == 0:
for line in result.stdout.splitlines():
if ': ' in line:
key, val = line.split(': ')
key, val = line.split(': ', 1)
else:
key = last_key
val = f'{fact_dict[key]} {line}'
Expand Down
129 changes: 33 additions & 96 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from broker.hosts import Host
from dynaconf.vendor.box.exceptions import BoxKeyError
from fauxfactory import gen_alpha, gen_string
from manifester import Manifester
from nailgun import entities
from packaging.version import Version
import requests
Expand All @@ -41,12 +40,8 @@
CUSTOM_PUPPET_MODULE_REPOS,
CUSTOM_PUPPET_MODULE_REPOS_PATH,
CUSTOM_PUPPET_MODULE_REPOS_VERSION,
DEFAULT_ARCHITECTURE,
HAMMER_CONFIG,
KEY_CLOAK_CLI,
PRDS,
REPOS,
REPOSET,
RHSSO_NEW_GROUP,
RHSSO_NEW_USER,
RHSSO_RESET_PASSWORD,
Expand Down Expand Up @@ -108,53 +103,6 @@ def get_sat_rhel_version():
return Version(rhel_version)


def setup_capsule(satellite, capsule, org, registration_args=None, installation_args=None):
"""Given satellite and capsule instances, run the commands needed to set up the capsule
Note: This does not perform content setup actions on the Satellite
:param satellite: An instance of this module's Satellite class
:param capsule: An instance of this module's Capsule class
:param org: An instance of the org to use on the Satellite
:param registration_args: A dictionary mapping argument: value pairs for registration
:param installation_args: A dictionary mapping argument: value pairs for installation
:return: An ssh2-python result object for the installation command.
"""
# Unregister capsule incase it's registered to CDN
capsule.unregister()

# Add a manifest to the Satellite
with Manifester(manifest_category=settings.manifest.entitlement) as manifest:
satellite.upload_manifest(org.id, manifest.content)

# Enable RHEL 8 BaseOS and AppStream repos and sync
for rh_repo_key in ['rhel8_bos', 'rhel8_aps']:
satellite.api_factory.enable_rhrepo_and_fetchid(
basearch=DEFAULT_ARCHITECTURE,
org_id=org.id,
product=PRDS['rhel8'],
repo=REPOS[rh_repo_key]['name'],
reposet=REPOSET[rh_repo_key],
releasever=REPOS[rh_repo_key]['releasever'],
)
product = satellite.api.Product(name=PRDS['rhel8'], organization=org.id).search()[0]
product.sync(timeout=1800, synchronous=True)

if not registration_args:
registration_args = {}
file, _, cmd_args = satellite.capsule_certs_generate(capsule)
if installation_args:
cmd_args.update(installation_args)
satellite.execute(
f'sshpass -p "{capsule.password}" scp -o "StrictHostKeyChecking no" '
f'{file} root@{capsule.hostname}:{file}'
)
capsule.install_katello_ca(satellite)
capsule.register_contenthost(org=org.label, **registration_args)
return capsule.install(cmd_args)


class ContentHostError(Exception):
pass

Expand Down Expand Up @@ -673,27 +621,6 @@ def remove_katello_ca(self):
self.execute('subscription-manager clean')
self._satellite = None

def install_capsule_katello_ca(self, capsule=None):
"""Downloads and installs katello-ca rpm on the broker virtual machine.
:param: str capsule: Capsule hostname
:raises robottelo.hosts.ContentHostError: If katello-ca wasn't
installed.
"""
warnings.warn(
message=(
'The install_capsule_katello_ca method is deprecated, '
'use the register method instead.'
),
category=DeprecationWarning,
stacklevel=2,
)
url = urlunsplit(('http', capsule, 'pub/', '', ''))
ca_url = urljoin(url, 'katello-ca-consumer-latest.noarch.rpm')
result = self.execute(f'rpm -Uvh {ca_url}')
if result.status != 0:
raise ContentHostError('Failed to install the katello-ca rpm')

def install_cockpit(self):
"""Installs cockpit on the broker virtual machine.
Expand Down Expand Up @@ -1097,8 +1024,19 @@ def configure_rex(self, satellite, org, subnet_id=None, by_ip=True, register=Tru
:param bool register: Whether to register to the Satellite. Keyexchange done regardless
"""
if register:
self.install_katello_ca(satellite)
self.register_contenthost(org.label, lce='Library')
ak = satellite.api.ActivationKey(
content_view=org.default_content_view.id,
environment=org.library.id,
organization=org,
).create()
self.register(
org,
None,
ak.name,
satellite,
setup_remote_execution=True,
setup_remote_execution_pull=True,
)
assert self.subscribed
self.add_rex_key(satellite=satellite)
if register and subnet_id is not None:
Expand Down Expand Up @@ -1134,10 +1072,15 @@ def configure_rhai_client(
:return: None
"""
if register:
# Install Satellite CA rpm
self.install_katello_ca(satellite)

self.register_contenthost(org, activation_key)
if not activation_key:
activation_key = satellite.api.ActivationKey(
content_view=org.default_content_view.id,
environment=org.library.id,
organization=org,
).create()
self.register(
org, None, activation_key.name, satellite, setup_insights=register_insights
)

# Red Hat Insights requires RHEL 6/7/8 repo and it is not
# possible to sync the repo during the tests, Adding repo file.
Expand All @@ -1157,17 +1100,10 @@ def configure_rhai_client(
else:
self.create_custom_repos(**{rhel_distro: rhel_repo})

# Install insights-client rpm
# Ensure insights-client rpm is installed
if self.execute('yum install -y insights-client').status != 0:
raise ContentHostError('Unable to install insights-client rpm')

if register_insights:
# Register client
if self.execute('insights-client --register').status != 0:
raise ContentHostError('Unable to register client to Insights through Satellite')
if self.execute('insights-client --test-connection').status != 0:
raise ContentHostError('Test connection failed via insights.')

def unregister_insights(self):
"""Unregister insights client.
Expand Down Expand Up @@ -1230,10 +1166,12 @@ def contenthost_setup(
"""
rh_repo_ids = rh_repo_ids or []
repo_labels = repo_labels or []
loc = location_title
if location_title:
self.set_facts({'locations.facts': {'foreman_location': str(location_title)}})
self.install_katello_ca(satellite)
result = self.register_contenthost(org_label, activation_key=activation_key, lce=lce)
loc = satellite.api.Location().search(query={'search': f'name="{location_title}"'})[0]
org = satellite.api.Organization().search(query={'search': f'name="{org_label}"'})[0]
result = self.register(org, loc, activation_key, satellite)
if not self.subscribed:
logger.info(result.stdout)
raise CLIFactoryError('Virtual machine failed subscription')
Expand Down Expand Up @@ -2224,13 +2162,12 @@ def register_host_custom_repo(self, module_org, rhel_contenthost, repo_urls):
assert task_status['result'] == 'success'

# register contenthost
rhel_contenthost.install_katello_ca(self)
register = rhel_contenthost.register_contenthost(
org=module_org.label,
lce='Library',
name=f'{gen_string("alpha")}-{rhel_contenthost.hostname}',
force=True,
)
ak = self.api.ActivationKey(
content_view=module_org.default_content_view.id,
environment=module_org.library.id,
organization=module_org,
).create()
register = rhel_contenthost.register(module_org, None, ak.name, self)
assert register.status == 0, (
f'Failed to register the host: {rhel_contenthost.hostname}:'
f'rc: {register.status}: {register.stderr}'
Expand Down
6 changes: 6 additions & 0 deletions robottelo/utils/datafactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from functools import wraps
import random
import string
from string import punctuation
from urllib.parse import quote_plus

from fauxfactory import gen_alpha, gen_integer, gen_string, gen_url, gen_utf8
Expand Down Expand Up @@ -625,6 +626,11 @@ def valid_url_list():
return [gen_url(scheme="http"), gen_url(scheme="https")]


@filtered_datapoint
def invalid_url_list():
return invalid_names_list() + [f'http://{gen_string("alpha")}{punctuation}.com']


@filtered_datapoint
def valid_cron_expressions():
"""Returns a list of valid cron expressions"""
Expand Down
2 changes: 1 addition & 1 deletion tests/foreman/api/test_capsulecontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,7 @@ def test_automatic_content_counts_update_toggle(
:BlockedBy: SAT-25503
:BZ: 2284027
:verifies: SAT-26453
:customerscenario: true
"""
Expand Down
2 changes: 2 additions & 0 deletions tests/foreman/api/test_computeresource_vmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def test_positive_provision_end_to_end(
:customerscenario: true
:BZ: 2186114
:verifies: SAT-18721
"""
sat = module_provisioning_sat.sat
name = gen_string('alpha').lower()
Expand Down
Loading

0 comments on commit 66838c3

Please sign in to comment.