From e4e45b8aa199e6d1bc8f35ee024e226a6f03c715 Mon Sep 17 00:00:00 2001 From: Peter Ondrejka Date: Thu, 1 Aug 2024 13:58:40 +0200 Subject: [PATCH] test timeout_to_kill (#15162) (cherry picked from commit 162875976ae0bb3ba1fd7eb5e3c93a693f27e6ff) --- tests/foreman/cli/test_remoteexecution.py | 45 +++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/foreman/cli/test_remoteexecution.py b/tests/foreman/cli/test_remoteexecution.py index 149d43b1cc1..f19bb85058d 100644 --- a/tests/foreman/cli/test_remoteexecution.py +++ b/tests/foreman/cli/test_remoteexecution.py @@ -134,6 +134,51 @@ def test_positive_run_default_job_template( assert 'Exit' in out assert 'Internal Server Error' not in out + @pytest.mark.tier3 + @pytest.mark.rhel_ver_list([8]) + def test_positive_timeout_to_kill(self, module_org, rex_contenthost, module_target_sat): + """Use timeout to kill setting to cancel the job + + :id: 580f886b-ac24-4afa-9aca-e9afc5cfdc9c + + :expectedresults: Verify the job was killed after specified times + + :parametrized: yes + + :Verifies: SAT-25243 + """ + client = rex_contenthost + command = r'for run in {1..160}; do sleep 1; done' + template_id = ( + module_target_sat.api.JobTemplate() + .search(query={'search': 'name="Run Command - Script Default"'})[0] + .id + ) + invocation_command = module_target_sat.api.JobInvocation().run( + synchronous=False, + data={ + 'job_template_id': template_id, + 'organization': module_org.name, + 'inputs': { + 'command': command, + }, + 'search_query': f'name = {client.hostname}', + 'targeting_type': 'static_query', + 'execution_timeout_interval': '5', + }, + ) + sleep(10) + result = module_target_sat.api.JobInvocation(id=invocation_command['id']).read() + assert result.failed == 1 + out = module_target_sat.cli.JobInvocation.get_output( + { + 'id': invocation_command['id'], + 'host': client.hostname, + 'organization-id': module_org.id, + } + ) + assert 'Timeout for execution passed, trying to stop the job' in out + @pytest.mark.tier3 @pytest.mark.pit_client @pytest.mark.pit_server