From bc5717051d263426ba536e085987c72d2dcf819b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hellebrandt?= Date: Wed, 15 May 2024 22:49:21 +0200 Subject: [PATCH] Automate BZ 2250732 (#15049) --- tests/foreman/cli/test_ansible.py | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/foreman/cli/test_ansible.py b/tests/foreman/cli/test_ansible.py index 3bc5872dacd..76730ac0aa6 100644 --- a/tests/foreman/cli/test_ansible.py +++ b/tests/foreman/cli/test_ansible.py @@ -15,6 +15,7 @@ import pytest from robottelo.config import settings +from robottelo.exceptions import CLIFactoryError def assert_job_invocation_result( @@ -334,6 +335,37 @@ def test_positive_run_concurrent_jobs(self, rex_contenthosts, target_sat): target_sat.cli.GlobalParameter().delete({'name': param_name}) assert len(target_sat.cli.GlobalParameter().list({'search': param_name})) == 0 + @pytest.mark.parametrize( + 'value', [0, -2, 2.5, 'a'], ids=['zero', 'negative', 'decimal', 'string'] + ) + @pytest.mark.rhel_ver_list([8]) + def test_negative_invalid_concurrency_level(self, rex_contenthost, target_sat, value): + """Tests you can not invoke job with invalid concurrency level + + :id: 15b55f91-759a-4b77-8ba2-330a5ca7ca0b + + :steps: + 1. Run a REX job with invalid concurrency-setting + + :expectedresults: should refuse gracefully + + :BZ: 2250732 + + :parametrized: yes + """ + with pytest.raises(CLIFactoryError) as error: + target_sat.cli_factory.job_invocation( + { + 'job-template': 'Run Command - Ansible Default', + 'inputs': 'command=ls', + 'search-query': f'name ~ {rex_contenthost.hostname}', + 'concurrency-level': f'{value}', + } + ) + assert 'Concurrency level: must be greater than 0' in str( + error.value + ) or 'Numeric value is required' in str(error.value) + @pytest.mark.rhel_ver_list([8]) def test_positive_run_serial(self, rex_contenthosts, target_sat): """Tests subtasks in a job run one by one when concurrency level set to 1