77check_application_routes = ""
88cerberus_url = None
99exit_on_failure = False
10+ cerberus_enabled = False
1011
1112def set_url (config ):
1213 global exit_on_failure
1314 exit_on_failure = get_yaml_item_value (config ["kraken" ], "exit_on_failure" , False )
14- if config ["cerberus" ]["cerberus_enabled" ]:
15+ global cerberus_enabled
16+ cerberus_enabled = get_yaml_item_value (config ["cerberus" ],"cerberus_enabled" , False )
17+ if cerberus_enabled :
1518 global cerberus_url
1619 cerberus_url = get_yaml_item_value (config ["cerberus" ],"cerberus_url" , "" )
1720 global check_application_routes
@@ -25,50 +28,50 @@ def get_status(start_time, end_time):
2528 cerberus_status = True
2629 check_application_routes = False
2730 application_routes_status = True
28-
29- if not cerberus_url :
30- logging .error (
31- "url where Cerberus publishes True/False signal "
32- "is not provided."
33- )
34- sys .exit (1 )
35- cerberus_status = requests .get (cerberus_url , timeout = 60 ).content
36- cerberus_status = True if cerberus_status == b"True" else False
31+ if cerberus_enabled :
32+ if not cerberus_url :
33+ logging .error (
34+ "url where Cerberus publishes True/False signal "
35+ "is not provided."
36+ )
37+ sys .exit (1 )
38+ cerberus_status = requests .get (cerberus_url , timeout = 60 ).content
39+ cerberus_status = True if cerberus_status == b"True" else False
3740
38- # Fail if the application routes monitored by cerberus
39- # experience downtime during the chaos
40- if check_application_routes :
41- application_routes_status , unavailable_routes = application_status (
42- cerberus_url ,
43- start_time ,
44- end_time
45- )
46- if not application_routes_status :
41+ # Fail if the application routes monitored by cerberus
42+ # experience downtime during the chaos
43+ if check_application_routes :
44+ application_routes_status , unavailable_routes = application_status (
45+ cerberus_url ,
46+ start_time ,
47+ end_time
48+ )
49+ if not application_routes_status :
50+ logging .error (
51+ "Application routes: %s monitored by cerberus "
52+ "encountered downtime during the run, failing"
53+ % unavailable_routes
54+ )
55+ else :
56+ logging .info (
57+ "Application routes being monitored "
58+ "didn't encounter any downtime during the run!"
59+ )
60+
61+ if not cerberus_status :
4762 logging .error (
48- "Application routes: %s monitored by cerberus "
49- "encountered downtime during the run, failing "
50- % unavailable_routes
63+ "Received a no-go signal from Cerberus, looks like "
64+ "the cluster is unhealthy. Please check the Cerberus "
65+ "report for more details. Test failed."
5166 )
67+
68+ if not application_routes_status or not cerberus_status :
69+ sys .exit (1 )
5270 else :
5371 logging .info (
54- "Application routes being monitored "
55- "didn't encounter any downtime during the run! "
72+ "Received a go signal from Ceberus, the cluster is healthy. "
73+ "Test passed. "
5674 )
57-
58- if not cerberus_status :
59- logging .error (
60- "Received a no-go signal from Cerberus, looks like "
61- "the cluster is unhealthy. Please check the Cerberus "
62- "report for more details. Test failed."
63- )
64-
65- if not application_routes_status or not cerberus_status :
66- sys .exit (1 )
67- else :
68- logging .info (
69- "Received a go signal from Ceberus, the cluster is healthy. "
70- "Test passed."
71- )
7275 return cerberus_status
7376
7477
0 commit comments