Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.14.z] Fix flaky SyncPlans in cli_factory #14352

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading