From dc4acb90c43859096b7cb34b583d11e167e1400a Mon Sep 17 00:00:00 2001 From: Peter Ondrejka Date: Mon, 18 Mar 2024 18:19:17 +0100 Subject: [PATCH] rex longrun job --- robottelo/cli/job_invocation.py | 4 +- tests/foreman/longrun/test_remoteexecution.py | 50 +++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 tests/foreman/longrun/test_remoteexecution.py diff --git a/robottelo/cli/job_invocation.py b/robottelo/cli/job_invocation.py index e1aeacdc84e..fe02dae4d74 100644 --- a/robottelo/cli/job_invocation.py +++ b/robottelo/cli/job_invocation.py @@ -32,7 +32,7 @@ def get_output(cls, options): return cls.execute(cls._construct_command(options)) @classmethod - def create(cls, options): + def create(cls, options, timeout=None): """Create a job""" cls.command_sub = 'create' - return cls.execute(cls._construct_command(options), output_format='csv') + return cls.execute(cls._construct_command(options), output_format='csv', timeout=timeout) diff --git a/tests/foreman/longrun/test_remoteexecution.py b/tests/foreman/longrun/test_remoteexecution.py new file mode 100644 index 00000000000..abff4966d7a --- /dev/null +++ b/tests/foreman/longrun/test_remoteexecution.py @@ -0,0 +1,50 @@ +"""Test module for Remote Execution + +:Requirement: Remoteexecution + +:CaseAutomation: Automated + +:CaseComponent: RemoteExecution + +:Team: Endeavour + +:CaseImportance: High + +""" +import pytest + + +@pytest.mark.rhel_ver_list([9]) +def test_positive_run_long_job(module_org, rex_contenthost, module_target_sat): + """Run a long running job + + :id: 76934868-89e6-4eb6-905e-d0d5ededc077 + + :expectedresults: Verify the long job was successfully ran and not terminated too soon + + :bz: 2270295 + + :parametrized: yes + """ + client = rex_contenthost + invocation_command = module_target_sat.cli_factory.job_invocation( + { + 'job-template': 'Run Command - Script Default', + 'inputs': 'command=sleep 700', + 'search-query': f"name ~ {client.hostname}", + }, + timeout='800s', + ) + result = module_target_sat.cli.JobInvocation.info({'id': invocation_command['id']}) + try: + assert result['success'] == '1' + except AssertionError as err: + raise AssertionError( + 'host output: {}'.format( + ' '.join( + module_target_sat.cli.JobInvocation.get_output( + {'id': invocation_command['id'], 'host': client.hostname} + ) + ) + ) + ) from err