Skip to content

Commit

Permalink
more adjustments for pull rex on rhel10
Browse files Browse the repository at this point in the history
  • Loading branch information
pondrejk committed Feb 25, 2025
1 parent 3f9cf29 commit ac5e4b2
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 146 deletions.
14 changes: 14 additions & 0 deletions pytest_fixtures/core/contenthosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,20 @@ def katello_host_tools_tracer_host(rex_contenthost, target_sat):
return rex_contenthost


@pytest.fixture
def rhel_contenthost_with_repos(request, target_sat):
"""Install katello-host-tools-tracer, create custom
repositories on the host"""
with Broker(**host_conf(request), host_class=ContentHost) as host:
# create a custom, rhel version-specific OS repo
rhelver = request.param['rhel_version']
if rhelver > 7:
host.create_custom_repos(**settings.repos[f'rhel{rhelver}_os'])
else:
host.create_custom_repos(**{f'rhel{rhelver}_os': settings.repos[f'rhel{rhelver}_os']})
yield host


@pytest.fixture(scope='module')
def module_container_contenthost(request, module_target_sat, module_org, module_activation_key):
"""Fixture that installs docker on the content host"""
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 @@ -5,6 +5,7 @@

TARGET_FIXTURES = [
'rhel_contenthost',
'rhel_contenthost_with_repos',
'module_rhel_contenthost',
'mod_content_hosts',
'content_hosts',
Expand Down
10 changes: 10 additions & 0 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,16 @@ def update_host_location(self, location):
host.location = location
host.update(['location'])

def get_yggdrasil_service_name(self):
return (
'yggdrasil'
if (
self.os_version.major > 9
or (self.os_version.major == 9 and self.os_version.minor > 5)
)
else 'yggdrasild'
)


class Capsule(ContentHost, CapsuleMixins):
rex_key_path = '~foreman-proxy/.ssh/id_rsa_foreman_proxy.pub'
Expand Down
37 changes: 18 additions & 19 deletions tests/foreman/api/test_remoteexecution.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_positive_find_capsule_upgrade_playbook(target_sat):

@pytest.mark.tier3
@pytest.mark.no_containers
@pytest.mark.rhel_ver_list('8')
@pytest.mark.rhel_ver_list([settings.content_host.default_rhel_version])
@pytest.mark.parametrize(
'setting_update',
['remote_execution_global_proxy=False'],
Expand All @@ -53,7 +53,7 @@ def test_negative_time_to_pickup(
smart_proxy_location,
module_ak_with_cv,
module_capsule_configured_mqtt,
rhel_contenthost,
rhel_contenthost_with_repos,
setting_update,
):
"""Time to pickup setting is honored for host registered to mqtt
Expand All @@ -69,12 +69,13 @@ def test_negative_time_to_pickup(
:parametrized: yes
"""
client = rhel_contenthost_with_repos
client_repo = ohsnap.dogfood_repository(
settings.ohsnap,
product='client',
repo='client',
release='client',
os_release=rhel_contenthost.os_version.major,
os_release=client.os_version.major,
)
# Update module_capsule_configured_mqtt to include module_org/smart_proxy_location
module_target_sat.cli.Capsule.update(
Expand All @@ -85,7 +86,7 @@ def test_negative_time_to_pickup(
}
)
# register host with pull provider rex
result = rhel_contenthost.register(
result = client.register(
module_org,
smart_proxy_location,
module_ak_with_cv.name,
Expand All @@ -100,13 +101,11 @@ def test_negative_time_to_pickup(
)
assert result.status == 0, f'Failed to register host: {result.stderr}'
# check mqtt client is running
service_name = (
'yggdrasil' if float(rhel_contenthost.os_distribution_version) > 9.5 else 'yggdrasild'
)
result = rhel_contenthost.execute(f'systemctl status {service_name}')
service_name = client.get_yggdrasil_service_name()
result = client.execute(f'systemctl status {service_name}')
assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}'
# stop yggdrasil client on host
result = rhel_contenthost.execute(f'systemctl stop {service_name}')
result = client.execute(f'systemctl stop {service_name}')
assert result.status == 0, f'Failed to stop yggdrasil on client: {result.stderr}'

# run script provider rex command with time_to_pickup
Expand All @@ -120,7 +119,7 @@ def test_negative_time_to_pickup(
'command': 'ls -la',
},
'targeting_type': 'static_query',
'search_query': f'name = {rhel_contenthost.hostname}',
'search_query': f'name = {client.hostname}',
'time_to_pickup': '10',
},
)
Expand Down Expand Up @@ -151,7 +150,7 @@ def test_negative_time_to_pickup(
'command': 'ls -la',
},
'targeting_type': 'static_query',
'search_query': f'name = {rhel_contenthost.hostname}',
'search_query': f'name = {client.hostname}',
},
)
module_target_sat.wait_for_tasks(
Expand All @@ -166,15 +165,15 @@ def test_negative_time_to_pickup(
global_ttp.value = default_global_ttp
global_ttp.update(['value'])
# start yggdrasil client on host
result = rhel_contenthost.execute(f'systemctl start {service_name}')
result = client.execute(f'systemctl start {service_name}')
assert result.status == 0, f'Failed to start on client: {result.stderr}'
result = rhel_contenthost.execute(f'systemctl status {service_name}')
result = client.execute(f'systemctl status {service_name}')
assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}'


@pytest.mark.tier3
@pytest.mark.no_containers
@pytest.mark.rhel_ver_list('8')
@pytest.mark.rhel_ver_list([settings.content_host.default_rhel_version])
@pytest.mark.parametrize(
'setting_update',
['remote_execution_global_proxy=False'],
Expand All @@ -187,7 +186,7 @@ def test_positive_check_longrunning_job(
smart_proxy_location,
module_ak_with_cv,
module_capsule_configured_mqtt,
rhel_contenthost,
rhel_contenthost_with_repos,
setting_update,
):
"""Time to pickup setting doesn't disrupt longrunning jobs
Expand All @@ -203,13 +202,13 @@ def test_positive_check_longrunning_job(
:parametrized: yes
"""

client = rhel_contenthost_with_repos
client_repo = ohsnap.dogfood_repository(
settings.ohsnap,
product='client',
repo='client',
release='client',
os_release=rhel_contenthost.os_version.major,
os_release=client.os_version.major,
)
# Update module_capsule_configured_mqtt to include module_org/smart_proxy_location
module_target_sat.cli.Capsule.update(
Expand All @@ -220,7 +219,7 @@ def test_positive_check_longrunning_job(
}
)
# register host with pull provider rex
result = rhel_contenthost.register(
result = client.register(
module_org,
smart_proxy_location,
module_ak_with_cv.name,
Expand All @@ -244,7 +243,7 @@ def test_positive_check_longrunning_job(
'command': 'echo start; sleep 25; echo done',
},
'targeting_type': 'static_query',
'search_query': f'name = {rhel_contenthost.hostname}',
'search_query': f'name = {client.hostname}',
'time_to_pickup': '20',
},
)
Expand Down
15 changes: 2 additions & 13 deletions tests/foreman/cli/test_leapp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@
from robottelo.utils import ohsnap


def get_yggdrasil_service_name(rhel_contenthost):
return (
'yggdrasil'
if (
rhel_contenthost.os_version.major > 9
or (rhel_contenthost.os_version.major == 9 and rhel_contenthost.os_version.minor > 5)
)
else 'yggdrasild'
)


@pytest.mark.e2e
@pytest.mark.parametrize(
'upgrade_path',
Expand Down Expand Up @@ -216,7 +205,7 @@ def test_positive_ygdrassil_client_after_leapp_upgrade(
)
assert result.status == 0, f'Failed to register host: {result.stderr}'

service_name = get_yggdrasil_service_name(custom_leapp_host)
service_name = custom_leapp_host.get_yggdrasil_service_name()
result = custom_leapp_host.execute(f'systemctl status {service_name}')
assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}'

Expand Down Expand Up @@ -262,7 +251,7 @@ def test_positive_ygdrassil_client_after_leapp_upgrade(
assert str(custom_leapp_host.os_version) == upgrade_path['target_version']

# check mqtt still works after upgrade
service_name = get_yggdrasil_service_name(custom_leapp_host)
service_name = custom_leapp_host.get_yggdrasil_service_name()
result = custom_leapp_host.execute(f'systemctl status {service_name}')
assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}'

Expand Down
Loading

0 comments on commit ac5e4b2

Please sign in to comment.