Skip to content

Commit

Permalink
Merge branch 'master' into add_capsule_provisioning_test
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauravtalreja1 authored Dec 26, 2023
2 parents 6a53dee + bf97bdb commit 9887e06
Show file tree
Hide file tree
Showing 23 changed files with 659 additions and 317 deletions.
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 @@ -40,7 +40,7 @@ jobs:
- name: Wait for other status checks to Pass
id: waitforstatuschecks
uses: lewagon/[email protected].1
uses: lewagon/[email protected].3
with:
ref: ${{ github.head_ref }}
repo-token: ${{ secrets.CHERRYPICK_PAT }}
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 @@ -51,7 +51,7 @@ jobs:

- name: Wait for other status checks to Pass
id: waitforstatuschecks
uses: lewagon/[email protected].1
uses: lewagon/[email protected].3
with:
ref: ${{ github.head_ref }}
repo-token: ${{ secrets.CHERRYPICK_PAT }}
Expand Down
13 changes: 12 additions & 1 deletion pytest_fixtures/component/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from nailgun.entity_mixins import call_entity_method_with_timeout
import pytest

from robottelo.constants import DEFAULT_ARCHITECTURE, PRDS, REPOS, REPOSET
from robottelo.config import settings
from robottelo.constants import DEFAULT_ARCHITECTURE, DEFAULT_ORG, PRDS, REPOS, REPOSET


@pytest.fixture(scope='module')
Expand Down Expand Up @@ -102,6 +103,16 @@ def module_repository(os_path, module_product, module_target_sat):
return repo


@pytest.fixture
def custom_synced_repo(target_sat):
custom_repo = target_sat.api.Repository(
product=target_sat.api.Product(organization=DEFAULT_ORG).create(),
url=settings.repos.yum_0.url,
).create()
custom_repo.sync()
return custom_repo


def _simplify_repos(request, repos):
"""This is a helper function that transforms repos_collection related fixture parameters into
a list that can be passed to robottelo.host_helpers.RepositoryMixins.RepositoryCollection
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Version updates managed by dependabot

betelgeuse==1.10.0
betelgeuse==1.11.0
broker[docker]==0.4.1
cryptography==41.0.7
deepdiff==6.7.1
Expand Down
23 changes: 13 additions & 10 deletions robottelo/host_helpers/cli_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ def _setup_org_for_a_rh_repo(self, options=None):
1. Checks if organization and lifecycle environment were given, otherwise
creates new ones.
2. Clones and uploads manifest.
2. If manifest does not exist, clone and upload it.
3. Enables RH repo and synchronizes it.
4. Checks if content view was given, otherwise creates a new one and
- adds the RH repo
Expand All @@ -717,15 +717,13 @@ def _setup_org_for_a_rh_repo(self, options=None):
env_id = self.make_lifecycle_environment({'organization-id': org_id})['id']
else:
env_id = options['lifecycle-environment-id']
# Clone manifest and upload it
with clone() as manifest:
self._satellite.put(manifest.path, manifest.name)
try:
self._satellite.cli.Subscription.upload(
{'file': manifest.name, 'organization-id': org_id}
)
except CLIReturnCodeError as err:
raise CLIFactoryError(f'Failed to upload manifest\n{err.msg}')
# If manifest does not exist, clone and upload it
if len(self._satellite.cli.Subscription.exists({'organization-id': org_id})) == 0:
with clone() as manifest:
try:
self._satellite.upload_manifest(org_id, manifest.content)
except CLIReturnCodeError as err:
raise CLIFactoryError(f'Failed to upload manifest\n{err.msg}')
# Enable repo from Repository Set
try:
self._satellite.cli.RepositorySet.enable(
Expand Down Expand Up @@ -820,6 +818,11 @@ def _setup_org_for_a_rh_repo(self, options=None):
),
}
)
# Override RHST product to true ( turned off by default in 6.14 )
rhel_repo = self._satellite.cli.Repository.info({'id': rhel_repo['id']})
self._satellite.cli.ActivationKey.content_override(
{'id': activationkey_id, 'content-label': rhel_repo['content-label'], 'value': 'true'}
)
return {
'activationkey-id': activationkey_id,
'content-view-id': cv_id,
Expand Down
1 change: 1 addition & 0 deletions scripts/polarion-test-case-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ TRANSFORM_CUSTOMERSCENARIO_VALUE = default_config._transform_to_lower
DEFAULT_CUSTOMERSCENARIO_VALUE = 'false'
DEFAULT_REQUIREMENT_TEAM_VALUE = None
TRANSFORM_REQUIREMENT_TEAM_VALUE = default_config._transform_to_lower
MARKERS_IGNORE_LIST = ['parametrize', 'skip.*', 'usefixtures', 'rhel_ver_.*']
EOF

set -x
Expand Down
2 changes: 1 addition & 1 deletion tests/foreman/api/test_audit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Tests for audit functionality.
:Requirement: Audit
:Requirement: AuditLog
:CaseAutomation: Automated
Expand Down
19 changes: 11 additions & 8 deletions tests/foreman/api/test_discoveryrule.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_positive_update_and_provision_with_rule_priority(

@pytest.mark.tier3
def test_positive_multi_provision_with_rule_limit(
module_target_sat, module_discovery_hostgroup, discovery_location, discovery_org
request, module_target_sat, module_discovery_hostgroup, discovery_location, discovery_org
):
"""Create a discovery rule with certain host limit and try to provision more than the passed limit
Expand All @@ -177,13 +177,12 @@ def test_positive_multi_provision_with_rule_limit(
:CaseImportance: High
"""
for _ in range(2):
discovered_host = module_target_sat.api_factory.create_discovered_host()

discovered_host1 = module_target_sat.api_factory.create_discovered_host()
discovered_host2 = module_target_sat.api_factory.create_discovered_host()
rule = module_target_sat.api.DiscoveryRule(
max_count=1,
hostgroup=module_discovery_hostgroup,
search_=f'name = {discovered_host["name"]}',
search_=f'name = {discovered_host1["name"]}',
location=[discovery_location],
organization=[discovery_org],
priority=1000,
Expand All @@ -192,6 +191,10 @@ def test_positive_multi_provision_with_rule_limit(
assert '1 discovered hosts were provisioned' in result['message']

# Delete discovery rule
rule.delete()
with pytest.raises(HTTPError):
rule.read()
@request.addfinalizer
def _finalize():
rule.delete()
module_target_sat.api.Host(id=discovered_host1['id']).delete()
module_target_sat.api.DiscoveredHost(id=discovered_host2['id']).delete()
with pytest.raises(HTTPError):
rule.read()
30 changes: 29 additions & 1 deletion tests/foreman/api/test_provisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def assert_host_logs(channel, pattern):


@pytest.mark.e2e
@pytest.mark.upgrade
@pytest.mark.parametrize('pxe_loader', ['bios', 'uefi'], indirect=True)
@pytest.mark.on_premises_provisioning
@pytest.mark.rhel_ver_match('[^6]')
Expand Down Expand Up @@ -185,12 +186,18 @@ def test_rhel_pxe_provisioning(
)
assert job['result'] == 'success', 'Job invocation failed'

# check if katello-ca-consumer is not used while host registration
assert provisioning_host.execute('rpm -qa |grep katello-ca-consumer').status == 1
assert (
'katello-ca-consumer' not in provisioning_host.execute('cat /root/install.post.log').stdout
)
# assert that the host is subscribed and consumes
# subsctiption provided by the activation key
assert provisioning_host.subscribed, 'Host is not subscribed'


@pytest.mark.e2e
@pytest.mark.upgrade
@pytest.mark.parametrize('pxe_loader', ['ipxe'], indirect=True)
@pytest.mark.on_premises_provisioning
@pytest.mark.rhel_ver_match('[^6]')
Expand Down Expand Up @@ -320,6 +327,7 @@ def test_rhel_ipxe_provisioning(

@pytest.mark.skip_if_open("BZ:2242925")
@pytest.mark.e2e
@pytest.mark.upgrade
@pytest.mark.parametrize('pxe_loader', ['http_uefi'], indirect=True)
@pytest.mark.on_premises_provisioning
@pytest.mark.rhel_ver_match('[^6]')
Expand Down Expand Up @@ -581,7 +589,6 @@ def test_rhel_pxe_provisioning_fips_enabled(
# subsctiption provided by the activation key
assert provisioning_host.subscribed, 'Host is not subscribed'


@pytest.mark.e2e
@pytest.mark.parametrize('pxe_loader', ['bios', 'uefi'], indirect=True)
@pytest.mark.parametrize('capsule_provisioning_rhel_content', [8], indirect=True)
Expand Down Expand Up @@ -705,3 +712,24 @@ def test_capsule_pxe_provisioning(
# assert that the host is subscribed and consumes
# subsctiption provided by the activation key
assert provisioning_host.subscribed, 'Host is not subscribed'


@pytest.mark.stubbed
def test_rhel_provisioning_using_realm():
"""Provision a host using realm
:id: 687e7d71-7e46-46d5-939b-4562f88c4598
:steps:
1. Configure satellite for provisioning
2. Configure Satellite for Realm support
3. Provision a Host
4. Check host is subscribed to Satellite
:expectedresults:
1. Provisioning via Realm is successful
2. Check if the provisioned host is automatically registered to IdM
3. Host installs right version of RHEL
4. Satellite is able to run REX job on the host
5. Host is registered to Satellite and subscription status is 'Success'
"""
63 changes: 62 additions & 1 deletion tests/foreman/api/test_provisioningtemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def test_positive_template_check_rex_snippet(
:steps:
1. Create a host by setting host params remote_execution_ssh_user, remote_execution_create_user, remote_execution_effective_user_method and remote_execution_ssh_keys
2. Read the provision templete to verify host params
2. Read the provision template to verify host params
:expectedresults: The rendered template has the host params set and correct home directory permissions for the rex user.
Expand Down Expand Up @@ -641,6 +641,67 @@ def test_positive_template_check_rex_snippet(
)
assert ssh_key in rex_snippet

@pytest.mark.parametrize('module_sync_kickstart_content', [7, 8, 9], indirect=True)
def test_positive_template_check_rex_pull_mode_snippet(
self,
module_sync_kickstart_content,
module_target_sat,
module_provisioning_capsule,
module_sca_manifest_org,
module_location,
module_default_org_view,
module_lce_library,
default_architecture,
default_partitiontable,
):
"""Read the provision template and verify the host params and REX pull mode snippet rendered correctly.
:id: e5212c46-d269-4bce-8e03-9d00c086e69m
:steps:
1. Create a host by setting host param enable-remote-execution-pull/host_registration_remote_execution_pull
2. Read the template to verify the host param and REX pull mode snippet for respective rhel hosts
:expectedresults: The rendered template has the host params set and correct home directory permissions for the rex user
:parametrized: yes
"""
host = module_target_sat.api.Host(
organization=module_sca_manifest_org,
location=module_location,
name=gen_string('alpha').lower(),
mac=gen_mac(multicast=False),
operatingsystem=module_sync_kickstart_content.os,
architecture=default_architecture,
domain=module_sync_kickstart_content.domain,
root_pass=settings.provisioning.host_root_password,
ptable=default_partitiontable,
host_parameters_attributes=[
{
'name': 'host_registration_remote_execution_pull',
'value': True,
'parameter_type': 'boolean',
},
{
'name': 'enable-remote-execution-pull',
'value': True,
'parameter_type': 'boolean',
},
],
).create()
rex_snippet = host.read_template(data={'template_kind': 'provision'})['template']
assert 'chmod +x /root/remote_execution_pull_setup.sh' in rex_snippet

rex_snippet = host.read_template(data={'template_kind': 'host_init_config'})['template']
assert 'Starting deployment of REX pull provider' in rex_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 'yggdrasil status' in rex_snippet
assert 'Remote execution pull provider successfully configured!' in rex_snippet

@pytest.mark.parametrize('module_sync_kickstart_content', [7, 8, 9], indirect=True)
def test_positive_template_check_fips_enabled(
self,
Expand Down
14 changes: 14 additions & 0 deletions tests/foreman/api/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from fauxfactory import gen_ipaddr, gen_mac
import pytest
from requests import HTTPError

from robottelo import constants
from robottelo.config import settings
Expand Down Expand Up @@ -213,3 +214,16 @@ def test_positive_rex_interface_for_global_registration(
assert interface['execution'] is True
assert interface['ip'] == ip
assert interface['mac'] == mac_address


@pytest.mark.tier1
def test_negative_global_registration_without_ak(module_target_sat):
"""Attempt to register a host without ActivationKey
:id: e48a6260-97e0-4234-a69c-77bbbcde85de
:expectedresults: Generate command is disabled without ActivationKey
"""
with pytest.raises(HTTPError) as context:
module_target_sat.api.RegistrationCommand().create()
assert 'Missing activation key!' in context.value.response.text
Loading

0 comments on commit 9887e06

Please sign in to comment.