@@ -65,6 +65,7 @@ def _finish_with_exit_code(exit_code, write_report=True, report_dir_path=REPORT_
65
65
copyfile (DEBUG_FILE , report_dir_path + "/" + DEBUG_FILE )
66
66
with open (report_dir_path + "/" + report_file , "w+" ) as file :
67
67
file .write (str (report_dir_path + "/" + DEBUG_FILE ))
68
+ finish_canary_metrics ()
68
69
sys .exit (exit_code )
69
70
70
71
def _check_env (args ):
@@ -438,6 +439,39 @@ def _cluster_check():
438
439
_finish_with_exit_code (1 )
439
440
440
441
442
+ # Canary Metrics **************************************************************
443
+ #
444
+
445
+ CM_SIMPLE = "flex_volume_driver_simple"
446
+
447
+ def canary_metric_date ():
448
+ return datetime .datetime .today ().strftime ('%Y-%m-%d-%H%m%S' )
449
+
450
+ def init_canary_metrics ():
451
+ if "METRICS_FILE" in os .environ :
452
+ _log ("generating metrics file..." )
453
+ canary_metrics = {}
454
+ canary_metrics ["start_time" ] = canary_metric_date ()
455
+ canary_metrics [CM_SIMPLE ] = 0
456
+ with open (os .environ .get ("METRICS_FILE" ), 'w' ) as metrics_file :
457
+ json .dump (canary_metrics , metrics_file , sort_keys = True , indent = 4 )
458
+
459
+ def update_canary_metric (name , result ):
460
+ if "METRICS_FILE" in os .environ :
461
+ _log ("updating metrics fle..." )
462
+ with open (os .environ .get ("METRICS_FILE" ), 'r' ) as metrics_file :
463
+ canary_metrics = json .load (metrics_file )
464
+ canary_metrics [name ] = result
465
+ with open (os .environ .get ("METRICS_FILE" ), 'w' ) as metrics_file :
466
+ json .dump (canary_metrics , metrics_file , sort_keys = True , indent = 4 )
467
+
468
+ def finish_canary_metrics ():
469
+ update_canary_metric ("end_time" , canary_metric_date ())
470
+
471
+
472
+ # Main ************************************************************************
473
+ #
474
+
441
475
def _main ():
442
476
_reset_debug_file ()
443
477
parser = argparse .ArgumentParser (description = 'System test runner for the OCI Block Volume flexvolume driver' )
@@ -524,6 +558,8 @@ def _destroy_test_volume_atexit():
524
558
if not args ['no_test' ]:
525
559
_log ("Running system test: " , as_banner = True )
526
560
561
+ init_canary_metrics ()
562
+
527
563
_log ("Starting the replication controller (creates a single nginx pod)." )
528
564
_kubectl ("delete -f " + replication_controller , exit_on_error = False , display_errors = False )
529
565
_kubectl ("create -f " + replication_controller )
@@ -569,6 +605,8 @@ def _destroy_test_volume_atexit():
569
605
if args ['destructive' ]:
570
606
_log ("Adding the original node back into the cluster." )
571
607
_kubectl ("uncordon " + node1 )
608
+
609
+ update_canary_metric (CM_SIMPLE , 1 )
572
610
573
611
_finish_with_exit_code (0 )
574
612
0 commit comments