Skip to content

Commit 45d2464

Browse files
Alter API Ping usage in tests to match new endpoint (#20909)
* AlterApiPingUsage * update docstring
1 parent aed2e40 commit 45d2464

File tree

3 files changed

+44
-25
lines changed

3 files changed

+44
-25
lines changed

tests/foreman/api/test_ping.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,31 @@ def test_positive_ping(target_sat):
2323
2424
:id: b8ecc7ba-8007-4067-bf99-21a82c833de7
2525
26-
:expectedresults: Overall and individual services status should be 'ok'.
26+
:expectedresults: Overall and individual Katello services status should be 'ok'.
2727
"""
2828
response = target_sat.api.Ping().search_json()
29-
assert response['status'] == 'ok' # overall status
30-
31-
# Check that all services are OK. ['services'] is in this format:
29+
# Full response format:
3230
#
33-
# {'services': {
34-
# 'candlepin': {'duration_ms': '40', 'status': 'ok'},
35-
# 'candlepin_auth': {'duration_ms': '41', 'status': 'ok'},
36-
# …
37-
# }, 'status': 'ok'}
38-
services = response['services']
39-
assert all([service['status'] == 'ok' for service in services.values()]), (
31+
# {'results': {
32+
# 'foreman': {'cache': {'servers': [{'duration_ms': '0', 'status': 'ok'}]},
33+
# 'database': {'active': True, 'duration_ms': '0'}},
34+
# 'foreman_rh_cloud': {'services': {
35+
# 'advisor': {'duration_ms': '27', 'status': 'ok'},
36+
# 'vulnerability': {'duration_ms': '26', 'status': 'ok'},
37+
# }, 'status': 'ok'},
38+
# 'katello': {'services': {
39+
# 'candlepin': {'duration_ms': '16', 'status': 'ok'},
40+
# 'candlepin_auth': {'duration_ms': '15', 'status': 'ok'},
41+
# 'candlepin_events': {'duration_ms': '0', 'message': '9 Processed, 0 Failed', 'status': 'ok'},
42+
# 'foreman_tasks': {'duration_ms': '2', 'status': 'ok'},
43+
# 'katello_events': {'duration_ms': '1', 'message': '3 Processed, 0 Failed', 'status': 'ok'},
44+
# 'pulp3': {'duration_ms': '97', 'status': 'ok'},
45+
# 'pulp3_content': {'duration_ms': '47', 'status': 'ok'},
46+
# }, 'status': 'ok'}
47+
# }}
48+
katello = response['results']['katello']
49+
assert katello['status'] == 'ok' # overall status
50+
services = katello['services']
51+
assert all(service['status'] == 'ok' for service in services.values()), (
4052
'Not all services seem to be up and running!'
4153
)

tests/foreman/api/test_subscription.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,13 @@ def test_positive_candlepin_events_processed_by_stomp(
258258
259259
1. Create a manifest
260260
2. Check the number of candlepin events
261-
/katello/api/v2/ping
261+
/api/v2/ping
262262
3. Import a Manifest
263263
4. Check the number of new candlepin events
264-
/katello/api/v2/ping
264+
/api/v2/ping
265265
5. Verify that the new candlepin events value is greater than the old value
266266
6. Verify that there are no failed candlepin events
267-
/katello/api/v2/ping
267+
/api/v2/ping
268268
269269
:expectedresults: Candlepin events are being read and processed
270270
correctly without any failures
@@ -279,9 +279,9 @@ def test_positive_candlepin_events_processed_by_stomp(
279279
def parse(events):
280280
return {key: int(value) for value, key in re.findall(r'(\d+)\s(\w+)', events)}
281281

282-
pre_candlepin_events = target_sat.api.Ping().search_json()['services']['candlepin_events'][
283-
'message'
284-
]
282+
pre_candlepin_events = target_sat.api.Ping().search_json()['results']['katello']['services'][
283+
'candlepin_events'
284+
]['message']
285285
pre_processed_count = parse(pre_candlepin_events)['Processed']
286286

287287
target_sat.upload_manifest(function_org.id, function_sca_manifest.content)
@@ -290,20 +290,27 @@ def parse(events):
290290
# Use polling instead of fixed sleep to avoid flakiness
291291
wait_for(
292292
lambda: (
293-
parse(target_sat.api.Ping().search_json()['services']['candlepin_events']['message'])[
294-
'Processed'
295-
]
293+
parse(
294+
target_sat.api.Ping().search_json()['results']['katello']['services'][
295+
'candlepin_events'
296+
]['message']
297+
)['Processed']
296298
> pre_processed_count
297299
),
298300
timeout=60,
299301
delay=5,
300302
handle_exception=True,
301303
)
302304

303-
assert target_sat.api.Ping().search_json()['services']['candlepin_events']['status'] == 'ok'
304-
post_candlepin_events = target_sat.api.Ping().search_json()['services']['candlepin_events'][
305-
'message'
306-
]
305+
assert (
306+
target_sat.api.Ping().search_json()['results']['katello']['services']['candlepin_events'][
307+
'status'
308+
]
309+
== 'ok'
310+
)
311+
post_candlepin_events = target_sat.api.Ping().search_json()['results']['katello']['services'][
312+
'candlepin_events'
313+
]['message']
307314
assert parse(post_candlepin_events)['Processed'] > pre_processed_count
308315
assert parse(pre_candlepin_events)['Failed'] == 0
309316
assert parse(post_candlepin_events)['Failed'] == 0

tests/foreman/destructive/test_ping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ def test_negative_api_ping_fail_status(tomcat_service_teardown):
5757
:expectedresults: API ping fails and shows FAIL status.
5858
"""
5959
response = tomcat_service_teardown.api.Ping().search_json()
60-
assert response['status'] == 'FAIL'
60+
assert response['results']['katello']['status'] == 'FAIL'

0 commit comments

Comments
 (0)