From 00f8f2e7e310586486aad90e0f4b5ff7ee04d256 Mon Sep 17 00:00:00 2001 From: Lukas Hellebrandt Date: Wed, 13 Dec 2023 11:51:36 +0100 Subject: [PATCH] bz1784254 (cherry picked from commit 95d0b88c9e6c9452178d30b85ea15d9056c1b593) --- tests/foreman/cli/test_remoteexecution.py | 46 +++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/foreman/cli/test_remoteexecution.py b/tests/foreman/cli/test_remoteexecution.py index 45c2183e9dc..48a65175671 100644 --- a/tests/foreman/cli/test_remoteexecution.py +++ b/tests/foreman/cli/test_remoteexecution.py @@ -20,6 +20,7 @@ from dateutil.relativedelta import FR, relativedelta from fauxfactory import gen_string import pytest +from wait_for import wait_for from robottelo import constants from robottelo.config import settings @@ -581,6 +582,51 @@ def test_positive_run_scheduled_job_template(self, rex_contenthost, target_sat): sleep(30) assert_job_invocation_result(target_sat, invocation_command['id'], client.hostname) + @pytest.mark.tier3 + @pytest.mark.rhel_ver_list([8, 9]) + def test_recurring_with_unreachable_host(self, module_target_sat, rhel_contenthost): + """Run a recurring task against a host that is not reachable and verify it gets rescheduled + + :id: 570f6d75-6bbf-40b0-a1df-6c26b588dca8 + + :expectedresults: The job is being rescheduled indefinitely even though it fails + + :BZ: 1784254 + + :customerscenario: true + + :parametrized: yes + """ + cli = module_target_sat.cli + host = module_target_sat.cli_factory.make_fake_host() + # shutdown the host and wait for it to surely be unreachable + rhel_contenthost.execute("shutdown -h +1") # shutdown after one minute + sleep(120) + invocation = module_target_sat.cli_factory.job_invocation( + { + 'job-template': 'Run Command - Script Default', + 'inputs': 'command=echo this wont ever run', + 'search-query': f'name ~ {host.name}', + 'cron-line': '* * * * *', # every minute + } + ) + cli.RecurringLogic.info( + {'id': cli.JobInvocation.info({'id': invocation.id})['recurring-logic-id']} + ) + # wait for the third task to be planned which verifies the BZ + wait_for( + lambda: int( + cli.RecurringLogic.info( + {'id': cli.JobInvocation.info({'id': invocation.id})['recurring-logic-id']} + )['task-count'] + ) + > 2, + timeout=180, + delay=10, + ) + # check that the first task indeed failed which verifies the test was done correctly + assert cli.JobInvocation.info({'id': invocation.id})['failed'] != '0' + class TestAnsibleREX: """Test class for remote execution via Ansible"""