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 Dec 12, 2024
1 parent 8c12788 commit b8950e0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 25 deletions.
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 b8950e0

Please sign in to comment.