Skip to content

Commit

Permalink
preparation for new yggdrasil
Browse files Browse the repository at this point in the history
  • Loading branch information
pondrejk committed Oct 25, 2024
1 parent a373ef2 commit 546521d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 27 deletions.
4 changes: 2 additions & 2 deletions tests/foreman/api/test_provisioningtemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 7 additions & 5 deletions tests/foreman/api/test_remoteexecution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
43 changes: 27 additions & 16 deletions tests/foreman/cli/test_remoteexecution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
{
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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}",
}
)
Expand Down Expand Up @@ -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(
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions tests/foreman/destructive/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 546521d

Please sign in to comment.