Skip to content

Commit

Permalink
Check bulk generate applicability task.
Browse files Browse the repository at this point in the history
  • Loading branch information
damoore044 committed Nov 2, 2023
1 parent 4a8e566 commit b999a80
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions tests/foreman/ui/test_errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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}",
Expand All @@ -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(
Expand Down

0 comments on commit b999a80

Please sign in to comment.