Merge "Segment Routing tests"
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 43cff72..9e6d5ff 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -997,16 +997,22 @@
             i = self.handle.expect( [
                 "Job\sis\salready\srunning",
                 "start/running",
+                "\$",
                 "Unknown\sinstance",
                 pexpect.TIMEOUT ], timeout=120 )
-            self.handle.expect( "\$" )
             if i == 0:
+                self.handle.expect( "\$" )
                 main.log.info( "Service is already running" )
                 return main.TRUE
             elif i == 1:
+                self.handle.expect( "\$" )
+                main.log.info( "ONOS service started" )
+                return main.TRUE
+            elif i == 2:
                 main.log.info( "ONOS service started" )
                 return main.TRUE
             else:
+                self.handle.expect( "\$" )
                 main.log.error( "ONOS service failed to start" )
                 main.cleanup()
                 main.exit()
diff --git a/TestON/tests/HAclusterRestart/HAclusterRestart.py b/TestON/tests/HAclusterRestart/HAclusterRestart.py
index 4e7ac23..835633e 100644
--- a/TestON/tests/HAclusterRestart/HAclusterRestart.py
+++ b/TestON/tests/HAclusterRestart/HAclusterRestart.py
@@ -1739,6 +1739,10 @@
         utilities.assert_equals( expect=main.TRUE, actual=killResults,
                                  onpass="ONOS nodes killed",
                                  onfail="ONOS kill unsuccessful" )
+        # FIXME: Remove once ONOS-4117 is fixed
+        time.sleep(1)
+        for node in main.nodes:
+            main.ONOSbench.onosStart( node.ip_address )
 
         main.step( "Checking if ONOS is up yet" )
         for i in range( 2 ):
diff --git a/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.py b/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.py
index 3ab5072..dda9b26 100644
--- a/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.py
+++ b/TestON/tests/HAsingleInstanceRestart/HAsingleInstanceRestart.py
@@ -1200,6 +1200,9 @@
 
         main.step( "Killing ONOS processes" )
         killResult = main.ONOSbench.onosKill( main.nodes[0].ip_address )
+        # FIXME: Remove once ONOS-4117 is fixed
+        time.sleep(1)
+        main.ONOSbench.onosStart( main.nodes[0].ip_address )
         start = time.time()
         utilities.assert_equals( expect=main.TRUE, actual=killResult,
                                  onpass="ONOS Killed",
diff --git a/TestON/tests/SCPFhostLat/SCPFhostLat.py b/TestON/tests/SCPFhostLat/SCPFhostLat.py
index 3dd5129..c24b6a7 100644
--- a/TestON/tests/SCPFhostLat/SCPFhostLat.py
+++ b/TestON/tests/SCPFhostLat/SCPFhostLat.py
@@ -322,11 +322,15 @@
             HosttoRemove.append( json.loads( gethost[1:len(gethost)-1] ).get('id') )
             main.CLIs[0].removeHost(HosttoRemove)
 
+        main.log.info("Result List: {}".format(addingHostTime))
+
         # calculate average latency from each nodes
         averageResult = numpy.average(addingHostTime)
+        main.log.info("Average Latency: {}".format(averageResult))
 
         # calculate std
         stdResult = numpy.std(addingHostTime)
+        main.log.info("std: {}".format(stdResult))
 
         # write to DB file
         main.log.info("Writing results to DS file")
diff --git a/TestON/tests/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py b/TestON/tests/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
index 03d6c56..a5fb104 100644
--- a/TestON/tests/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
+++ b/TestON/tests/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
@@ -432,6 +432,10 @@
             offfset = offfset + main.batchSize
 
             totalIntents = main.batchSize * main.numCtrls + totalIntents
+
+            # Contain the previous Flows
+            tempFlowsList = []
+
             if totalIntents >= main.minIntents and totalIntents % main.checkInterval == 0:
                 # if reach to minimum number and check interval, verify Intetns and flows
                 time.sleep( main.verifySleep * main.numCtrls )
@@ -457,10 +461,10 @@
                         break
                     intentVerify = main.FALSE
                     k = k+1
-
                 if not intentVerify:
-                    # If some intents are not installed, finished this test case
+                    # If some intents are not installed, grep the previous flows list, and finished this test case
                     main.log.warn( "Some intens did not install" )
+                    flowsState = tempFlowsList
                     # We don't want to check flows if intents not installed, because onos will drop flows
                     if currFlows == 0:
                     # If currFlows equal 0, which means we failed to install intents at first, or we didn't get
@@ -471,13 +475,14 @@
                 main.log.info("Verify Flows states")
                 k = 1
                 flowsVerify = main.TRUE
-
                 while k <= main.verifyAttempts:
                     # while loop for check flows by using REST api
                     time.sleep(3)
                     temp = 0
                     flowsStateCount = []
                     flowsState = json.loads( main.ONOSrest1.flows() )
+                    if ( len(flowsState) < len(tempFlowsList) ):
+                        tempFlowsList = flowsState
                     for f in flowsState:
                         # get PENDING_ADD flows
                         if f.get("state") == "PENDING_ADD":