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

preparation for new yggdrasil #16789

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
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 = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be in one place? If not, can at least the versions be constants?

'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
Loading