[ONOS-7937] Automatically check portLat results

Change-Id: Idfcd0c84d80505271c3984093f6ed9a24af4c08c
(cherry picked from commit a8e75026bab69f7380728047cd41e812c978fa7f)
diff --git a/TestON/tests/SCPF/SCPFportLat/SCPFportLat.params b/TestON/tests/SCPF/SCPFportLat/SCPFportLat.params
index e558365..a2444e3 100644
--- a/TestON/tests/SCPF/SCPFportLat/SCPFportLat.params
+++ b/TestON/tests/SCPF/SCPFportLat/SCPFportLat.params
@@ -1,13 +1,13 @@
 <PARAMS>
-    <testcases>0,1,2,1,2,1,2,1,2</testcases>
+    <testcases>0,1,2,1,2,1,2</testcases>
 
     <GRAPH>
         <nodeCluster>BM</nodeCluster>
         <builds>20</builds>
     </GRAPH>
 
-    <SCALE>1,3,5,7</SCALE>
-    <max>7</max>
+    <SCALE>1,3,5</SCALE>
+    <max>5</max>
 
     <ENV>
         <cellName>topo_perf_test</cellName>
@@ -73,4 +73,11 @@
         <linkTimestamp>topologyLinkEventTimestamp</linkTimestamp>
         <graphTimestamp>topologyGraphEventTimestamp</graphTimestamp>
     </JSON>
+
+    <ALARM>
+        <maxPortUpAve>10,20,21</maxPortUpAve>
+        <maxPortUpStd>10,10,10</maxPortUpStd>
+        <maxPortDownAve>6,6,7</maxPortDownAve>
+        <maxPortDownStd>2,2,2</maxPortDownStd>
+    </ALARM>
 </PARAMS>
diff --git a/TestON/tests/SCPF/SCPFportLat/SCPFportLat.py b/TestON/tests/SCPF/SCPFportLat/SCPFportLat.py
index 3a6f503..9ca7d2c 100644
--- a/TestON/tests/SCPF/SCPFportLat/SCPFportLat.py
+++ b/TestON/tests/SCPF/SCPFportLat/SCPFportLat.py
@@ -230,6 +230,20 @@
                 main.log.report(
                     "Link to Grapg Std: {}".format( str( resultDict[ d ][ 'node' + str( i ) ][ 'Std' ][ 'LtoG' ] ) ) )
 
+        # Check if any result is abnormal
+        result = resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'EtoE' ]
+        if result > float( main.params[ 'ALARM' ][ 'maxPortUpAve' ].split( ',' )[ main.cycle - 1 ] ):
+            main.log.alarm( "Average of port up latency is {} with cluster size {}".format( result, main.Cluster.numCtrls ) )
+        result = resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ]
+        if result > float( main.params[ 'ALARM' ][ 'maxPortUpStd' ].split( ',' )[ main.cycle - 1 ] ):
+            main.log.alarm( "Std of port up latency is {} with cluster size {}".format( result, main.Cluster.numCtrls ) )
+        result = resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'EtoE' ]
+        if result > float( main.params[ 'ALARM' ][ 'maxPortDownAve' ].split( ',' )[ main.cycle - 1 ] ):
+            main.log.alarm( "Average of port down latency is {} with cluster size {}".format( result, main.Cluster.numCtrls ) )
+        result = resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ]
+        if result > float( main.params[ 'ALARM' ][ 'maxPortDownStd' ].split( ',' )[ main.cycle - 1 ] ):
+            main.log.alarm( "Std of port down latency is {} with cluster size {}".format( result, main.Cluster.numCtrls ) )
+
         with open( main.dbFileName, "a" ) as dbFile:
             # Scale number
             temp = str( main.Cluster.numCtrls )