[ONOS-7937] Trigger slack notifications when test pass percentage is lower than expected
Change-Id: I2cec4181e6b9b8d972956aacbeab1adfe61d707b
diff --git a/TestON/core/logger.py b/TestON/core/logger.py
index 0fdc49a..263e95b 100644
--- a/TestON/core/logger.py
+++ b/TestON/core/logger.py
@@ -126,7 +126,7 @@
main.resultFile = main.logdir + "/" + main.TEST + "Result.txt"
main.alarmFileName = main.logdir + "/" + main.TEST + "Alarm.txt"
- main.TOTAL_TC_SUCCESS = 0
+ main.TOTAL_TC_SUCCESS_PERCENT = 0
# Add log-level - Report
logging.addLevelName( 9, "REPORT" )
@@ -283,9 +283,9 @@
main.ENDTIME = datetime.datetime.now()
main.EXECTIME = main.ENDTIME - main.STARTTIME
if ( main.TOTAL_TC_PASS == 0 ):
- main.TOTAL_TC_SUCCESS = 0
+ main.TOTAL_TC_SUCCESS_PERCENT = 0
else:
- main.TOTAL_TC_SUCCESS = str( ( main.TOTAL_TC_PASS * 100 ) / main.TOTAL_TC_RUN )
+ main.TOTAL_TC_SUCCESS_PERCENT = main.TOTAL_TC_PASS * 100 / main.TOTAL_TC_RUN
if ( main.TOTAL_TC_RUN == 0 ):
main.TOTAL_TC_EXECPERCENT = 0
else:
@@ -294,13 +294,13 @@
testResult = testResult + "\n Test Start : " + str( main.STARTTIME.strftime( "%d %b %Y %H:%M:%S" ) )
testResult = testResult + "\n Test End : " + str( main.ENDTIME.strftime( "%d %b %Y %H:%M:%S" ) )
testResult = testResult + "\n Execution Time : " + str( main.EXECTIME )
- testResult = testResult + "\n Total tests planned : " + str( main.TOTAL_TC_PLANNED )
- testResult = testResult + "\n Total tests RUN : " + str( main.TOTAL_TC_RUN )
+ testResult = testResult + "\n Total Tests Planned : " + str( main.TOTAL_TC_PLANNED )
+ testResult = testResult + "\n Total Tests Run : " + str( main.TOTAL_TC_RUN )
testResult = testResult + "\n Total Pass : " + str( main.TOTAL_TC_PASS )
testResult = testResult + "\n Total Fail : " + str( main.TOTAL_TC_FAIL )
testResult = testResult + "\n Total No Result : " + str( main.TOTAL_TC_NORESULT )
- testResult = testResult + "\n Success Percentage : " + str( main.TOTAL_TC_SUCCESS ) + "%"
- testResult = testResult + "\n Execution Result : " + str( main.TOTAL_TC_EXECPERCENT ) + "%\n"
+ testResult = testResult + "\n Success Percentage : " + str( main.TOTAL_TC_SUCCESS_PERCENT ) + "%"
+ testResult = testResult + "\n Execution Percentage : " + str( main.TOTAL_TC_EXECPERCENT ) + "%\n"
if main.failedCase:
testResult = testResult + "\n Case Failed : " + str( main.failedCase )
if main.noResultCase:
@@ -311,6 +311,12 @@
main.testResult = testResult
main.log.exact( testResult )
+ # Write to alarm log if Success Percentage is lower than expected
+ if 'ALARM' in main.params.keys() and 'minPassPercent' in main.params[ 'ALARM' ].keys():
+ minPassPercent = int( main.params[ 'ALARM' ][ 'minPassPercent' ] )
+ if main.TOTAL_TC_SUCCESS_PERCENT < minPassPercent:
+ main.log.alarm( 'Success percentage: {}% < {}%'.format( main.TOTAL_TC_SUCCESS_PERCENT, minPassPercent ) )
+
# CSV output needed for Jenkin's plot plugin
# NOTE: the elements were orded based on the colors assigned to the data
logfile = open( main.JenkinsCSV , "w" )
diff --git a/TestON/core/utilities.py b/TestON/core/utilities.py
index 91fc105..012b651 100644
--- a/TestON/core/utilities.py
+++ b/TestON/core/utilities.py
@@ -220,13 +220,13 @@
sub = "Result summary of \"" + main.TEST + "\" run on component \"" + \
main.test_target + "\" Version \"" + \
vars( main )[ main.test_target ].get_version() + "\": " + \
- str( main.TOTAL_TC_SUCCESS ) + "% Passed"
+ str( main.TOTAL_TC_SUCCESS_PERCENT ) + "% Passed"
else:
sub = "Result summary of \"" + main.TEST + "\": " + \
- str( main.TOTAL_TC_SUCCESS ) + "% Passed"
+ str( main.TOTAL_TC_SUCCESS_PERCENT ) + "% Passed"
except( KeyError, AttributeError ):
sub = "Result summary of \"" + main.TEST + "\": " + \
- str( main.TOTAL_TC_SUCCESS ) + "% Passed"
+ str( main.TOTAL_TC_SUCCESS_PERCENT ) + "% Passed"
msg[ 'Subject' ] = sub
msg[ 'From' ] = main.sender
diff --git a/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params b/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params
index 748844e..6f9d60e 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params
+++ b/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params
@@ -41,4 +41,8 @@
<SLEEP>
<startup>10</startup>
</SLEEP>
+
+ <ALARM>
+ <minPassPercent>100</minPassPercent>
+ </ALARM>
</PARAMS>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRDhcprelay/SRDhcprelay.params b/TestON/tests/USECASE/SegmentRouting/SRDhcprelay/SRDhcprelay.params
index 0fba048..e337e12 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRDhcprelay/SRDhcprelay.params
+++ b/TestON/tests/USECASE/SegmentRouting/SRDhcprelay/SRDhcprelay.params
@@ -41,4 +41,8 @@
<SLEEP>
<startup>10</startup>
</SLEEP>
+
+ <ALARM>
+ <minPassPercent>63</minPassPercent>
+ </ALARM>
</PARAMS>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRDynamicConf/SRDynamicConf.params b/TestON/tests/USECASE/SegmentRouting/SRDynamicConf/SRDynamicConf.params
index 551b649..fa26772 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRDynamicConf/SRDynamicConf.params
+++ b/TestON/tests/USECASE/SegmentRouting/SRDynamicConf/SRDynamicConf.params
@@ -40,4 +40,8 @@
<SLEEP>
<startup>10</startup>
</SLEEP>
+
+ <ALARM>
+ <minPassPercent>70</minPassPercent>
+ </ALARM>
</PARAMS>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRMulticast/SRMulticast.params b/TestON/tests/USECASE/SegmentRouting/SRMulticast/SRMulticast.params
index 73b1578..14b0977 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRMulticast/SRMulticast.params
+++ b/TestON/tests/USECASE/SegmentRouting/SRMulticast/SRMulticast.params
@@ -56,4 +56,7 @@
<linkNum>48</linkNum>
</TOPO>
+ <ALARM>
+ <minPassPercent>75</minPassPercent>
+ </ALARM>
</PARAMS>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.params b/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.params
index 1ffa100..1b86dcb 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.params
+++ b/TestON/tests/USECASE/SegmentRouting/SRRouting/SRRouting.params
@@ -54,4 +54,7 @@
<linkNum>48</linkNum>
</TOPO>
+ <ALARM>
+ <minPassPercent>80</minPassPercent>
+ </ALARM>
</PARAMS>