Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more adjustments for pull rex on rhel10 #17551

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1534,6 +1534,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 @@ -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
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