[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/USECASE/SegmentRouting/dependencies/Testcaselib.py b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
index 9c73c0c..d83585a 100755
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
@@ -47,7 +47,7 @@
             main.testSetUp = ONOSSetup()
         except ImportError:
             main.log.error( "ONOSSetup not found. exiting the test" )
-            main.exit()
+            main.cleanAndExit()
         main.testSetUp.envSetupDescription()
         stepResult = main.FALSE
         try:
@@ -146,8 +146,7 @@
             main.pingChart = json.load( chart )
         if not ready:
             main.log.error( "ONOS startup failed!" )
-            main.cleanup( )
-            main.exit( )
+            main.cleanAndExit()
 
         for ctrl in main.Cluster.active():
             ctrl.CLI.logSet( "DEBUG", "org.onosproject.segmentrouting" )
@@ -169,8 +168,7 @@
                                  onfail="Failed to load topology" )
         # Exit if topology did not load properly
         if not topoResult:
-            main.cleanup( )
-            main.exit( )
+            main.cleanAndExit()
 
     @staticmethod
     def config( main, cfgName ):
@@ -213,8 +211,7 @@
 
         else :
             main.log.error( "Configuration failed!" )
-            main.cleanup( )
-            main.exit( )
+            main.cleanAndExit()
 
     @staticmethod
     def checkFlows( main, minFlowCount, dumpflows=True ):
@@ -396,7 +393,7 @@
             from tests.dependencies.utils import Utils
         except ImportError:
             main.log.error( "Utils not found exiting the test" )
-            main.exit()
+            main.cleanAndExit()
         try:
             main.utils
         except ( NameError, AttributeError ):
@@ -444,8 +441,7 @@
                         ctrl.name,
                         ctrl.CLI.sendline( "scr:list | grep -v ACTIVE" ) ) )
                 main.log.error( "Failed to kill ONOS, stopping test" )
-                main.cleanup()
-                main.exit()
+                main.cleanAndExit()
 
             topology = utilities.retry( main.Cluster.active( 0 ).checkStatus,
                                         main.FALSE,
@@ -502,8 +498,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()
 
         topology = utilities.retry( main.Cluster.active( 0 ).CLI.checkStatus,
                                     main.FALSE,
@@ -526,8 +521,7 @@
                                  onfail="ONOS summary command failed" )
         if not ready:
             main.log.error( "ONOS startup failed!" )
-            main.cleanup( )
-            main.exit( )
+            main.cleanAndExit()
 
     @staticmethod
     def addHostCfg( main ):
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.py b/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.py
index 48b0a66..93f0735 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.py
+++ b/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.py
@@ -45,8 +45,7 @@
                                  onfail="Failed to load topology" )
         # Exit if topology did not load properly
         if not topoResult:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
         main.step( "Connect switches to controller" )
 
         # connect all switches to controller
@@ -60,8 +59,7 @@
                                  onpass="Successfully connect all switches to ONOS",
                                  onfail="Failed to connect all switches to ONOS" )
         if not swResult:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Set up tunnel from Mininet node to onos node" )
         forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', main.Cluster.active( 0 ).ipAddress )
@@ -76,8 +74,7 @@
                                  onpass="Created tunnel succeeded",
                                  onfail="Create tunnel failed" )
         if ("PasswordAuthentication" not in tunnelResult) :
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
     def CASE101( self, main ):
         """
@@ -95,7 +92,7 @@
             from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase
         except ImportError:
             main.log.error( "sdnBase not found. exiting the test" )
-            main.exit()
+            main.cleanAndExit()
         try:
             main.sdnBase
         except ( NameError, AttributeError ):
@@ -121,8 +118,7 @@
             time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
             listResult = main.Cluster.active( 0 ).CLI.links( jsonFormat=False )
             main.log.info( listResult )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Activate sdn-ip application" )
         activeSDNIPresult = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.sdnip" )
@@ -132,8 +128,7 @@
                                  onfail="Activate SDN-IP failed" )
         if not activeSDNIPresult:
             main.log.info( "Activate SDN-IP failed!" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
 
         main.log.info( "Wait SDN-IP to finish installing connectivity intents \
@@ -260,8 +255,7 @@
             main.Functions.checkP2PintentNum( main, 36 ) #6 intents from sw to speakers x 6 intents to sw x 2 intents between them
         else:
             main.log.error( "Stopping switch failed!" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Check ping between hosts behind BGP peers" )
         result1 = main.Mininet.pingHost( src="h64514", target="h64515" )
@@ -275,8 +269,7 @@
                                  onfail="Ping test result is wrong" )
 
         if pingResult1 == False:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Check ping between BGP peers and speakers" )
         result4 = main.Mininet.pingHost( src="spk1", target="p64514" )
@@ -290,8 +283,7 @@
                                  onfail="Speaker1 ping peers NOT successful" )
 
         if pingResult2 == False:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Check whether all flow status are ADDED" )
         flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
@@ -334,8 +326,7 @@
             main.Functions.checkP2PintentNum( main, 42 )
         else:
             main.log.error( "Starting switch failed!" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Check whether all flow status are ADDED" )
         flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
@@ -386,8 +377,7 @@
             main.Functions.checkP2PintentNum( main, 42 )
         else:
             main.log.error( "Stopping switch failed!" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Check whether all flow status are ADDED" )
         flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
@@ -442,8 +432,7 @@
             main.log.debug( main.Mininet.checkFlows( "sw7" ) )
         else:
             main.log.error( "Starting switch failed!" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Check whether all flow status are ADDED" )
         flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunction/dependencies/Functions.py b/TestON/tests/USECASE/USECASE_SdnipFunction/dependencies/Functions.py
index 85b732d..a284213 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunction/dependencies/Functions.py
+++ b/TestON/tests/USECASE/USECASE_SdnipFunction/dependencies/Functions.py
@@ -121,12 +121,10 @@
     """
     if len( speakers ) == 0:
         main.log.error( "Parameter speakers can not be empty." )
-        main.cleanup()
-        main.exit()
+        main.cleanAndExit()
     if len( peers ) == 0:
         main.log.error( "Parameter speakers can not be empty." )
-        main.cleanup()
-        main.exit()
+        main.cleanAndExit()
 
     if expectAllSuccess:
         main.step( "BGP speakers ping peers, expect all tests to succeed" )
@@ -151,8 +149,7 @@
                              onfail = "Ping test results are Not expected" )
 
     if result == False:
-        main.cleanup()
-        main.exit()
+        main.cleanAndExit()
 
 
 def pingHostToHost( main,
@@ -169,8 +166,7 @@
                str( expectAllSuccess ) )
     if len( hosts ) == 0:
         main.log.error( "Parameter hosts can not be empty." )
-        main.cleanup()
-        main.exit()
+        main.cleanAndExit()
 
     result = True
     if expectAllSuccess:
@@ -194,7 +190,6 @@
 
     '''
     if result == False:
-        main.cleanup()
-        main.exit()
+        main.cleanAndExit()
     '''
 
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/USECASE_SdnipFunctionCluster.py b/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/USECASE_SdnipFunctionCluster.py
index 63940cb..d058a85 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/USECASE_SdnipFunctionCluster.py
+++ b/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/USECASE_SdnipFunctionCluster.py
@@ -45,8 +45,7 @@
                                  onfail="Failed to load topology" )
         # Exit if topology did not load properly
         if not topoResult:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
         main.step( "Connect switches to controllers" )
 
         # connect all switches to controllers
@@ -60,8 +59,7 @@
                                  onpass="Successfully connect all switches to ONOS",
                                  onfail="Failed to connect all switches to ONOS" )
         if not swResult:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
 
     def CASE101( self, main ):
@@ -89,7 +87,7 @@
             from tests.USECASE.dependencies.sdnipBaseFunction import SdnBase
         except ImportError:
             main.log.error( "sdnBase not found. exiting the test" )
-            main.exit()
+            main.cleanAndExit()
         try:
             main.sdnBase
         except ( NameError, AttributeError ):
@@ -117,8 +115,7 @@
                                  onpass="ONOS correctly discovered all links",
                                  onfail="ONOS Failed to discover all links" )
         if linkNum < 100:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Activate sdn-ip application" )
         activeSDNIPresult = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.sdnip" )
@@ -128,8 +125,7 @@
                                  onfail="Activate SDN-IP failed" )
         if not activeSDNIPresult:
             main.log.info( "Activate SDN-IP failed!" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
     def CASE102( self, main ):
         '''
@@ -259,8 +255,7 @@
             main.Functions.checkP2PintentNum( main, 48 ) #14 * 2
         else:
             main.log.error( "Stopping switch failed!" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Check ping between hosts behind BGP peers" )
         result1 = main.Mininet.pingHost( src="h64514", target="h64515" )
@@ -274,8 +269,7 @@
                                  onfail="Ping test result is wrong" )
 
         if pingResult1 == False:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Check ping between BGP peers and spk1" )
         result4 = main.Mininet.pingHost( src="spk1", target="p64514" )
@@ -289,8 +283,7 @@
                                  onfail="Speaker1 ping peers NOT successful" )
 
         if pingResult2 == False:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Check ping between BGP peers and spk2" )
         # TODO
@@ -305,8 +298,7 @@
                                  onfail="Speaker2 ping peers NOT successful" )
 
         if pingResult3 == False:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Check whether all flow status are ADDED" )
         flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
@@ -345,8 +337,7 @@
             main.Functions.checkP2PintentNum( main, 30 * 2 ) # 18*2
         else:
             main.log.error( "Starting switch failed!" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Check whether all flow status are ADDED" )
         flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
@@ -400,8 +391,7 @@
             main.Functions.checkP2PintentNum( main, 30 * 2 ) #18 * 2
         else:
             main.log.error( "Stopping switch failed!" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Check whether all flow status are ADDED" )
         flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
@@ -458,8 +448,7 @@
             main.log.debug( main.Mininet.checkFlows( "sw7" ) )
         else:
             main.log.error( "Starting switch failed!" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Check whether all flow status are ADDED" )
         flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
@@ -532,8 +521,7 @@
                                  onfail="Kill spk1 failed" )
         if ( "4" not in result3 ) :
             main.log.info( result3 )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
         main.Functions.checkRouteNum( main, 7 )
@@ -588,8 +576,7 @@
                                  onpass="Uninstall ONOS leader succeeded",
                                  onfail="Uninstall ONOS leader failed" )
         if uninstallResult != main.TRUE:
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
         time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
 
         if leaderIP == main.Cluster.active( 0 ).ipAddress:
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/dependencies/Functions.py b/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/dependencies/Functions.py
index 3a042a5..36f1eb4 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/dependencies/Functions.py
+++ b/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/dependencies/Functions.py
@@ -115,12 +115,10 @@
     """
     if len( speakers ) == 0:
         main.log.error( "Parameter speakers can not be empty." )
-        main.cleanup()
-        main.exit()
+        main.cleanAndExit()
     if len( peers ) == 0:
         main.log.error( "Parameter speakers can not be empty." )
-        main.cleanup()
-        main.exit()
+        main.cleanAndExit()
 
     if expectAllSuccess:
         main.step( "BGP speakers ping peers, expect all tests to succeed" )
@@ -145,8 +143,7 @@
                              onfail = "Ping test results are Not expected" )
 
     if result == False:
-        main.cleanup()
-        main.exit()
+        main.cleanAndExit()
 
 
 def pingHostToHost( main, hosts = ["h64514", "h64515", "h64516"],
@@ -162,8 +159,7 @@
                str( expectAllSuccess ) )
     if len( hosts ) == 0:
         main.log.error( "Parameter hosts can not be empty." )
-        main.cleanup()
-        main.exit()
+        main.cleanAndExit()
 
     result = True
     if expectAllSuccess:
@@ -187,8 +183,7 @@
 
     '''
     if result == False:
-        main.cleanup()
-        main.exit()
+        main.cleanAndExit()
     '''
 
 
@@ -211,6 +206,5 @@
                              onpass = "Created tunnel succeeded",
                              onfail = "Create tunnel failed" )
     if ( "PasswordAuthentication" not in tunnelResult ) :
-        main.cleanup()
-        main.exit()
+        main.cleanAndExit()
 
diff --git a/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.py b/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.py
index 0b8c85d..d0f4ed7 100644
--- a/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.py
+++ b/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.py
@@ -56,7 +56,7 @@
             main.testSetUp = ONOSSetup()
         except ImportError:
             main.log.error( "ONOSSetup not found. exiting the test" )
-            main.exit()
+            main.cleanAndExit()
         main.testSetUp.envSetupDescription()
         stepResult = main.FALSE
         try:
diff --git a/TestON/tests/USECASE/dependencies/sdnipBaseFunction.py b/TestON/tests/USECASE/dependencies/sdnipBaseFunction.py
index e51318c..1d913cc 100644
--- a/TestON/tests/USECASE/dependencies/sdnipBaseFunction.py
+++ b/TestON/tests/USECASE/dependencies/sdnipBaseFunction.py
@@ -11,7 +11,7 @@
             main.testSetUp = ONOSSetup()
         except Exception:
             main.log.error( "ONOSSetup not found. exiting the test" )
-            main.exit()
+            main.cleanAndExit()
         main.testSetUp.envSetupDescription()
         main.testSetUp.envSetup()
         main.apps = main.params[ 'ENV' ][ 'appString' ]
@@ -41,8 +41,7 @@
 
         if not ready:
             main.log.error( "ONOS startup failed!" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
     def pToPIntentTest( self, intentExpectedNum ):
         '''
@@ -155,8 +154,7 @@
             main.Functions.checkM2SintentNum( main, link1IntentNum )
         else:
             main.log.error( "Bring " + upOrDown + " link failed!" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Bring " + upOrDown + " the link between sw8 and " + link2Peer )
         linkResult2 = main.Mininet.link( END1="sw8", END2=link2Peer,
@@ -171,8 +169,7 @@
             main.Functions.checkM2SintentNum( main, link2IntentNum )
         else:
             main.log.error( "Bring " + upOrDown + " link failed!" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Bring " + upOrDown + " the link between sw28 and "+ link3Peer )
         linkResult3 = main.Mininet.link( END1="sw28", END2=link3Peer,
@@ -187,8 +184,7 @@
             main.Functions.checkM2SintentNum( main, link3IntentNum )
         else:
             main.log.error( "Bring " + upOrDown + " link failed!" )
-            main.cleanup()
-            main.exit()
+            main.cleanAndExit()
 
         main.step( "Check whether all flow status are ADDED" )
         flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,