-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathtest_cluster_events.py
More file actions
60 lines (53 loc) · 1.77 KB
/
test_cluster_events.py
File metadata and controls
60 lines (53 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from tests import TEST_CLIENT
EXPECTED_ALL_FIELDS = [
"id",
"recorded_at",
"all_healthy",
"api_status",
"api_self_info",
"api_resources_info",
"compiler_status",
"compiler_self_info",
"compiler_resources_info",
"runner_status",
"runner_self_info",
"runner_resources_info",
]
EXPECTED_STATUS_FIELDS = [
"id",
"recorded_at",
"all_healthy",
"api_status",
"compiler_status",
"runner_status",
]
def check_event_all(event):
assert sorted(event.keys()) == sorted(EXPECTED_ALL_FIELDS)
def check_event_status(event):
assert sorted(event.keys()) == sorted(EXPECTED_STATUS_FIELDS)
def test_cluster_events():
"""
Checks the cluster events endpoints for latest event, specific event and list of events.
"""
latest_event_all = TEST_CLIENT.get_cluster_event("latest", selector="all")
latest_event_status = TEST_CLIENT.get_cluster_event("latest")
specific_event_all = TEST_CLIENT.get_cluster_event(
latest_event_all["id"], selector="all"
)
specific_event_status = TEST_CLIENT.get_cluster_event(latest_event_status["id"])
all_events_status = TEST_CLIENT.get_cluster_events()
assert latest_event_status in all_events_status, (
"Latest event is not in full events list"
)
assert latest_event_status == specific_event_status, (
"Specifically retrieved event does not match the latest event"
)
assert latest_event_all == specific_event_all, (
"Specifically retrieved extended event does not match the latest event"
)
check_event_all(latest_event_all)
check_event_all(specific_event_all)
check_event_status(latest_event_status)
check_event_status(specific_event_status)
for event in all_events_status:
check_event_status(event)