Skip to content

Commit

Permalink
[6.13.z] Fix flaky SyncPlans in cli_factory (#14350)
Browse files Browse the repository at this point in the history
  • Loading branch information
Satellite-QE authored Mar 11, 2024
1 parent 91e142b commit 62adaee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
11 changes: 11 additions & 0 deletions robottelo/cli/syncplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 3 additions & 1 deletion robottelo/host_helpers/cli_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
},
Expand Down
4 changes: 2 additions & 2 deletions tests/foreman/cli/test_syncplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']}"
Expand All @@ -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
Expand Down

0 comments on commit 62adaee

Please sign in to comment.