From f868ea00043a9dc236f9bf50dfebb9ad462c68f8 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Mon, 22 Apr 2024 05:50:40 -0400 Subject: [PATCH] [6.15.z] rex longrun job (#14850) --- robottelo/cli/job_invocation.py | 4 +- robottelo/host_helpers/cli_factory.py | 4 +- tests/foreman/longrun/test_remoteexecution.py | 50 +++++++++++++++++++ 3 files changed, 54 insertions(+), 4 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/robottelo/host_helpers/cli_factory.py b/robottelo/host_helpers/cli_factory.py index 30a28d57479..13eaf2242ec 100644 --- a/robottelo/host_helpers/cli_factory.py +++ b/robottelo/host_helpers/cli_factory.py @@ -33,7 +33,7 @@ from robottelo.utils.manifest import clone -def create_object(cli_object, options, values=None, credentials=None): +def create_object(cli_object, options, values=None, credentials=None, timeout=None): """ Creates with dictionary of arguments. @@ -52,7 +52,7 @@ def create_object(cli_object, options, values=None, credentials=None): if credentials: cli_object = cli_object.with_user(*credentials) try: - result = cli_object.create(options) + result = cli_object.create(options, timeout) except CLIReturnCodeError as err: # If the object is not created, raise exception, stop the show. raise CLIFactoryError( 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