From b999a809e98840b081f38a9b00b69f312e86607a Mon Sep 17 00:00:00 2001 From: David Moore Date: Thu, 2 Nov 2023 13:15:42 -0400 Subject: [PATCH] Check bulk generate applicability task. --- tests/foreman/ui/test_errata.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/tests/foreman/ui/test_errata.py b/tests/foreman/ui/test_errata.py index bfb85012766..d8bc2b8275d 100644 --- a/tests/foreman/ui/test_errata.py +++ b/tests/foreman/ui/test_errata.py @@ -286,6 +286,7 @@ def test_end_to_end( ], 'module_stream_packages': [], } + _UTC_format = '%Y-%m-%d %H:%M:%S UTC' # Capture product and repository with the desired content assert len(product_list := module_target_sat.api.Product(organization=module_org).search()) > 0 _product = product_list[-1].read() @@ -326,7 +327,7 @@ def test_end_to_end( == ERRATA_PACKAGES['module_stream_packages'] ) - # Install Errata, find and assert REX task + # Install Errata, find REX install task session.host_new.apply_erratas( entity_name=registered_contenthost.hostname, search=f"errata_id == {CUSTOM_REPO_ERRATA_ID}", @@ -346,12 +347,29 @@ def test_end_to_end( assert ( registered_contenthost.applicable_errata_count == 0 ), 'Unexpected applicable errata found after install.' + # Check UTC timing for install task and session + install_start = datetime.strptime(task_status['started_at'], _UTC_format) + install_end = datetime.strptime(task_status['ended_at'], _UTC_format) + assert (install_end - install_start).total_seconds() <= 60 + assert (install_end - datetime_utc_start).total_seconds() <= 600 - task_start = datetime.strptime(task_status['started_at'], '%Y-%m-%d %H:%M:%S UTC') - task_end = datetime.strptime(task_status['ended_at'], '%Y-%m-%d %H:%M:%S UTC') - # Checking UTC timing for install task and session - assert (task_end - task_start).total_seconds() <= 60 - assert (task_end - datetime_utc_start).total_seconds() <= 600 + # Find bulk generate applicability task + result = module_target_sat.wait_for_tasks( + search_query=( + f'"Bulk generate applicability for host {registered_contenthost.hostname}"' + ), + search_rate=2, + max_tries=60, + ) + task_status = module_target_sat.api.ForemanTask(id=result[0].id).poll() + assert ( + task_status['result'] == 'success' + ), f'Bulk Generate Errata Applicability task failed:\n{task_status}' + # Check UTC timing for generate applicability task + bulk_gen_start = datetime.strptime(task_status['started_at'], _UTC_format) + bulk_gen_end = datetime.strptime(task_status['ended_at'], _UTC_format) + assert (bulk_gen_start - install_end).total_seconds() <= 30 + assert (bulk_gen_end - bulk_gen_start).total_seconds() <= 60 # Errata should still be visible on satellite, but not on contenthost assert session.errata.read(CUSTOM_REPO_ERRATA_ID) assert not session.errata.search_content_hosts(