Merge "Get device add time value from log and change thark capture method"
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 3b437cb..c30ac53 100755
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -2216,21 +2216,27 @@
             intentDictONOS = {}
             for intent in intentsJson:
                 intentDictONOS[ intent[ 'id' ] ] = intent[ 'state' ]
+            returnValue = main.TRUE
             if len( intentDict ) != len( intentDictONOS ):
-                main.log.info( self.name + ": expected intent count does not match that in ONOS, " +
+                main.log.warn( self.name + ": expected intent count does not match that in ONOS, " +
                                str( len( intentDict ) ) + " expected and " +
                                str( len( intentDictONOS ) ) + " actual" )
-                return main.FALSE
-            returnValue = main.TRUE
+                returnValue = main.FALSE
             for intentID in intentDict.keys():
                 if not intentID in intentDictONOS.keys():
                     main.log.debug( self.name + ": intent ID - " + intentID + " is not in ONOS" )
                     returnValue = main.FALSE
-                elif intentDict[ intentID ] != intentDictONOS[ intentID ]:
-                    main.log.debug( self.name + ": intent ID - " + intentID +
-                                    " expected state is " + intentDict[ intentID ] +
-                                    " but actual state is " + intentDictONOS[ intentID ] )
-                    returnValue = main.FALSE
+                else:
+                    if intentDict[ intentID ] != intentDictONOS[ intentID ]:
+                        main.log.debug( self.name + ": intent ID - " + intentID +
+                                        " expected state is " + intentDict[ intentID ] +
+                                        " but actual state is " + intentDictONOS[ intentID ] )
+                        returnValue = main.FALSE
+                    intentDictONOS.pop( intentID )
+            if len( intentDictONOS ) > 0:
+                returnValue = main.FALSE
+                for intentID in intentDictONOS.keys():
+                    main.log.debug( self.name + ": find extra intent in ONOS: intent ID " + intentID )
             if returnValue == main.TRUE:
                 main.log.info( self.name + ": all intent IDs and states match that in ONOS" )
             return returnValue
@@ -2654,14 +2660,20 @@
             main.cleanup()
             main.exit()
 
-    def FlowAddedCount( self, deviceId ):
+    def flowAddedCount( self, deviceId, core=False ):
         """
         Determine the number of flow rules for the given device id that are
         in the added state
+        Params:
+            core: if True, only return the number of core flows added
         """
         try:
-            cmdStr = "flows any " + str( deviceId ) + " | " +\
-                     "grep 'state=ADDED' | wc -l"
+            if core:
+                cmdStr = "flows any " + str( deviceId ) + " | " +\
+                         "grep 'state=ADDED' | grep org.onosproject.core | wc -l"
+            else:
+                cmdStr = "flows any " + str( deviceId ) + " | " +\
+                         "grep 'state=ADDED' | wc -l"
             handle = self.sendline( cmdStr )
             assert "Command not found:" not in handle, handle
             return handle
@@ -3369,7 +3381,7 @@
             main.cleanup()
             main.exit()
 
-    def apps( self, jsonFormat=True ):
+    def apps( self, summary=False, active=False, jsonFormat=True ):
         """
         Returns the output of the apps command for ONOS. This command lists
         information about installed ONOS applications
@@ -3381,6 +3393,10 @@
         # "features":"[onos-openflow]","state":"ACTIVE"}]
         try:
             cmdStr = "onos:apps"
+            if summary:
+                cmdStr += " -s"
+            if active:
+                cmdStr += " -a"
             if jsonFormat:
                 cmdStr += " -j"
             output = self.sendline( cmdStr )
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index dfb85fb..d46e99a 100755
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -388,6 +388,8 @@
                     # Prompt returned
                     break
             main.log.debug( output )
+            # FIXME: This is a workaround for a bug in buck see ONOS-5320
+            self.buckPackage( )
             return ret
         except pexpect.TIMEOUT:
             main.log.exception( self.name + ": TIMEOUT exception found" )
@@ -403,6 +405,53 @@
             main.cleanup()
             main.exit()
 
+    def buckPackage( self, timeout=180 ):
+        """
+        Package onos using buck. This will not build the source and this rule
+        should be automatically run when building onos.
+        """
+        try:
+            ret = main.TRUE
+            self.handle.sendline( "buck build package" )
+            self.handle.expect( "buck build package" )
+            output = ""
+            while True:
+                i = self.handle.expect( [ "This does not appear to be the root of a Buck project.",
+                                          "\n",
+                                          "BUILD FAILED",
+                                          "\$" ],
+                                        timeout=timeout )
+                output += str( self.handle.before + self.handle.after )
+                if i == 0:
+                    main.log.error( "Wrong location" )
+                    ret = main.FALSE
+                elif i == 1:
+                    # end of a line, buck is still printing output
+                    pass
+                elif i == 2:
+                    # Build failed
+                    main.log.error( "Build failed" )
+                    ret = main.FALSE
+                elif i == 3:
+                    # Prompt returned
+                    break
+            main.log.debug( output )
+            return ret
+        except pexpect.TIMEOUT:
+            main.log.exception( self.name + ": TIMEOUT exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
+            return main.FALSE
+        except pexpect.EOF:
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
+            main.cleanup()
+            main.exit()
+        except Exception:
+            main.log.exception( "Failed to package ONOS" )
+            main.cleanup()
+            main.exit()
+
+
     def gitPull( self, comp1="", fastForward=True ):
         """
         Assumes that "git pull" works without login
@@ -1624,19 +1673,20 @@
             main.cleanup()
             main.exit()
 
-    def dumpFlows(self,ONOSIp, destDir, filename="flows" ):
+    def dumpONOSCmd(self, ONOSIp, CMD, destDir, filename, options=""):
         """
-        Dump Flow Tables to a desired directory.
+        Dump Cmd to a desired directory.
         For debugging purposes, you may want to use
-        this function to capture flows at a given point in time.
+        this function to capture Cmd at a given point in time.
         Localtime will be attached to the filename
 
         Required:
             * ONOSIp: the IP of the target ONOS instance
+            * CMD: the command to dump;
             * destDir: specify directory to copy to.
               ex ) /tmp/
-        Optional:
             * fileName: Name of the file
+            * options: Options for ONOS command
         """
 
         localtime = time.strftime( '%x %X' )
@@ -1645,32 +1695,8 @@
         localtime = localtime.replace( ":", "" )
         if destDir[ -1: ] != "/":
             destDir += "/"
-        cmd="flows > "+ str( destDir ) + str( filename ) + localtime
-        return self.onosCli(ONOSIp,cmd)
-
-    def dumpGroups(self,ONOSIp, destDir, filename="groups" ):
-        """
-        Dump Group Tables to a desired directory.
-        For debugging purposes, you may want to use
-        this function to capture groups at a given point in time.
-        Localtime will be attached to the filename
-
-        Required:
-            * ONOSIp: the IP of the target ONOS instance
-            * destDir: specify directory to copy to.
-              ex ) /tmp/
-        Optional:
-            * fileName: Name of the file
-        """
-
-        localtime = time.strftime( '%H %M' )
-        localtime = localtime.replace( "/", "" )
-        localtime = localtime.replace( " ", "_" )
-        localtime = localtime.replace( ":", "" )
-        if destDir[ -1: ] != "/":
-            destDir += "/"
-        cmd="groups > "+ str( destDir ) + str( filename ) + localtime
-        return self.onosCli(ONOSIp,cmd)
+        cmd=CMD + " " + options + " > " + str( destDir ) + str( filename ) + localtime
+        return self.onosCli(ONOSIp, cmd)
 
     def cpLogsToDir( self, logToCopy,
                      destDir, copyFileName="" ):
diff --git a/TestON/install.sh b/TestON/install.sh
index 0327ca7..fc434bc 100755
--- a/TestON/install.sh
+++ b/TestON/install.sh
@@ -217,6 +217,7 @@
 
 if [ $# -eq 0 ]
 then
+    init
     default
 elif [ $1 == "--help" ]
 then
diff --git a/TestON/tests/CHOTestMonkey/CHOTestMonkey.params b/TestON/tests/CHOTestMonkey/CHOTestMonkey.params
index 6c9ef4b..85b2e0e 100644
--- a/TestON/tests/CHOTestMonkey/CHOTestMonkey.params
+++ b/TestON/tests/CHOTestMonkey/CHOTestMonkey.params
@@ -94,6 +94,8 @@
             <CLIParamNum>0</CLIParamNum>
             <rerunInterval>5</rerunInterval>
             <maxRerunNum>5</maxRerunNum>
+            <coreFlowNum>4</coreFlowNum>
+            <coreFlowNum6>6</coreFlowNum6>
         </FlowCheck>
 
         <TrafficCheck>
diff --git a/TestON/tests/CHOTestMonkey/CHOTestMonkey.py b/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
index 29a40aa..e6606d4 100644
--- a/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
+++ b/TestON/tests/CHOTestMonkey/CHOTestMonkey.py
@@ -178,8 +178,8 @@
         setIPv6CfgSleep = int( main.params[ 'TEST' ][ 'setIPv6CfgSleep' ] )
         if main.enableIPv6:
             time.sleep( setIPv6CfgSleep )
-            cfgResult1 = main.controllers[ 0 ].CLI.setCfg( "org.onosproject.proxyarp.ProxyArp",
-                                                           "ipv6NeighborDiscovery",
+            cfgResult1 = main.controllers[ 0 ].CLI.setCfg( "org.onosproject.incubator.net.neighbour.impl.NeighbourResolutionManager",
+                                                           "ndpEnabled",
                                                            "true" )
             time.sleep( setIPv6CfgSleep )
             cfgResult2 = main.controllers[ 0 ].CLI.setCfg( "org.onosproject.provider.host.impl.HostLocationProvider",
@@ -848,7 +848,7 @@
             with main.eventScheduler.idleCondition:
                 while not main.eventScheduler.isIdle():
                     main.eventScheduler.idleCondition.wait()
-            #time.sleep( sleepSec )
+            time.sleep( sleepSec )
         utilities.assert_equals( expect=main.TRUE,
                                  actual=main.caseResult,
                                  onpass="Randomly generate events test passed",
diff --git a/TestON/tests/CHOTestMonkey/dependencies/events/CheckEvent.py b/TestON/tests/CHOTestMonkey/dependencies/events/CheckEvent.py
index fa42e12..8c85ff8 100755
--- a/TestON/tests/CHOTestMonkey/dependencies/events/CheckEvent.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/events/CheckEvent.py
@@ -46,9 +46,27 @@
     def startCheckEvent( self, args=None ):
         import json
         checkResult = EventStates().PASS
+        if main.enableIPv6:
+            coreFlowNum = int( main.params[ 'EVENT' ][ 'FlowCheck' ][ 'coreFlowNum6' ] )
+        else:
+            coreFlowNum = int( main.params[ 'EVENT' ][ 'FlowCheck' ][ 'coreFlowNum' ] )
         for controller in main.controllers:
             if controller.isUp():
                 with controller.CLILock:
+                    # Check core flow number
+                    for device in main.devices:
+                        if device.isRemoved():
+                            continue
+                        coreFlowNumOnos = controller.CLI.flowAddedCount( device.dpid, core=True )
+                        if coreFlowNumOnos == None:
+                            main.log.warn( "Flow Check - error when trying to get flow number of %s on ONOS%s" % ( device.dpid, controller.index ) )
+                            checkResult = EventStates().FAIL
+                        else:
+                            coreFlowNumOnos = int( coreFlowNumOnos )
+                            if coreFlowNumOnos != coreFlowNum:
+                                main.log.warn( "Flow Check - core flow number of %s on ONOS%s is %s" % ( device.dpid, controller.index, coreFlowNumOnos ) )
+                                checkResult = EventStates().FAIL
+                    # Get flows for comparison
                     flows = controller.CLI.flows()
                     try:
                         flows = json.loads( flows )
@@ -160,7 +178,7 @@
         topics = []
         # TODO: Other topics?
         for i in range( 14 ):
-            topics.append( "intent-partition-" + str( i ) )
+            topics.append( "work-partition-" + str( i ) )
         dpidToAvailability = {}
         dpidToMaster = {}
         for device in main.devices:
diff --git a/TestON/tests/FUNC/FUNCipv6Intent/FUNCipv6Intent.py b/TestON/tests/FUNC/FUNCipv6Intent/FUNCipv6Intent.py
index 72fa1df..2f70420 100755
--- a/TestON/tests/FUNC/FUNCipv6Intent/FUNCipv6Intent.py
+++ b/TestON/tests/FUNC/FUNCipv6Intent/FUNCipv6Intent.py
@@ -6,7 +6,6 @@
         self.default = ''
 
     def CASE1( self, main ):
-        import time
         import imp
         import re
 
@@ -127,7 +126,7 @@
         - Install ONOS cluster
         - Connect to cli
         """
-
+        import time
         # main.scale[ 0 ] determines the current number of ONOS controller
         main.numCtrls = int( main.scale[ 0 ] )
 
@@ -250,7 +249,7 @@
             main.exit()
 
         main.step( "setup the ipv6NeighbourDiscovery" )
-        cfgResult1 = main.CLIs[0].setCfg( "org.onosproject.proxyarp.ProxyArp", "ipv6NeighborDiscovery", "true" )
+        cfgResult1 = main.CLIs[0].setCfg( "org.onosproject.incubator.net.neighbour.impl.NeighbourResolutionManager", "ndpEnabled", "true" )
         cfgResult2 = main.CLIs[0].setCfg( "org.onosproject.provider.host.impl.HostLocationProvider", "ipv6NeighborDiscovery", "true" )
         cfgResult = cfgResult1 and cfgResult2
         utilities.assert_equals( expect=main.TRUE, actual=cfgResult,
@@ -338,7 +337,6 @@
         """
         main.case( "Discover all hosts" )
 
-        stepResult = main.TRUE
         main.step( "Discover all hosts using pingall " )
         stepResult = main.intentFunction.getHostsData( main )
         utilities.assert_equals( expect=main.TRUE,
diff --git a/TestON/tests/FUNC/FUNCipv6Intent/dependencies/FUNCIpv6IntentFunction.py b/TestON/tests/FUNC/FUNCipv6Intent/dependencies/FUNCIpv6IntentFunction.py
index 0d71604..edca254 100755
--- a/TestON/tests/FUNC/FUNCipv6Intent/dependencies/FUNCIpv6IntentFunction.py
+++ b/TestON/tests/FUNC/FUNCipv6Intent/dependencies/FUNCIpv6IntentFunction.py
@@ -1795,7 +1795,7 @@
     main.log.info( "Activating reactive forwarding app " )
     activateResult = main.CLIs[ 0 ].activateApp( "org.onosproject.fwd" )
     main.CLIs[ 0 ].setCfg( "org.onosproject.provider.host.impl.HostLocationProvider", "ipv6NeighborDiscovery", "true")
-    main.CLIs[ 0 ].setCfg( "org.onosproject.proxyarp.ProxyArp", "ipv6NeighborDiscovery", "true")
+    main.CLIs[ 0 ].setCfg( "org.onosproject.incubator.net.neighbour.impl.NeighbourResolutionManager", "ndpEnabled", "true" )
     main.CLIs[ 0 ].setCfg( "org.onosproject.fwd.ReactiveForwarding", "ipv6Forwarding", "true")
     main.CLIs[ 0 ].setCfg( "org.onosproject.fwd.ReactiveForwarding", "matchIpv6Address", "true")
     time.sleep( main.fwdSleep )
diff --git a/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py b/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
index 8b5add6..914c3ce 100644
--- a/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
+++ b/TestON/tests/HA/HAclusterRestart/HAclusterRestart.py
@@ -719,7 +719,7 @@
                 # check for all intent partitions
                 topics = []
                 for i in range( 14 ):
-                    topics.append( "intent-partition-" + str( i ) )
+                    topics.append( "work-partition-" + str( i ) )
                 main.log.debug( topics )
                 ONOStopics = [ j['topic'] for j in parsedLeaders ]
                 for topic in topics:
@@ -875,7 +875,7 @@
                     # check for election
                     topics = []
                     for i in range( 14 ):
-                        topics.append( "intent-partition-" + str( i ) )
+                        topics.append( "work-partition-" + str( i ) )
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
@@ -1025,7 +1025,7 @@
                 # TODO: Look at Devices as topics now that it uses this system
                 topics = []
                 for i in range( 14 ):
-                    topics.append( "intent-partition-" + str( i ) )
+                    topics.append( "work-partition-" + str( i ) )
                 # FIXME: this should only be after we start the app
                 # FIXME: topics.append( "org.onosproject.election" )
                 # Print leaders output
@@ -1124,7 +1124,7 @@
                     # check for election
                     topics = []
                     for i in range( 14 ):
-                        topics.append( "intent-partition-" + str( i ) )
+                        topics.append( "work-partition-" + str( i ) )
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
diff --git a/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py b/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
index a85d949..7fee993 100644
--- a/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
+++ b/TestON/tests/HA/HAfullNetPartition/HAfullNetPartition.py
@@ -182,7 +182,7 @@
         #       index = The number of the graph under plot name
         job = "HAfullNetPartition"
         plotName = "Plot-HA"
-        index = "1"
+        index = "2"
         graphs = '<ac:structured-macro ac:name="html">\n'
         graphs += '<ac:plain-text-body><![CDATA[\n'
         graphs += '<iframe src="https://onos-jenkins.onlab.us/job/' + job +\
@@ -732,7 +732,7 @@
                 # check for all intent partitions
                 topics = []
                 for i in range( 14 ):
-                    topics.append( "intent-partition-" + str( i ) )
+                    topics.append( "work-partition-" + str( i ) )
                 main.log.debug( topics )
                 ONOStopics = [ j['topic'] for j in parsedLeaders ]
                 for topic in topics:
@@ -877,7 +877,7 @@
                     # check for election
                     topics = []
                     for i in range( 14 ):
-                        topics.append( "intent-partition-" + str( i ) )
+                        topics.append( "work-partition-" + str( i ) )
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
@@ -1027,7 +1027,7 @@
                 # TODO: Look at Devices as topics now that it uses this system
                 topics = []
                 for i in range( 14 ):
-                    topics.append( "intent-partition-" + str( i ) )
+                    topics.append( "work-partition-" + str( i ) )
                 # FIXME: this should only be after we start the app
                 # FIXME: topics.append( "org.onosproject.election" )
                 # Print leaders output
@@ -1126,7 +1126,7 @@
                     # check for election
                     topics = []
                     for i in range( 14 ):
-                        topics.append( "intent-partition-" + str( i ) )
+                        topics.append( "work-partition-" + str( i ) )
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
diff --git a/TestON/tests/HA/HAkillNodes/HAkillNodes.py b/TestON/tests/HA/HAkillNodes/HAkillNodes.py
index 147f183..ead3713 100644
--- a/TestON/tests/HA/HAkillNodes/HAkillNodes.py
+++ b/TestON/tests/HA/HAkillNodes/HAkillNodes.py
@@ -753,7 +753,7 @@
                 # check for all intent partitions
                 topics = []
                 for i in range( 14 ):
-                    topics.append( "intent-partition-" + str( i ) )
+                    topics.append( "work-partition-" + str( i ) )
                 main.log.debug( topics )
                 ONOStopics = [ j['topic'] for j in parsedLeaders ]
                 for topic in topics:
@@ -898,7 +898,7 @@
                     # check for election
                     topics = []
                     for i in range( 14 ):
-                        topics.append( "intent-partition-" + str( i ) )
+                        topics.append( "work-partition-" + str( i ) )
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
@@ -1048,7 +1048,7 @@
                 # TODO: Look at Devices as topics now that it uses this system
                 topics = []
                 for i in range( 14 ):
-                    topics.append( "intent-partition-" + str( i ) )
+                    topics.append( "work-partition-" + str( i ) )
                 # FIXME: this should only be after we start the app
                 # FIXME: topics.append( "org.onosproject.election" )
                 # Print leaders output
@@ -1147,7 +1147,7 @@
                     # check for election
                     topics = []
                     for i in range( 14 ):
-                        topics.append( "intent-partition-" + str( i ) )
+                        topics.append( "work-partition-" + str( i ) )
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
diff --git a/TestON/tests/HA/HAsanity/HAsanity.py b/TestON/tests/HA/HAsanity/HAsanity.py
index fd850fc..f23935f 100644
--- a/TestON/tests/HA/HAsanity/HAsanity.py
+++ b/TestON/tests/HA/HAsanity/HAsanity.py
@@ -721,7 +721,7 @@
                 # check for all intent partitions
                 topics = []
                 for i in range( 14 ):
-                    topics.append( "intent-partition-" + str( i ) )
+                    topics.append( "work-partition-" + str( i ) )
                 main.log.debug( topics )
                 ONOStopics = [ j['topic'] for j in parsedLeaders ]
                 for topic in topics:
@@ -866,7 +866,7 @@
                     # check for election
                     topics = []
                     for i in range( 14 ):
-                        topics.append( "intent-partition-" + str( i ) )
+                        topics.append( "work-partition-" + str( i ) )
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
@@ -1016,7 +1016,7 @@
                 # TODO: Look at Devices as topics now that it uses this system
                 topics = []
                 for i in range( 14 ):
-                    topics.append( "intent-partition-" + str( i ) )
+                    topics.append( "work-partition-" + str( i ) )
                 # FIXME: this should only be after we start the app
                 # FIXME: topics.append( "org.onosproject.election" )
                 # Print leaders output
@@ -1115,7 +1115,7 @@
                     # check for election
                     topics = []
                     for i in range( 14 ):
-                        topics.append( "intent-partition-" + str( i ) )
+                        topics.append( "work-partition-" + str( i ) )
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
diff --git a/TestON/tests/HA/HAscaling/HAscaling.py b/TestON/tests/HA/HAscaling/HAscaling.py
index 4fd29f3..f3ccacf 100644
--- a/TestON/tests/HA/HAscaling/HAscaling.py
+++ b/TestON/tests/HA/HAscaling/HAscaling.py
@@ -202,7 +202,7 @@
         #       index = The number of the graph under plot name
         job = "HAscaling"
         plotName = "Plot-HA"
-        index = "0"
+        index = "1"
         graphs = '<ac:structured-macro ac:name="html">\n'
         graphs += '<ac:plain-text-body><![CDATA[\n'
         graphs += '<iframe src="https://onos-jenkins.onlab.us/job/' + job +\
@@ -770,7 +770,7 @@
                 # check for all intent partitions
                 topics = []
                 for i in range( 14 ):
-                    topics.append( "intent-partition-" + str( i ) )
+                    topics.append( "work-partition-" + str( i ) )
                 main.log.debug( topics )
                 ONOStopics = [ j['topic'] for j in parsedLeaders ]
                 for topic in topics:
@@ -926,7 +926,7 @@
                     # check for election
                     topics = []
                     for i in range( 14 ):
-                        topics.append( "intent-partition-" + str( i ) )
+                        topics.append( "work-partition-" + str( i ) )
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
@@ -1076,7 +1076,7 @@
                 # TODO: Look at Devices as topics now that it uses this system
                 topics = []
                 for i in range( 14 ):
-                    topics.append( "intent-partition-" + str( i ) )
+                    topics.append( "work-partition-" + str( i ) )
                 # FIXME: this should only be after we start the app
                 # FIXME: topics.append( "org.onosproject.election" )
                 # Print leaders output
@@ -1175,7 +1175,7 @@
                     # check for election
                     topics = []
                     for i in range( 14 ):
-                        topics.append( "intent-partition-" + str( i ) )
+                        topics.append( "work-partition-" + str( i ) )
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
diff --git a/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py b/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py
index be59032..f158408 100644
--- a/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py
+++ b/TestON/tests/HA/HAsingleInstanceRestart/HAsingleInstanceRestart.py
@@ -680,7 +680,7 @@
                 # check for all intent partitions
                 topics = []
                 for i in range( 14 ):
-                    topics.append( "intent-partition-" + str( i ) )
+                    topics.append( "work-partition-" + str( i ) )
                 main.log.debug( topics )
                 ONOStopics = [ j['topic'] for j in parsedLeaders ]
                 for topic in topics:
@@ -825,7 +825,7 @@
                     # check for election
                     topics = []
                     for i in range( 14 ):
-                        topics.append( "intent-partition-" + str( i ) )
+                        topics.append( "work-partition-" + str( i ) )
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
@@ -967,7 +967,7 @@
                 # TODO: Look at Devices as topics now that it uses this system
                 topics = []
                 for i in range( 14 ):
-                    topics.append( "intent-partition-" + str( i ) )
+                    topics.append( "work-partition-" + str( i ) )
                 # FIXME: this should only be after we start the app
                 # FIXME: topics.append( "org.onosproject.election" )
                 # Print leaders output
@@ -1066,7 +1066,7 @@
                     # check for election
                     topics = []
                     for i in range( 14 ):
-                        topics.append( "intent-partition-" + str( i ) )
+                        topics.append( "work-partition-" + str( i ) )
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
diff --git a/TestON/tests/HA/HAstopNodes/HAstopNodes.py b/TestON/tests/HA/HAstopNodes/HAstopNodes.py
index a3b818f..388200a 100644
--- a/TestON/tests/HA/HAstopNodes/HAstopNodes.py
+++ b/TestON/tests/HA/HAstopNodes/HAstopNodes.py
@@ -732,7 +732,7 @@
                 # check for all intent partitions
                 topics = []
                 for i in range( 14 ):
-                    topics.append( "intent-partition-" + str( i ) )
+                    topics.append( "work-partition-" + str( i ) )
                 main.log.debug( topics )
                 ONOStopics = [ j['topic'] for j in parsedLeaders ]
                 for topic in topics:
@@ -877,7 +877,7 @@
                     # check for election
                     topics = []
                     for i in range( 14 ):
-                        topics.append( "intent-partition-" + str( i ) )
+                        topics.append( "work-partition-" + str( i ) )
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
@@ -1027,7 +1027,7 @@
                 # TODO: Look at Devices as topics now that it uses this system
                 topics = []
                 for i in range( 14 ):
-                    topics.append( "intent-partition-" + str( i ) )
+                    topics.append( "work-partition-" + str( i ) )
                 # FIXME: this should only be after we start the app
                 # FIXME: topics.append( "org.onosproject.election" )
                 # Print leaders output
@@ -1126,7 +1126,7 @@
                     # check for election
                     topics = []
                     for i in range( 14 ):
-                        topics.append( "intent-partition-" + str( i ) )
+                        topics.append( "work-partition-" + str( i ) )
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
diff --git a/TestON/tests/HA/HAswapNodes/HAswapNodes.py b/TestON/tests/HA/HAswapNodes/HAswapNodes.py
index 5c8d694..24daf1d 100644
--- a/TestON/tests/HA/HAswapNodes/HAswapNodes.py
+++ b/TestON/tests/HA/HAswapNodes/HAswapNodes.py
@@ -196,7 +196,7 @@
         #       index = The number of the graph under plot name
         job = "HAswapNodes"
         plotName = "Plot-HA"
-        index = "0"
+        index = "2"
         graphs = '<ac:structured-macro ac:name="html">\n'
         graphs += '<ac:plain-text-body><![CDATA[\n'
         graphs += '<iframe src="https://onos-jenkins.onlab.us/job/' + job +\
@@ -764,7 +764,7 @@
                 # check for all intent partitions
                 topics = []
                 for i in range( 14 ):
-                    topics.append( "intent-partition-" + str( i ) )
+                    topics.append( "work-partition-" + str( i ) )
                 main.log.debug( topics )
                 ONOStopics = [ j['topic'] for j in parsedLeaders ]
                 for topic in topics:
@@ -920,7 +920,7 @@
                     # check for election
                     topics = []
                     for i in range( 14 ):
-                        topics.append( "intent-partition-" + str( i ) )
+                        topics.append( "work-partition-" + str( i ) )
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
@@ -1070,7 +1070,7 @@
                 # TODO: Look at Devices as topics now that it uses this system
                 topics = []
                 for i in range( 14 ):
-                    topics.append( "intent-partition-" + str( i ) )
+                    topics.append( "work-partition-" + str( i ) )
                 # FIXME: this should only be after we start the app
                 # FIXME: topics.append( "org.onosproject.election" )
                 # Print leaders output
@@ -1169,7 +1169,7 @@
                     # check for election
                     topics = []
                     for i in range( 14 ):
-                        topics.append( "intent-partition-" + str( i ) )
+                        topics.append( "work-partition-" + str( i ) )
                     # FIXME: this should only be after we start the app
                     topics.append( "org.onosproject.election" )
                     main.log.debug( topics )
diff --git a/TestON/tests/USECASE/SegmentRouting/SRLinkFailure/SRLinkFailure.py b/TestON/tests/USECASE/SegmentRouting/SRLinkFailure/SRLinkFailure.py
index b388a64..0bef93e 100755
--- a/TestON/tests/USECASE/SegmentRouting/SRLinkFailure/SRLinkFailure.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRLinkFailure/SRLinkFailure.py
@@ -35,7 +35,7 @@
         run.killLink( main, 'spine101', 'leaf2', switches='4', links='6' )
         run.pingAll( main, "CASE1_Failure" )
         run.restoreLink( main, 'spine101', 'leaf2', 'of:0000000000000101',
-                         'of:0000000000000002', '2', '1', '4', '8' )
+                         'of:0000000000000002', '2', '3', '4', '8' )
         run.pingAll( main, "CASE1_Recovery" )
         # TODO Dynamic config of hosts in subnet
         # TODO Dynamic config of host not in subnet
@@ -69,7 +69,7 @@
         run.killLink( main, 'spine101', 'leaf2', switches='8', links='30' )
         run.pingAll( main, "CASE2_Failure" )
         run.restoreLink( main, 'spine101', 'leaf2', 'of:0000000000000101',
-                         'of:0000000000000002', '2', '1', '8', '32' )
+                         'of:0000000000000002', '2', '3', '8', '32' )
         run.pingAll( main, "CASE2_Recovery" )
         # TODO Dynamic config of hosts in subnet
         # TODO Dynamic config of host not in subnet
@@ -103,7 +103,7 @@
         run.killLink( main, 'spine101', 'leaf2', switches='4', links='6' )
         run.pingAll( main, "CASE3_Failure" )
         run.restoreLink( main, 'spine101', 'leaf2', 'of:0000000000000101',
-                         'of:0000000000000002', '2', '1', '4', '8' )
+                         'of:0000000000000002', '2', '3', '4', '8' )
         run.pingAll( main, "CASE3_Recovery" )
         # TODO Dynamic config of hosts in subnet
         # TODO Dynamic config of host not in subnet
@@ -137,7 +137,7 @@
         run.killLink( main, 'spine101', 'leaf2', switches='8', links='30' )
         run.pingAll( main, "CASE2_Failure" )
         run.restoreLink( main, 'spine101', 'leaf2', 'of:0000000000000101',
-                         'of:0000000000000002', '2', '1', '8', '32' )
+                         'of:0000000000000002', '2', '3', '8', '32' )
         run.pingAll( main, "CASE2_Recovery" )
         # TODO Dynamic config of hosts in subnet
         # TODO Dynamic config of host not in subnet
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
index dcaddbf..5da5834 100755
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/Testcaselib.py
@@ -7,6 +7,9 @@
 
 
 class Testcaselib:
+
+    useSSH=False
+
     @staticmethod
     def initTest( main ):
         """
@@ -98,7 +101,7 @@
                                        apps,
                                        tempOnosIp,
                                        onosUser,
-                                       useSSH=True )
+                                       useSSH=Testcaselib.useSSH )
         cellResult = main.ONOSbench.setCell( "temp" )
         verifyResult = main.ONOSbench.verifyCell( )
         stepResult = cellResult and verifyResult
@@ -125,15 +128,16 @@
                                  actual=stepResult,
                                  onpass="Successfully installed ONOS package",
                                  onfail="Failed to install ONOS package" )
-        for i in range( main.numCtrls ):
-            onosInstallResult = onosInstallResult and \
-                                main.ONOSbench.onosSecureSSH(
-                                        node=main.ONOSip[ i ] )
-        stepResult = onosInstallResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="Successfully secure SSH",
-                                 onfail="Failed to secure SSH" )
+        if Testcaselib.useSSH:
+            for i in range( main.numCtrls ):
+                onosInstallResult = onosInstallResult and \
+                                    main.ONOSbench.onosSecureSSH(
+                                            node=main.ONOSip[ i ] )
+            stepResult = onosInstallResult
+            utilities.assert_equals( expect=main.TRUE,
+                                     actual=stepResult,
+                                     onpass="Successfully secure SSH",
+                                     onfail="Failed to secure SSH" )
         main.step( "Starting ONOS service" )
         stopResult, startResult, onosIsUp = main.TRUE, main.TRUE, main.TRUE,
         for i in range( main.numCtrls ):
@@ -240,12 +244,14 @@
                 onpass="Flow status is correct!",
                 onfail="Flow status is wrong!" )
         if dumpflows:
-            main.ONOSbench.dumpFlows( main.ONOSip[ main.active ],
-                                      main.logdir,
-                                      "flowsBefore" + main.cfgName )
-            main.ONOSbench.dumpGroups( main.ONOSip[ main.active ],
-                                       main.logdir,
-                                       "groupsBefore" + main.cfgName )
+            main.ONOSbench.dumpONOSCmd( main.ONOSip[ main.active ],
+                                        "flows",
+                                        main.logdir,
+                                        "flowsBefore" + main.cfgName )
+            main.ONOSbench.dumpONOSCmd( main.ONOSip[ main.active ],
+                                        "groups",
+                                        main.logdir,
+                                        "groupsBefore" + main.cfgName )
 
     @staticmethod
     def pingAll( main, tag="", dumpflows=True ):
@@ -261,10 +267,14 @@
                                      onpass="IP connectivity successfully tested",
                                      onfail="IP connectivity failed" )
         if dumpflows:
-            main.ONOSbench.dumpFlows( main.ONOSip[ main.active ],
-                                      main.logdir, "flowsOn" + tag )
-            main.ONOSbench.dumpGroups( main.ONOSip[ main.active ],
-                                       main.logdir, "groupsOn" + tag )
+            main.ONOSbench.dumpONOSCmd( main.ONOSip[ main.active ],
+                                        "flows",
+                                        main.logdir,
+                                        "flowsOn" + tag )
+            main.ONOSbench.dumpONOSCmd( main.ONOSip[ main.active ],
+                                        "groups",
+                                        main.logdir,
+                                        "groupsOn" + tag )
 
     @staticmethod
     def killLink( main, end1, end2, switches, links ):
@@ -276,6 +286,7 @@
         main.linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] )
         main.step( "Kill link between %s and %s" % (end1, end2) )
         LinkDown = main.Mininet1.link( END1=end1, END2=end2, OPTION="down" )
+        LinkDown = main.Mininet1.link( END2=end1, END1=end2, OPTION="down" )
         main.log.info(
                 "Waiting %s seconds for link down to be discovered" % main.linkSleep )
         time.sleep( main.linkSleep )
@@ -311,8 +322,12 @@
             main.log.info(
                     "Waiting %s seconds for link up to be discovered" % main.linkSleep )
             time.sleep( main.linkSleep )
-            main.CLIs[ main.active ].portstate( dpid=dpid1, port=port1 )
-            main.CLIs[ main.active ].portstate( dpid=dpid2, port=port2 )
+
+            for i in range(0, main.numCtrls):
+                onosIsUp = main.ONOSbench.isup( main.ONOSip[ i ] )
+                if onosIsUp == main.TRUE:
+                    main.CLIs[ i ].portstate( dpid=dpid1, port=port1 )
+                    main.CLIs[ i ].portstate( dpid=dpid2, port=port2 )
             time.sleep( main.linkSleep )
 
             result = main.CLIs[ main.active ].checkStatus( numoswitch=switches,