From 55aa0d72e7721d181dd94f34f3c6f56691d5da7b Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Wed, 29 May 2024 06:23:18 -0400 Subject: [PATCH] [6.15.z] Remove sleeps and make cron expression more accurate (#15209) --- tests/foreman/ui/test_syncplan.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/foreman/ui/test_syncplan.py b/tests/foreman/ui/test_syncplan.py index b4be83f7141..3c58f70655e 100644 --- a/tests/foreman/ui/test_syncplan.py +++ b/tests/foreman/ui/test_syncplan.py @@ -13,7 +13,6 @@ """ from datetime import datetime, timedelta -import time from fauxfactory import gen_choice import pytest @@ -197,10 +196,9 @@ 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 - expected_next_run_time = start_date + timedelta(seconds=next_sync) - cron_expression = f'{expected_next_run_time.minute} * * * *' + # forming cron expression sync repo after 5 min + expected_next_run_time = start_date + timedelta(minutes=5) + 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 +225,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 +261,9 @@ 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 - expected_next_run_time = start_date + timedelta(seconds=next_sync) - cron_expression = f'{expected_next_run_time.minute} * * * *' + # forming cron expression sync repo after 5 min + expected_next_run_time = start_date + timedelta(minutes=5) + 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 +290,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)