From 546521d054571465174df5a8d64eb302f7094637 Mon Sep 17 00:00:00 2001 From: Peter Ondrejka Date: Fri, 25 Oct 2024 15:31:17 +0200 Subject: [PATCH] preparation for new yggdrasil --- .../foreman/api/test_provisioningtemplate.py | 4 +- tests/foreman/api/test_remoteexecution.py | 12 +++--- tests/foreman/cli/test_remoteexecution.py | 43 ++++++++++++------- .../foreman/destructive/test_registration.py | 9 ++-- 4 files changed, 41 insertions(+), 27 deletions(-) diff --git a/tests/foreman/api/test_provisioningtemplate.py b/tests/foreman/api/test_provisioningtemplate.py index 606153d703d..aeb84e64674 100644 --- a/tests/foreman/api/test_provisioningtemplate.py +++ b/tests/foreman/api/test_provisioningtemplate.py @@ -646,8 +646,8 @@ def test_positive_template_check_rex_pull_mode_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 'systemctl try-restart $YGGDRASIL_SERVICE' in rex_snippet + assert 'systemctl enable --now $YGGDRASIL_SERVICE' in rex_snippet assert 'yggdrasil status' in rex_snippet assert 'Remote execution pull provider successfully configured!' in rex_snippet diff --git a/tests/foreman/api/test_remoteexecution.py b/tests/foreman/api/test_remoteexecution.py index a551e3a3f88..d5d1b2b0187 100644 --- a/tests/foreman/api/test_remoteexecution.py +++ b/tests/foreman/api/test_remoteexecution.py @@ -142,10 +142,13 @@ def test_negative_time_to_pickup( ) assert result.status == 0, f'Failed to register host: {result.stderr}' # check mqtt client is running - result = rhel_contenthost.execute('systemctl status yggdrasild') + service_name = ( + 'yggdrasil' if float(rhel_contenthost.os_distribution_version) > 9.5 else 'yggdrasild' + ) + result = rhel_contenthost.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('systemctl stop yggdrasild') + result = rhel_contenthost.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 @@ -205,11 +208,10 @@ 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('systemctl start yggdrasild') + result = rhel_contenthost.execute(f'systemctl start {service_name}') assert result.status == 0, f'Failed to start on client: {result.stderr}' - result = rhel_contenthost.execute('systemctl status yggdrasild') + result = rhel_contenthost.execute(f'systemctl status {service_name}') assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}' - rhel_contenthost.execute('yggdrasil status') @pytest.mark.tier3 diff --git a/tests/foreman/cli/test_remoteexecution.py b/tests/foreman/cli/test_remoteexecution.py index b0b6bef7aa7..058bc46f71e 100644 --- a/tests/foreman/cli/test_remoteexecution.py +++ b/tests/foreman/cli/test_remoteexecution.py @@ -1020,13 +1020,14 @@ def test_positive_run_job_on_host_converted_to_pull_provider( ) assert result.status == 0, f'Failed to register host: {result.stderr}' + service_name = ( + 'yggdrasil' if float(rhel_contenthost.os_distribution_version) > 9.5 else 'yggdrasild' + ) # install conversion script (SAT-1670) result = rhel_contenthost.execute('yum install -y katello-pull-transport-migrate') assert result.status == 0, 'Failed to install katello-pull-transport-migrate' # check mqtt client is running - result = rhel_contenthost.execute('systemctl status yggdrasild') - assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}' - result = rhel_contenthost.execute('systemctl status yggdrasild') + result = rhel_contenthost.execute(f'systemctl status {service_name}') assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}' # run script provider rex command invocation_command = module_target_sat.cli_factory.job_invocation( @@ -1052,9 +1053,7 @@ def test_positive_run_job_on_host_converted_to_pull_provider( ) # check katello-agent removal did not influence ygdrassil (SAT-1672) - result = rhel_contenthost.execute('systemctl status yggdrasild') - assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}' - result = rhel_contenthost.execute('systemctl status yggdrasild') + result = rhel_contenthost.execute(f'systemctl status {service_name}') assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}' invocation_command = module_target_sat.cli_factory.job_invocation( { @@ -1123,19 +1122,22 @@ def test_positive_run_job_in_chosen_directory( ignore_subman_errors=True, force=True, ) - assert result.status == 0, f'Failed to register host: {result.stderr}' + # check mqtt client is running - result = rhel_contenthost.execute('systemctl status yggdrasild') + service_name = ( + 'yggdrasil' if float(rhel_contenthost.os_distribution_version) > 9.5 else 'yggdrasild' + ) + result = rhel_contenthost.execute(f'systemctl status {service_name}') assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}' # create a new directory and set in in yggdrasil path = f'/{gen_string("alpha")}' - config_path_dir = '/etc/systemd/system/yggdrasild.service.d/' + config_path_dir = f'/etc/systemd/system/{service_name}.service.d/' config_path = f'{config_path_dir}/override.conf' assert ( rhel_contenthost.execute( - f'mkdir {path} && mount -t tmpfs tmpfs {path} && mkdir {config_path_dir} && echo -e "[Service]\nEnvironment=FOREMAN_YGG_WORKER_WORKDIR={path}" > {config_path} && systemctl daemon-reload && systemctl restart yggdrasild' + f'mkdir {path} && mount -t tmpfs tmpfs {path} && mkdir {config_path_dir} && echo -e "[Service]\nEnvironment=FOREMAN_YGG_WORKER_WORKDIR={path}" > {config_path} && systemctl daemon-reload && systemctl restart {service_name}' ).status == 0 ) @@ -1234,13 +1236,16 @@ def test_positive_run_job_on_host_registered_to_pull_provider( assert result.status == 0, f'Failed to register host: {result.stderr}' # check mqtt client is running - result = rhel_contenthost.execute('systemctl status yggdrasild') + service_name = ( + 'yggdrasil' if float(rhel_contenthost.os_distribution_version) > 9.5 else 'yggdrasild' + ) + result = rhel_contenthost.execute(f'systemctl status {service_name}') assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}' # run script provider rex command invocation_command = module_target_sat.cli_factory.job_invocation( { 'job-template': 'Service Action - Script Default', - 'inputs': 'action=status, service=yggdrasild', + 'inputs': f'action=status, service={service_name}', 'search-query': f"name ~ {rhel_contenthost.hostname}", } ) @@ -1330,10 +1335,13 @@ def test_positive_run_pull_job_on_offline_host( assert result.status == 0, f'Failed to register host: {result.stderr}' # check mqtt client is running - result = rhel_contenthost.execute('systemctl status yggdrasild') + service_name = ( + 'yggdrasil' if float(rhel_contenthost.os_distribution_version) > 9.5 else 'yggdrasild' + ) + result = rhel_contenthost.execute(f'systemctl status {service_name}') assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}' # stop the client on host - result = rhel_contenthost.execute('systemctl stop yggdrasild') + result = rhel_contenthost.execute(f'systemctl stop {service_name}') assert result.status == 0, f'Failed to stop yggdrasil on client: {result.stderr}' # run script provider rex command invocation_command = module_target_sat.cli_factory.job_invocation( @@ -1349,7 +1357,7 @@ def test_positive_run_pull_job_on_offline_host( module_target_sat, invocation_command['id'], rhel_contenthost.hostname, 'running' ) # start client on host - result = rhel_contenthost.execute('systemctl start yggdrasild') + result = rhel_contenthost.execute(f'systemctl status {service_name}') assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}' # wait twice the mqtt_resend_interval (set in module_capsule_configured_mqtt) sleep(60) @@ -1420,7 +1428,10 @@ def test_positive_apply_errata_on_pull_provider_host( assert result.status == 0, f'Failed to register host: {result.stderr}' # check mqtt client is running - result = rhel_contenthost.execute('systemctl status yggdrasild') + service_name = ( + 'yggdrasil' if float(rhel_contenthost.os_distribution_version) > 9.5 else 'yggdrasild' + ) + result = rhel_contenthost.execute(f'systemctl status {service_name}') assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}' # enable repo, install old pkg diff --git a/tests/foreman/destructive/test_registration.py b/tests/foreman/destructive/test_registration.py index 083bbaff6bd..4e0149b1e15 100644 --- a/tests/foreman/destructive/test_registration.py +++ b/tests/foreman/destructive/test_registration.py @@ -52,9 +52,11 @@ def test_host_registration_rex_pull_mode( assert result.status == 0, f'Failed to register host: {result.stderr}' # check mqtt client is running - result = rhel_contenthost.execute('systemctl status yggdrasild') + service_name = ( + 'yggdrasil' if float(rhel_contenthost.os_distribution_version) > 9.5 else 'yggdrasild' + ) + result = rhel_contenthost.execute(f'systemctl status {service_name}') assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}' - assert rhel_contenthost.execute('yggdrasil status').status == 0 mqtt_url = f'mqtts://{module_satellite_mqtt.hostname}:1883' assert rhel_contenthost.execute(f'cat /etc/yggdrasil/config.toml | grep {mqtt_url}').status == 0 @@ -77,9 +79,8 @@ def test_host_registration_rex_pull_mode( assert result.status == 0, f'Failed to register host: {result.stderr}' # check mqtt client is running - result = rhel_contenthost.execute('systemctl status yggdrasild') + result = rhel_contenthost.execute(f'systemctl status {service_name}') assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}' - assert rhel_contenthost.execute('yggdrasil status').status == 0 new_mqtt_url = f'mqtts://{module_capsule_configured_mqtt.hostname}:1883' assert ( rhel_contenthost.execute(f'cat /etc/yggdrasil/config.toml | grep {new_mqtt_url}').status