Merge "Added Case32 and updated SAMPstartTemplate"
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 3e94166..a3e2b6a 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -849,7 +849,7 @@
             main.cleanup()
             main.exit()
 
-    def links( self, jsonFormat=True ):
+    def links( self, jsonFormat=True, timeout=30 ):
         """
         Lists all core links
         Optional argument:
@@ -859,7 +859,7 @@
             cmdStr = "links"
             if jsonFormat:
                 cmdStr += " -j"
-            handle = self.sendline( cmdStr )
+            handle = self.sendline( cmdStr, timeout=timeout )
             assert "Command not found:" not in handle, handle
             return handle
         except AssertionError:
@@ -1872,7 +1872,7 @@
             main.cleanup()
             main.exit()
 
-    def removeAllIntents( self, purge=False, sync=False, app='org.onosproject.cli' ):
+    def removeAllIntents( self, purge=False, sync=False, app='org.onosproject.cli', timeout=30 ):
         """
         Description:
             Remove all the intents
@@ -1891,7 +1891,7 @@
                 cmdStr += " -s"
 
             cmdStr += " " + app
-            handle = self.sendline( cmdStr )
+            handle = self.sendline( cmdStr, timeout=timeout )
             assert "Command not found:" not in handle, handle
             if re.search( "Error", handle ):
                 main.log.error( "Error in removing intent" )
@@ -4386,7 +4386,7 @@
             main.cleanup()
             main.exit()
 
-    def summary( self, jsonFormat=True ):
+    def summary( self, jsonFormat=True, timeout=30 ):
         """
         Description: Execute summary command in onos
         Returns: json object ( summary -j ), returns main.FALSE if there is
@@ -4397,7 +4397,7 @@
             cmdStr = "summary"
             if jsonFormat:
                 cmdStr += " -j"
-            handle = self.sendline( cmdStr )
+            handle = self.sendline( cmdStr, timeout=timeout )
             assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             assert "Error:" not in handle, handle
@@ -4758,7 +4758,7 @@
             main.cleanup()
             main.exit()
 
-    def link( self, begin, end, state ):
+    def link( self, begin, end, state, timeout=30, showResponse=True ):
         '''
         Description:
             Bring link down or up in the null-provider.
@@ -4771,7 +4771,7 @@
         '''
         try:
             cmd =  "null-link null:{} null:{} {}".format( begin, end, state )
-            response = self.sendline( cmd, showResponse=True )
+            response = self.sendline( cmd, showResponse=showResponse, timeout=timeout )
             assert response is not None, "Error in sendline"
             assert "Command not found:" not in response, response
             if "Error" in response or "Failure" in response:
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 0b5906f..dde65d3 100755
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -1664,6 +1664,8 @@
                 "stop/waiting",
                 "Not Running ...",
                 pexpect.TIMEOUT ], timeout=120 )
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
 
             if i == 0 or i == 1:
                 main.log.info( "ONOS is running" )
diff --git a/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.params b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.params
new file mode 100755
index 0000000..34dba48
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.params
@@ -0,0 +1,43 @@
+<PARAMS>
+#**** Scripted by Antony Silvester  - antony.silvester@huawei.com ******
+#This Test check the bgp_ls functionality
+#List of test cases:
+#CASE1: Compile ONOS and push it to the test machines
+#CASE2: Discovery the topology using BGPLS
+#CASE3: Addition of new Node to existing topology
+#CASE4: Deletion of Node
+#Case5: Uninstalling the app
+
+
+    <testcases>1,2,3,4,5</testcases>
+
+    <DEPENDENCY>
+        <path>/tests/FUNCbgpls/Dependencies/</path>
+    </DEPENDENCY>
+
+    <ENV>
+        <cellName>bgp_ls</cellName>
+        <cellApps>drivers,openflow,proxyarp,mobility</cellApps>
+    </ENV>
+
+    <CTRL>
+        <ip1>OC1</ip1>
+        <port1>6653</port1>
+    </CTRL>
+
+    <HTTP>
+        <port>8181</port>
+        <path>/onos/</path>
+    </HTTP>
+
+    <GIT>
+        <pull>False</pull>
+        <branch>master</branch>
+    </GIT>
+
+   <SCAPY>
+        <HOSTNAMES>OCN</HOSTNAMES>
+    </SCAPY>
+
+
+</PARAMS>
diff --git a/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py
new file mode 100755
index 0000000..0e86351
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py
@@ -0,0 +1,578 @@
+"""
+**** Scripted by Antony Silvester  - antony.silvester@huawei.com ******
+
+
+This Test check the bgp_ls functionality
+
+List of test cases:
+CASE1: Compile ONOS and push it to the test machines
+CASE2: Discovery the topology using BGPLS
+CASE3: Addition of new Node to existing topology
+CASE4: Deletion of Node
+Case5: Uninstalling the app
+
+
+"""
+
+
+class FUNCbgpls:
+
+    def __init__( self ):
+        self.default = ''
+
+    def CASE1( self, main ):
+        """
+        CASE1 is to compile ONOS and push it to the test machines
+
+        Startup sequence:
+        cell <name>
+        onos-verify-cell
+        NOTE: temporary - onos-remove-raft-logs
+        onos-uninstall
+        git pull
+        mvn clean install
+        onos-package
+        onos-install -f
+        onos-wait-for-start
+        start cli sessions
+        start BGPLS apps
+
+        """
+
+        import os
+        main.log.info( "ONOS Single node start " +
+                         "Scapy Tool - initialization" )
+        main.case( "Setting up test environment" )
+        main.caseExplanation = "Setup the test environment including " +\
+                                "installing ONOS, start ONOS."
+
+
+        PULLCODE = False
+        if main.params[ 'GIT' ][ 'pull' ] == 'True':
+            PULLCODE = True
+        gitBranch = main.params[ 'GIT' ][ 'branch' ]
+        cellName = main.params[ 'ENV' ][ 'cellName' ]
+        ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
+        scapy_ip = os.getenv(main.params ['SCAPY'] ['HOSTNAMES'] )
+
+        main.log.info( "Removing raft logs" )
+        main.ONOSbench.onosRemoveRaftLogs()
+
+        main.CLIs = []
+        main.nodes = []
+        main.numCtrls= 1
+
+        for i in range( 1, main.numCtrls + 1 ):
+            try:
+                main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+                main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+                ipList.append( main.nodes[ -1 ].ip_address )
+            except AttributeError:
+                break
+
+        main.log.info( "Uninstalling ONOS" )
+        for node in main.nodes:
+            main.ONOSbench.onosUninstall( node.ip_address )
+
+        main.step( "Create cell file" )
+        cellAppString = main.params[ 'ENV' ][ 'cellApps' ]
+
+        main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
+                                       scapy_ip,
+                                       cellAppString, ipList )
+
+        main.step( "Applying cell variable to environment" )
+        cellResult = main.ONOSbench.setCell( cellName )
+
+        verifyResult = main.ONOSbench.verifyCell()
+
+        # Make sure ONOS process is not running
+        main.log.info( "Killing any ONOS processes" )
+        killResults = main.TRUE
+        for node in main.nodes:
+            killed = main.ONOSbench.onosKill( node.ip_address )
+            killResults = killResults and killed
+
+        cleanInstallResult = main.TRUE
+        gitPullResult = main.FALSE
+        main.step( "Git checkout and pull" + gitBranch )
+        if PULLCODE:
+            main.ONOSbench.gitCheckout( gitBranch )
+            gitPullResult = main.ONOSbench.gitPull()
+            # values of 1 or 3 are good
+            utilities.assert_lesser( expect=0, actual=gitPullResult,
+                                      onpass="Git pull successful",
+                                      onfail="Git pull failed" )
+
+        #main.ONOSbench.getVersion( report=True )
+
+        main.step( "Using mvn clean install" )
+        cleanInstallResult = main.TRUE
+        if PULLCODE and gitPullResult == main.TRUE:
+            cleanInstallResult = main.ONOSbench.cleanInstall()
+        else:
+            main.log.warn( "Did not pull new code so skipping mvn" +
+                           "clean install" )
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=cleanInstallResult,
+                                 onpass="MCI successful",
+                                 onfail="MCI failed" )
+
+        main.step( "Creating ONOS package" )
+        packageResult = main.ONOSbench.onosPackage()
+        utilities.assert_equals( expect=main.TRUE,
+                                     actual=packageResult,
+                                     onpass="Successfully created ONOS package",
+                                     onfail="Failed to create ONOS package" )
+
+        main.step( "Installing ONOS package" )
+        onosInstallResult = main.ONOSbench.onosInstall(
+                options="-f", node=main.nodes[0].ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
+                                 onpass="ONOS install successful",
+                                 onfail="ONOS install failed" )
+
+        main.step( "Checking if ONOS is up yet" )
+        print main.nodes[0].ip_address
+        for i in range( 2 ):
+            onos1Isup = main.ONOSbench.isup( main.nodes[0].ip_address )
+            if onos1Isup:
+                break
+        utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
+                                 onpass="ONOS startup successful",
+                                 onfail="ONOS startup failed" )
+        main.log.step( "Starting ONOS CLI sessions" )
+        print main.nodes[0].ip_address
+        cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=cliResults,
+                                 onpass="ONOS cli startup successful",
+                                 onfail="ONOS cli startup failed" )
+
+        main.step( "App Ids check" )
+        appCheck = main.ONOScli1.appToIDCheck()
+
+        if appCheck !=main.TRUE:
+            main.log.warn( main.CLIs[0].apps() )
+            main.log.warn( main.CLIs[0].appIDs() )
+            utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+                                 onpass="App Ids seem to be correct",
+                                 onfail="Something is wrong with app Ids" )
+        if cliResults == main.FALSE:
+            main.log.error( "Failed to start ONOS,stopping test" )
+            main.cleanup()
+            main.exit()
+
+
+
+
+
+    def CASE2( self, main ):
+        """
+        Discovery the topology using BGPLS
+        """
+        import os , sys
+        import re
+        import time
+
+        main.case( "Testcase 2 : Discovery the Network Topology using BGPLS" )
+
+        try:
+            from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
+        except ImportError:
+            main.log.exception( "Something wrong with import file or code error." )
+            main.log.info( "Import Error, please check!" )
+            main.cleanup()
+            main.exit()
+
+        bgplsConfig = BgpLs()
+        Ne_id = bgplsConfig.Constants()
+        app = bgplsConfig.apps()
+        main.CLIs = []
+        main.nodes = []
+        main.numCtrls= 1
+
+
+        ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
+        scapy_ip = os.getenv(main.params ['SCAPY'] ['HOSTNAMES'] )
+        httpport = main.params['HTTP']['port']
+        path = main.params['HTTP']['path']
+        bgplsConfig.ipValue(ipList,scapy_ip)
+
+        for i in range( 1, main.numCtrls + 1 ):
+            try:
+                main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+                main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+                ipList.append( main.nodes[ -1 ].ip_address )
+            except AttributeError:
+                break
+
+        main.step( "Apply cell to environment" )
+        bgplsConfig.Comments()
+
+        bgplsConfig.Comments()
+        main.log.info( "Sending BGPLS information " )
+        bgplsConfig.Comments()
+
+
+        main.Scapy1.handle.sendline( "sudo python  OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\
+        dependencies/Scapyfiles/Topo_discovery.py" )
+        bgplsConfig.Comments()
+        main.log.info( "Enable BGPlS plugin in ONOS" )
+        bgplsConfig.Comments()
+
+
+        cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address)
+
+        main.step( "Getting connected to ONOS" )
+        utilities.assert_equals( expect=main.TRUE, actual=cliResults,
+                                 onpass="ONOS cli startup successful",
+                                 onfail="ONOS cli startup failed" )
+        installResults = main.ONOScli1.activateApp( app[0])
+
+        main.step( "Install onos-app-bgp" )
+        utilities.assert_equals( expect=main.TRUE, actual=installResults,
+                                 onpass="Install onos-app-bgp successful",
+                                 onfail="Install onos-app-bgp failed" )
+
+        bgpls_post = bgplsConfig.DictoJson()
+
+        bgplsConfig.Comments()
+        main.log.info( "BGPLS RestConf input" )
+        bgplsConfig.Comments()
+
+        print (bgpls_post)
+        main.ONOSrest.user_name = "karaf"
+        main.ONOSrest.pwd = "karaf"
+        Poststatus, result = main.ONOSrest.send( '/network/configuration/', method="POST", data=bgpls_post)
+        main.step( "Configure BGP through RESTCONF" )
+
+        utilities.assert_equals(
+                expect='200',
+                actual=Poststatus,
+                onpass="Post Port Success",
+                onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
+
+
+        bgplsConfig.Comments()
+        main.log.info( "Check Network devices are Updated in ONOS " )
+        bgplsConfig.Comments()
+        time.sleep(15)
+
+        response = main.ONOScli1.devices()
+        main.step( "Check the nodes are discovered" )
+        if response.find( Ne_id[1][0]) and response.find(Ne_id[1][1]) and response.find(Ne_id[1][2]) != -1:
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Node " + str( Ne_id[1][0]) + ( Ne_id[1][1]) + ( Ne_id[1][2]) + "  sucess",
+                                 onfail="Node " + str( Ne_id[1][0]) + ( Ne_id[1][1]) + ( Ne_id[1][2]) + " failed" )
+
+
+        bgplsConfig.Comments()
+        main.log.info( "Kill Scapy process" )
+        bgplsConfig.Comments()
+
+        main.Scapy1.handle.sendline( "\x03" )
+        time.sleep(90) #This Sleep time gives time for the socket to close.
+
+
+
+
+    def CASE3( self, main ):
+        """
+        Addition of new Node to existing topology
+        """
+        import os , sys
+        import re
+        import time
+
+        main.case( "Testcase 3: Addition of New Node to existing topology" )
+        try:
+            from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
+        except ImportError:
+            main.log.exception( "Something wrong with import file or code error." )
+            main.log.info( "Import Error, please check!" )
+            main.cleanup()
+            main.exit()
+
+        bgplsConfig = BgpLs()
+        Ne_id = bgplsConfig.Constants()
+        app = bgplsConfig.apps()
+        main.CLIs = []
+        main.nodes = []
+        main.numCtrls= 1
+
+
+        ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
+        scapy_ip = os.getenv( main.params ['SCAPY'] ['HOSTNAMES'] )
+        cellName = main.params[ 'ENV' ][ 'cellName' ]
+        cellAppString= main.params[ 'ENV' ][ 'cellApps' ]
+        httpport = main.params['HTTP']['port']
+        path = main.params['HTTP']['path']
+
+        bgplsConfig.ipValue(ipList,scapy_ip)
+
+        for i in range( 1, main.numCtrls + 1 ):
+            try:
+                main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+                main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+                ipList.append( main.nodes[ -1 ].ip_address )
+            except AttributeError:
+                break
+
+        bgplsConfig.Comments()
+        main.log.info( "Sending BGPLS Packet " )
+        bgplsConfig.Comments()
+
+        main.Scapy1.handle.sendline( "sudo python  OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\
+        dependencies/Scapyfiles/Update_Node.py" )
+        bgplsConfig.Comments()
+        main.log.info( "Enable BGPlS plugin in ONOS" )
+        bgplsConfig.Comments()
+
+        main.step( "UnInstall onos-app-bgp" )
+        installResults = main.ONOScli1.deactivateApp( app[0] )
+        utilities.assert_equals( expect=main.TRUE, actual=installResults,
+                                 onpass="Uninstall  onos-app-bgp successful",
+                                 onfail="Uninstall  onos-app-bgp failed" )
+
+        installResults = main.ONOScli1.activateApp( app[0])
+        main.step( "Install onos-app-bgp" )
+        utilities.assert_equals( expect=main.TRUE, actual=installResults,
+                                 onpass="Install onos-app-bgp successful",
+                                 onfail="Install onos-app-bgp failed" )
+
+
+        bgpls_post = bgplsConfig.DictoJson()
+
+        bgplsConfig.Comments()
+        main.log.info( "BGPLS RestConf input" )
+        bgplsConfig.Comments()
+
+        bgplsConfig.Comments()
+        main.log.info( "Check Network devices are Updated in ONOS " )
+        bgplsConfig.Comments()
+        time.sleep(120)
+
+        response = main.ONOScli1.devices()
+        main.step( "Check Newly added Node is getting updated" )
+
+        if response.find( Ne_id[1][3]) != -1:
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Node " + str( Ne_id[1][3] ) + " update  sucess",
+                                 onfail="Node " + str( Ne_id[1][3]) + " update failed" )
+        bgplsConfig.Comments()
+        main.log.info( "Kill Scapy process" )
+        bgplsConfig.Comments()
+        main.Scapy1.handle.sendline( "\x03" )
+
+
+
+    def CASE4( self, main ):
+        """
+        Deletion of  Node
+        """
+        import os , sys
+        import re
+        import time
+        main.case( "TestCase 4: Deletion of Node from existing Topology" )
+
+        try:
+            from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
+        except ImportError:
+            main.log.exception( "Something wrong with import file or code error." )
+            main.log.info( "Import Error, please check!" )
+            main.cleanup()
+            main.exit()
+
+        bgplsConfig = BgpLs()
+        Ne_id = bgplsConfig.Constants()
+        app = bgplsConfig.apps()
+        main.CLIs = []
+        main.nodes = []
+        main.numCtrls= 1
+
+        bgplsConfig.Comments()
+        main.log.info( "Blocked due to this defect : ONOS-3920 " )
+        bgplsConfig.Comments()
+
+        '''
+        ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
+        scapy_ip = os.getenv(main.params ['SCAPY'] ['HOSTNAMES'] )
+        cellName = main.params[ 'ENV' ][ 'cellName' ]
+        cellAppString= main.params[ 'ENV' ][ 'cellApps' ]
+        httpport = main.params['HTTP']['port']
+        path = main.params['HTTP']['path']
+        bgplsConfig = BgpLs()
+        bgplsConfig.ipValue(ipList,scapy_ip)
+
+        main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
+                                       scapy_ip,
+                                       cellAppString, ipList , onosUser="karaf" )
+
+        for i in range( 1, main.numCtrls + 1 ):
+            try:
+                main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+                main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+                ipList.append( main.nodes[ -1 ].ip_address )
+            except AttributeError:
+                break
+
+        main.step( "Apply cell to environment" )
+        bgplsConfig.Comments()
+        cellResult = main.ONOSbench.setCell( cellName )
+
+        bgplsConfig.Comments()
+        main.log.info( "Sending BGPLS information " )
+        bgplsConfig.Comments()
+
+
+        main.Scapy1.handle.sendline( "sudo python  OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py" )
+        #main.Scapy1.handle.expect( "sdn:" )
+        #main.Scapy1.handle.sendline( "rocks" )
+
+
+        bgplsConfig.Comments()
+        main.log.info( "Enable BGPlS plugin in ONOS" )
+        bgplsConfig.Comments()
+
+
+        cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address)
+
+        main.step( "Getting connected to ONOS" )
+        utilities.assert_equals( expect=main.TRUE, actual=cliResults,
+                                 onpass="ONOS cli startup successful",
+                                 onfail="ONOS cli startup failed" )
+        installResults = main.ONOScli1.activateApp( app[0])
+
+        main.step( "Install onos-app-bgp" )
+        utilities.assert_equals( expect=main.TRUE, actual=installResults,
+                                 onpass="Install onos-app-bgp successful",
+                                 onfail="Install onos-app-bgp failed" )
+
+        main.step( "Install onos-app-bgpflow" )
+        installResults = main.ONOScli1.activateApp( app[1] )
+        utilities.assert_equals( expect=main.TRUE, actual=installResults,
+                                 onpass="Install onos-app-bgpflow successful",
+                                 onfail="Install onos-app-bgpflow failed" )
+
+
+        bgpls_post = bgplsConfig.DictoJson()
+
+        bgplsConfig.Comments()
+        main.log.info( "BGPLS RestConf input" )
+        bgplsConfig.Comments()
+
+        print (bgpls_post)
+        main.ONOSrest.user_name = "karaf"
+        main.ONOSrest.pwd = "karaf"
+        Poststatus, result = main.ONOSrest.send( ipList,httpport,'', path + 'v1/network/configuration/',
+                                                 'POST', None, bgpls_post, debug=True )
+
+        main.step( "Configure BGP through RESTCONF" )
+        utilities.assert_equals(
+                expect='200',
+                actual=Poststatus,
+                onpass="Post Port Success",
+                onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
+
+
+        bgplsConfig.Comments()
+        main.log.info( "Check Network devices is deleted from  ONOS " )
+        bgplsConfig.Comments()
+        time.sleep(15)
+
+        response = main.ONOScli1.devices()
+
+        main.step( "Check whehther Node is deleted successfully" )
+
+        if response.find(Ne_id[3]) != -1:
+            stepResult = main.TRUE
+        else:
+            stepResult = main.FALSE
+        utilities.assert_equals( expect=main.FALSE,
+                                 actual=stepResult,
+                                 onpass="Node " + str( Ne_id[3] ) + " Deletion sucess",
+                                 onfail="Node " + str( Ne_id[3] ) + " Deletion  failed" )
+
+        bgplsConfig.Comments()
+        main.log.info( "Kill Scapy process" )
+        bgplsConfig.Comments()
+
+        main.Scapy1.handle.sendline( "\x03" )
+        '''
+
+
+    def CASE5( self, main ):
+        """
+        Uninstalling the app
+        """
+        import os,sys
+        import re
+        import time
+
+        main.case( "TestCase 5: UnInstalling of app" )
+        try:
+            from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
+        except ImportError:
+            main.log.exception( "Something wrong with import file or code error." )
+            main.log.info( "Import Error, please check!" )
+            main.cleanup()
+            main.exit()
+
+        bgplsConfig = BgpLs()
+        app = bgplsConfig.apps()
+        main.CLIs = []
+        main.nodes = []
+        main.numCtrls= 1
+
+
+        ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
+        scapy_ip = os.getenv(main.params ['SCAPY'] ['HOSTNAMES'] )
+        cellName = main.params[ 'ENV' ][ 'cellName' ]
+        cellAppString= main.params[ 'ENV' ][ 'cellApps' ]
+
+        bgplsConfig = BgpLs()
+        bgplsConfig.ipValue(ipList,scapy_ip)
+        main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
+                                       scapy_ip,
+                                       cellAppString, ipList , onosUser="karaf" )
+
+        for i in range( 1, main.numCtrls + 1 ):
+            try:
+                main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+                main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+                ipList.append( main.nodes[ -1 ].ip_address )
+            except AttributeError:
+                break
+
+        main.step( "Apply cell to environment" )
+        bgplsConfig.Comments()
+        cellResult = main.ONOSbench.setCell( cellName )
+
+        bgplsConfig.Comments()
+        main.log.info( "Logging into ONOS CLI " )
+        bgplsConfig.Comments()
+
+        cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=cliResults,
+                                 onpass="ONOS cli startup successful",
+                                 onfail="ONOS cli startup failed" )
+
+        bgplsConfig.Comments()
+        main.log.info( "Uninstall onos-app-bgp" )
+        bgplsConfig.Comments()
+        main.step( "UnInstall onos-app-bgp" )
+        installResults = main.ONOScli1.deactivateApp( app[0] )
+        utilities.assert_equals( expect=main.TRUE, actual=installResults,
+                                 onpass="Uninstall  onos-app-bgp successful",
+                                 onfail="Uninstall  onos-app-bgp failed" )
+
+
+
diff --git a/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.topo b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.topo
new file mode 100755
index 0000000..fc1bf21
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.topo
@@ -0,0 +1,52 @@
+<TOPOLOGY>
+    <COMPONENT>
+
+        <ONOSbench>
+            <host>OCN</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>1</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOSbench>
+
+        <ONOScli1>
+            <host>OCN</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosCliDriver</type>
+            <connect_order>2</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOScli1>
+
+        <ONOS1>
+            <host>OC1</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosDriver</type>
+            <connect_order>3</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOS1>
+
+        <ONOSrest>
+            <host>OC1</host>
+            <user>sdn</user>
+            <port>8181</port>
+            <user>onos</user>
+            <password>rocks</password>
+            <type>OnosRestDriver</type>
+            <connect_order>4</connect_order>
+            <COMPONENTS> </COMPONENTS>
+        </ONOSrest>
+
+       <Scapy1>
+            <host>OCN</host>
+           <user>sdn</user>
+            <password>rocks</password>
+            <type>ScapyCliDriver</type>
+            <connect_order>5</connect_order>
+        </Scapy1>
+
+    </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/FUNC/FUNCbgpls/README b/TestON/tests/FUNC/FUNCbgpls/README
new file mode 100755
index 0000000..2ecb554
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/README
@@ -0,0 +1,42 @@
+
+ONOS BGPLS Feature Scripts
+***************************
+
+Brief :
+*******
+        BGPLS as a southbound plug-in in ONOS controller to collect the
+        topology information of the network. This network topology can be
+        used by some applications like PCE would benefit from visibility
+        outside one area or Autonomous System (AS) in order to make better
+        decisions for path computation.
+
+
+Prerequisites:
+**************
+
+1] Scapy should be installed and running in OCN.
+2] The Scapy version should be 2.3.1 and above.
+3] Then  git clone https://github.com/secdev/scapy.git
+4] cd to scapy folder and run --- > sudo python setup.py install
+5] Test TOPO :  OCN --- OCI
+6] OnosSystemTest folder should be under ~/
+
+
+Things to know :
+****************
+
+1] We use Scapy tool, to send the BGPLS packet to ONOS.
+2] The packets are already pre-captured.
+3] ONOS reads those packet and displays the topology.
+4] We query the devices information in ONOS to check the devices/links are learn
+
+
+Steps :
+*******
+
+  1] run FUNCbgpls
+
+
+***************************************************************END************************************************************************
+
+
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/__init__.py b/TestON/tests/FUNC/FUNCbgpls/__init__.py
old mode 100644
new mode 100755
similarity index 100%
copy from TestON/tests/USECASE/USECASE_SegmentRouting/__init__.py
copy to TestON/tests/FUNC/FUNCbgpls/__init__.py
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/Topo_pkts.pcap b/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/Topo_pkts.pcap
new file mode 100755
index 0000000..2021f22
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/Topo_pkts.pcap
Binary files differ
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls_all.pcap b/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls_all.pcap
new file mode 100755
index 0000000..e831d22
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls_all.pcap
Binary files differ
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Nbdata.py b/TestON/tests/FUNC/FUNCbgpls/dependencies/Nbdata.py
new file mode 100755
index 0000000..8a83748
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/Nbdata.py
@@ -0,0 +1,80 @@
+"""**** Scripted by Antony Silvester ****** """
+import json
+from urllib import addbase
+import os
+
+
+import requests
+from requests.auth import HTTPBasicAuth
+
+
+class BgpLs:
+
+    def __init__(self):
+        self.localAs = 100
+        self.maxSession = 20
+        self.lsCapability = True
+        self.holdTime = 180
+        self.largeAsCapability = False
+        self.flowSpecCapability = 'IPV4'
+        self.flowSpecRpdCapability = False
+        self.remoteAs = 100
+        self.peerHoldTime = 120
+        self.connectMode = 'active'
+        self.bgpPeer = []
+        self.routerId = ''
+        self.peerIp = ''
+        #self.org_bgp = []
+
+    def ipValue(self,localip,remoteip):
+        self.routerId = localip
+        self.peerIp = remoteip
+        return self.routerId , self.peerIp
+
+    def DictoJson(self):
+        Dicdata = {}
+        org_bgp =[]
+        org_bgp.append({'peerIp': self.peerIp , 'remoteAs':self.remoteAs,
+                        'peerHoldTime':self.peerHoldTime , 'connectMode':self.connectMode })
+        if self.routerId != '':
+            Dicdata['routerId'] = self.routerId
+        if self.localAs != '':
+            Dicdata['localAs'] = self.localAs
+        if self.maxSession != '':
+            Dicdata['maxSession'] = self.maxSession
+        if self.lsCapability != '':
+            Dicdata['lsCapability'] = self.lsCapability
+        if self.holdTime != '':
+            Dicdata['holdTime'] = self.holdTime
+        if self.largeAsCapability != '':
+            Dicdata['largeAsCapability'] = self.largeAsCapability
+        if self.flowSpecCapability != '':
+            Dicdata['flowSpecCapability'] = self.flowSpecCapability
+        if self.flowSpecRpdCapability != '':
+            Dicdata['flowSpecRpdCapability'] = self.flowSpecRpdCapability
+        if self.bgpPeer != '':
+            Dicdata['bgpPeer'] = org_bgp
+
+        Dicdata = {'bgpapp':Dicdata}
+        Dicdata = {'org.onosproject.provider.bgp.cfg':Dicdata}
+        Dicdata = {'apps':Dicdata}
+        return json.dumps(Dicdata,indent=4)
+
+
+    def  Comments(self):
+        print("**********************************************************************************\n")
+
+    def Constants(self):
+        self.Ne_id_1 =  '1111.1111.0011'
+        self.Ne_id_2 = '2222.2222.0022'
+        self.Ne_id_3 = '3333.3333.0033'
+        self.Ne_id_4 = '4444.4444.0044'
+        listnum = [self.Ne_id_1,self.Ne_id_2,self.Ne_id_3,self.Ne_id_4,]
+        var = [self.peerIp]
+        return var,listnum
+
+    def apps(self):
+        self.app_bgp = 'org.onosproject.bgp'
+        self.app_bgpflow = 'org.onosproject.bgpflow'
+        self.list1 = [self.app_bgp,self.app_bgpflow]
+        return self.list1
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py
new file mode 100755
index 0000000..abd1cfc
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py
@@ -0,0 +1,53 @@
+#!/usr/bin/python           # This is server.py file
+from scapy.all import *
+import socket               # Import socket module
+import time                 # Import Time module
+import sys
+import os
+
+path = os.getcwd()
+sys.path.append('OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies')   #Setting the path for BgpLS
+from Nbdata import BgpLs
+
+obj = BgpLs()
+returnlist = obj.Constants()
+peerIp = returnlist[0][0]
+
+load_contrib('bgp')
+s = socket.socket()         # Create a socket object
+host = peerIp # Get local machine name
+port = 179                # Reserve a port for your service.
+s.bind((host, port))        # Bind to the port
+pkts = rdpcap(path + "/OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls_all.pcap")
+pkts[69][BGPOpen].bgp_id = peerIp
+
+s.listen(5)                   # Now wait for client connection.
+
+print("starting Connecting to ONOS peer")
+c, addr = s.accept()     # Establish connection with client.
+print 'Got connection from ONOS :', addr
+c.send(str(pkts[69][BGPHeader])) # OPEN MESSAGE
+c.recv(4096)
+c.send(str(pkts[71][BGPHeader]))# KEEPALIVE MESSAGE
+c.recv(4096)
+c.send(str(pkts[72][BGPHeader]))   # UPDATE MESSAGES
+c.send(str(pkts[74][BGPHeader]))
+c.send(str(pkts[71][BGPHeader]))
+
+time.sleep(10)               # Waiting for 120 seconds for update message.
+
+c.send(str(pkts[298][BGPHeader]))
+c.send(str(pkts[860][BGPHeader]))   # UPDATE MESSAGES with new node
+c.send(str(pkts[865][BGPHeader]))
+print ("New Node update msg sent")
+
+time.sleep(5)
+c.send(str(pkts[890][BGPHeader]))
+print ("Node Delete msg sent")
+
+
+while True:
+    c.recv(4096)
+    c.send(str(pkts[71][BGPHeader]))
+
+  # c.close()                # Close the connection
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Topo_discovery.py b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Topo_discovery.py
new file mode 100755
index 0000000..a7daf91
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Topo_discovery.py
@@ -0,0 +1,41 @@
+#!/usr/bin/python           # This is server.py file
+from scapy.all import *
+import socket               # Import socket module
+import time                 # Import Time module
+import sys
+import os
+
+path = os.getcwd()
+sys.path.append('OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies')   #Setting the path for BgpLS
+from Nbdata import BgpLs
+
+obj = BgpLs()
+returnlist = obj.Constants()
+peerIp = returnlist[0][0]
+
+load_contrib('bgp')
+s = socket.socket()         # Create a socket object
+host = peerIp # Get local machine name
+port = 179                # Reserve a port for your service.
+s.bind((host, port))        # Bind to the port
+pkts = rdpcap(path + "/OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls_all.pcap")
+pkts[69][BGPOpen].bgp_id = peerIp
+
+s.listen(5)                 # Now wait for client connection.
+
+print("starting Connecting to ONOS peer")
+c, addr = s.accept()     # Establish connection with client.
+print 'Got connection from ONOS :', addr
+c.send(str(pkts[69][BGPHeader])) # OPEN MESSAGE
+c.recv(4096)
+c.send(str(pkts[71][BGPHeader]))# KEEPALIVE MESSAGE
+c.recv(4096)
+c.send(str(pkts[72][BGPHeader]))   # UPDATE MESSAGES
+c.send(str(pkts[74][BGPHeader]))
+c.send(str(pkts[71][BGPHeader]))
+
+while True:
+    c.recv(4096)
+    c.send(str(pkts[71][BGPHeader]))
+
+  # c.close()                # Close the connection
diff --git a/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Update_Node.py b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Update_Node.py
new file mode 100755
index 0000000..3a40d6c
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Update_Node.py
@@ -0,0 +1,48 @@
+#!/usr/bin/python           # This is server.py file
+from scapy.all import *
+import socket               # Import socket module
+import time                 # Import Time module
+import sys
+import os
+
+path = os.getcwd()
+sys.path.append('OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies')   #Setting the path for BgpLS
+from Nbdata import BgpLs
+
+obj = BgpLs()
+returnlist = obj.Constants()
+peerIp = returnlist[0][0]
+
+load_contrib('bgp')
+s = socket.socket()         # Create a socket object
+host = peerIp # Get local machine name
+port = 179                # Reserve a port for your service.
+s.bind((host, port))        # Bind to the port
+pkts = rdpcap(path + "/OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Bgpls_packets/bgpls_all.pcap")
+pkts[69][BGPOpen].bgp_id = peerIp
+
+s.listen(5)                 # Now wait for client connection.
+
+print("starting Connecting to ONOS peer")
+c, addr = s.accept()     # Establish connection with client.
+print 'Got connection from ONOS :', addr
+c.send(str(pkts[69][BGPHeader])) # OPEN MESSAGE
+c.recv(4096)
+c.send(str(pkts[71][BGPHeader]))# KEEPALIVE MESSAGE
+c.recv(4096)
+c.send(str(pkts[72][BGPHeader]))   # UPDATE MESSAGES
+c.send(str(pkts[74][BGPHeader]))
+c.send(str(pkts[71][BGPHeader]))
+
+time.sleep(10)               # Waiting for 120 seconds for update message.
+
+c.send(str(pkts[298][BGPHeader]))
+c.send(str(pkts[860][BGPHeader]))   # UPDATE MESSAGES with new node
+c.send(str(pkts[865][BGPHeader]))
+print ("New Node update msg sent")
+
+while True:
+    c.recv(4096)
+    c.send(str(pkts[71][BGPHeader]))
+
+  # c.close()                # Close the connection
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/__init__.py b/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/__init__.py
old mode 100644
new mode 100755
similarity index 100%
copy from TestON/tests/USECASE/USECASE_SegmentRouting/__init__.py
copy to TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/__init__.py
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/__init__.py b/TestON/tests/FUNC/FUNCbgpls/dependencies/__init__.py
old mode 100644
new mode 100755
similarity index 100%
copy from TestON/tests/USECASE/USECASE_SegmentRouting/__init__.py
copy to TestON/tests/FUNC/FUNCbgpls/dependencies/__init__.py
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.py b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
index 9cd16a8..ba0f2a9 100644
--- a/TestON/tests/FUNC/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
@@ -667,18 +667,29 @@
         main.caseExplanation = "Copying the karaf logs to preserve them through" +\
                                "reinstalling ONOS"
         main.step( "Copying karaf logs" )
+        stepResult = main.TRUE
+        scpResult = main.TRUE
+        copyResult = main.TRUE
         i = 0
         for cli in main.CLIs:
             main.node = cli
             ip = main.ONOSip[ i ]
             main.node.ip_address = ip
-            main.ONOSbench.scp( main.node ,
-                                "/opt/onos/log/karaf.log",
-                                "/tmp/karaf.log",
-                                direction="from" )
-            main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
-                                        copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
+            scpResult = scpResult and main.ONOSbench.scp( main.node ,
+                                            "/opt/onos/log/karaf.log",
+                                            "/tmp/karaf.log",
+                                            direction="from" )
+            copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
+                                                                    copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
+            if scpResult and copyResult:
+                stepResult =  main.TRUE and stepResult
+            else:
+                stepResult = main.FALSE and stepResult
             i += 1
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully copied remote ONOS logs",
+                                 onfail="Failed to copy remote ONOS logs" )
 
     def CASE1000( self, main ):
         """
diff --git a/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py b/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py
index 5a8e5cc..51ad5b1 100644
--- a/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py
+++ b/TestON/tests/FUNC/FUNCintentRest/FUNCintentRest.py
@@ -782,18 +782,29 @@
         main.caseExplanation = "Copying the karaf logs to preserve them through" +\
                                "reinstalling ONOS"
         main.step( "Copying karaf logs" )
+        stepResult = main.TRUE
+        scpResult = main.TRUE
+        copyResult = main.TRUE
         i = 0
         for cli in main.CLIs2:
             main.node = cli
             ip = main.ONOSip[ i ]
             main.node.ip_address = ip
-            main.ONOSbench.scp( main.node ,
-                                "/opt/onos/log/karaf.log",
-                                "/tmp/karaf.log",
-                                direction="from" )
-            main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
-                                        copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
+            scpResult = scpResult and main.ONOSbench.scp( main.node ,
+                                            "/opt/onos/log/karaf.log",
+                                            "/tmp/karaf.log",
+                                            direction="from" )
+            copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
+                                                                    copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
+            if scpResult and copyResult:
+                stepResult =  main.TRUE and stepResult
+            else:
+                stepResult = main.FALSE and stepResult
             i += 1
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully copied remote ONOS logs",
+                                 onfail="Failed to copy remote ONOS logs" )
 
     def CASE1000( self, main ):
         """
diff --git a/TestON/tests/FUNC/FUNCnetconf/FUNCnetconf.py b/TestON/tests/FUNC/FUNCnetconf/FUNCnetconf.py
index 874aecf..94fd0ef 100644
--- a/TestON/tests/FUNC/FUNCnetconf/FUNCnetconf.py
+++ b/TestON/tests/FUNC/FUNCnetconf/FUNCnetconf.py
@@ -266,18 +266,31 @@
         main.caseExplanation = "Copying the karaf logs to preserve them through" +\
                                "reinstalling ONOS"
         main.step( "Copying karaf logs" )
+        stepResult = main.TRUE
+        scpResult = main.TRUE
+        copyResult = main.TRUE
         i = 0
         for cli in main.CLIs2:
             main.node = cli
             ip = main.ONOSip[ i ]
             main.node.ip_address = ip
-            main.ONOSbench.scp( main.node ,
-                                "/opt/onos/log/karaf.log",
-                                "/tmp/karaf.log",
-                                direction="from" )
-            main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
-                                        copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
+            scpResult = scpResult and main.ONOSbench.scp( main.node ,
+                                            "/opt/onos/log/karaf.log",
+                                            "/tmp/karaf.log",
+                                            direction="from" )
+            copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
+                                                                    copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
+            if scpResult and copyResult:
+                stepResult =  main.TRUE and stepResult
+            else:
+                stepResult = main.FALSE and stepResult
             i += 1
+            if main.numCtrls == 1:
+                break
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully copied remote ONOS logs",
+                                 onfail="Failed to copy remote ONOS logs" )
 
     def CASE100( self, main ):
         """
diff --git a/TestON/tests/FUNC/FUNCoptical/FUNCoptical.py b/TestON/tests/FUNC/FUNCoptical/FUNCoptical.py
index f4ac6ce..65c731b 100644
--- a/TestON/tests/FUNC/FUNCoptical/FUNCoptical.py
+++ b/TestON/tests/FUNC/FUNCoptical/FUNCoptical.py
@@ -314,18 +314,29 @@
         main.caseExplanation = "Copying the karaf logs to preserve them through" +\
                                "reinstalling ONOS"
         main.step( "Copying karaf logs" )
+        stepResult = main.TRUE
+        scpResult = main.TRUE
+        copyResult = main.TRUE
         i = 0
         for cli in main.CLIs:
             main.node = cli
             ip = main.ONOSip[ i ]
             main.node.ip_address = ip
-            main.ONOSbench.scp( main.node ,
-                                "/opt/onos/log/karaf.log",
-                                "/tmp/karaf.log",
-                                direction="from" )
-            main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
-                                        copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
+            scpResult = scpResult and main.ONOSbench.scp( main.node ,
+                                            "/opt/onos/log/karaf.log",
+                                            "/tmp/karaf.log",
+                                            direction="from" )
+            copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir,
+                                                                    copyFileName=( "karaf.log.node{0}.cycle{1}".format( str( i + 1 ), str( main.cycle ) ) ) )
+            if scpResult and copyResult:
+                stepResult =  main.TRUE and stepResult
+            else:
+                stepResult = main.FALSE and stepResult
             i += 1
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully copied remote ONOS logs",
+                                 onfail="Failed to copy remote ONOS logs" )
 
     def CASE21( self,main ):
         """
diff --git a/TestON/tests/HA/HAscaling/dependencies/onos-gen-partitions b/TestON/tests/HA/HAscaling/dependencies/onos-gen-partitions
index 2e49db0..303427a 100755
--- a/TestON/tests/HA/HAscaling/dependencies/onos-gen-partitions
+++ b/TestON/tests/HA/HAscaling/dependencies/onos-gen-partitions
@@ -27,12 +27,6 @@
   node = lambda k: { 'id': k, 'ip': k, 'port': port }
   return [ node(environ[v]) for v in vars ]
 
-def generate_base_partition(nodes):
-  return {
-            'id': 0,
-            'members': nodes
-         }
-
 def generate_extended_partitions_scaling(nodes, k, partitions=3, equal=False):
   l = deque(nodes)
   perms = []
@@ -64,11 +58,9 @@
   if num:
       nodes = nodes[:num]
 
-  base_partition = generate_base_partition([v.get('id') for v in nodes])
   extended_partitions = generate_extended_partitions_scaling([v.get('id') for v in nodes],
           3, equal=equal)
   partitions = []
-  partitions.append(base_partition)
   partitions.extend(extended_partitions)
   name = hash("HAScaling")
   data = {
diff --git a/TestON/tests/HA/HAswapNodes/dependencies/onos-gen-partitions b/TestON/tests/HA/HAswapNodes/dependencies/onos-gen-partitions
index ae7da6c..90231e3 100755
--- a/TestON/tests/HA/HAswapNodes/dependencies/onos-gen-partitions
+++ b/TestON/tests/HA/HAswapNodes/dependencies/onos-gen-partitions
@@ -27,12 +27,6 @@
   node = lambda k: { 'id': k, 'ip': k, 'port': port }
   return [ node(environ[v]) for v in vars ]
 
-def generate_base_partition(nodes):
-  return {
-            'id': 0,
-            'members': nodes
-         }
-
 def generate_extended_partitions_scaling(nodes, k, partitions=3, equal=False):
   l = deque(nodes)
   perms = []
@@ -65,11 +59,9 @@
   if num:
       nodes = nodes[:num]
 
-  base_partition = generate_base_partition([v.get('id') for v in nodes])
   extended_partitions = generate_extended_partitions_scaling([v.get('id') for v in nodes],
           3, equal=equal)
   partitions = []
-  partitions.append(base_partition)
   partitions.extend(extended_partitions)
   name = hash("HAScaling")
   data = {
diff --git a/TestON/tests/HA/dependencies/onos-gen-partitions b/TestON/tests/HA/dependencies/onos-gen-partitions
index 06c5ec9..b83aea6 100755
--- a/TestON/tests/HA/dependencies/onos-gen-partitions
+++ b/TestON/tests/HA/dependencies/onos-gen-partitions
@@ -27,12 +27,6 @@
   node = lambda k: { 'id': k, 'ip': k, 'port': port }
   return [ node(environ[v]) for v in vars ]
 
-def generate_base_partition(nodes):
-  return {
-            'id': 0,
-            'members': nodes
-         }
-
 def generate_extended_partitions(nodes, k):
   l = deque(nodes)
   perms = []
@@ -60,10 +54,8 @@
 if __name__ == '__main__':
   vars = get_OC_vars()
   nodes = get_nodes(vars)
-  base_partition = generate_base_partition([v.get('id') for v in nodes])
   extended_partitions = generate_extended_partitions_HA([v.get('id') for v in nodes], 3)
   partitions = []
-  partitions.append(base_partition)
   partitions.extend(extended_partitions)
   name = 0
   for node in nodes:
diff --git a/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.params b/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.params
index 3799982..9dfa7a4 100644
--- a/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.params
+++ b/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.params
@@ -1,6 +1,6 @@
 <PARAMS>
 
-    <testcases>1,2,1,2,1,2,1,2</testcases>
+    <testcases>0,1,2,1,2,1,2,1,2</testcases>
 
     <SCALE>1,3,5,7</SCALE>
     <max>7</max>
@@ -14,30 +14,33 @@
         <skipCleanInstall>yes</skipCleanInstall>
         <warmUp>5</warmUp>
         <sampleSize>20</sampleSize>
-        <wait></wait>
         <intents>1,100,1000</intents>                       #list format, will be split on ','
-        <debug>True</debug>
-
-        <s1>1,1,1,1,1,1,1,1</s1>
-        <s3>2,2,1,1,3,3,3,1</s3>
-        <s5>2,2,1,1,3,4,5,3</s5>
-        <s7>2,3,1,1,5,6,7,4</s7>
-
+        <ingress>null:0000000000000001/0</ingress>
+        <egress>null:0000000000000007/0</egress>
+        <debug>False</debug>
     </TEST>
-
-    <METRICS>
-        <Submitted>0</Submitted>
-        <Installed>1</Installed>
-        <Failed>0</Failed>
-        <Withdraw>0</Withdraw>
-        <Withdrawn>0</Withdrawn>
-    </METRICS>
+    <DATABASE>
+        <file>/tmp/IntentRerouteLatDB</file>
+    </DATABASE>
 
     <GIT>
-        <autopull>off</autopull>
-        <checkout>master</checkout>
+        <gitPull>False</gitPull>
+        <gitBranch>master</gitBranch>
     </GIT>
 
+    <ATTEMPTS>
+        <verify>3</verify>
+    </ATTEMPTS>
+
+    <SLEEP>
+        <startup>10</startup>
+        <install>10</install>
+        <verify>3</verify>
+        <reroute>3</reroute>
+        # timeout for pexpect
+        <timeout>300</timeout>
+    </SLEEP>
+
     <CTRL>
         <USER>sdn</USER>
 
diff --git a/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.py b/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.py
index 0c4d950..182f4b6 100644
--- a/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.py
+++ b/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.py
@@ -1,419 +1,366 @@
-# ScaleOutTemplate
-#
-# CASE1 starts number of nodes specified in param file
-#
-# cameron@onlab.us
-
-import sys
-import os.path
-
+# SCPFintentRerouteLat
+"""
+SCPFintentRerouteLat
+    - Test Intent Reroute Latency
+    - Test Algorithm:
+        1. Start Null Provider reroute Topology
+        2. Using Push-test-intents to push batch size intents from switch 1 to switch 7
+        3. Cut the link between switch 3 and switch 4 (the path will reroute to switch 8)
+        4. Get the topology time stamp
+        5. Get Intent reroute(Installed) time stamp from each nodes
+        6. Use the latest intent time stamp subtract topology time stamp
+    - This test will run 5 warm up by default, warm up iteration can be setup in Param file
+    - The intent batch size will default set to 1, 100, and 1000, also can be set in Param file
+    - The unit of the latency result is milliseconds
+"""
 
 class SCPFintentRerouteLat:
-
-    def __init__( self ):
+    def __init__(self):
         self.default = ''
 
-    def CASE1( self, main ):
+    def CASE0( self, main ):
+        '''
+        - GIT
+        - BUILDING ONOS
+            Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
+            This step is usually skipped. Because in a Jenkins driven automated
+            test env. We want Jenkins jobs to pull&build for flexibility to handle
+            different versions of ONOS.
+        - Construct tests variables
+        '''
+        gitPull = main.params['GIT']['gitPull']
+        gitBranch = main.params['GIT']['gitBranch']
 
+        main.case("Pull onos branch and build onos on Teststation.")
+
+        if gitPull == 'True':
+            main.step("Git Checkout ONOS branch: " + gitBranch)
+            stepResult = main.ONOSbench.gitCheckout(branch=gitBranch)
+            utilities.assert_equals(expect=main.TRUE,
+                                    actual=stepResult,
+                                    onpass="Successfully checkout onos branch.",
+                                    onfail="Failed to checkout onos branch. Exiting test...")
+            if not stepResult: main.exit()
+
+            main.step("Git Pull on ONOS branch:" + gitBranch)
+            stepResult = main.ONOSbench.gitPull()
+            utilities.assert_equals(expect=main.TRUE,
+                                    actual=stepResult,
+                                    onpass="Successfully pull onos. ",
+                                    onfail="Failed to pull onos. Exiting test ...")
+            if not stepResult: main.exit()
+
+            main.step("Building ONOS branch: " + gitBranch)
+            stepResult = main.ONOSbench.cleanInstall(skipTest=True)
+            utilities.assert_equals(expect=main.TRUE,
+                                    actual=stepResult,
+                                    onpass="Successfully build onos.",
+                                    onfail="Failed to build onos. Exiting test...")
+            if not stepResult: main.exit()
+
+        else:
+            main.log.warn("Skipped pulling onos and Skipped building ONOS")
+
+        main.apps = main.params['ENV']['cellApps']
+        main.BENCHUser = main.params['BENCH']['user']
+        main.BENCHIp = main.params['BENCH']['ip1']
+        main.MN1Ip = main.params['MN']['ip1']
+        main.maxNodes = int(main.params['max'])
+        main.skipMvn = main.params['TEST']['skipCleanInstall']
+        main.cellName = main.params['ENV']['cellName']
+        main.scale = (main.params['SCALE']).split(",")
+        main.dbFileName = main.params['DATABASE']['file']
+        main.timeout = int(main.params['SLEEP']['timeout'])
+        main.startUpSleep = int(main.params['SLEEP']['startup'])
+        main.installSleep = int(main.params['SLEEP']['install'])
+        main.verifySleep = int(main.params['SLEEP']['verify'])
+        main.verifyAttempts = int(main.params['ATTEMPTS']['verify'])
+        main.sampleSize = int(main.params['TEST']['sampleSize'])
+        main.warmUp = int(main.params['TEST']['warmUp'])
+        main.intentsList = (main.params['TEST']['intents']).split(",")
+        main.ingress = main.params['TEST']['ingress']
+        main.egress = main.params['TEST']['egress']
+        main.debug = main.params['TEST']['debug']
+        for i in range(0, len(main.intentsList)):
+            main.intentsList[i] = int(main.intentsList[i])
+            # Create DataBase file
+        main.log.info("Create Database file " + main.dbFileName)
+        resultsDB = open(main.dbFileName, "w+")
+        resultsDB.close()
+
+    def CASE1( self, main ):
+        '''
+            clean up test environment and set up
+        '''
         import time
 
-        global init
-        try:
-            if type(init) is not bool:
-                init = False
-        except NameError:
-            init = False
+        main.log.info("Get ONOS cluster IP")
+        print(main.scale)
+        main.numCtrls = int(main.scale[0])
+        main.ONOSip = []
+        main.maxNumBatch = 0
+        main.AllONOSip = main.ONOSbench.getOnosIps()
+        for i in range(main.numCtrls):
+            main.ONOSip.append(main.AllONOSip[i])
+        main.log.info(main.ONOSip)
+        main.CLIs = []
+        main.log.info("Creating list of ONOS cli handles")
+        for i in range(main.numCtrls):
+            main.CLIs.append(getattr(main, 'ONOS%scli' % (i + 1)))
 
-        #Load values from params file
-        checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
-        gitPull = main.params[ 'GIT' ][ 'autopull' ]
-        cellName = main.params[ 'ENV' ][ 'cellName' ]
-        Apps = main.params[ 'ENV' ][ 'cellApps' ]
-        BENCHUser = main.params[ 'BENCH' ][ 'user' ]
-        BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
-        MN1Ip = main.params[ 'MN' ][ 'ip1' ]
-        main.maxNodes = int(main.params[ 'max' ])
-        skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
-        cellName = main.params[ 'ENV' ][ 'cellName' ]
+        if not main.CLIs:
+            main.log.error("Failed to create the list of ONOS cli handles")
+            main.cleanup()
+            main.exit()
 
-        # -- INIT SECTION, ONLY RUNS ONCE -- #
-        if init == False:
-            init = True
-            global clusterCount             #number of nodes running
-            global ONOSIp                   #list of ONOS IP addresses
-            global scale
-            global commit
+        main.commit = main.ONOSbench.getVersion(report=True)
+        main.commit = main.commit.split(" ")[1]
+        main.log.info("Starting up %s node(s) ONOS cluster" % main.numCtrls)
+        main.log.info("Safety check, killing all ONOS processes" +
+                      " before initiating environment setup")
 
-            clusterCount = 0
-            ONOSIp = [ 0 ]
-            scale = (main.params[ 'SCALE' ]).split(",")
-            clusterCount = int(scale[0])
+        for i in range(main.numCtrls):
+            main.ONOSbench.onosDie(main.ONOSip[i])
 
-            #Populate ONOSIp with ips from params
-            ONOSIp = [0]
-            ONOSIp.extend(main.ONOSbench.getOnosIps())
+        main.log.info("NODE COUNT = %s" % main.numCtrls)
 
-            print("-----------------" + str(ONOSIp))
-            #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
-            if skipMvn != "yes":
-                mvnResult = main.ONOSbench.cleanInstall()
+        # tempOnosIp = []
+        # for i in range(main.numCtrls):
+        #    tempOnosIp.append(main.AllONOSip[i])
+        # print(tempOnosIp)
+        main.ONOSbench.createCellFile(main.ONOSbench.ip_address,
+                                      main.cellName,
+                                      main.MN1Ip,
+                                      main.apps,
+                                      main.ONOSip)
+        main.step("Apply cell to environment")
+        cellResult = main.ONOSbench.setCell(main.cellName)
+        verifyResult = main.ONOSbench.verifyCell()
+        stepResult = cellResult and verifyResult
+        utilities.assert_equals(expect=main.TRUE,
+                                actual=stepResult,
+                                onpass="Successfully applied cell to " + \
+                                       "environment",
+                                onfail="Failed to apply cell to environment ")
 
-            #git
-            main.step( "Git checkout and pull " + checkoutBranch )
-            if gitPull == 'on':
-                checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
-                pullResult = main.ONOSbench.gitPull()
-
-            else:
-                checkoutResult = main.TRUE
-                pullResult = main.TRUE
-                main.log.info( "Skipped git checkout and pull" )
-
-            commit = main.ONOSbench.getVersion()
-            commit = (commit.split(" "))[1]
-
-            resultsDB = open("/tmp/IntentRerouteLatDB", "w+")
-            resultsDB.close()
-
-        # -- END OF INIT SECTION --#
-
-        clusterCount = int(scale[0])
-        scale.remove(scale[0])
-
-        #kill off all onos processes
-        main.log.step("Safety check, killing all ONOS processes")
-        main.log.step("before initiating environment setup")
-        for node in range(1, main.maxNodes + 1):
-            main.ONOSbench.onosDie(ONOSIp[node])
-
-        #Uninstall everywhere
-        main.log.step( "Cleaning Enviornment..." )
-        for i in range(1, main.maxNodes + 1):
-            main.log.info(" Uninstalling ONOS " + str(i) )
-            main.ONOSbench.onosUninstall( ONOSIp[i] )
-
-        #construct the cell file
-        main.log.info("Creating cell file")
-        cellIp = []
-        for node in range (1, clusterCount + 1):
-            cellIp.append(ONOSIp[node])
-
-        main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), cellIp)
-
-        main.step( "Set Cell" )
-        main.ONOSbench.setCell(cellName)
-
-        main.step( "Creating ONOS package" )
+        main.step("Creating ONOS package")
         packageResult = main.ONOSbench.onosPackage()
+        stepResult = packageResult
+        utilities.assert_equals(expect=main.TRUE,
+                                actual=stepResult,
+                                onpass="Successfully created ONOS package",
+                                onfail="Failed to create ONOS package")
 
-        main.step( "verify cells" )
-        verifyCellResult = main.ONOSbench.verifyCell()
+        main.step("Uninstall ONOS package on all Nodes")
+        uninstallResult = main.TRUE
+        for i in range(int(main.numCtrls)):
+            main.log.info("Uninstalling package on ONOS Node IP: " + main.ONOSip[i])
+            u_result = main.ONOSbench.onosUninstall(main.ONOSip[i])
+            utilities.assert_equals(expect=main.TRUE, actual=u_result,
+                                    onpass="Test step PASS",
+                                    onfail="Test step FAIL")
+            uninstallResult = (uninstallResult and u_result)
 
-        main.log.report( "Initializing " + str( clusterCount ) + " node cluster." )
-        for node in range(1, clusterCount + 1):
-            main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
-            main.ONOSbench.onosInstall( ONOSIp[node])
+        main.step("Install ONOS package on all Nodes")
+        installResult = main.TRUE
+        for i in range(int(main.numCtrls)):
+            main.log.info("Installing package on ONOS Node IP: " + main.ONOSip[i])
+            i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i])
+            utilities.assert_equals(expect=main.TRUE, actual=i_result,
+                                    onpass="Test step PASS",
+                                    onfail="Test step FAIL")
+            installResult = installResult and i_result
 
-        for node in range(1, clusterCount + 1):
-            for i in range( 2 ):
-                isup = main.ONOSbench.isup( ONOSIp[node] )
-                if isup:
-                    main.log.info("ONOS " + str(node) + " is up\n")
-                    break
-            if not isup:
-                main.log.report( "ONOS " + str(node) + " didn't start!" )
-        main.log.info("Startup sequence complete")
+        main.step("Verify ONOS nodes UP status")
+        statusResult = main.TRUE
+        for i in range(int(main.numCtrls)):
+            main.log.info("ONOS Node " + main.ONOSip[i] + " status:")
+            onos_status = main.ONOSbench.onosStatus(node=main.ONOSip[i])
+            utilities.assert_equals(expect=main.TRUE, actual=onos_status,
+                                    onpass="Test step PASS",
+                                    onfail="Test step FAIL")
+            statusResult = (statusResult and onos_status)
+        time.sleep(2)
+        main.step("Start ONOS CLI on all nodes")
+        cliResult = main.TRUE
+        main.log.step(" Start ONOS cli using thread ")
+        startCliResult = main.TRUE
+        pool = []
+        main.threadID = 0
+        for i in range(int(main.numCtrls)):
+            t = main.Thread(target=main.CLIs[i].startOnosCli,
+                            threadID=main.threadID,
+                            name="startOnosCli",
+                            args=[main.ONOSip[i]],
+                            kwargs={"onosStartTimeout": main.timeout})
+            pool.append(t)
+            t.start()
+            main.threadID = main.threadID + 1
+        for t in pool:
+            t.join()
+            startCliResult = startCliResult and t.result
+        time.sleep(main.startUpSleep)
 
-        deviceMastership = (main.params[ 'TEST' ][ "s" + str(clusterCount) ]).split(",")
-        print("Device mastership list: " + str(deviceMastership))
+        # configure apps
+        main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8)
+        main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="reroute")
+        main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
+        main.CLIs[0].setCfg("org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupEnabled", value="false")
 
-        main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupEnabled false")
+        time.sleep(main.startUpSleep)
 
-        main.log.step("Setting up null provider")
-        for i in range(3):
-            main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "deviceCount 8")
-            main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "topoShape reroute")
-            main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "enabled true")
-            time.sleep(5)
-            main.ONOSbench.handle.sendline("onos $OC1 summary")
-            main.ONOSbench.handle.expect(":~")
-            x = main.ONOSbench.handle.before
-            if "devices=8" in x and "links=16," in x:
-                break
-
-        index = 1
-        for node in deviceMastership:
-            for attempt in range(0,10):
-                cmd = ( "onos $OC" + node + """ "device-role null:000000000000000""" + str(index) + " " + ONOSIp[int(node)]  + """ master" """)
-                main.log.info("assigning mastership of device " + str(index) + " to node " + node + ": \n " + cmd + "\n")
-                main.ONOSbench.handle.sendline(cmd)
-                main.ONOSbench.handle.expect(":~")
-                time.sleep(4)
-
-                cmd = ( "onos $OC" + node + " roles|grep 00000" + str(index))
-                main.log.info(cmd)
-                main.ONOSbench.handle.sendline(cmd)
-                main.ONOSbench.handle.expect(":~")
-                check = main.ONOSbench.handle.before
-                main.log.info("CHECK:\n" + check)
-                if ("master=" + ONOSIp[int(node)]) in check:
-                    break
-            index += 1
-
-        main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
+        # Balance Master
+        main.CLIs[0].balanceMasters()
+        if len(main.ONOSip) > 1:
+            main.CLIs[0].deviceRole("null:0000000000000003", main.ONOSip[0])
+            main.CLIs[0].deviceRole("null:0000000000000004", main.ONOSip[0])
 
     def CASE2( self, main ):
-
         import time
         import numpy
         import datetime
-        #from scipy import stats
+        import json
+        # from scipy import stats
 
         ts = time.time()
-
-        sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
-        warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
-        intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",")
-        debug = main.params[ 'TEST' ][ 'debug' ]
-        for i in range(0,len(intentsList)):
-            intentsList[i] = int(intentsList[i])
-
-        timestampMetrics = []
-        if main.params['METRICS']['Submitted'] == "1":
-            timestampMetrics.append("Submitted")
-        if main.params['METRICS']['Installed'] == "1":
-            timestampMetrics.append("Installed")
-        if main.params['METRICS']['Failed'] == "1":
-            timestampMetrics.append("Failed")
-        if main.params['METRICS']['Withdraw'] == "1":
-            timestampMetrics.append("Withdraw")
-        if main.params['METRICS']['Withdrawn'] == "1":
-            timestampMetrics.append("Withdrawn")
-        if debug: main.log.info(timestampMetrics)
-
-        if debug == "True":
-            debug = True
-        else:
-            debug = False
-
-        ingress = "null:0000000000000001"
-        egress = "null:0000000000000007"
-
-        for intents in intentsList:
-            main.log.report("Intent Batch size: " + str(intents) + "\n      ")
-            myResult = [["latency", "lastNode"] for x in range(sampleSize)]
-
-            for run in range(0, (warmUp + sampleSize)):
-                if run > warmUp:
-                    main.log.info("Starting test iteration " + str(run-warmUp))
-
-                cmd = """onos $OC1 "push-test-intents -i """
-                cmd += ingress + "/0 "
-                cmd += egress + "/0 "
-                cmd += str(intents) +""" 1" """
-                if debug: main.log.info(cmd)
-
-                withdrawCmd = cmd.replace("intents -i", "intents -w ")
-
-                #push-test-intents
-                main.ONOSbench.handle.sendline(cmd)
-                main.ONOSbench.handle.expect(":~")
-                myRawResult = main.ONOSbench.handle.before
-
-                for i in range(0, 40):
-                    main.ONOSbench.handle.sendline("onos $OC1 summary")
-                    main.ONOSbench.handle.expect(":~")
-                    linkCheck = main.ONOSbench.handle.before
-                    if ("links=16,") in linkCheck and ("flows=" + str(intents*7) + ","):
-                        break
-                    if i == 39:
-                        main.log.error("Flow/link count incorrect, data invalid."+ linkCheck)
-                        main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], "d")
-                        #main.ONOSbench.logReport(ONOSIp[(clusterCount-1)], ["ERROR", "WARNING", "EXCEPT"], "d")
-                        main.ONOSbench.sendline("onos $OC1 summary")
-                        main.ONOSbench.sendline("onos $OC1 devices")
-                        main.ONOSbench.sendline("onos $OC1 links")
-                        main.ONOSbench.expect(":~")
-                        main.log.info(main.ONOSbench.before)
-
-                #collect timestamp from link cut
-                cmd = """onos $OC1 null-link "null:0000000000000004/1 null:0000000000000003/2 down" """
-                if debug: main.log.info("COMMAND: " + str(cmd))
-                main.ONOSbench.handle.sendline(cmd)
-                main.ONOSbench.handle.expect(":~")
-
-                cmd = "onos-ssh $OC1 cat /opt/onos/log/karaf.log | grep TopologyManager| tail -1"
-                for i in range(0,10):
-                    main.ONOSbench.handle.sendline(cmd)
-                    time.sleep(2)
-                    main.ONOSbench.handle.expect(":~")
-                    raw = main.ONOSbench.handle.before
-                    #if "NullLinkProvider" in raw and "links=14" in raw:
-                    if "links=14" in raw:
-                        break
-                    if i >= 9:
-                        main.log.error("Expected output not being recieved... continuing")
-                        main.log.info(raw)
-                        break
-                    time.sleep(2)
-
-                if debug: main.log.debug("raw: " + raw)
-
-                temp = raw.splitlines()
-
-                if debug: main.log.debug("temp (after splitlines): " + str(temp))
-
-                # Since the string is deterministic the date is always the 3rd element.
-                # However, if the data were grepping for in the onos log changes then this will
-                # not work. This is why we print out the raw and temp string so we can visually
-                # check if everything is in the correct order. temp should like this:
-                # temp = ['/onos$ onos-ssh $OC1 cat /opt/onos/log/karaf.log | grep Top ', 
-                #         'ologyManager| tail -1', '2015-10-15 12:03:33,736 ... ]
-                temp = temp[2]
-
-                if debug: main.log.debug("temp (checking for date): " + str(temp))
-
-                cutTimestamp = (temp.split(" "))[0] + " " + (temp.split(" "))[1]
-
-                if debug: main.log.info("Cut timestamp: " + cutTimestamp)
-
-                #validate link count and flow count
-                for i in range(0, 40):
-                    main.ONOSbench.handle.sendline("onos $OC1 summary")
-                    main.ONOSbench.handle.expect(":~")
-                    linkCheck = main.ONOSbench.handle.before
-                    #if "links=" + str(7*intents)+ "," in linkCheck and ("flows=" + str(7*intents) + ",") in linkCheck:
-                    if "links=14," in linkCheck and ("flows=" + str(8*intents) + ",") in linkCheck:
-                        break
-                    if i == 39:
-                        main.log.error("Link or flow count incorrect, data invalid." + linkCheck)
-                        main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], "d")
-
-                time.sleep(5) #trying to avoid negative values
-
-                #intents events metrics installed timestamp
-                IEMtimestamps = [0]*(clusterCount + 1)
-                installedTemp = [0]*(clusterCount + 1)
-                for node in range(1, clusterCount +1):
-                    cmd = "onos $OC" + str(node) + """ "intents-events-metrics"|grep Timestamp """
-                    raw = ""
-                    while "epoch)" not in raw:
-                        main.ONOSbench.handle.sendline(cmd)
-                        main.ONOSbench.handle.expect(":~")
-                        raw = main.ONOSbench.handle.before
-
-                    print(raw)
-
-                    intentsTimestamps = {}
-                    rawTimestamps = raw.splitlines()
-                    for line in rawTimestamps:
-                        if "Timestamp" in line and "grep" not in line:
-                            metricKey = (line.split(" "))[1]
-                            metricTimestamp = (line.split(" ")[len(line.split(" ")) -1]).replace("epoch)=","")
-                            metricTimestamp = float(metricTimestamp)
-                            metricTimestamp = numpy.divide(metricTimestamp, 1000)
-                            if debug: main.log.info(repr(metricTimestamp))
-                            intentsTimestamps[metricKey] = metricTimestamp
-                            if metricKey == "Installed":
-                                installedTemp[node] = metricTimestamp
-
-                    main.log.info("Node: " + str(node) + " Timestamps: " + str(intentsTimestamps))
-                    IEMtimestamps[node] = intentsTimestamps
-
-                myMax = max(installedTemp)
-                indexOfMax = installedTemp.index(myMax)
-
-                #number crunch
-                for metric in timestampMetrics:     #this is where we sould add support for computing other timestamp metrics
-                    if metric == "Installed":
-                        if run >= warmUp:
-                            main.log.report("link cut timestamp: " + cutTimestamp)
-                            #readableInstalledTimestamp = str(intentsTimestamps["Installed"])
-                            readableInstalledTimestamp = str(myMax)
-
-                            #main.log.report("Intent Installed timestamp: " + str(intentsTimestamps["Installed"]))
-                            main.log.report("Intent Installed timestamp: " + str(myMax))
-
-                            cutEpoch = time.mktime(time.strptime(cutTimestamp, "%Y-%m-%d %H:%M:%S,%f"))
-                            if debug: main.log.info("cutEpoch=" + str(cutEpoch))
-                            #rerouteLatency = float(intentsTimestamps["Installed"] - cutEpoch)
-                            rerouteLatency = float(myMax - cutEpoch)
-
-                            rerouteLatency = numpy.divide(rerouteLatency, 1000)
-                            main.log.report("Reroute latency:" + str(rerouteLatency) + " (seconds)\n    ")
-                            myResult[run-warmUp][0] = rerouteLatency
-                            myResult[run-warmUp][1] = indexOfMax
-                            if debug: main.log.info("Latency: " + str(myResult[run-warmUp][0]))
-                            if debug: main.log.info("last node: " + str(myResult[run-warmUp][1]))
-
-                cmd = """ onos $OC1 null-link "null:0000000000000004/1 null:0000000000000003/2 up" """
-                if debug: main.log.info(cmd)
-                main.ONOSbench.handle.sendline(cmd)
-                main.ONOSbench.handle.expect(":~")
-
-                #wait for intent withdraw
-                main.ONOSbench.handle.sendline(withdrawCmd)
-                main.log.info(withdrawCmd)
-                main.ONOSbench.handle.expect(":~")
-                if debug: main.log.info(main.ONOSbench.handle.before)
-                main.ONOSbench.handle.sendline("onos $OC1 intents|grep WITHDRAWN|wc -l")
-                main.ONOSbench.handle.expect(":~")
-                intentWithdrawCheck = main.ONOSbench.handle.before
-                if (str(intents)) in intentWithdrawCheck:
-                    main.log.info("intents withdrawn")
-                if debug: main.log.info(intentWithdrawCheck)
-
-                # wait for links to be reestablished
-                for i in range(0, 10):
-                    main.ONOSbench.handle.sendline("onos $OC1 summary")
-                    main.ONOSbench.handle.expect(":~")
-                    linkCheck = main.ONOSbench.handle.before
-                    if "links=16," in linkCheck:
-                        break
-                    time.sleep(1)
-                    if i == 9:
-                        main.log.info("Links Failed to reconnect, next iteration of data invalid." + linkCheck)
-
-                if run < warmUp:
-                    main.log.info("Warm up run " + str(run+1) + " completed")
-
-            if debug: main.log.info(myResult)
-            latTemp = []
-            nodeTemp = []
-            for i in myResult:
-                latTemp.append(i[0])
-                nodeTemp.append(i[1])
-
-            mode = {}
-            for i in nodeTemp:
-                if i in mode:
-                    mode[i] += 1
+        print(main.intentsList)
+        for batchSize in main.intentsList:
+            main.log.report("Intent Batch size: " + str(batchSize) + "\n      ")
+            main.LatencyList = []
+            for run in range(0, (main.warmUp + main.sampleSize)):
+                if run >= main.warmUp:
+                    main.log.info("================================================")
+                    main.log.info("Starting test iteration " + str(run - main.warmUp))
+                    main.log.info("================================================")
                 else:
-                    mode[i] = 1
+                    main.log.info("====================Warm Up=====================")
 
-            for i in mode.keys():
-                if mode[i] == max(mode.values()):
-                    nodeMode = i
+                # push intents
+                main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize,
+                                             offset=1, options="-i", timeout=main.timeout)
 
-            average = numpy.average(latTemp)
-            stdDev = numpy.std(latTemp)
+                # check links and flows
+                k = 0
+                verify = main.FALSE
+                linkCheck = 0
+                flowsCheck = 0
+                while k <= main.verifyAttempts:
+                    time.sleep(main.verifySleep)
+                    summary = json.loads(main.CLIs[0].summary(timeout=main.timeout))
+                    linkCheck = summary.get("links")
+                    flowsCheck = summary.get("flows")
+                    if linkCheck == 16 and flowsCheck == batchSize * 7:
+                        main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck))
+                        verify = main.TRUE
+                        break
+                    k += 1
+                if not verify:
+                    main.log.warn("Links or flows number are not match!")
+                    main.log.warn("links: {}, flows: {} ".format(linkCheck, flowsCheck))
+                    continue
 
-            average = numpy.multiply(average, 1000)
-            stdDev = numpy.multiply(stdDev, 1000)
+                # Bring link down
+                main.CLIs[0].link("0000000000000004/1", "0000000000000003/2", "down",
+                                  timeout=main.timeout, showResponse=False)
+                verify = main.FALSE
+                k = 0
+                topoManagerLog = ""
+                while k <= main.verifyAttempts:
+                    time.sleep(main.verifySleep)
+                    summary = json.loads(main.CLIs[0].summary(timeout=main.timeout))
+                    linkCheck = summary.get("links")
+                    flowsCheck = summary.get("flows")
+                    if linkCheck == 14:
+                        main.log.info("links: {}, flows: {} ".format(linkCheck, flowsCheck))
+                        verify = main.TRUE
+                        break
+                    k += 1
+                if not verify:
+                    main.log.warn("Links number are not match in TopologyManager log!")
+                    main.log.warn(topoManagerLog)
+                    continue
 
-            main.log.report("Scale: " + str(clusterCount) + "  \tIntent batch: " + str(intents))
-            main.log.report("Latency average:................" + str(average))
-            main.log.report("Latency standard deviation:....." + str(stdDev))
-            main.log.report("Mode of last node to respond:..." + str(nodeMode))
+                try:
+                    # expect twice to clean the pexpect buffer
+                    main.ONOSbench.handle.sendline("")
+                    main.ONOSbench.handle.expect("\$")
+                    main.ONOSbench.handle.expect("\$")
+                    # send line by using bench, can't use driver because pexpect buffer problem
+                    cmd = "onos-ssh $OC1 cat /opt/onos/log/karaf.log | grep TopologyManager| tail -1"
+                    main.ONOSbench.handle.sendline(cmd)
+                    time.sleep(1)
+                    main.ONOSbench.handle.expect(":~")
+                    topoManagerLog = main.ONOSbench.handle.before
+                    topoManagerLogTemp = topoManagerLog.splitlines()
+                    # To make sure we get correct topology log
+                    for lines in topoManagerLogTemp:
+                        if "creationTime" in lines:
+                            topoManagerLog = lines
+                    main.log.info("Topology Manager log:")
+                    print(topoManagerLog)
+                    cutTimestamp = float(topoManagerLog.split("creationTime=")[1].split(",")[0])
+                except:
+                    main.log.error("Topology Log is not correct!")
+                    print(topoManagerLog)
+                    # If we got wrong Topology log, we should skip this iteration, and continue for next one
+                    continue
+
+                installedTemp = []
+                time.sleep(1)
+                for cli in main.CLIs:
+                    tempJson = json.loads(cli.intentsEventsMetrics())
+                    Installedtime = tempJson.get('intentInstalledTimestamp').get('value')
+                    installedTemp.append(float(Installedtime))
+                for i in range(0, len(installedTemp)):
+                    main.log.info("ONOS Node {} Installed Time stemp: {}".format((i + 1), installedTemp[i]))
+                maxInstallTime = float(max(installedTemp))
+                if run >= main.warmUp:
+                    main.log.info("Installed time stemp: {0:f}".format(maxInstallTime))
+                    main.log.info("CutTimestamp: {0:f}".format(cutTimestamp))
+                    # Both timeStemps are milliseconds
+                    main.log.info("Latency: {0:f}".format(float(maxInstallTime - cutTimestamp)))
+                    main.LatencyList.append(float(maxInstallTime - cutTimestamp))
+
+                # Verify Summary after we bring up link, and withdrawn intents
+                main.CLIs[0].link("0000000000000004/1", "0000000000000003/2", "up",
+                                  timeout=main.timeout)
+                k = 0
+                verify = main.FALSE
+                linkCheck = 0
+                flowsCheck = 0
+                while k <= main.verifyAttempts:
+                    time.sleep(main.verifySleep)
+                    main.CLIs[0].removeAllIntents(purge=True, sync=True, timeout=main.timeout)
+                    time.sleep(1)
+                    main.CLIs[0].purgeWithdrawnIntents()
+                    summary = json.loads(main.CLIs[0].summary())
+                    linkCheck = summary.get("links")
+                    flowsCheck = summary.get("flows")
+                    intentCheck = summary.get("intents")
+                    if linkCheck == 16 and flowsCheck == 0 and intentCheck == 0:
+                        main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck))
+                        verify = main.TRUE
+                        break
+                    k += 1
+                if not verify:
+                    main.log.error("links, flows, or intents are not correct!")
+                    main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck))
+                    continue
+
+            aveLatency = 0
+            stdLatency = 0
+            aveLatency = numpy.average(main.LatencyList)
+            stdLatency = numpy.std(main.LatencyList)
+            main.log.report("Scale: " + str(main.numCtrls) + "  \tIntent batch: " + str(batchSize))
+            main.log.report("Latency average:................" + str(aveLatency))
+            main.log.report("Latency standard deviation:....." + str(stdLatency))
             main.log.report("________________________________________________________")
 
-            resultsDB = open("/tmp/IntentRerouteLatDB", "a")
-            resultsDB.write("'" + commit + "',")
-            resultsDB.write(str(clusterCount) + ",")
-            resultsDB.write(str(intents) + ",")
-            resultsDB.write(str(average) + ",")
-            resultsDB.write(str(stdDev) + "\n")
+            resultsDB = open(main.dbFileName, "a")
+            resultsDB.write("'" + main.commit + "',")
+            resultsDB.write(str(main.numCtrls) + ",")
+            resultsDB.write(str(batchSize) + ",")
+            resultsDB.write(str(aveLatency) + ",")
+            resultsDB.write(str(stdLatency) + "\n")
             resultsDB.close()
-
-            main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
-
+        del main.scale[0]
diff --git a/TestON/tests/SCPF/SCPFintentRerouteLatWithFlowObj/SCPFintentRerouteLatWithFlowObj.params b/TestON/tests/SCPF/SCPFintentRerouteLatWithFlowObj/SCPFintentRerouteLatWithFlowObj.params
index 3799982..35fbefb 100644
--- a/TestON/tests/SCPF/SCPFintentRerouteLatWithFlowObj/SCPFintentRerouteLatWithFlowObj.params
+++ b/TestON/tests/SCPF/SCPFintentRerouteLatWithFlowObj/SCPFintentRerouteLatWithFlowObj.params
@@ -1,6 +1,6 @@
 <PARAMS>
 
-    <testcases>1,2,1,2,1,2,1,2</testcases>
+    <testcases>0,1,2,1,2,1,2,1,2</testcases>
 
     <SCALE>1,3,5,7</SCALE>
     <max>7</max>
@@ -14,30 +14,33 @@
         <skipCleanInstall>yes</skipCleanInstall>
         <warmUp>5</warmUp>
         <sampleSize>20</sampleSize>
-        <wait></wait>
         <intents>1,100,1000</intents>                       #list format, will be split on ','
-        <debug>True</debug>
-
-        <s1>1,1,1,1,1,1,1,1</s1>
-        <s3>2,2,1,1,3,3,3,1</s3>
-        <s5>2,2,1,1,3,4,5,3</s5>
-        <s7>2,3,1,1,5,6,7,4</s7>
-
+        <ingress>null:0000000000000001/0</ingress>
+        <egress>null:0000000000000007/0</egress>
+        <debug>False</debug>
     </TEST>
-
-    <METRICS>
-        <Submitted>0</Submitted>
-        <Installed>1</Installed>
-        <Failed>0</Failed>
-        <Withdraw>0</Withdraw>
-        <Withdrawn>0</Withdrawn>
-    </METRICS>
+    <DATABASE>
+        <file>/tmp/IntentRerouteLatDB</file>
+    </DATABASE>
 
     <GIT>
-        <autopull>off</autopull>
-        <checkout>master</checkout>
+        <gitPull>False</gitPull>
+        <gitBranch>master</gitBranch>
     </GIT>
 
+    <ATTEMPTS>
+        <verify>3</verify>
+    </ATTEMPTS>
+
+    <SLEEP>
+        <startup>10</startup>
+        <install>10</install>
+        <verify>5</verify>
+        <reroute>3</reroute>
+        # timeout for pexpect
+        <timeout>300</timeout>
+    </SLEEP>
+
     <CTRL>
         <USER>sdn</USER>
 
diff --git a/TestON/tests/SCPF/SCPFintentRerouteLatWithFlowObj/SCPFintentRerouteLatWithFlowObj.py b/TestON/tests/SCPF/SCPFintentRerouteLatWithFlowObj/SCPFintentRerouteLatWithFlowObj.py
index ff158b7..ce9155d 100644
--- a/TestON/tests/SCPF/SCPFintentRerouteLatWithFlowObj/SCPFintentRerouteLatWithFlowObj.py
+++ b/TestON/tests/SCPF/SCPFintentRerouteLatWithFlowObj/SCPFintentRerouteLatWithFlowObj.py
@@ -1,419 +1,369 @@
-# ScaleOutTemplate
-#
-# CASE1 starts number of nodes specified in param file
-#
-# cameron@onlab.us
-
-import sys
-import os.path
-
+# SCPFintentRerouteLatWithFlowObj
+"""
+SCPFintentRerouteLat
+    - Test Intent Reroute Latency
+    - Test Algorithm:
+        1. Start Null Provider reroute Topology
+        2. Using Push-test-intents to push batch size intents from switch 1 to switch 7
+        3. Cut the link between switch 3 and switch 4 (the path will reroute to switch 8)
+        4. Get the topology time stamp
+        5. Get Intent reroute(Installed) time stamp from each nodes
+        6. Use the latest intent time stamp subtract topology time stamp
+    - This test will run 5 warm up by default, warm up iteration can be setup in Param file
+    - The intent batch size will default set to 1, 100, and 1000, also can be set in Param file
+    - The unit of the latency result is milliseconds
+    - Ues flowObject set to True
+"""
 
 class SCPFintentRerouteLatWithFlowObj:
+    def __init__(self):
+        self.default=''
 
-    def __init__( self ):
-        self.default = ''
+    def CASE0( self, main ):
+        '''
+        - GIT
+        - BUILDING ONOS
+            Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
+            This step is usually skipped. Because in a Jenkins driven automated
+            test env. We want Jenkins jobs to pull&build for flexibility to handle
+            different versions of ONOS.
+        - Construct tests variables
+        '''
+        gitPull = main.params['GIT']['gitPull']
+        gitBranch = main.params['GIT']['gitBranch']
+
+        main.case("Pull onos branch and build onos on Teststation.")
+
+        if gitPull == 'True':
+            main.step("Git Checkout ONOS branch: " + gitBranch)
+            stepResult = main.ONOSbench.gitCheckout(branch=gitBranch)
+            utilities.assert_equals(expect=main.TRUE,
+                                    actual=stepResult,
+                                    onpass="Successfully checkout onos branch.",
+                                    onfail="Failed to checkout onos branch. Exiting test...")
+            if not stepResult: main.exit()
+
+            main.step("Git Pull on ONOS branch:" + gitBranch)
+            stepResult = main.ONOSbench.gitPull()
+            utilities.assert_equals(expect=main.TRUE,
+                                    actual=stepResult,
+                                    onpass="Successfully pull onos. ",
+                                    onfail="Failed to pull onos. Exiting test ...")
+            if not stepResult: main.exit()
+
+            main.step("Building ONOS branch: " + gitBranch)
+            stepResult = main.ONOSbench.cleanInstall(skipTest=True)
+            utilities.assert_equals(expect=main.TRUE,
+                                    actual=stepResult,
+                                    onpass="Successfully build onos.",
+                                    onfail="Failed to build onos. Exiting test...")
+            if not stepResult: main.exit()
+
+        else:
+            main.log.warn("Skipped pulling onos and Skipped building ONOS")
+
+        main.apps = main.params['ENV']['cellApps']
+        main.BENCHUser = main.params['BENCH']['user']
+        main.BENCHIp = main.params['BENCH']['ip1']
+        main.MN1Ip = main.params['MN']['ip1']
+        main.maxNodes = int(main.params['max'])
+        main.skipMvn = main.params['TEST']['skipCleanInstall']
+        main.cellName = main.params['ENV']['cellName']
+        main.scale = (main.params['SCALE']).split(",")
+        main.dbFileName = main.params['DATABASE']['file']
+        main.timeout = int(main.params['SLEEP']['timeout'])
+        main.startUpSleep = int(main.params['SLEEP']['startup'])
+        main.installSleep = int(main.params['SLEEP']['install'])
+        main.verifySleep = int(main.params['SLEEP']['verify'])
+        main.verifyAttempts = int(main.params['ATTEMPTS']['verify'])
+        main.sampleSize = int(main.params['TEST']['sampleSize'])
+        main.warmUp = int(main.params['TEST']['warmUp'])
+        main.intentsList = (main.params['TEST']['intents']).split(",")
+        main.ingress = main.params['TEST']['ingress']
+        main.egress = main.params['TEST']['egress']
+        main.debug = main.params['TEST']['debug']
+        for i in range ( 0, len(main.intentsList) ):
+            main.intentsList[i] = int(main.intentsList[i])
+         # Create DataBase file
+        main.log.info( "Create Database file " + main.dbFileName )
+        resultsDB = open( main.dbFileName, "w+")
+        resultsDB.close()
+
 
     def CASE1( self, main ):
-
+        '''
+            clean up test environment and set up
+        '''
         import time
 
-        global init
-        try:
-            if type(init) is not bool:
-                init = False
-        except NameError:
-            init = False
+        main.log.info( "Get ONOS cluster IP" )
+        print(main.scale)
+        main.numCtrls = int(main.scale[0])
+        main.ONOSip = []
+        main.maxNumBatch = 0
+        main.AllONOSip = main.ONOSbench.getOnosIps()
+        for i in range(main.numCtrls):
+            main.ONOSip.append(main.AllONOSip[i])
+        main.log.info(main.ONOSip)
+        main.CLIs=[]
+        main.log.info("Creating list of ONOS cli handles")
+        for i in range(main.numCtrls):
+            main.CLIs.append(getattr(main, 'ONOS%scli' % (i + 1)))
 
-        #Load values from params file
-        checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
-        gitPull = main.params[ 'GIT' ][ 'autopull' ]
-        cellName = main.params[ 'ENV' ][ 'cellName' ]
-        Apps = main.params[ 'ENV' ][ 'cellApps' ]
-        BENCHUser = main.params[ 'BENCH' ][ 'user' ]
-        BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
-        MN1Ip = main.params[ 'MN' ][ 'ip1' ]
-        main.maxNodes = int(main.params[ 'max' ])
-        skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
-        cellName = main.params[ 'ENV' ][ 'cellName' ]
+        if not main.CLIs:
+            main.log.error("Failed to create the list of ONOS cli handles")
+            main.cleanup()
+            main.exit()
 
-        # -- INIT SECTION, ONLY RUNS ONCE -- #
-        if init == False:
-            init = True
-            global clusterCount             #number of nodes running
-            global ONOSIp                   #list of ONOS IP addresses
-            global scale
-            global commit
+        main.commit = main.ONOSbench.getVersion(report=True)
+        main.commit = main.commit.split(" ")[1]
+        main.log.info("Starting up %s node(s) ONOS cluster" % main.numCtrls)
+        main.log.info("Safety check, killing all ONOS processes" +
+                      " before initiating environment setup")
 
-            clusterCount = 0
-            ONOSIp = [ 0 ]
-            scale = (main.params[ 'SCALE' ]).split(",")
-            clusterCount = int(scale[0])
+        for i in range(main.numCtrls):
+            main.ONOSbench.onosDie(main.ONOSip[i])
 
-            #Populate ONOSIp with ips from params
-            ONOSIp = [0]
-            ONOSIp.extend(main.ONOSbench.getOnosIps())
+        main.log.info("NODE COUNT = %s" % main.numCtrls)
 
-            print("-----------------" + str(ONOSIp))
-            #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
-            if skipMvn != "yes":
-                mvnResult = main.ONOSbench.cleanInstall()
+        #tempOnosIp = []
+        #for i in range(main.numCtrls):
+        #    tempOnosIp.append(main.AllONOSip[i])
+        #print(tempOnosIp)
+        main.ONOSbench.createCellFile(main.ONOSbench.ip_address,
+                                      main.cellName,
+                                      main.MN1Ip,
+                                      main.apps,
+                                      main.ONOSip )
+        main.step("Apply cell to environment")
+        cellResult = main.ONOSbench.setCell(main.cellName)
+        verifyResult = main.ONOSbench.verifyCell()
+        stepResult = cellResult and verifyResult
+        utilities.assert_equals(expect=main.TRUE,
+                                actual=stepResult,
+                                onpass="Successfully applied cell to " + \
+                                       "environment",
+                                onfail="Failed to apply cell to environment ")
 
-            #git
-            main.step( "Git checkout and pull " + checkoutBranch )
-            if gitPull == 'on':
-                checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
-                pullResult = main.ONOSbench.gitPull()
-
-            else:
-                checkoutResult = main.TRUE
-                pullResult = main.TRUE
-                main.log.info( "Skipped git checkout and pull" )
-
-            commit = main.ONOSbench.getVersion()
-            commit = (commit.split(" "))[1]
-
-            resultsDB = open("/tmp/IntentRerouteLatDBWithFlowObj", "w+")
-            resultsDB.close()
-
-        # -- END OF INIT SECTION --#
-
-        clusterCount = int(scale[0])
-        scale.remove(scale[0])
-
-        #kill off all onos processes
-        main.log.step("Safety check, killing all ONOS processes")
-        main.log.step("before initiating environment setup")
-        for node in range(1, main.maxNodes + 1):
-            main.ONOSbench.onosDie(ONOSIp[node])
-
-        #Uninstall everywhere
-        main.log.step( "Cleaning Enviornment..." )
-        for i in range(1, main.maxNodes + 1):
-            main.log.info(" Uninstalling ONOS " + str(i) )
-            main.ONOSbench.onosUninstall( ONOSIp[i] )
-
-        #construct the cell file
-        main.log.info("Creating cell file")
-        cellIp = []
-        for node in range (1, clusterCount + 1):
-            cellIp.append(ONOSIp[node])
-
-        main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), cellIp)
-
-        main.step( "Set Cell" )
-        main.ONOSbench.setCell(cellName)
-
-        main.step( "Creating ONOS package" )
+        main.step("Creating ONOS package")
         packageResult = main.ONOSbench.onosPackage()
+        stepResult = packageResult
+        utilities.assert_equals(expect=main.TRUE,
+                                actual=stepResult,
+                                onpass="Successfully created ONOS package",
+                                onfail="Failed to create ONOS package")
 
-        main.step( "verify cells" )
-        verifyCellResult = main.ONOSbench.verifyCell()
+        main.step("Uninstall ONOS package on all Nodes")
+        uninstallResult = main.TRUE
+        for i in range(int(main.numCtrls)):
+            main.log.info("Uninstalling package on ONOS Node IP: " + main.ONOSip[i])
+            u_result = main.ONOSbench.onosUninstall(main.ONOSip[i])
+            utilities.assert_equals(expect=main.TRUE, actual=u_result,
+                                    onpass="Test step PASS",
+                                    onfail="Test step FAIL")
+            uninstallResult = (uninstallResult and u_result)
 
-        main.log.report( "Initializing " + str( clusterCount ) + " node cluster." )
-        for node in range(1, clusterCount + 1):
-            main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
-            main.ONOSbench.onosInstall( ONOSIp[node])
+        main.step("Install ONOS package on all Nodes")
+        installResult = main.TRUE
+        for i in range(int(main.numCtrls)):
+            main.log.info("Installing package on ONOS Node IP: " + main.ONOSip[i])
+            i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i])
+            utilities.assert_equals(expect=main.TRUE, actual=i_result,
+                                    onpass="Test step PASS",
+                                    onfail="Test step FAIL")
+            installResult = installResult and i_result
 
-        for node in range(1, clusterCount + 1):
-            for i in range( 2 ):
-                isup = main.ONOSbench.isup( ONOSIp[node] )
-                if isup:
-                    main.log.info("ONOS " + str(node) + " is up\n")
-                    break
-            if not isup:
-                main.log.report( "ONOS " + str(node) + " didn't start!" )
-        main.log.info("Startup sequence complete")
+        main.step("Verify ONOS nodes UP status")
+        statusResult = main.TRUE
+        for i in range(int(main.numCtrls)):
+            main.log.info("ONOS Node " + main.ONOSip[i] + " status:")
+            onos_status = main.ONOSbench.onosStatus(node=main.ONOSip[i])
+            utilities.assert_equals(expect=main.TRUE, actual=onos_status,
+                                    onpass="Test step PASS",
+                                    onfail="Test step FAIL")
+            statusResult = (statusResult and onos_status)
+        time.sleep(2)
+        main.step("Start ONOS CLI on all nodes")
+        cliResult = main.TRUE
+        main.log.step(" Start ONOS cli using thread ")
+        startCliResult = main.TRUE
+        pool = []
+        main.threadID=0
+        for i in range(int(main.numCtrls)):
+            t = main.Thread(target=main.CLIs[i].startOnosCli,
+                            threadID=main.threadID,
+                            name="startOnosCli",
+                            args=[main.ONOSip[i]],
+                            kwargs={"onosStartTimeout": main.timeout})
+            pool.append(t)
+            t.start()
+            main.threadID = main.threadID + 1
+        for t in pool:
+            t.join()
+            startCliResult = startCliResult and t.result
+        time.sleep(main.startUpSleep)
 
-        deviceMastership = (main.params[ 'TEST' ][ "s" + str(clusterCount) ]).split(",")
-        print("Device mastership list: " + str(deviceMastership))
+        # configure apps
+        main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=8)
+        main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="reroute")
+        main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
+        main.CLIs[0].setCfg("org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupEnabled", value="false")
+        main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
+                            "useFlowObjectives", value="true")
+        time.sleep(main.startUpSleep)
 
-        main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupEnabled false")
+        # Balance Master
+        main.CLIs[0].balanceMasters()
+        if len(main.ONOSip) > 1:
+            main.CLIs[0].deviceRole("null:0000000000000003", main.ONOSip[0])
+            main.CLIs[0].deviceRole("null:0000000000000004", main.ONOSip[0])
 
-        main.log.step("Setting up null provider")
-        for i in range(3):
-            main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "deviceCount 8")
-            main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "topoShape reroute")
-            main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "enabled true")
-            main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator", "useFlowObjectives true" )
-            time.sleep(5)
-            main.ONOSbench.handle.sendline("onos $OC1 summary")
-            main.ONOSbench.handle.expect(":~")
-            x = main.ONOSbench.handle.before
-            if "devices=8" in x and "links=16," in x:
-                break
-
-        index = 1
-        for node in deviceMastership:
-            for attempt in range(0,10):
-                cmd = ( "onos $OC" + node + """ "device-role null:000000000000000""" + str(index) + " " + ONOSIp[int(node)]  + """ master" """)
-                main.log.info("assigning mastership of device " + str(index) + " to node " + node + ": \n " + cmd + "\n")
-                main.ONOSbench.handle.sendline(cmd)
-                main.ONOSbench.handle.expect(":~")
-                time.sleep(4)
-
-                cmd = ( "onos $OC" + node + " roles|grep 00000" + str(index))
-                main.log.info(cmd)
-                main.ONOSbench.handle.sendline(cmd)
-                main.ONOSbench.handle.expect(":~")
-                check = main.ONOSbench.handle.before
-                main.log.info("CHECK:\n" + check)
-                if ("master=" + ONOSIp[int(node)]) in check:
-                    break
-            index += 1
-
-        main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
-
-    def CASE2( self, main ):
-
+    def CASE2( self, main):
         import time
         import numpy
         import datetime
-        #from scipy import stats
+        import json
+        # from scipy import stats
 
         ts = time.time()
-
-        sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
-        warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
-        intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",")
-        debug = main.params[ 'TEST' ][ 'debug' ]
-        for i in range(0,len(intentsList)):
-            intentsList[i] = int(intentsList[i])
-
-        timestampMetrics = []
-        if main.params['METRICS']['Submitted'] == "1":
-            timestampMetrics.append("Submitted")
-        if main.params['METRICS']['Installed'] == "1":
-            timestampMetrics.append("Installed")
-        if main.params['METRICS']['Failed'] == "1":
-            timestampMetrics.append("Failed")
-        if main.params['METRICS']['Withdraw'] == "1":
-            timestampMetrics.append("Withdraw")
-        if main.params['METRICS']['Withdrawn'] == "1":
-            timestampMetrics.append("Withdrawn")
-        if debug: main.log.info(timestampMetrics)
-
-        if debug == "True":
-            debug = True
-        else:
-            debug = False
-
-        ingress = "null:0000000000000001"
-        egress = "null:0000000000000007"
-
-        for intents in intentsList:
-            main.log.report("Intent Batch size: " + str(intents) + "\n      ")
-            myResult = [["latency", "lastNode"] for x in range(sampleSize)]
-
-            for run in range(0, (warmUp + sampleSize)):
-                if run > warmUp:
-                    main.log.info("Starting test iteration " + str(run-warmUp))
-
-                cmd = """onos $OC1 "push-test-intents -i """
-                cmd += ingress + "/0 "
-                cmd += egress + "/0 "
-                cmd += str(intents) +""" 1" """
-                if debug: main.log.info(cmd)
-
-                withdrawCmd = cmd.replace("intents -i", "intents -w ")
-
-                #push-test-intents
-                main.ONOSbench.handle.sendline(cmd)
-                main.ONOSbench.handle.expect(":~")
-                myRawResult = main.ONOSbench.handle.before
-
-                for i in range(0, 40):
-                    main.ONOSbench.handle.sendline("onos $OC1 summary")
-                    main.ONOSbench.handle.expect(":~")
-                    linkCheck = main.ONOSbench.handle.before
-                    if ("links=16,") in linkCheck and ("flows=" + str(intents*7) + ","):
-                        break
-                    if i == 39:
-                        main.log.error("Flow/link count incorrect, data invalid."+ linkCheck)
-                        main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], "d")
-                        #main.ONOSbench.logReport(ONOSIp[(clusterCount-1)], ["ERROR", "WARNING", "EXCEPT"], "d")
-                        main.ONOSbench.sendline("onos $OC1 summary")
-                        main.ONOSbench.sendline("onos $OC1 devices")
-                        main.ONOSbench.sendline("onos $OC1 links")
-                        main.ONOSbench.expect(":~")
-                        main.log.info(main.ONOSbench.before)
-
-                #collect timestamp from link cut
-                cmd = """onos $OC1 null-link "null:0000000000000004/1 null:0000000000000003/2 down" """
-                if debug: main.log.info("COMMAND: " + str(cmd))
-                main.ONOSbench.handle.sendline(cmd)
-                main.ONOSbench.handle.expect(":~")
-
-                cmd = "onos-ssh $OC1 cat /opt/onos/log/karaf.log | grep TopologyManager| tail -1"
-                for i in range(0,10):
-                    main.ONOSbench.handle.sendline(cmd)
-                    time.sleep(2)
-                    main.ONOSbench.handle.expect(":~")
-                    raw = main.ONOSbench.handle.before
-                    #if "NullLinkProvider" in raw and "links=14" in raw:
-                    if "links=14" in raw:
-                        break
-                    if i >= 9:
-                        main.log.error("Expected output not being recieved... continuing")
-                        main.log.info(raw)
-                        break
-                    time.sleep(2)
-
-                if debug: main.log.debug("raw: " + raw)
-
-                temp = raw.splitlines()
-
-                if debug: main.log.debug("temp (after splitlines): " + str(temp))
-
-                # Since the string is deterministic the date is always the 3rd element.
-                # However, if the data were grepping for in the onos log changes then this will
-                # not work. This is why we print out the raw and temp string so we can visually
-                # check if everything is in the correct order. temp should like this:
-                # temp = ['/onos$ onos-ssh $OC1 cat /opt/onos/log/karaf.log | grep Top ', 
-                #         'ologyManager| tail -1', '2015-10-15 12:03:33,736 ... ]
-                temp = temp[2]
-
-                if debug: main.log.debug("temp (checking for date): " + str(temp))
-
-                cutTimestamp = (temp.split(" "))[0] + " " + (temp.split(" "))[1]
-
-                if debug: main.log.info("Cut timestamp: " + cutTimestamp)
-
-                #validate link count and flow count
-                for i in range(0, 40):
-                    main.ONOSbench.handle.sendline("onos $OC1 summary")
-                    main.ONOSbench.handle.expect(":~")
-                    linkCheck = main.ONOSbench.handle.before
-                    #if "links=" + str(7*intents)+ "," in linkCheck and ("flows=" + str(7*intents) + ",") in linkCheck:
-                    if "links=14," in linkCheck and ("flows=" + str(8*intents) + ",") in linkCheck:
-                        break
-                    if i == 39:
-                        main.log.error("Link or flow count incorrect, data invalid." + linkCheck)
-                        main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], "d")
-
-                time.sleep(5) #trying to avoid negative values
-
-                #intents events metrics installed timestamp
-                IEMtimestamps = [0]*(clusterCount + 1)
-                installedTemp = [0]*(clusterCount + 1)
-                for node in range(1, clusterCount +1):
-                    cmd = "onos $OC" + str(node) + """ "intents-events-metrics"|grep Timestamp """
-                    raw = ""
-                    while "epoch)" not in raw:
-                        main.ONOSbench.handle.sendline(cmd)
-                        main.ONOSbench.handle.expect(":~")
-                        raw = main.ONOSbench.handle.before
-
-                    print(raw)
-
-                    intentsTimestamps = {}
-                    rawTimestamps = raw.splitlines()
-                    for line in rawTimestamps:
-                        if "Timestamp" in line and "grep" not in line:
-                            metricKey = (line.split(" "))[1]
-                            metricTimestamp = (line.split(" ")[len(line.split(" ")) -1]).replace("epoch)=","")
-                            metricTimestamp = float(metricTimestamp)
-                            metricTimestamp = numpy.divide(metricTimestamp, 1000)
-                            if debug: main.log.info(repr(metricTimestamp))
-                            intentsTimestamps[metricKey] = metricTimestamp
-                            if metricKey == "Installed":
-                                installedTemp[node] = metricTimestamp
-
-                    main.log.info("Node: " + str(node) + " Timestamps: " + str(intentsTimestamps))
-                    IEMtimestamps[node] = intentsTimestamps
-
-                myMax = max(installedTemp)
-                indexOfMax = installedTemp.index(myMax)
-
-                #number crunch
-                for metric in timestampMetrics:     #this is where we sould add support for computing other timestamp metrics
-                    if metric == "Installed":
-                        if run >= warmUp:
-                            main.log.report("link cut timestamp: " + cutTimestamp)
-                            #readableInstalledTimestamp = str(intentsTimestamps["Installed"])
-                            readableInstalledTimestamp = str(myMax)
-
-                            #main.log.report("Intent Installed timestamp: " + str(intentsTimestamps["Installed"]))
-                            main.log.report("Intent Installed timestamp: " + str(myMax))
-
-                            cutEpoch = time.mktime(time.strptime(cutTimestamp, "%Y-%m-%d %H:%M:%S,%f"))
-                            if debug: main.log.info("cutEpoch=" + str(cutEpoch))
-                            #rerouteLatency = float(intentsTimestamps["Installed"] - cutEpoch)
-                            rerouteLatency = float(myMax - cutEpoch)
-
-                            rerouteLatency = numpy.divide(rerouteLatency, 1000)
-                            main.log.report("Reroute latency:" + str(rerouteLatency) + " (seconds)\n    ")
-                            myResult[run-warmUp][0] = rerouteLatency
-                            myResult[run-warmUp][1] = indexOfMax
-                            if debug: main.log.info("Latency: " + str(myResult[run-warmUp][0]))
-                            if debug: main.log.info("last node: " + str(myResult[run-warmUp][1]))
-
-                cmd = """ onos $OC1 null-link "null:0000000000000004/1 null:0000000000000003/2 up" """
-                if debug: main.log.info(cmd)
-                main.ONOSbench.handle.sendline(cmd)
-                main.ONOSbench.handle.expect(":~")
-
-                #wait for intent withdraw
-                main.ONOSbench.handle.sendline(withdrawCmd)
-                main.log.info(withdrawCmd)
-                main.ONOSbench.handle.expect(":~")
-                if debug: main.log.info(main.ONOSbench.handle.before)
-                main.ONOSbench.handle.sendline("onos $OC1 intents|grep WITHDRAWN|wc -l")
-                main.ONOSbench.handle.expect(":~")
-                intentWithdrawCheck = main.ONOSbench.handle.before
-                if (str(intents)) in intentWithdrawCheck:
-                    main.log.info("intents withdrawn")
-                if debug: main.log.info(intentWithdrawCheck)
-
-                # wait for links to be reestablished
-                for i in range(0, 10):
-                    main.ONOSbench.handle.sendline("onos $OC1 summary")
-                    main.ONOSbench.handle.expect(":~")
-                    linkCheck = main.ONOSbench.handle.before
-                    if "links=16," in linkCheck:
-                        break
-                    time.sleep(1)
-                    if i == 9:
-                        main.log.info("Links Failed to reconnect, next iteration of data invalid." + linkCheck)
-
-                if run < warmUp:
-                    main.log.info("Warm up run " + str(run+1) + " completed")
-
-            if debug: main.log.info(myResult)
-            latTemp = []
-            nodeTemp = []
-            for i in myResult:
-                latTemp.append(i[0])
-                nodeTemp.append(i[1])
-
-            mode = {}
-            for i in nodeTemp:
-                if i in mode:
-                    mode[i] += 1
+        print( main.intentsList )
+        for batchSize in main.intentsList:
+            main.log.report("Intent Batch size: " + str(batchSize) + "\n      ")
+            main.LatencyList = []
+            for run in range( 0, (main.warmUp + main.sampleSize) ):
+                if run >= main.warmUp:
+                    main.log.info( "================================================" )
+                    main.log.info( "Starting test iteration " + str(run - main.warmUp) )
+                    main.log.info( "================================================" )
                 else:
-                    mode[i] = 1
+                    main.log.info( "====================Warm Up=====================" )
 
-            for i in mode.keys():
-                if mode[i] == max(mode.values()):
-                    nodeMode = i
+                # push intents
+                main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize,
+                                             offset=1,options="-i",timeout=main.timeout)
 
-            average = numpy.average(latTemp)
-            stdDev = numpy.std(latTemp)
+                # check links and flows
+                k = 0
+                verify = main.FALSE
+                linkCheck = 0
+                flowsCheck = 0
+                while k <= main.verifyAttempts:
+                    time.sleep( main.verifySleep )
+                    summary = json.loads( main.CLIs[0].summary(timeout=main.timeout) )
+                    linkCheck = summary.get("links")
+                    flowsCheck = summary.get("flows")
+                    if linkCheck == 16 and flowsCheck == batchSize*7:
+                        main.log.info( "links: {}, flows: {} ".format(linkCheck,flowsCheck) )
+                        verify = main.TRUE
+                        break
+                    k += 1
+                if not verify:
+                    main.log.warn( "Links or flows number are not match!")
+                    main.log.warn( "links: {}, flows: {} ".format(linkCheck, flowsCheck) )
+                    continue
 
-            average = numpy.multiply(average, 1000)
-            stdDev = numpy.multiply(stdDev, 1000)
+                # Bring link down
+                main.CLIs[0].link("0000000000000004/1", "0000000000000003/2", "down",
+                                  timeout=main.timeout, showResponse=False )
+                verify = main.FALSE
+                k = 0
+                topoManagerLog = ""
+                while k <= main.verifyAttempts:
+                    time.sleep(main.verifySleep)
+                    summary = json.loads( main.CLIs[0].summary(timeout=main.timeout) )
+                    linkCheck = summary.get("links")
+                    flowsCheck = summary.get("flows")
+                    if linkCheck == 14:
+                        main.log.info( "links: {}, flows: {} ".format(linkCheck, flowsCheck) )
+                        verify = main.TRUE
+                        break
+                    k += 1
+                if not verify:
+                    main.log.warn( "Links number are not match in TopologyManager log!" )
+                    main.log.warn( topoManagerLog )
+                    continue
 
-            main.log.report("Scale: " + str(clusterCount) + "  \tIntent batch: " + str(intents))
-            main.log.report("Latency average:................" + str(average))
-            main.log.report("Latency standard deviation:....." + str(stdDev))
-            main.log.report("Mode of last node to respond:..." + str(nodeMode))
+                try:
+                    # expect twice to clean the pexpect buffer
+                    main.ONOSbench.handle.sendline("")
+                    main.ONOSbench.handle.expect("\$")
+                    main.ONOSbench.handle.expect("\$")
+                    # send line by using bench, can't use driver because pexpect buffer problem
+                    cmd = "onos-ssh $OC1 cat /opt/onos/log/karaf.log | grep TopologyManager| tail -1"
+                    main.ONOSbench.handle.sendline(cmd)
+                    time.sleep(1)
+                    main.ONOSbench.handle.expect(":~")
+                    topoManagerLog = main.ONOSbench.handle.before
+                    topoManagerLogTemp = topoManagerLog.splitlines()
+                    # To make sure we get correct topology log
+                    for lines in topoManagerLogTemp:
+                        if "creationTime" in lines:
+                            topoManagerLog = lines
+                    main.log.info("Topology Manager log:")
+                    print(topoManagerLog)
+                    cutTimestamp = float(topoManagerLog.split("creationTime=")[1].split(",")[0])
+                except:
+                    main.log.error("Topology Log is not correct!")
+                    print(topoManagerLog)
+                    # If we got wrong Topology log, we should skip this iteration, and continue for next one
+                    continue
+
+                installedTemp = []
+                time.sleep(1)
+                for cli in main.CLIs:
+                    tempJson = json.loads( cli.intentsEventsMetrics() )
+                    Installedtime = tempJson.get('intentInstalledTimestamp').get('value')
+                    installedTemp.append(float(Installedtime))
+                for i in range(0, len(installedTemp)):
+                    main.log.info("ONOS Node {} Installed Time stemp: {}".format((i+1),installedTemp[i]))
+                maxInstallTime = float( max(installedTemp) )
+                if run >= main.warmUp:
+                    main.log.info( "Installed time stemp: {0:f}".format( maxInstallTime ) )
+                    main.log.info("CutTimestamp: {0:f}".format( cutTimestamp) )
+                    # Both timeStemps are milliseconds
+                    main.log.info( "Latency: {0:f}".format( float(maxInstallTime-cutTimestamp)) )
+                    main.LatencyList.append(float(maxInstallTime-cutTimestamp))
+
+                # Verify Summary after we bring up link, and withdrawn intents
+                main.CLIs[0].link( "0000000000000004/1", "0000000000000003/2", "up",
+                                   timeout=main.timeout )
+                k = 0
+                verify = main.FALSE
+                linkCheck = 0
+                flowsCheck = 0
+                while k <= main.verifyAttempts:
+                    time.sleep(main.verifySleep)
+                    main.CLIs[0].removeAllIntents( purge=True, sync=True, timeout=main.timeout )
+                    time.sleep(1)
+                    main.CLIs[0].purgeWithdrawnIntents()
+                    summary = json.loads( main.CLIs[0].summary() )
+                    linkCheck = summary.get("links")
+                    flowsCheck = summary.get("flows")
+                    intentCheck = summary.get("intents")
+                    if linkCheck == 16 and flowsCheck == 0 and intentCheck == 0:
+                        main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck))
+                        verify = main.TRUE
+                        break
+                    k += 1
+                if not verify:
+                    main.log.error("links, flows, or intents are not correct!")
+                    main.log.info("links: {}, flows: {}, intents: {} ".format(linkCheck, flowsCheck, intentCheck))
+                    continue
+
+            aveLatency=0
+            stdLatency=0
+            aveLatency = numpy.average(main.LatencyList)
+            stdLatency = numpy.std(main.LatencyList)
+            main.log.report("Scale: " + str(main.numCtrls) + "  \tIntent batch: " + str(batchSize))
+            main.log.report("Latency average:................" + str(aveLatency))
+            main.log.report("Latency standard deviation:....." + str(stdLatency))
             main.log.report("________________________________________________________")
 
-            resultsDB = open("/tmp/IntentRerouteLatDBWithFlowObj", "a")
-            resultsDB.write("'" + commit + "',")
-            resultsDB.write(str(clusterCount) + ",")
-            resultsDB.write(str(intents) + ",")
-            resultsDB.write(str(average) + ",")
-            resultsDB.write(str(stdDev) + "\n")
+            resultsDB = open(main.dbFileName, "a")
+            resultsDB.write("'" + main.commit + "',")
+            resultsDB.write(str(main.numCtrls) + ",")
+            resultsDB.write(str(batchSize) + ",")
+            resultsDB.write(str(aveLatency) + ",")
+            resultsDB.write(str(stdLatency) + "\n")
             resultsDB.close()
-
-            main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
+        del main.scale[0]
diff --git a/TestON/tests/USECASE/SegmentRouting/SRSanity/README.md b/TestON/tests/USECASE/SegmentRouting/SRSanity/README.md
new file mode 100755
index 0000000..59c1214
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRSanity/README.md
@@ -0,0 +1,16 @@
+This test verifies basic connectivity using SegmentRouting via pingall,
+it should not fail.
+
+It consists of 
+
+1) Configure and Install ONOS
+2) Start Mininet and check flow state
+3) Pingall
+
+Requirements
+
+ - An updated version of the CPQD switch has to be running to make sure it supports group chaining.
+
+The test is executed using the netcfg subsystem:
+    1) APPS=openflow-base,netcfghostprovider,netcfglinksprovider
+The topology is a 2x2 Leaf-spine
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.params b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.params
similarity index 66%
rename from TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.params
rename to TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.params
index 15ce439..24403e2 100755
--- a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.params
+++ b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.params
@@ -1,6 +1,6 @@
 <PARAMS>
 
-    <testcases>1,[2,3,4,4,10]*2</testcases>
+    <testcases>1,2,3,4,10</testcases>
 
     <SCALE>
         <size>1</size>
@@ -8,7 +8,6 @@
     </SCALE>
 
     <DEPENDENCY>
-        <path>/tests/USECASE_SegmentRouting/dependencies/</path>
         <wrapper1>startUp</wrapper1>
         <topology>cord_fabric.py</topology>
     </DEPENDENCY>
@@ -16,7 +15,7 @@
     <ENV>
         <cellName>productionCell</cellName>
         <cellApps>drivers,segmentrouting</cellApps>
-        <diffApps>openflow-base,netcfghostprovider,netcfglinksprovider;openflow</diffApps>
+        <diffApps>openflow-base,netcfghostprovider,netcfglinksprovider</diffApps>
         <cellUser>sdn</cellUser>
     </ENV>
 
@@ -29,6 +28,17 @@
         <port>6653</port>
     </CTRL>
 
+    <timers>
+        <LinkDiscovery>12</LinkDiscovery>
+        <SwitchDiscovery>12</SwitchDiscovery>
+    </timers>
+
+    <kill>
+        <switch> spine101 </switch>
+        <dpid> 000000000101 </dpid>
+        <links> leaf1 leaf2 </links>
+    </kill>
+
     <SLEEP>
         <startup>10</startup>
     </SLEEP>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.py b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.py
new file mode 100755
index 0000000..9a0d91c
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.py
@@ -0,0 +1,619 @@
+# This test should always succeed. it runs cases 1,2,3,4
+#CASE1: Get and Build ONOS
+#CASE2: Package and Install ONOS
+#CASE3: Start Mininet and check flows
+#CASE4: Ping all
+#CASE5: Link Failure
+#CASE6: Switch Failure
+#CASE7: ONOS Failure
+#CASE8: CLUSTER Failure
+#CASE10: Logging
+
+class SRSanity:
+
+    def __init__( self ):
+        self.default = ''
+
+    def CASE1( self, main ):
+        import time
+        import os
+        import imp
+        import re
+
+        """
+        - Construct tests variables
+        - GIT ( optional )
+            - Checkout ONOS master branch
+            - Pull latest ONOS code
+        - Building ONOS ( optional )
+            - Install ONOS package
+            - Build ONOS package
+        """
+
+        main.case( "Constructing test variables and building ONOS" )
+        main.step( "Constructing test variables" )
+        stepResult = main.FALSE
+
+        # Test variables
+        main.cellName = main.params[ 'ENV' ][ 'cellName' ]
+        main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+        main.diff = []
+        main.diff.extend(( main.params[ 'ENV' ][ 'diffApps' ] ).split(";"))
+        main.diff=main.diff*2
+        gitBranch = main.params[ 'GIT' ][ 'branch' ]
+        main.path = os.path.dirname( main.testFile )
+        main.dependencyPath = main.path +"/../dependencies/"
+        main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
+        main.json = ["2x2"]*4
+        main.args = [" "]*4
+        main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
+        main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
+        main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
+        wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
+        main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
+        gitPull = main.params[ 'GIT' ][ 'pull' ]
+        main.cellData = {} # for creating cell file
+        main.CLIs = []
+        main.ONOSip = []
+
+        # Assigning ONOS cli handles to a list
+        for i in range( 1,  main.maxNodes + 1 ):
+            main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+            main.ONOSip.append( main.CLIs[i-1].ip_address )
+        # -- INIT SECTION, ONLY RUNS ONCE -- #
+        main.startUp = imp.load_source( wrapperFile1,
+                                        main.dependencyPath +
+                                        wrapperFile1 +
+                                        ".py" )
+
+        copyResult1 = main.ONOSbench.scp( main.Mininet1,
+                                          main.dependencyPath +
+                                          main.topology,
+                                          main.Mininet1.home,
+                                          direction="to" )
+        if main.CLIs:
+            stepResult = main.TRUE
+        else:
+            main.log.error( "Did not properly created list of ONOS CLI handle" )
+            stepResult = main.FALSE
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully construct " +
+                                        "test variables ",
+                                 onfail="Failed to construct test variables" )
+
+        if gitPull == 'True':
+            main.step( "Building ONOS in " + gitBranch + " branch" )
+            onosBuildResult = main.startUp.onosBuild( main, gitBranch )
+            stepResult = onosBuildResult
+            utilities.assert_equals( expect=main.TRUE,
+                                     actual=stepResult,
+                                     onpass="Successfully compiled " +
+                                            "latest ONOS",
+                                     onfail="Failed to compile " +
+                                            "latest ONOS" )
+        else:
+            main.log.warn( "Did not pull new code so skipping mvn " +
+                           "clean install" )
+        main.numCtrls = int( main.scale[ 0 ] )
+         
+    def CASE2( self, main ):
+        """
+        - Set up cell
+            - Create cell file
+            - Set cell file
+            - Verify cell file
+        - Kill ONOS process
+        - Uninstall ONOS cluster
+        - Verify ONOS start up
+        - Install ONOS cluster
+        - Connect to cli
+        """
+
+        # main.scale[ 0 ] determines the current number of ONOS controller
+        main.numCtrls = int( main.scale[ 0 ] )
+        main.scale.remove( main.scale[ 0 ] )
+        apps=main.apps
+        if main.diff:
+            apps = main.apps+","+main.diff.pop(0)
+        else: main.log.error( "App list is empty" )
+        main.case( "Package and start ONOS using apps:" + apps)
+
+        print "NODE COUNT = ", main.numCtrls
+        print main.ONOSip
+        tempOnosIp = []
+        for i in range( main.numCtrls ):
+            tempOnosIp.append( main.ONOSip[i] )
+
+        onosUser = main.params[ 'ENV' ][ 'cellUser' ]
+        main.step("Create and Apply cell file")
+        main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
+                                       "temp",
+                                       main.Mininet1.ip_address,
+                                       apps,
+                                       tempOnosIp,
+                                       onosUser )
+
+        cellResult = main.ONOSbench.setCell( "temp" )
+        verifyResult = main.ONOSbench.verifyCell()
+        stepResult = cellResult and verifyResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully applied cell to " + \
+                                        "environment",
+                                 onfail="Failed to apply cell to environment " )
+        #kill off all onos processes
+        main.log.info( "Safety check, killing all ONOS processes" +
+                       " before initiating environment setup" )
+
+        for i in range( main.maxNodes ):
+            main.ONOSbench.onosDie( main.ONOSip[ i ] )
+
+        main.step( "Create and Install ONOS package" )
+        main.jsonFile=main.json.pop(0)
+        main.ONOSbench.handle.sendline( "cp "+main.dependencyPath+"/"+main.jsonFile+".json ~/onos/tools/package/config/network-cfg.json")
+        packageResult = main.ONOSbench.onosPackage()
+
+        onosInstallResult = main.TRUE
+        for i in range( main.numCtrls ):
+            onosInstallResult = onosInstallResult and \
+                    main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
+        stepResult = onosInstallResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully installed ONOS package",
+                                 onfail="Failed to install ONOS package" )
+
+        main.step( "Starting ONOS service" )
+        stopResult = main.TRUE
+        startResult = main.TRUE
+        onosIsUp = main.TRUE
+
+        for i in range( main.numCtrls ):
+            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
+        if onosIsUp == main.TRUE:
+            main.log.report( "ONOS instance is up and ready" )
+        else:
+            main.log.report( "ONOS instance may not be up, stop and " +
+                             "start ONOS again " )
+            for i in range( main.numCtrls ):
+                stopResult = stopResult and \
+                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
+            for i in range( main.numCtrls ):
+                startResult = startResult and \
+                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
+        stepResult = onosIsUp and stopResult and startResult
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="ONOS service is ready",
+                                 onfail="ONOS service did not start properly" )
+        main.step( "Checking if ONOS CLI is ready" )
+        main.CLIs[0].startCellCli()
+        cliResult = main.CLIs[0].startOnosCli( main.ONOSip[ 0 ],
+                                           commandlineTimeout=60, onosStartTimeout=100 )
+        utilities.assert_equals( expect=main.TRUE,
+                             actual=cliResult,
+                             onpass="ONOS CLI is ready",
+                             onfail="ONOS CLI is not ready" )
+        for i in range( 10 ):
+            ready = True
+            output = main.CLIs[0].summary()
+            if not output:
+                ready = False
+            if ready:
+                break
+            time.sleep( 10 )
+        utilities.assert_equals( expect=True, actual=ready,
+                                 onpass="ONOS summary command succeded",
+                                 onfail="ONOS summary command failed" )
+
+        if not ready:
+            main.log.error( "ONOS startup failed!" )
+            main.cleanup()
+            main.exit()
+
+    def CASE3( self, main ):
+        """
+            Start mininet
+        """
+        main.case( "Start Leaf-Spine "+main.jsonFile+" Mininet Topology" )
+        main.log.report( "Start Mininet topology" )
+
+        main.step( "Starting Mininet Topology" )
+        args,topo=" "," "
+        if main.args:
+            args = "--onos %d %s" % (main.numCtrls, main.args.pop(0))
+        else: main.log.error( "Argument list is empty" )
+ 
+        topoResult = main.Mininet1.startNet( topoFile= main.dependencyPath + main.topology, args=args )
+        stepResult = topoResult
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully loaded topology",
+                                 onfail="Failed to load topology" )
+        # Exit if topology did not load properly
+        if not topoResult:
+            main.cleanup()
+            main.exit()
+        main.step(" Check whether the flow count is bigger than 116" )
+        count =  utilities.retry( main.CLIs[0].checkFlowCount,
+                                 main.FALSE,
+                                 kwargs={'min':116},
+                                 attempts=10,
+                                 sleep=10 )
+        utilities.assertEquals( \
+            expect=True,
+            actual=(count>0),
+            onpass="Flow count looks correct: "+str(count),
+            onfail="Flow count looks wrong: "+str(count) )
+
+        main.step( "Check whether all flow status are ADDED" )
+        flowCheck = utilities.retry( main.CLIs[0].checkFlowsState,
+                                 main.FALSE,
+                                 kwargs={'isPENDING':False},
+                                 attempts=10,
+                                 sleep=10)
+        utilities.assertEquals( \
+            expect=main.TRUE,
+            actual=flowCheck,
+            onpass="Flow status is correct!",
+            onfail="Flow status is wrong!" )
+        main.ONOSbench.dumpFlows( main.ONOSip[0],
+                 main.logdir, "flowsBefore" + main.jsonFile)
+        main.ONOSbench.dumpGroups( main.ONOSip[0],
+                                   main.logdir, "groupsBefore" + main.jsonFile)
+        main.count=1
+
+    def CASE4( self, main ):
+        main.case( "Check full connectivity" )
+        main.log.report( "Check full connectivity" )
+
+        main.step("Check full connectivity"+str(main.count))
+        pa = main.Mininet1.pingall()
+        utilities.assert_equals( expect=main.TRUE, actual=pa,
+                                 onpass="Full connectivity successfully tested",
+                                 onfail="Full connectivity failed" )
+        main.ONOSbench.dumpFlows( main.ONOSip[0],
+                 main.logdir, "flowsAfter" + str(main.count) + main.jsonFile)
+        main.ONOSbench.dumpGroups( main.ONOSip[0],
+                           main.logdir, "groupsAfter" + str(main.count) + main.jsonFile)
+
+    def CASE5( self, main ):
+        """
+        Link spine101-leaf2 down
+        Pingall
+        Link spine101-leaf2 up
+        Pingall
+        """
+        import time
+        assert main.numCtrls, "main.numCtrls not defined"
+        assert main, "main not defined"
+        assert utilities.assert_equals, "utilities.assert_equals not defined"
+        assert main.CLIs, "main.CLIs not defined"
+
+        linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+
+        description = "Turn off a link to ensure that Segment Routing reroutes traffic " + \
+                      "properly"
+        main.case( description )
+
+        main.step( "Kill Link between spine101 and leaf2" )
+        LinkDown = main.Mininet1.link( END1="spine101", END2="leaf2", OPTION="down" )
+        main.log.info( "Waiting %s seconds for link up to be discovered" % (linkSleep) )
+        # TODO Maybe parameterize number of expected links
+        time.sleep( linkSleep )
+        topology =  utilities.retry( main.CLIs[0].checkStatus,
+                                      main.FALSE,
+                                      kwargs={'numoswitch':'4', 'numolink':'6'},
+                                      attempts=10,
+                                      sleep=linkSleep)
+        result = topology & LinkDown
+        utilities.assert_equals( expect=main.TRUE, actual=result,
+                                 onpass="Link down successful",
+                                 onfail="Failed to turn off link?" )
+
+        main.step( "Check connectivity after link failure" )
+        pa = main.Mininet1.pingall()
+        utilities.assert_equals( expect=main.TRUE, actual=pa,
+                                 onpass="Survived link failure successfully",
+                                 onfail="Did not survive link failure" )
+        main.ONOSbench.dumpFlows( main.ONOSip[0],
+                                  main.logdir,
+                                  "flowsAfterLinkFailure" + main.jsonFile)
+        main.ONOSbench.dumpGroups( main.ONOSip[0],
+                                   main.logdir,
+                                   "groupsAfterLinkFailure" + main.jsonFile)
+
+        main.step( "Restore link between spine101 and leaf2" )
+
+        result = False
+        count=0
+        while True:
+            count+=0
+            main.Mininet1.link( END1="spine101", END2="leaf2", OPTION="up" )
+            main.Mininet1.link( END2="spine101", END1="leaf2", OPTION="up" )
+            main.log.info( "Waiting %s seconds for link up to be discovered" % (linkSleep) )
+            time.sleep( linkSleep )
+
+            main.CLIs[0].portstate(dpid='of:0000000000000002', port='1')
+            main.CLIs[0].portstate(dpid='of:0000000000000101', port='2')
+            time.sleep( linkSleep )
+
+            result = main.CLIs[0].checkStatus(numoswitch='4', numolink='8')
+            if count>10 or result:
+                break
+        utilities.assert_equals( expect=main.TRUE, actual=result,
+                                 onpass="Link up successful",
+                                 onfail="Failed to bring link up" )
+
+        main.step( "Check connectivity after link recovery" )
+        pa = main.Mininet1.pingall()
+        utilities.assert_equals( expect=main.TRUE, actual=pa,
+                                 onpass="Survived link recovery successfully",
+                                 onfail="Did not survive link recovery" )
+        main.ONOSbench.dumpFlows( main.ONOSip[0],
+                                  main.logdir,
+                                  "flowsAfterLinkRecovery" + main.jsonFile)
+        main.ONOSbench.dumpGroups( main.ONOSip[0],
+                                   main.logdir,
+                                   "groupsAfterLinkRecovery" + main.jsonFile)
+
+    def CASE6( self, main ):
+        """
+        Switch Down
+        Pingall
+        Switch up
+        Pingall
+        """
+        import time
+        assert main.numCtrls, "main.numCtrls not defined"
+        assert main, "main not defined"
+        assert utilities.assert_equals, "utilities.assert_equals not defined"
+        assert main.CLIs, "main.CLIs not defined"
+    
+        switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
+    
+        description = "Killing a switch to ensure it is discovered correctly"
+        onosCli = main.CLIs[0]
+        main.case( description )
+        switch = main.params[ 'kill' ][ 'switch' ]
+        switchDPID = main.params[ 'kill' ][ 'dpid' ]
+
+        main.step( "Kill " + switch )
+        main.log.info( "Stopping" + switch )
+        main.Mininet1.switch( SW=switch, OPTION="stop")
+        main.log.info( "Waiting %s seconds for switch down to be discovered" %(switchSleep))
+        time.sleep( switchSleep )
+        topology =  utilities.retry( main.CLIs[0].checkStatus,
+                                      main.FALSE,
+                                     kwargs={'numoswitch':'3', 'numolink':'4'},
+                                      attempts=10,
+                                     sleep=switchSleep)
+        utilities.assert_equals( expect=main.TRUE, actual=topology,
+                                 onpass="Kill switch successful",
+                                 onfail="Failed to kill switch?" )
+
+        main.step( "Check connectivity after switch failure" )
+        pa = main.Mininet1.pingall()
+        utilities.assert_equals( expect=main.TRUE, actual=pa,
+                                 onpass="Survived switch failure successfully",
+                                 onfail="Did not survive switch failure" )
+        main.ONOSbench.dumpFlows( main.ONOSip[0],
+                                  main.logdir,
+                                  "flowsAfterSwitchFailure" + main.jsonFile)
+        main.ONOSbench.dumpGroups( main.ONOSip[0],
+                                   main.logdir,
+                                   "groupsAfterSwitchFailure" + main.jsonFile)
+
+        main.step( "Recovering " + switch )
+        main.log.info( "Starting" + switch )
+        main.Mininet1.switch( SW=switch, OPTION="start")
+        main.log.info( "Waiting %s seconds for switch up to be discovered" %(switchSleep))
+        time.sleep( switchSleep )
+        topology =  utilities.retry( main.CLIs[0].checkStatus,
+                                     main.FALSE,
+                                     kwargs={'numoswitch':'4', 'numolink':'8'},
+                                     attempts=10,
+                                     sleep=switchSleep)
+        utilities.assert_equals( expect=main.TRUE, actual=topology,
+                                 onpass="Switch recovery successful",
+                                 onfail="Failed to recover switch?" )
+
+        main.step( "Check connectivity after switch recovery" )
+        pa = main.Mininet1.pingall()
+        utilities.assert_equals( expect=main.TRUE, actual=pa,
+                                 onpass="Survived switch recovery successfully",
+                                 onfail="Did not survive switch recovery" )
+        main.ONOSbench.dumpFlows( main.ONOSip[0],
+                                  main.logdir,
+                                  "flowsAfterSwitchRecovery" + main.jsonFile)
+        main.ONOSbench.dumpGroups( main.ONOSip[0],
+                                   main.logdir,
+                                   "groupsAfterSwitchRecovery" + main.jsonFile)
+
+    def CASE7( self, main ):
+        """
+        OnosInstance1 Down
+        Pingall
+        OnosInstance1 up
+        Pingall
+        """
+
+        description = "Killing single instance to test controlplane resilience of Segment Routing"
+        main.case( description )
+        main.step( "Killing ONOS instance" )
+        killResult = main.ONOSbench.onosDie( main.CLIs[0].ip_address )
+        utilities.assert_equals( expect=main.TRUE, actual=killResult,
+                                 onpass="ONOS instance Killed",
+                                 onfail="Error killing ONOS instance" )
+        time.sleep( 12 )
+        topology =  utilities.retry( main.CLIs[1].checkStatus,
+                                     main.FALSE,
+                                     kwargs={'numoswitch':'4', 'numolink':'8', 'numoctrl':'2'},
+                                     attempts=10,
+                                     sleep=12)
+        utilities.assert_equals( expect=main.TRUE, actual=topology,
+                                 onpass="ONOS Instance down successful",
+                                 onfail="Failed to turn off ONOS Instance" )
+        main.step( "Check connectivity after ONOS instance failure" )
+        pa = main.Mininet1.pingall()
+        utilities.assert_equals( expect=main.TRUE, actual=pa,
+                                 onpass="Survived instance failure successfully",
+                                 onfail="Did not survive instance failure" )
+        main.ONOSbench.dumpFlows( main.ONOSip[1], main.logdir,
+                                  "flowsAfterSwitchFailure" + main.jsonFile)
+        main.ONOSbench.dumpGroups( main.ONOSip[1], main.logdir,
+                                   "groupsAfterSwitchFailure" + main.jsonFile)
+        main.step( "Recovering ONOS instance" )
+        startResult = main.ONOSbench.onosStart( main.CLIs[0].ip_address )
+        isUp = main.ONOSbench.isup( main.ONOSip[ 0 ] )
+        utilities.assert_equals( expect=main.TRUE, actual=isUp,
+                                 onpass="ONOS service is ready",
+                                 onfail="ONOS service did not start properly" )
+        main.step( "Checking if ONOS CLI is ready" )
+        main.CLIs[0].startCellCli()
+        cliResult = main.CLIs[0].startOnosCli( main.ONOSip[ 0 ],
+                                               commandlineTimeout=60, onosStartTimeout=100 )
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=cliResult,
+                                 onpass="ONOS CLI is ready",
+                                 onfail="ONOS CLI is not ready" )
+        for i in range( 10 ):
+            ready = True
+            output = main.CLIs[0].summary()
+            if not output:
+                ready = False
+            if ready:
+                break
+            time.sleep( 10 )
+        utilities.assert_equals( expect=True, actual=ready,
+                                 onpass="ONOS summary command succeded",
+                                 onfail="ONOS summary command failed" )
+        if not ready:
+            main.log.error( "ONOS startup failed!" )
+            main.cleanup()
+            main.exit()
+        main.step(" Check whether the flow count is bigger than 116" )
+        count =  utilities.retry( main.CLIs[0].checkFlowCount,
+                                  main.FALSE,
+                                  kwargs={'min':116},
+                                  attempts=10,
+                                  sleep=10 )
+        utilities.assertEquals( expect=True,
+                                actual=(count>0),
+                                onpass="Flow count looks correct: "+str(count),
+                                onfail="Flow count looks wrong: "+str(count) )
+
+        main.step( "Check connectivity after ONOS instance recovery" )
+        pa = main.Mininet1.pingall()
+        utilities.assert_equals( expect=main.TRUE, actual=pa,
+                                 onpass="Survived instance recovery successfully",
+                                 onfail="Did not survive recovery failure" )
+        main.ONOSbench.dumpFlows( main.ONOSip[0], main.logdir,
+                                  "flowsAfterCtrlFailure" + main.jsonFile)
+        main.ONOSbench.dumpGroups( main.ONOSip[0], main.logdir,
+                                   "groupsAfterCtrlFailure" + main.jsonFile)
+
+    def CASE8( self, main ):
+        """
+        Cluster Down
+        Pingall
+        Cluster up
+        Pingall
+        """
+        description = "Killing all instances to test controlplane resilience of Segment Routing"
+        main.case( description )
+        main.step( "Shutting down ONOS Cluster" )
+        for i in range( main.numCtrls ):
+            killResult = main.ONOSbench.onosDie( main.CLIs[i].ip_address )
+            utilities.assert_equals( expect=main.TRUE, actual=killResult,
+                                 onpass="ONOS instance Killed",
+                                 onfail="Error killing ONOS instance" )
+        time.sleep(12)
+        main.step( "Check connectivity after ONOS instance failure" )
+        pa = main.Mininet1.pingall()
+        utilities.assert_equals( expect=main.TRUE, actual=pa,
+                                 onpass="Survived instance failure successfully",
+                                 onfail="Did not survive instance failure" )
+        main.step( "Recovering ONOS Cluster" )
+        for i in range( main.numCtrls ):
+            startResult = main.ONOSbench.onosStart( main.CLIs[i].ip_address )
+            isUp = main.ONOSbench.isup( main.ONOSip[ i ] )
+            utilities.assert_equals( expect=main.TRUE, actual=isUp,
+                                 onpass="ONOS service is ready",
+                                 onfail="ONOS service did not start properly" )
+        main.step( "Checking if ONOS CLI is ready" )
+        for i in range( main.numCtrls ):
+            main.CLIs[i].startCellCli()
+            cliResult = main.CLIs[i].startOnosCli( main.ONOSip[ i ],
+                                           commandlineTimeout=60, onosStartTimeout=100 )
+            utilities.assert_equals( expect=main.TRUE,
+                             actual=cliResult,
+                             onpass="ONOS CLI is ready",
+                             onfail="ONOS CLI is not ready" )
+        for i in range( 10 ):
+            ready = True
+            output = main.CLIs[0].summary()
+            if not output:
+                ready = False
+            if ready:
+                break
+            time.sleep( 10 )
+        utilities.assert_equals( expect=True, actual=ready,
+                                 onpass="ONOS summary command succeded",
+                                 onfail="ONOS summary command failed" )
+        if not ready:
+            main.log.error( "ONOS startup failed!" )
+            main.cleanup()
+            main.exit()
+
+        main.step(" Check whether the flow count is bigger than 116" )
+        count =  utilities.retry( main.CLIs[0].checkFlowCount,
+                                  main.FALSE,
+                                  kwargs={'min':116},
+                                  attempts=10,
+                                  sleep=10 )
+        utilities.assertEquals( expect=True,
+                                actual=(count>0),
+                                onpass="Flow count looks correct: "+str(count),
+                                onfail="Flow count looks wrong: "+str(count) )
+
+        main.step( "Check connectivity after CLUSTER recovery" )
+        pa = main.Mininet1.pingall()
+        utilities.assert_equals( expect=main.TRUE, actual=pa,
+                                 onpass="Survived instance recovery successfully",
+                                 onfail="Did not survive recovery failure" )
+        main.ONOSbench.dumpFlows( main.ONOSip[0], main.logdir,
+                                  "flowsAfterCtrlFailure" + main.jsonFile)
+        main.ONOSbench.dumpGroups( main.ONOSip[0], main.logdir,
+                                   "groupsAfterCtrlFailure" + main.jsonFile)
+
+    def CASE10( self, main ):
+        '''
+            Report errors/warnings/exceptions
+        '''
+        main.case( "Logging test for " + main.jsonFile )
+        for i in range(main.numCtrls):
+            main.ONOSbench.onosStop( main.ONOSip[i] )
+        main.Mininet1.stopNet()
+        
+        main.ONOSbench.scp( main.ONOScli1 ,
+                                          "/opt/onos/log/karaf.log",
+                                          "/tmp/karaf.log",
+                                          direction="from" )
+        main.ONOSbench.cpLogsToDir("/tmp/karaf.log",main.logdir,
+                                   copyFileName="karaf.log."+main.jsonFile+str(len(main.json)))
+        #main.ONOSbench.logReport( main.ONOSip[ 0 ],
+        #                          [ "INFO" ],
+        #                          "a" )
+        #main.log.info("Error report: \n" )
+        main.ONOSbench.logReport( main.ONOSip[ 0 ],
+                                  [ "INFO",
+                                    "FOLLOWER",
+                                    "WARN",
+                                    "flow",
+                                    "ERROR",
+                                    "Except" ],
+                                  "s" )
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.topo b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.topo
similarity index 61%
rename from TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.topo
rename to TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.topo
index a5266a0..546a023 100755
--- a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.topo
+++ b/TestON/tests/USECASE/SegmentRouting/SRSanity/SRSanity.topo
@@ -13,7 +13,7 @@
         </ONOSbench>
 
         <ONOScli1>
-            <host>localhost</host>
+            <host>OC1</host>
             <user>sdn</user>
             <password>rocks</password>
             <type>OnosCliDriver</type>
@@ -21,13 +21,34 @@
             <COMPONENTS>
             </COMPONENTS>
         </ONOScli1>
+        
+        <ONOScli2>
+            <host>OC2</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosCliDriver</type>
+            <connect_order>3</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOScli2>
+
+        <ONOScli3>
+            <host>OC3</host>
+            <user>sdn</user>
+            <password>rocks</password>
+            <type>OnosCliDriver</type>
+            <connect_order>4</connect_order>
+            <COMPONENTS>
+            </COMPONENTS>
+        </ONOScli3>
+
 
         <Mininet1>
             <host>OCN</host>
             <user>sdn</user>
             <password>rocks</password>
             <type>MininetCliDriver</type>
-            <connect_order>3</connect_order>
+            <connect_order>5</connect_order>
             <COMPONENTS>
                 <home>~/mininet/custom/</home>
             </COMPONENTS>
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/__init__.py b/TestON/tests/USECASE/SegmentRouting/SRSanity/__init__.py
old mode 100644
new mode 100755
similarity index 100%
copy from TestON/tests/USECASE/USECASE_SegmentRouting/__init__.py
copy to TestON/tests/USECASE/SegmentRouting/SRSanity/__init__.py
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/__init__.py b/TestON/tests/USECASE/SegmentRouting/__init__.py
old mode 100644
new mode 100755
similarity index 100%
rename from TestON/tests/USECASE/USECASE_SegmentRouting/__init__.py
rename to TestON/tests/USECASE/SegmentRouting/__init__.py
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/2x2.json b/TestON/tests/USECASE/SegmentRouting/dependencies/2x2.json
old mode 100644
new mode 100755
similarity index 100%
rename from TestON/tests/USECASE/USECASE_SegmentRouting/2x2.json
rename to TestON/tests/USECASE/SegmentRouting/dependencies/2x2.json
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/4x4.json b/TestON/tests/USECASE/SegmentRouting/dependencies/4x4.json
old mode 100644
new mode 100755
similarity index 100%
rename from TestON/tests/USECASE/USECASE_SegmentRouting/4x4.json
rename to TestON/tests/USECASE/SegmentRouting/dependencies/4x4.json
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/dependencies/cord_fabric.py b/TestON/tests/USECASE/SegmentRouting/dependencies/cord_fabric.py
similarity index 100%
rename from TestON/tests/USECASE/USECASE_SegmentRouting/dependencies/cord_fabric.py
rename to TestON/tests/USECASE/SegmentRouting/dependencies/cord_fabric.py
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/dependencies/startUp.py b/TestON/tests/USECASE/SegmentRouting/dependencies/startUp.py
old mode 100644
new mode 100755
similarity index 100%
rename from TestON/tests/USECASE/USECASE_SegmentRouting/dependencies/startUp.py
rename to TestON/tests/USECASE/SegmentRouting/dependencies/startUp.py
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/README.md b/TestON/tests/USECASE/USECASE_SegmentRouting/README.md
deleted file mode 100644
index 8240068..0000000
--- a/TestON/tests/USECASE/USECASE_SegmentRouting/README.md
+++ /dev/null
@@ -1,33 +0,0 @@
-This test is designed to verify basic connectivity the SegmentRouting application via pingaall.
-
-It consists of 
-
-1) Configure and Install ONOS
-2) Start Mininet and check flow state
-2) Test connectivity
-
-Requirements
-
- - A single ONOS instance is required for the test, the application is currently not stable in a cluster as of today.
- - An updated version of the CPQD switch has to be running to make sure it supports group chaining.
-
-Step 1:
-In this step, we copy config file to ONOS, next we package ONOS and install it in the target machine.
-
-Step 2:
-
-In this step we start the topology, connect to ONOS
-
-Step:3
-
-Here, we send several pings between hosts to test connectivity.
-
-Then Steps are repeated for different configurations and topologies.
-
-    Configurations:
-     1) APPS=openflow-base,netcfghostprovider,netcfglinksprovider
-     2) APPS=openflow
-
-    Topologies:
-     1) 2x2 Leaf-Spine
-     2) 4x4 Leaf-Spine
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py b/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py
deleted file mode 100755
index 1a4834b..0000000
--- a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py
+++ /dev/null
@@ -1,320 +0,0 @@
-
-# This test is to determine if the Segment Routing application is working properly
-
-class USECASE_SegmentRouting:
-
-    def __init__( self ):
-        self.default = ''
-
-    def CASE1( self, main ):
-        import time
-        import os
-        import imp
-        import re
-
-        """
-        - Construct tests variables
-        - GIT ( optional )
-            - Checkout ONOS master branch
-            - Pull latest ONOS code
-        - Building ONOS ( optional )
-            - Install ONOS package
-            - Build ONOS package
-        """
-
-        main.case( "Constructing test variables and building ONOS" )
-        main.step( "Constructing test variables" )
-        stepResult = main.FALSE
-
-        # Test variables
-        main.cellName = main.params[ 'ENV' ][ 'cellName' ]
-        main.apps = main.params[ 'ENV' ][ 'cellApps' ]
-        main.diff = []
-        main.diff.extend(( main.params[ 'ENV' ][ 'diffApps' ] ).split(";"))
-        main.diff.extend(( main.params[ 'ENV' ][ 'diffApps' ] ).split(";"))
-        gitBranch = main.params[ 'GIT' ][ 'branch' ]
-        main.path = os.path.dirname( main.testFile )
-        main.dependencyPath = main.path + "/dependencies/"
-        main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
-        #main.json = ["0x1","0x1"]
-        main.json = ["2x2", "2x2","4x4","4x4"]
-        main.args = [" ", " ", " --spine 4 --leaf 4 ", " --spine 4 --leaf 4 "]
-        #main.args = [" --spine 0 --leaf 1 "," --spine 0 --leaf 1 "]
-        main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
-        main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
-        main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
-        wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
-        main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
-        gitPull = main.params[ 'GIT' ][ 'pull' ]
-        main.cellData = {} # for creating cell file
-        main.CLIs = []
-        main.ONOSip = []
-
-        main.ONOSip = main.ONOSbench.getOnosIps()
-
-        # Assigning ONOS cli handles to a list
-        for i in range( 1,  main.maxNodes + 1 ):
-            main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
-
-        # -- INIT SECTION, ONLY RUNS ONCE -- #
-        main.startUp = imp.load_source( wrapperFile1,
-                                        main.dependencyPath +
-                                        wrapperFile1 +
-                                        ".py" )
-
-        copyResult1 = main.ONOSbench.scp( main.Mininet1,
-                                          main.dependencyPath +
-                                          main.topology,
-                                          main.Mininet1.home,
-                                          direction="to" )
-        if main.CLIs:
-            stepResult = main.TRUE
-        else:
-            main.log.error( "Did not properly created list of ONOS CLI handle" )
-            stepResult = main.FALSE
-
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="Successfully construct " +
-                                        "test variables ",
-                                 onfail="Failed to construct test variables" )
-
-        if gitPull == 'True':
-            main.step( "Building ONOS in " + gitBranch + " branch" )
-            onosBuildResult = main.startUp.onosBuild( main, gitBranch )
-            stepResult = onosBuildResult
-            utilities.assert_equals( expect=main.TRUE,
-                                     actual=stepResult,
-                                     onpass="Successfully compiled " +
-                                            "latest ONOS",
-                                     onfail="Failed to compile " +
-                                            "latest ONOS" )
-        else:
-            main.log.warn( "Did not pull new code so skipping mvn " +
-                           "clean install" )
-         
-    def CASE2( self, main ):
-        """
-        - Set up cell
-            - Create cell file
-            - Set cell file
-            - Verify cell file
-        - Kill ONOS process
-        - Uninstall ONOS cluster
-        - Verify ONOS start up
-        - Install ONOS cluster
-        - Connect to cli
-        """
-
-        # main.scale[ 0 ] determines the current number of ONOS controller
-        main.numCtrls = int( main.scale[ 0 ] )
-        apps=main.apps
-        if main.diff:
-            apps = main.apps+","+main.diff.pop(0)
-        else: main.log.error( "App list is empty" )
-        main.case( "Package and start ONOS using apps:" + apps)
-
-        print "NODE COUNT = ", main.numCtrls
-
-        tempOnosIp = []
-        for i in range( main.numCtrls ):
-            tempOnosIp.append( main.ONOSip[i] )
-
-        onosUser = main.params[ 'ENV' ][ 'cellUser' ]
-        main.step("Create and Apply cell file")
-        main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
-                                       "temp",
-                                       main.Mininet1.ip_address,
-                                       apps,
-                                       tempOnosIp,
-                                       onosUser )
-
-        cellResult = main.ONOSbench.setCell( "temp" )
-        verifyResult = main.ONOSbench.verifyCell()
-        stepResult = cellResult and verifyResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="Successfully applied cell to " + \
-                                        "environment",
-                                 onfail="Failed to apply cell to environment " )
-        #kill off all onos processes
-        main.log.info( "Safety check, killing all ONOS processes" +
-                       " before initiating environment setup" )
-
-        for i in range( main.maxNodes ):
-            main.ONOSbench.onosDie( main.ONOSip[ i ] )
-
-        main.step( "Create and Install ONOS package" )
-        main.jsonFile=main.json.pop(0)
-        main.ONOSbench.handle.sendline( "cp "+main.path+"/"+main.jsonFile+".json ~/onos/tools/package/config/network-cfg.json")
-        packageResult = main.ONOSbench.onosPackage()
-        #stepResult = packageResult
-        #utilities.assert_equals( expect=main.TRUE,
-        #                         actual=stepResult,
-        #                         onpass="Successfully created ONOS package",
-        #                         onfail="Failed to create ONOS package" )
-
-        #time.sleep( main.startUpSleep )
-
-        onosInstallResult = main.TRUE
-        for i in range( main.numCtrls ):
-            onosInstallResult = onosInstallResult and \
-                    main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
-        stepResult = onosInstallResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="Successfully installed ONOS package",
-                                 onfail="Failed to install ONOS package" )
-
-        main.step( "Starting ONOS service" )
-        stopResult = main.TRUE
-        startResult = main.TRUE
-        onosIsUp = main.TRUE
-
-        for i in range( main.numCtrls ):
-            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
-        if onosIsUp == main.TRUE:
-            main.log.report( "ONOS instance is up and ready" )
-        else:
-            main.log.report( "ONOS instance may not be up, stop and " +
-                             "start ONOS again " )
-            for i in range( main.numCtrls ):
-                stopResult = stopResult and \
-                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
-            for i in range( main.numCtrls ):
-                startResult = startResult and \
-                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
-        stepResult = onosIsUp and stopResult and startResult
-
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="ONOS service is ready",
-                                 onfail="ONOS service did not start properly" )
-        #time.sleep( 2*main.startUpSleep )
-        #main.ONOSbench.handle.sendline( "onos-secure-ssh")
-        main.step( "Checking if ONOS CLI is ready" )
-        cellResult = main.CLIs[0].setCell( "temp" )
-
-        cliResult = main.CLIs[0].startOnosCli( main.ONOSip[ 0 ],
-                                           commandlineTimeout=60, onosStartTimeout=100 )
-        utilities.assert_equals( expect=main.TRUE,
-                             actual=cliResult,
-                             onpass="ONOS CLI is ready",
-                             onfail="ONOS CLI is not ready" )
-        for i in range( 10 ):
-            ready = True
-            output = main.CLIs[0].summary()
-            if not output:
-                ready = False
-            if ready:
-                break
-            time.sleep( 10 )
-        utilities.assert_equals( expect=True, actual=ready,
-                                 onpass="ONOS summary command succeded",
-                                 onfail="ONOS summary command failed" )
-
-        if not ready:
-            main.log.error( "ONOS startup failed!" )
-            main.cleanup()
-            main.exit()
-
-    def CASE3( self, main ):
-        """
-            Start mininet
-        """
-        main.case( "Start Leaf-Spine "+main.jsonFile+" Mininet Topology" )
-        main.log.report( "Start Mininet topology" )
-
-        main.step( "Starting Mininet Topology" )
-        args,topo=" "," "
-        #if main.topology:
-        #    topo = main.topology.pop(0)
-        #else: main.log.error( "Topo list is empty" )
-        if main.args:
-            args = "--onos 1 " + main.args.pop(0)
-        else: main.log.error( "Argument list is empty" )
-
-        topoResult = main.Mininet1.startNet( topoFile= main.dependencyPath + main.topology, args=args )
-        stepResult = topoResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="Successfully loaded topology",
-                                 onfail="Failed to load topology" )
-        # Exit if topology did not load properly
-        if not topoResult:
-            main.cleanup()
-            main.exit()
-        #main.step("Waiting for switch initialization and configuration")
-        main.step(" Check whether the flow count is bigger than 116" )
-        count =  utilities.retry( main.CLIs[0].checkFlowCount,
-                                 main.FALSE,
-                                 kwargs={'min':116},
-                                 attempts=10 )
-        utilities.assertEquals( \
-            expect=True,
-            actual=(count>0),
-            onpass="Flow count looks correct: "+str(count),
-            onfail="Flow count looks wrong: "+str(count) )
-
-        main.step( "Check whether all flow status are ADDED" )
-        flowCheck = utilities.retry( main.CLIs[0].checkFlowsState,
-                                 main.FALSE,
-                                 kwargs={'isPENDING':False},
-                                 attempts=10 )
-        utilities.assertEquals( \
-            expect=main.TRUE,
-            actual=flowCheck,
-            onpass="Flow status is correct!",
-            onfail="Flow status is wrong!" )
-        main.ONOSbench.dumpFlows( main.ONOSip[0],
-                 main.logdir, "flowsBefore" + main.jsonFile)
-        main.ONOSbench.dumpGroups( main.ONOSip[0],
-                                   main.logdir, "groupsBefore" + main.jsonFile)
-        #time.sleep( 3*main.startUpSleep)
-        main.count=1
-
-    def CASE4( self, main ):
-        main.case( "Check full connectivity" )
-        main.log.report( "Check full connectivity" )
-
-        main.step("Check full connectivity"+str(main.count))
-        pa = main.Mininet1.pingall()
-        utilities.assert_equals( expect=main.TRUE, actual=pa,
-                                 onpass="Full connectivity successfully tested",
-                                 onfail="Full connectivity failed" )
-        # cleanup mininet
-        main.ONOSbench.dumpFlows( main.ONOSip[0],
-                 main.logdir, "flowsAfter" + str(main.count) + main.jsonFile)
-        main.ONOSbench.dumpGroups( main.ONOSip[0],
-                           main.logdir, "groupsAfter" + str(main.count) + main.jsonFile)
-
-    def CASE10( self, main ):
-        '''
-            Report errors/warnings/exceptions
-        '''
-        main.case( "Logging test for " + main.jsonFile )
-        #if len(main.json) > 0 :
-        main.ONOSbench.onosStop( main.ONOSip[0] )
-        main.Mininet1.stopNet()
-        
-        main.ONOSbench.scp( main.ONOScli1 ,
-                                          "/opt/onos/log/karaf.log",
-                                          "/tmp/karaf.log",
-                                          direction="from" )
-        main.ONOSbench.cpLogsToDir("/tmp/karaf.log",main.logdir,
-                                   copyFileName="karaf.log."+main.jsonFile+str(len(main.json)))
-        #main.ONOSbench.logReport( main.ONOSip[ 0 ],
-        #                          [ "INFO" ],
-        #                          "a" )
-        #main.log.info("Error report: \n" )
-        main.ONOSbench.logReport( main.ONOSip[ 0 ],
-                                  [ "INFO",
-                                    "FOLLOWER",
-                                    "WARN",
-                                    "flow",
-                                    "ERROR",
-                                    "Except" ],
-                                  "s" )
-
-
-