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 7, 2025
1 parent 5c17f27 commit e51f432
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 129 deletions.
15 changes: 15 additions & 0 deletions pytest_fixtures/core/contenthosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,21 @@ def katello_host_tools_tracer_host(rex_contenthost, target_sat):
return rex_contenthost


@pytest.fixture
def rhel_contenthost_whith_repos(rhel_contenthost, target_sat):
"""Install katello-host-tools-tracer, create custom
repositories on the host"""
# create a custom, rhel version-specific OS repo
rhelver = rhel_contenthost.os_version.major
if rhelver > 7:
rhel_contenthost.create_custom_repos(**settings.repos[f'rhel{rhelver}_os'])
else:
rhel_contenthost.create_custom_repos(
**{f'rhel{rhelver}_os': settings.repos[f'rhel{rhelver}_os']}
)
return rhel_contenthost


@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
14 changes: 14 additions & 0 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,20 @@ def update_host_location(self, location):
host.location = location
host.update(['location'])

def get_yggdrasil_service_name(self):
# os_distribution_version doesn't get updated after leapp upgrade
distro_ver_list = self.execute(
"""grep '^VERSION_ID' /etc/os-release | awk -F'=' ' gsub(/"/,"") { print $2}'"""
).stdout.split('.')
return (
'yggdrasil'
if (
int(distro_ver_list[0]) > 9
or (int(distro_ver_list[0]) == 9 and int(distro_ver_list[1]) > 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 @@ -82,7 +82,7 @@ def test_positive_run_capsule_update_playbook(module_capsule_configured, target_

@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 @@ -95,7 +95,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 @@ -111,12 +111,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 @@ -127,7 +128,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 @@ -142,13 +143,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 @@ -162,7 +161,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 @@ -193,7 +192,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 @@ -208,15 +207,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 @@ -229,7 +228,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 @@ -245,13 +244,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 @@ -262,7 +261,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 @@ -286,7 +285,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
Loading

0 comments on commit e51f432

Please sign in to comment.