[ONOS-6901] Fix how the systemTest does not return any result when it forced to quit the test

Change-Id: If93c48d46e8dc2494046b42de21f732775d7f520
diff --git a/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py b/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
index da20e97..08e437b 100644
--- a/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
+++ b/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
@@ -80,7 +80,7 @@
             main.testSetUp = ONOSSetup()
         except ImportError:
             main.log.error( "ONOSSetup not found exiting the test" )
-            main.exit()
+            main.cleanAndExit()
         main.testSetUp.envSetupDescription()
         try:
             from tests.HA.dependencies.HA import HA
@@ -174,8 +174,7 @@
                                  onpass="ONOS summary command succeded",
                                  onfail="ONOS summary command failed" )
         if not ready:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         # Grab the time of restart so we chan check how long the gossip
         # protocol has had time to work
diff --git a/TestON/tests/HA/HAcontinuousStopNodes/HAcontinuousStopNodes.py b/TestON/tests/HA/HAcontinuousStopNodes/HAcontinuousStopNodes.py
index 1f9f32d..026be2d 100644
--- a/TestON/tests/HA/HAcontinuousStopNodes/HAcontinuousStopNodes.py
+++ b/TestON/tests/HA/HAcontinuousStopNodes/HAcontinuousStopNodes.py
@@ -82,7 +82,7 @@
             main.testSetUp = ONOSSetup()
         except ImportError:
             main.log.error( "ONOSSetup not found. exiting the test" )
-            main.exit()
+            main.cleanAndExit()
         main.testSetUp.envSetupDescription()
         try:
             from tests.HA.dependencies.HA import HA
@@ -189,8 +189,7 @@
                     ctrl.name,
                     ctrl.CLI.sendline( "scr:list | grep -v ACTIVE" ) ) )
             main.log.error( "Failed to start ONOS, stopping test" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.killCount += 1
 
diff --git a/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py b/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
index 475759f..c3a2038 100644
--- a/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
+++ b/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
@@ -82,7 +82,7 @@
             main.testSetUp = ONOSSetup()
         except ImportError:
             main.log.error( "ONOSSetup not found. exiting the test" )
-            main.exit()
+            main.cleanAndExit()
         main.testSetUp.envSetupDescription()
         try:
             from tests.HA.dependencies.HA import HA
@@ -176,12 +176,10 @@
                     except pexpect.EOF:
                         main.log.error( self.name + ": EOF exception found" )
                         main.log.error( self.name + ":    " + self.handle.before )
-                        main.cleanup()
-                        main.exit()
+                        main.cleanAndExit()
                     except Exception:
                         main.log.exception( self.name + ": Uncaught exception!" )
-                        main.cleanup()
-                        main.exit()
+                        main.cleanAndExit()
             else:
                 for j in range( 0, n ):
                     if j not in main.partition:
@@ -196,12 +194,10 @@
                         except pexpect.EOF:
                             main.log.error( self.name + ": EOF exception found" )
                             main.log.error( self.name + ":    " + self.handle.before )
-                            main.cleanup()
-                            main.exit()
+                            main.cleanAndExit()
                         except Exception:
                             main.log.exception( self.name + ": Uncaught exception!" )
-                            main.cleanup()
-                            main.exit()
+                            main.cleanAndExit()
                 main.Cluster.runningNodes[ i ].active = False
             iCtrl.Bench.exitFromSsh( this, iCtrl.ipAddress )
         # NOTE: When dynamic clustering is finished, we need to start checking
@@ -247,8 +243,7 @@
                    "List of active nodes has duplicates, this likely indicates something was run out of order"
         except AssertionError:
             main.log.exception( "" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
         '''
 
         main.step( "Checking ONOS nodes" )
@@ -268,8 +263,7 @@
                     ctrl.name,
                     ctrl.CLI.sendline( "scr:list | grep -v ACTIVE" ) ) )
             main.log.error( "Failed to start ONOS, stopping test" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
     def CASE7( self, main ):
         """
diff --git a/TestON/tests/HA/HAkillNodes/HAkillNodes.py b/TestON/tests/HA/HAkillNodes/HAkillNodes.py
index e81dda9..63e34cb 100644
--- a/TestON/tests/HA/HAkillNodes/HAkillNodes.py
+++ b/TestON/tests/HA/HAkillNodes/HAkillNodes.py
@@ -77,7 +77,7 @@
             main.testSetUp = ONOSSetup()
         except ImportError:
             main.log.error( "ONOSSetup not found. exiting the test" )
-            main.exit()
+            main.cleanAndExit()
         main.testSetUp.envSetupDescription()
         try:
             from tests.HA.dependencies.HA import HA
@@ -177,8 +177,7 @@
                     ctrl.name,
                     ctrl.CLI.sendline( "scr:list | grep -v ACTIVE" ) ) )
             main.log.error( "Failed to start ONOS, stopping test" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
     def CASE62( self, main ):
         """
diff --git a/TestON/tests/HA/HAsanity/HAsanity.py b/TestON/tests/HA/HAsanity/HAsanity.py
index 8332a2b..82eeac5 100644
--- a/TestON/tests/HA/HAsanity/HAsanity.py
+++ b/TestON/tests/HA/HAsanity/HAsanity.py
@@ -76,7 +76,7 @@
             main.testSetUp = ONOSSetup()
         except ImportError:
             main.log.error( "ONOSSetup not found. exiting the test" )
-            main.exit()
+            main.cleanAndExit()
         main.testSetUp.envSetupDescription()
         try:
             from tests.HA.dependencies.HA import HA
diff --git a/TestON/tests/HA/HAscaling/HAscaling.py b/TestON/tests/HA/HAscaling/HAscaling.py
index 6a0abd4..cecd09e 100644
--- a/TestON/tests/HA/HAscaling/HAscaling.py
+++ b/TestON/tests/HA/HAscaling/HAscaling.py
@@ -80,7 +80,7 @@
             main.testSetUp = ONOSSetup()
         except ImportError:
             main.log.error( "ONOSSetup not found exiting the test" )
-            main.exit()
+            main.cleanAndExit()
 
         main.testSetUp.envSetupDescription()
         try:
@@ -184,8 +184,7 @@
                                      onfail="Failled to generate new metadata file" )
             time.sleep( 5 )  # Give time for nodes to read new file
         except IndexError:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         activeNodes = [ i for i in range( 0, main.Cluster.numCtrls ) ]
         newNodes = [ x for x in activeNodes if x not in prevNodes ]
@@ -226,8 +225,7 @@
                                  onpass="ONOS summary command succeded",
                                  onfail="ONOS summary command failed" )
         if not ready:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         # Rerun for election on new nodes
         runResults = main.TRUE
diff --git a/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py b/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py
index f8d5a49..13a4913 100644
--- a/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py
+++ b/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py
@@ -85,7 +85,7 @@
             main.testSetUp = ONOSSetup()
         except ImportError:
             main.log.error( "ONOSSetup not found. exiting the test" )
-            main.exit()
+            main.cleanAndExit()
         main.testSetUp.envSetupDescription()
         try:
             from tests.HA.dependencies.HA import HA
@@ -779,8 +779,7 @@
                     ctrl.CLI.sendline( "scr:list | grep -v ACTIVE" ) ) )
 
         if not topoResult:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
     def CASE9( self, main ):
         """
diff --git a/TestON/tests/HA/HAstopNodes/HAstopNodes.py b/TestON/tests/HA/HAstopNodes/HAstopNodes.py
index 8e6bd6f..2c4f059 100644
--- a/TestON/tests/HA/HAstopNodes/HAstopNodes.py
+++ b/TestON/tests/HA/HAstopNodes/HAstopNodes.py
@@ -77,7 +77,7 @@
             main.testSetUp = ONOSSetup()
         except ImportError:
             main.log.error( "ONOSSetup not found. exiting the test" )
-            main.exit()
+            main.cleanAndExit()
         main.testSetUp.envSetupDescription()
         try:
             from tests.HA.dependencies.HA import HA
@@ -174,8 +174,7 @@
                     ctrl.name,
                     ctrl.CLI.sendline( "scr:list | grep -v ACTIVE" ) ) )
             main.log.error( "Failed to start ONOS, stopping test" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
     def CASE62( self, main ):
         """
diff --git a/TestON/tests/HA/HAswapNodes/HAswapNodes.py b/TestON/tests/HA/HAswapNodes/HAswapNodes.py
index 923f67c..2de9f87 100644
--- a/TestON/tests/HA/HAswapNodes/HAswapNodes.py
+++ b/TestON/tests/HA/HAswapNodes/HAswapNodes.py
@@ -80,7 +80,7 @@
             main.testSetUp = ONOSSetup()
         except ImportError:
             main.log.error( "ONOSSetup not found. exiting the test" )
-            main.exit()
+            main.cleanAndExit()
         main.testSetUp.envSetupDescription()
         try:
             from tests.HA.dependencies.HA import HA
@@ -219,8 +219,7 @@
                                  onpass="ONOS summary command succeded",
                                  onfail="ONOS summary command failed" )
         if not ready:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         # Rerun for election on new nodes
         runResults = main.TRUE
diff --git a/TestON/tests/HA/dependencies/HA.py b/TestON/tests/HA/dependencies/HA.py
index 11bc039..4a22dc4 100644
--- a/TestON/tests/HA/dependencies/HA.py
+++ b/TestON/tests/HA/dependencies/HA.py
@@ -52,8 +52,7 @@
         except ( pexpect.TIMEOUT, pexpect.EOF ):
             main.log.exception( "ONOSbench: pexpect exception found:" +
                                 main.ONOSbench.handle.before )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
     def startingMininet( self ):
         main.step( "Starting Mininet" )
@@ -214,8 +213,7 @@
             return ( onosCounters, consistent )
         except Exception:
             main.log.exception( "" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
     def counterCheck( self, counterName, counterValue ):
         """
@@ -248,8 +246,7 @@
             return consistent and correctResults
         except Exception:
             main.log.exception( "" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
     def consistentLeaderboards( self, nodes ):
         TOPIC = 'org.onosproject.election'
@@ -359,8 +356,7 @@
                     ctrl.name,
                     ctrl.CLI.sendline( "scr:list | grep -v ACTIVE" ) ) )
             main.log.error( "Failed to start ONOS, stopping test" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Activate apps defined in the params file" )
         # get data from the params
@@ -640,8 +636,7 @@
         main.log.info( "Time for pingall: %2f seconds" %
                        ( time2 - time1 ) )
         if not pingResult:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
         # timeout for fwd flows
         time.sleep( 11 )
         # uninstall onos-app-fwd
@@ -1063,8 +1058,7 @@
             from tests.dependencies.topology import Topology
         except ImportError:
             main.log.error( "Topology not found exiting the test" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
         try:
             main.topoRelated
         except ( NameError, AttributeError ):
@@ -2770,8 +2764,7 @@
                     ctrl.name,
                     ctrl.CLI.sendline( "scr:list | grep -v ACTIVE" ) ) )
             main.log.error( "Failed to start ONOS, stopping test" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         self.commonChecks()
 
@@ -2838,8 +2831,7 @@
                                     "ONOSMastership[0] or mastershipState" )
                 main.log.debug( "ONOSMastership[0]: " + repr( ONOSMastership[ 0 ] ) )
                 main.log.debug( "mastershipState" + repr( mastershipState ) )
-                main.cleanup()
-                main.exit()
+                main.cleanAndExit()
             mastershipCheck = main.TRUE
             for i in range( 1, 29 ):
                 switchDPID = str(
@@ -3042,8 +3034,7 @@
             from tests.dependencies.topology import Topology
         except ImportError:
             main.log.error( "Topology not found exiting the test" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
         try:
             main.topoRelated
         except ( NameError, AttributeError ):
@@ -3388,8 +3379,7 @@
                     ctrl.CLI.sendline( "scr:list | grep -v ACTIVE" ) ) )
 
         if not topoResult:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
     def linkDown( self, main, fromS="s3", toS="s28" ):
         """