-
Notifications
You must be signed in to change notification settings - Fork 116
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
Remove sleeps and make cron expression more accurate #15172
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f743db8
Remove sleeps and make cron expression more accurate
sambible bde1f1a
Merge branch 'master' into fix-sync-plans
sambible 613dc42
Use minutes instead of seconds variable
sambible ff41602
Merge branch 'fix-sync-plans' of github.com:sambible/robottelo into f…
sambible File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
""" | ||
|
||
from datetime import datetime, timedelta | ||
import time | ||
|
||
from fauxfactory import gen_choice | ||
import pytest | ||
|
@@ -197,10 +196,10 @@ def test_positive_synchronize_custom_product_custom_cron_real_time(session, modu | |
# workaround: force session.browser to point to browser object on next line | ||
session.contenthost.read_all('current_user') | ||
start_date = session.browser.get_client_datetime() | ||
next_sync = 3 * 60 | ||
# forming cron expression sync repo after 3 min | ||
next_sync = 5 * 60 | ||
# forming cron expression sync repo after 5 min | ||
expected_next_run_time = start_date + timedelta(seconds=next_sync) | ||
cron_expression = f'{expected_next_run_time.minute} * * * *' | ||
cron_expression = f'{expected_next_run_time.minute} {expected_next_run_time.hour} {expected_next_run_time.day} {expected_next_run_time.month} *' | ||
session.syncplan.create( | ||
{ | ||
'name': plan_name, | ||
|
@@ -227,13 +226,13 @@ def test_positive_synchronize_custom_product_custom_cron_real_time(session, modu | |
assert 'No task was found using query' in str(context.value) | ||
validate_repo_content(repo, ['erratum', 'rpm', 'package_group'], after_sync=False) | ||
# Waiting part of delay that is left and check that product was synced | ||
time.sleep(next_sync) | ||
target_sat.wait_for_tasks( | ||
search_query='Actions::Katello::Repository::Sync' | ||
f' and organization_id = {module_org.id}' | ||
f' and resource_id = {repo.id}' | ||
' and resource_type = Katello::Repository', | ||
search_rate=10, | ||
max_tries=20, | ||
) | ||
validate_repo_content(repo, ['erratum', 'rpm', 'package_group']) | ||
repo_values = session.repository.read(product.name, repo.name) | ||
|
@@ -263,10 +262,10 @@ def test_positive_synchronize_custom_product_custom_cron_past_sync_date( | |
# workaround: force session.browser to point to browser object on next line | ||
session.contenthost.read_all('current_user') | ||
start_date = session.browser.get_client_datetime() | ||
next_sync = 3 * 60 | ||
# forming cron expression sync repo after 3 min | ||
next_sync = 5 * 60 | ||
# forming cron expression sync repo after 5 min | ||
expected_next_run_time = start_date + timedelta(seconds=next_sync) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
cron_expression = f'{expected_next_run_time.minute} * * * *' | ||
cron_expression = f'{expected_next_run_time.minute} {expected_next_run_time.hour} {expected_next_run_time.day} {expected_next_run_time.month} *' | ||
session.syncplan.create( | ||
{ | ||
'name': plan_name, | ||
|
@@ -293,13 +292,13 @@ def test_positive_synchronize_custom_product_custom_cron_past_sync_date( | |
assert 'No task was found using query' in str(context.value) | ||
validate_repo_content(repo, ['erratum', 'rpm', 'package_group'], after_sync=False) | ||
# Waiting part of delay that is left and check that product was synced | ||
time.sleep(next_sync) | ||
target_sat.wait_for_tasks( | ||
search_query='Actions::Katello::Repository::Sync' | ||
f' and organization_id = {module_org.id}' | ||
f' and resource_id = {repo.id}' | ||
' and resource_type = Katello::Repository', | ||
search_rate=10, | ||
max_tries=20, | ||
) | ||
validate_repo_content(repo, ['erratum', 'rpm', 'package_group']) | ||
repo_values = session.repository.read(product.name, repo.name) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we don't use
next_sync
later, could we go straight?