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

[6.15.z] fix for remote execution cli tests #13172

Merged
Merged
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
43 changes: 28 additions & 15 deletions tests/foreman/cli/test_remoteexecution.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def test_positive_run_custom_job_template(self, rex_contenthost, module_org, tar
invocation_command = target_sat.cli_factory.job_invocation(
{'job-template': template_name, 'search-query': f'name ~ {client.hostname}'}
)
assert_job_invocation_result(invocation_command['id'], client.hostname)
assert_job_invocation_result(target_sat, invocation_command['id'], client.hostname)

@pytest.mark.tier3
@pytest.mark.upgrade
Expand Down Expand Up @@ -320,7 +320,7 @@ def test_positive_install_remove_multiple_packages_with_a_job(
'search-query': f'name ~ {client.hostname}',
}
)
assert_job_invocation_result(invocation_command['id'], client.hostname)
assert_job_invocation_result(target_sat, invocation_command['id'], client.hostname)
post_versions = client.run(f'rpm -q {" ".join(packages)}').stdout.splitlines()
assert set(pre_versions) == set(post_versions)
# Remove packages
Expand Down Expand Up @@ -808,7 +808,7 @@ def test_positive_run_packages_and_services_job(
'search-query': f'name ~ {client.hostname}',
}
)
assert_job_invocation_result(invocation_command['id'], client.hostname)
assert_job_invocation_result(target_sat, invocation_command['id'], client.hostname)
result = client.run(f'rpm -q {" ".join(packages)}')
assert result.status == 0

Expand All @@ -821,7 +821,7 @@ def test_positive_run_packages_and_services_job(
'search-query': f"name ~ {client.hostname}",
}
)
assert_job_invocation_result(invocation_command['id'], client.hostname)
assert_job_invocation_result(target_sat, invocation_command['id'], client.hostname)
result = client.execute(f'systemctl status {service}')
assert result.status == 3

Expand All @@ -833,7 +833,7 @@ def test_positive_run_packages_and_services_job(
'search-query': f'name ~ {client.hostname}',
}
)
assert_job_invocation_result(invocation_command['id'], client.hostname)
assert_job_invocation_result(target_sat, invocation_command['id'], client.hostname)
result = client.execute(f'systemctl status {service}')
assert result.status == 0

Expand Down Expand Up @@ -1116,7 +1116,9 @@ def test_positive_run_job_on_host_registered_to_async_ssh_provider(
'search-query': f"name ~ {rhel_contenthost.hostname}",
}
)
assert_job_invocation_result(invocation_command['id'], rhel_contenthost.hostname)
assert_job_invocation_result(
module_target_sat, invocation_command['id'], rhel_contenthost.hostname
)


class TestPullProviderRex:
Expand Down Expand Up @@ -1189,7 +1191,9 @@ def test_positive_run_job_on_host_converted_to_pull_provider(
'search-query': f"name ~ {rhel_contenthost.hostname}",
}
)
assert_job_invocation_result(invocation_command['id'], rhel_contenthost.hostname)
assert_job_invocation_result(
module_target_sat, invocation_command['id'], rhel_contenthost.hostname
)
# check katello-agent runs along ygdrassil (SAT-1671)
result = rhel_contenthost.execute('systemctl status goferd')
assert result.status == 0, 'Failed to start goferd on client'
Expand Down Expand Up @@ -1218,7 +1222,9 @@ def test_positive_run_job_on_host_converted_to_pull_provider(
'search-query': f"name ~ {rhel_contenthost.hostname}",
}
)
assert_job_invocation_result(invocation_command['id'], rhel_contenthost.hostname)
assert_job_invocation_result(
module_target_sat, invocation_command['id'], rhel_contenthost.hostname
)
result = module_target_sat.cli.JobInvocation.info({'id': invocation_command['id']})

@pytest.mark.tier3
Expand All @@ -1234,7 +1240,6 @@ def test_positive_run_job_on_host_registered_to_pull_provider(
module_ak_with_cv,
module_capsule_configured_mqtt,
rhel_contenthost,
target_sat,
):
"""Run custom template on host registered to mqtt, check effective user setting

Expand Down Expand Up @@ -1279,25 +1284,29 @@ def test_positive_run_job_on_host_registered_to_pull_provider(
result = rhel_contenthost.execute('systemctl status yggdrasild')
assert result.status == 0, f'Failed to start yggdrasil on client: {result.stderr}'
# run script provider rex command
invocation_command = target_sat.cli_factory.job_invocation(
invocation_command = module_target_sat.cli_factory.job_invocation(
{
'job-template': 'Service Action - Script Default',
'inputs': 'action=status, service=yggdrasild',
'search-query': f"name ~ {rhel_contenthost.hostname}",
}
)
assert_job_invocation_result(invocation_command['id'], rhel_contenthost.hostname)
assert_job_invocation_result(
module_target_sat, invocation_command['id'], rhel_contenthost.hostname
)
# create user on host
username = gen_string('alpha')
filename = gen_string('alpha')
make_user_job = target_sat.cli_factory.job_invocation(
make_user_job = module_target_sat.cli_factory.job_invocation(
{
'job-template': 'Run Command - Script Default',
'inputs': f"command=useradd -m {username}",
'search-query': f"name ~ {rhel_contenthost.hostname}",
}
)
assert_job_invocation_result(make_user_job['id'], rhel_contenthost.hostname)
assert_job_invocation_result(
module_target_sat, make_user_job['id'], rhel_contenthost.hostname
)
# create a file as new user
invocation_command = module_target_sat.make_job_invocation(
{
Expand All @@ -1307,7 +1316,9 @@ def test_positive_run_job_on_host_registered_to_pull_provider(
'effective-user': f'{username}',
}
)
assert_job_invocation_result(invocation_command['id'], rhel_contenthost.hostname)
assert_job_invocation_result(
module_target_sat, invocation_command['id'], rhel_contenthost.hostname
)
# check the file owner
result = rhel_contenthost.execute(
f'''stat -c '%U' /home/{username}/{filename}''',
Expand Down Expand Up @@ -1387,4 +1398,6 @@ def test_positive_run_pull_job_on_offline_host(
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)
assert_job_invocation_result(invocation_command['id'], rhel_contenthost.hostname)
assert_job_invocation_result(
module_target_sat, invocation_command['id'], rhel_contenthost.hostname
)