From 896cfe82ad4fbe42b8dc10b9b471c6714f680f5c Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Mon, 11 Mar 2024 11:52:45 -0400 Subject: [PATCH] [6.15.z] Fix flaky SyncPlans in cli_factory (#14351) --- robottelo/cli/syncplan.py | 11 +++++++++++ robottelo/host_helpers/cli_factory.py | 4 +++- tests/foreman/cli/test_syncplan.py | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/robottelo/cli/syncplan.py b/robottelo/cli/syncplan.py index 3f8b9b8b347..151a72acb84 100644 --- a/robottelo/cli/syncplan.py +++ b/robottelo/cli/syncplan.py @@ -17,9 +17,20 @@ update """ from robottelo.cli.base import Base +from robottelo.exceptions import CLIError class SyncPlan(Base): """Manipulates Katello engine's sync-plan command.""" command_base = 'sync-plan' + + @classmethod + def create(cls, options=None): + """Create a SyncPlan""" + cls.command_sub = 'create' + + if options.get('interval') == 'custom cron' and options.get('cron-expression') is None: + raise CLIError('Missing "cron-expression" option for "custom cron" interval.') + + return super().create(options) diff --git a/robottelo/host_helpers/cli_factory.py b/robottelo/host_helpers/cli_factory.py index 6debf436c11..cd268732e96 100644 --- a/robottelo/host_helpers/cli_factory.py +++ b/robottelo/host_helpers/cli_factory.py @@ -140,7 +140,9 @@ def create_object(cli_object, options, values=None, credentials=None): 'sync_plan': { 'description': gen_alpha, 'enabled': 'true', - 'interval': lambda: random.choice(list(constants.SYNC_INTERVAL.values())), + 'interval': lambda: random.choice( + [i for i in constants.SYNC_INTERVAL.values() if i != 'custom cron'] + ), 'name': gen_alpha, 'sync-date': lambda: datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), }, diff --git a/tests/foreman/cli/test_syncplan.py b/tests/foreman/cli/test_syncplan.py index 86f33b68ffb..8669cd49a18 100644 --- a/tests/foreman/cli/test_syncplan.py +++ b/tests/foreman/cli/test_syncplan.py @@ -705,7 +705,7 @@ def test_positive_synchronize_rh_product_future_sync_date( # Verify product has not been synced yet with pytest.raises(AssertionError): validate_task_status(target_sat, repo['id'], org.id, max_tries=1) - validate_repo_content(repo, ['errata', 'packages'], after_sync=False) + validate_repo_content(target_sat, repo, ['errata', 'packages'], after_sync=False) # Wait the rest of expected time logger.info( f"Waiting {(delay * 4 / 5)} seconds to check product {product['name']}" @@ -714,7 +714,7 @@ def test_positive_synchronize_rh_product_future_sync_date( sleep(delay * 4 / 5) # Verify product was synced successfully validate_task_status(target_sat, repo['id'], org.id) - validate_repo_content(repo, ['errata', 'packages']) + validate_repo_content(target_sat, repo, ['errata', 'packages']) @pytest.mark.tier3