Skip to content
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
34 changes: 23 additions & 11 deletions tests/foreman/api/test_ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,31 @@ def test_positive_ping(target_sat):

:id: b8ecc7ba-8007-4067-bf99-21a82c833de7

:expectedresults: Overall and individual services status should be 'ok'.
:expectedresults: Overall and individual Katello services status should be 'ok'.
"""
response = target_sat.api.Ping().search_json()
assert response['status'] == 'ok' # overall status

# Check that all services are OK. ['services'] is in this format:
# Full response format:
#
# {'services': {
# 'candlepin': {'duration_ms': '40', 'status': 'ok'},
# 'candlepin_auth': {'duration_ms': '41', 'status': 'ok'},
# …
# }, 'status': 'ok'}
services = response['services']
assert all([service['status'] == 'ok' for service in services.values()]), (
# {'results': {
# 'foreman': {'cache': {'servers': [{'duration_ms': '0', 'status': 'ok'}]},
# 'database': {'active': True, 'duration_ms': '0'}},
# 'foreman_rh_cloud': {'services': {
# 'advisor': {'duration_ms': '27', 'status': 'ok'},
# 'vulnerability': {'duration_ms': '26', 'status': 'ok'},
# }, 'status': 'ok'},
# 'katello': {'services': {
# 'candlepin': {'duration_ms': '16', 'status': 'ok'},
# 'candlepin_auth': {'duration_ms': '15', 'status': 'ok'},
# 'candlepin_events': {'duration_ms': '0', 'message': '9 Processed, 0 Failed', 'status': 'ok'},
# 'foreman_tasks': {'duration_ms': '2', 'status': 'ok'},
# 'katello_events': {'duration_ms': '1', 'message': '3 Processed, 0 Failed', 'status': 'ok'},
# 'pulp3': {'duration_ms': '97', 'status': 'ok'},
# 'pulp3_content': {'duration_ms': '47', 'status': 'ok'},
# }, 'status': 'ok'}
# }}
katello = response['results']['katello']
assert katello['status'] == 'ok' # overall status
services = katello['services']
assert all(service['status'] == 'ok' for service in services.values()), (
'Not all services seem to be up and running!'
)
33 changes: 20 additions & 13 deletions tests/foreman/api/test_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ def test_positive_candlepin_events_processed_by_stomp(

1. Create a manifest
2. Check the number of candlepin events
/katello/api/v2/ping
/api/v2/ping
3. Import a Manifest
4. Check the number of new candlepin events
/katello/api/v2/ping
/api/v2/ping
5. Verify that the new candlepin events value is greater than the old value
6. Verify that there are no failed candlepin events
/katello/api/v2/ping
/api/v2/ping

:expectedresults: Candlepin events are being read and processed
correctly without any failures
Expand All @@ -279,9 +279,9 @@ def test_positive_candlepin_events_processed_by_stomp(
def parse(events):
return {key: int(value) for value, key in re.findall(r'(\d+)\s(\w+)', events)}

pre_candlepin_events = target_sat.api.Ping().search_json()['services']['candlepin_events'][
'message'
]
pre_candlepin_events = target_sat.api.Ping().search_json()['results']['katello']['services'][
'candlepin_events'
]['message']
pre_processed_count = parse(pre_candlepin_events)['Processed']

target_sat.upload_manifest(function_org.id, function_sca_manifest.content)
Expand All @@ -290,20 +290,27 @@ def parse(events):
# Use polling instead of fixed sleep to avoid flakiness
wait_for(
lambda: (
parse(target_sat.api.Ping().search_json()['services']['candlepin_events']['message'])[
'Processed'
]
parse(
target_sat.api.Ping().search_json()['results']['katello']['services'][
'candlepin_events'
]['message']
)['Processed']
> pre_processed_count
),
timeout=60,
delay=5,
handle_exception=True,
)

assert target_sat.api.Ping().search_json()['services']['candlepin_events']['status'] == 'ok'
post_candlepin_events = target_sat.api.Ping().search_json()['services']['candlepin_events'][
'message'
]
assert (
target_sat.api.Ping().search_json()['results']['katello']['services']['candlepin_events'][
'status'
]
== 'ok'
)
post_candlepin_events = target_sat.api.Ping().search_json()['results']['katello']['services'][
'candlepin_events'
]['message']
assert parse(post_candlepin_events)['Processed'] > pre_processed_count
assert parse(pre_candlepin_events)['Failed'] == 0
assert parse(post_candlepin_events)['Failed'] == 0
Expand Down
2 changes: 1 addition & 1 deletion tests/foreman/destructive/test_ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ def test_negative_api_ping_fail_status(tomcat_service_teardown):
:expectedresults: API ping fails and shows FAIL status.
"""
response = tomcat_service_teardown.api.Ping().search_json()
assert response['status'] == 'FAIL'
assert response['results']['katello']['status'] == 'FAIL'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (testing): Align assertion with the test’s "API ping fails" expectation by also checking the global failure indicator

Previously this test asserted the top-level response['status'] == 'FAIL', matching the docstring "API ping fails and shows FAIL status." It now only checks response['results']['katello']['status']. If the new API still exposes a global failure indicator (e.g. a top-level status), please assert both the global status and the Katello status so the test verifies a full API ping failure, not just Katello. If the global flag no longer exists, update the docstring to state that this test now only validates the Katello section’s failure state.