Merge "modify topo user/password to match production cluster"
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 0822879..6443467 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -151,7 +151,10 @@
                         # ONOS didn't fully load, and logout command isn't working
                         # or the command timed out
                         self.handle.send( "\x04" )  # send ctrl-d
-                        self.handle.expect( "\$" )
+                        try:
+                            self.handle.expect( "\$" )
+                        except pexpect.TIMEOUT:
+                            main.log.error( "ONOS did not respond to 'logout' or CTRL-d" )
                         return main.TRUE
                     else: # some other output
                         main.log.warn( "Unknown repsonse to logout command: '{}'",
@@ -396,25 +399,6 @@
             if level:
                 lvlStr = "--level=" + level
 
-            self.handle.sendline( "" )
-            i = self.handle.expect( [ "onos>", "\$", pexpect.TIMEOUT ] )
-            if i == 1:
-                main.log.error( self.name + ": onos cli session closed. ")
-                if self.onosIp:
-                    main.log.warn( "Trying to reconnect " + self.onosIp )
-                    reconnectResult = self.startOnosCli( self.onosIp )
-                    if reconnectResult:
-                        main.log.info( self.name + ": onos cli session reconnected." )
-                    else:
-                        main.log.error( self.name + ": reconnection failed." )
-                        main.cleanup()
-                        main.exit()
-                else:
-                    main.cleanup()
-                    main.exit()
-            if i == 2:
-                self.handle.sendline( "" )
-                self.handle.expect( "onos>" )
             self.handle.sendline( "log:log " + lvlStr + " " + cmdStr )
             self.handle.expect( "log:log" )
             self.handle.expect( "onos>" )
@@ -462,6 +446,27 @@
 
         """
         try:
+            # Try to reconnect if disconnected from cli
+            self.handle.sendline( "" )
+            i = self.handle.expect( [ "onos>", "\$", pexpect.TIMEOUT ] )
+            if i == 1:
+                main.log.error( self.name + ": onos cli session closed. ")
+                if self.onosIp:
+                    main.log.warn( "Trying to reconnect " + self.onosIp )
+                    reconnectResult = self.startOnosCli( self.onosIp )
+                    if reconnectResult:
+                        main.log.info( self.name + ": onos cli session reconnected." )
+                    else:
+                        main.log.error( self.name + ": reconnection failed." )
+                        main.cleanup()
+                        main.exit()
+                else:
+                    main.cleanup()
+                    main.exit()
+            if i == 2:
+                self.handle.sendline( "" )
+                self.handle.expect( "onos>" )
+
             if debug:
                 # NOTE: This adds and average of .4 seconds per call
                 logStr = "\"Sending CLI command: '" + cmdStr + "'\""
@@ -513,6 +518,7 @@
             return None
         except IndexError:
             main.log.exception( self.name + ": Object not as expected" )
+            main.log.debug( "response: {}".format( repr( response ) ) )
             return None
         except TypeError:
             main.log.exception( self.name + ": Object not as expected" )
@@ -555,6 +561,7 @@
             cmdStr = "add-node " + str( nodeId ) + " " +\
                 str( ONOSIp ) + " " + str( tcpPort )
             handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             if re.search( "Error", handle ):
                 main.log.error( "Error in adding node" )
@@ -590,6 +597,7 @@
 
             cmdStr = "remove-node " + str( nodeId )
             handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             if re.search( "Error", handle ):
                 main.log.error( "Error in removing node" )
@@ -625,6 +633,7 @@
             if jsonFormat:
                 cmdStr += " -j"
             output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             return output
         except AssertionError:
@@ -776,6 +785,7 @@
             if jsonFormat:
                 cmdStr += " -j"
             output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             return output
         except AssertionError:
@@ -1138,13 +1148,14 @@
             main.cleanup()
             main.exit()
 
-    def addHostIntent( self, hostIdOne, hostIdTwo, vlanId="" ):
+    def addHostIntent( self, hostIdOne, hostIdTwo, vlanId="", setVlan="" ):
         """
         Required:
             * hostIdOne: ONOS host id for host1
             * hostIdTwo: ONOS host id for host2
         Optional:
             * vlanId: specify a VLAN id for the intent
+            * setVlan: specify a VLAN id treatment
         Description:
             Adds a host-to-host intent ( bidirectional ) by
             specifying the two hosts.
@@ -1155,6 +1166,8 @@
             cmdStr = "add-host-intent "
             if vlanId:
                 cmdStr += "-v " + str( vlanId ) + " "
+            if setVlan:
+                cmdStr += "--setVlan " + str( vlanId ) + " "
             cmdStr += str( hostIdOne ) + " " + str( hostIdTwo )
             handle = self.sendline( cmdStr )
             assert "Command not found:" not in handle, handle
@@ -1252,7 +1265,8 @@
             ipDst="",
             tcpSrc="",
             tcpDst="",
-            vlanId="" ):
+            vlanId="",
+            setVlan="" ):
         """
         Required:
             * ingressDevice: device id of ingress device
@@ -1270,6 +1284,7 @@
             * tcpSrc: specify tcp source port
             * tcpDst: specify tcp destination port
             * vlanId: specify vlan ID
+            * setVlan: specify a VLAN id treatment
         Description:
             Adds a point-to-point intent ( uni-directional ) by
             specifying device id's and optional fields
@@ -1281,38 +1296,32 @@
               intent via cli
         """
         try:
-            # If there are no optional arguments
-            if not ethType and not ethSrc and not ethDst\
-                    and not bandwidth and not lambdaAlloc \
-                    and not ipProto and not ipSrc and not ipDst \
-                    and not tcpSrc and not tcpDst:
-                cmd = "add-point-intent"
+            cmd = "add-point-intent"
 
-            else:
-                cmd = "add-point-intent"
-
-                if ethType:
-                    cmd += " --ethType " + str( ethType )
-                if ethSrc:
-                    cmd += " --ethSrc " + str( ethSrc )
-                if ethDst:
-                    cmd += " --ethDst " + str( ethDst )
-                if bandwidth:
-                    cmd += " --bandwidth " + str( bandwidth )
-                if lambdaAlloc:
-                    cmd += " --lambda "
-                if ipProto:
-                    cmd += " --ipProto " + str( ipProto )
-                if ipSrc:
-                    cmd += " --ipSrc " + str( ipSrc )
-                if ipDst:
-                    cmd += " --ipDst " + str( ipDst )
-                if tcpSrc:
-                    cmd += " --tcpSrc " + str( tcpSrc )
-                if tcpDst:
-                    cmd += " --tcpDst " + str( tcpDst )
-                if vlanId:
-                    cmd += " -v " + str( vlanId )
+            if ethType:
+                cmd += " --ethType " + str( ethType )
+            if ethSrc:
+                cmd += " --ethSrc " + str( ethSrc )
+            if ethDst:
+                cmd += " --ethDst " + str( ethDst )
+            if bandwidth:
+                cmd += " --bandwidth " + str( bandwidth )
+            if lambdaAlloc:
+                cmd += " --lambda "
+            if ipProto:
+                cmd += " --ipProto " + str( ipProto )
+            if ipSrc:
+                cmd += " --ipSrc " + str( ipSrc )
+            if ipDst:
+                cmd += " --ipDst " + str( ipDst )
+            if tcpSrc:
+                cmd += " --tcpSrc " + str( tcpSrc )
+            if tcpDst:
+                cmd += " --tcpDst " + str( tcpDst )
+            if vlanId:
+                cmd += " -v " + str( vlanId )
+            if setVlan:
+                cmd += " --setVlan " + str( setVlan )
 
             # Check whether the user appended the port
             # or provided it as an input
@@ -1392,7 +1401,8 @@
             tcpDst="",
             setEthSrc="",
             setEthDst="",
-            vlanId="" ):
+            vlanId="",
+            setVlan="" ):
         """
         Note:
             This function assumes the format of all ingress devices
@@ -1418,6 +1428,7 @@
             * setEthSrc: action to Rewrite Source MAC Address
             * setEthDst: action to Rewrite Destination MAC Address
             * vlanId: specify vlan Id
+            * setVlan: specify VLAN Id treatment
         Description:
             Adds a multipoint-to-singlepoint intent ( uni-directional ) by
             specifying device id's and optional fields
@@ -1429,43 +1440,36 @@
               intent via cli
         """
         try:
-            # If there are no optional arguments
-            if not ethType and not ethSrc and not ethDst\
-                    and not bandwidth and not lambdaAlloc\
-                    and not ipProto and not ipSrc and not ipDst\
-                    and not tcpSrc and not tcpDst and not setEthSrc\
-                    and not setEthDst:
-                cmd = "add-multi-to-single-intent"
+            cmd = "add-multi-to-single-intent"
 
-            else:
-                cmd = "add-multi-to-single-intent"
-
-                if ethType:
-                    cmd += " --ethType " + str( ethType )
-                if ethSrc:
-                    cmd += " --ethSrc " + str( ethSrc )
-                if ethDst:
-                    cmd += " --ethDst " + str( ethDst )
-                if bandwidth:
-                    cmd += " --bandwidth " + str( bandwidth )
-                if lambdaAlloc:
-                    cmd += " --lambda "
-                if ipProto:
-                    cmd += " --ipProto " + str( ipProto )
-                if ipSrc:
-                    cmd += " --ipSrc " + str( ipSrc )
-                if ipDst:
-                    cmd += " --ipDst " + str( ipDst )
-                if tcpSrc:
-                    cmd += " --tcpSrc " + str( tcpSrc )
-                if tcpDst:
-                    cmd += " --tcpDst " + str( tcpDst )
-                if setEthSrc:
-                    cmd += " --setEthSrc " + str( setEthSrc )
-                if setEthDst:
-                    cmd += " --setEthDst " + str( setEthDst )
-                if vlanId:
-                    cmd += " -v " + str( vlanId )
+            if ethType:
+                cmd += " --ethType " + str( ethType )
+            if ethSrc:
+                cmd += " --ethSrc " + str( ethSrc )
+            if ethDst:
+                cmd += " --ethDst " + str( ethDst )
+            if bandwidth:
+                cmd += " --bandwidth " + str( bandwidth )
+            if lambdaAlloc:
+                cmd += " --lambda "
+            if ipProto:
+                cmd += " --ipProto " + str( ipProto )
+            if ipSrc:
+                cmd += " --ipSrc " + str( ipSrc )
+            if ipDst:
+                cmd += " --ipDst " + str( ipDst )
+            if tcpSrc:
+                cmd += " --tcpSrc " + str( tcpSrc )
+            if tcpDst:
+                cmd += " --tcpDst " + str( tcpDst )
+            if setEthSrc:
+                cmd += " --setEthSrc " + str( setEthSrc )
+            if setEthDst:
+                cmd += " --setEthDst " + str( setEthDst )
+            if vlanId:
+                cmd += " -v " + str( vlanId )
+            if setVlan:
+                cmd += " --setVlan " + str( setVlan )
 
             # Check whether the user appended the port
             # or provided it as an input
@@ -1549,7 +1553,8 @@
             tcpDst="",
             setEthSrc="",
             setEthDst="",
-            vlanId="" ):
+            vlanId="",
+            setVlan="" ):
         """
         Note:
             This function assumes the format of all egress devices
@@ -1575,6 +1580,7 @@
             * setEthSrc: action to Rewrite Source MAC Address
             * setEthDst: action to Rewrite Destination MAC Address
             * vlanId: specify vlan Id
+            * setVlan: specify VLAN ID treatment
         Description:
             Adds a singlepoint-to-multipoint intent ( uni-directional ) by
             specifying device id's and optional fields
@@ -1586,43 +1592,36 @@
               intent via cli
         """
         try:
-            # If there are no optional arguments
-            if not ethType and not ethSrc and not ethDst\
-                    and not bandwidth and not lambdaAlloc\
-                    and not ipProto and not ipSrc and not ipDst\
-                    and not tcpSrc and not tcpDst and not setEthSrc\
-                    and not setEthDst:
-                cmd = "add-single-to-multi-intent"
+            cmd = "add-single-to-multi-intent"
 
-            else:
-                cmd = "add-single-to-multi-intent"
-
-                if ethType:
-                    cmd += " --ethType " + str( ethType )
-                if ethSrc:
-                    cmd += " --ethSrc " + str( ethSrc )
-                if ethDst:
-                    cmd += " --ethDst " + str( ethDst )
-                if bandwidth:
-                    cmd += " --bandwidth " + str( bandwidth )
-                if lambdaAlloc:
-                    cmd += " --lambda "
-                if ipProto:
-                    cmd += " --ipProto " + str( ipProto )
-                if ipSrc:
-                    cmd += " --ipSrc " + str( ipSrc )
-                if ipDst:
-                    cmd += " --ipDst " + str( ipDst )
-                if tcpSrc:
-                    cmd += " --tcpSrc " + str( tcpSrc )
-                if tcpDst:
-                    cmd += " --tcpDst " + str( tcpDst )
-                if setEthSrc:
-                    cmd += " --setEthSrc " + str( setEthSrc )
-                if setEthDst:
-                    cmd += " --setEthDst " + str( setEthDst )
-                if vlanId:
-                    cmd += " -v " + str( vlanId )
+            if ethType:
+                cmd += " --ethType " + str( ethType )
+            if ethSrc:
+                cmd += " --ethSrc " + str( ethSrc )
+            if ethDst:
+                cmd += " --ethDst " + str( ethDst )
+            if bandwidth:
+                cmd += " --bandwidth " + str( bandwidth )
+            if lambdaAlloc:
+                cmd += " --lambda "
+            if ipProto:
+                cmd += " --ipProto " + str( ipProto )
+            if ipSrc:
+                cmd += " --ipSrc " + str( ipSrc )
+            if ipDst:
+                cmd += " --ipDst " + str( ipDst )
+            if tcpSrc:
+                cmd += " --tcpSrc " + str( tcpSrc )
+            if tcpDst:
+                cmd += " --tcpDst " + str( tcpDst )
+            if setEthSrc:
+                cmd += " --setEthSrc " + str( setEthSrc )
+            if setEthDst:
+                cmd += " --setEthDst " + str( setEthDst )
+            if vlanId:
+                cmd += " -v " + str( vlanId )
+            if setVlan:
+                cmd += " --setVlan " + str( setVlan )
 
             # Check whether the user appended the port
             # or provided it as an input
@@ -1737,43 +1736,34 @@
               intent via cli
         """
         try:
-            # If there are no optional arguments
-            if not ethType and not ethSrc and not ethDst\
-                    and not bandwidth and not lambdaAlloc \
-                    and not ipProto and not ipSrc and not ipDst \
-                    and not tcpSrc and not tcpDst and not ingressLabel \
-                    and not egressLabel:
-                cmd = "add-mpls-intent"
+            cmd = "add-mpls-intent"
 
-            else:
-                cmd = "add-mpls-intent"
-
-                if ethType:
-                    cmd += " --ethType " + str( ethType )
-                if ethSrc:
-                    cmd += " --ethSrc " + str( ethSrc )
-                if ethDst:
-                    cmd += " --ethDst " + str( ethDst )
-                if bandwidth:
-                    cmd += " --bandwidth " + str( bandwidth )
-                if lambdaAlloc:
-                    cmd += " --lambda "
-                if ipProto:
-                    cmd += " --ipProto " + str( ipProto )
-                if ipSrc:
-                    cmd += " --ipSrc " + str( ipSrc )
-                if ipDst:
-                    cmd += " --ipDst " + str( ipDst )
-                if tcpSrc:
-                    cmd += " --tcpSrc " + str( tcpSrc )
-                if tcpDst:
-                    cmd += " --tcpDst " + str( tcpDst )
-                if ingressLabel:
-                    cmd += " --ingressLabel " + str( ingressLabel )
-                if egressLabel:
-                    cmd += " --egressLabel " + str( egressLabel )
-                if priority:
-                    cmd += " --priority " + str( priority )
+            if ethType:
+                cmd += " --ethType " + str( ethType )
+            if ethSrc:
+                cmd += " --ethSrc " + str( ethSrc )
+            if ethDst:
+                cmd += " --ethDst " + str( ethDst )
+            if bandwidth:
+                cmd += " --bandwidth " + str( bandwidth )
+            if lambdaAlloc:
+                cmd += " --lambda "
+            if ipProto:
+                cmd += " --ipProto " + str( ipProto )
+            if ipSrc:
+                cmd += " --ipSrc " + str( ipSrc )
+            if ipDst:
+                cmd += " --ipDst " + str( ipDst )
+            if tcpSrc:
+                cmd += " --tcpSrc " + str( tcpSrc )
+            if tcpDst:
+                cmd += " --tcpDst " + str( tcpDst )
+            if ingressLabel:
+                cmd += " --ingressLabel " + str( ingressLabel )
+            if egressLabel:
+                cmd += " --egressLabel " + str( egressLabel )
+            if priority:
+                cmd += " --priority " + str( priority )
 
             # Check whether the user appended the port
             # or provided it as an input
@@ -2059,19 +2049,18 @@
 
     def getIntentState(self, intentsId, intentsJson=None):
         """
-            Check intent state.
-            Accepts a single intent ID (string type) or a list of intent IDs.
-            Returns the state(string type) of the id if a single intent ID is
-            accepted.
-            Returns a dictionary with intent IDs as the key and its
-            corresponding states as the values
-            Parameters:
-            intentId: intent ID (string type)
+        Description:
+            Gets intent state. Accepts a single intent ID (string type) or a
+            list of intent IDs.
+        Parameters:
+            intentsId: intent ID, both string type and list type are acceptable
             intentsJson: parsed json object from the onos:intents api
-            Returns:
-            state = An intent's state- INSTALL,WITHDRAWN etc.
-            stateDict = Dictionary of intent's state. intent ID as the keys and
-            state as the values.
+        Returns:
+            Returns the state (string type) of the ID if a single intent ID is
+            accepted.
+            Returns a list of dictionaries if a list of intent IDs is accepted,
+            and each dictionary maps 'id' to the Intent ID and 'state' to
+            corresponding intent state.
         """
         try:
             state = "State is Undefined"
@@ -2183,6 +2172,52 @@
             main.cleanup()
             main.exit()
 
+    def compareIntent( self, intentDict ):
+        """
+        Description:
+            Compare the intent ids and states provided in the argument with all intents in ONOS
+        Return:
+            Returns main.TRUE if the two sets of intents match exactly, otherwise main.FALSE
+        Arguments:
+            intentDict: a dictionary which maps intent ids to intent states
+        """
+        try:
+            intentsRaw = self.intents()
+            intentsJson = json.loads( intentsRaw )
+            intentDictONOS = {}
+            for intent in intentsJson:
+                intentDictONOS[ intent[ 'id' ] ] = intent[ 'state' ]
+            if len( intentDict ) != len( intentDictONOS ):
+                main.log.info( 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
+            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
+            if returnValue == main.TRUE:
+                main.log.info( self.name + ": all intent IDs and states match that in ONOS" )
+            return returnValue
+        except ( TypeError, ValueError ):
+            main.log.exception( "{}: Object not as expected: {!r}".format( self.name, intentsRaw ) )
+            return None
+        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( self.name + ": Uncaught exception!" )
+            main.cleanup()
+            main.exit()
+
     def checkIntentSummary( self, timeout=60 ):
         """
         Description:
@@ -2288,7 +2323,12 @@
             statesCount = [0, 0, 0, 0]
             for s in states:
                 rawFlows = self.flows( state=s, timeout = timeout )
-                checkedStates.append( json.loads( rawFlows ) )
+                if rawFlows:
+                    # if we didn't get flows or flows function return None, we should return
+                    # main.Flase
+                    checkedStates.append( json.loads( rawFlows ) )
+                else:
+                    return main.FALSE
             for i in range( len( states ) ):
                 for c in checkedStates[i]:
                     try:
@@ -2308,6 +2348,10 @@
         except ( TypeError, ValueError ):
             main.log.exception( "{}: Object not as expected: {!r}".format( self.name, rawFlows ) )
             return None
+        
+        except AssertionError:
+            main.log.exception( "" )
+            return None
         except pexpect.EOF:
             main.log.error( self.name + ": EOF exception found" )
             main.log.error( self.name + ":    " + self.handle.before )
@@ -2425,8 +2469,8 @@
 
             return int(totalFlows)
 
-        except TypeError:
-            main.log.exception( self.name + ": Object not as expected" )
+        except ( TypeError, ValueError ):
+            main.log.exception( "{}: Object not as expected: {!r}".format( self.name, rawFlows ) )
             return None
         except pexpect.EOF:
             main.log.error( self.name + ": EOF exception found" )
@@ -2455,8 +2499,8 @@
                 return  -1
             response = json.loads( response )
             return int( response.get("intents") )
-        except TypeError:
-            main.log.exception( self.name + ": Object not as expected" )
+        except ( TypeError, ValueError ):
+            main.log.exception( "{}: Object not as expected: {!r}".format( self.name, response ) )
             return None
         except pexpect.EOF:
             main.log.error( self.name + ": EOF exception found" )
@@ -2717,6 +2761,9 @@
             topology = json.loads(topologyOutput)
             main.log.debug( topology )
             return topology
+        except ( TypeError, ValueError ):
+            main.log.exception( "{}: Object not as expected: {!r}".format( self.name, topologyOutput ) )
+            return None
         except pexpect.EOF:
             main.log.error( self.name + ": EOF exception found" )
             main.log.error( self.name + ":    " + self.handle.before )
@@ -3022,12 +3069,12 @@
             dpid = str( dpid )
             cmdStr = "onos:ports -e " + dpid + " | wc -l"
             output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             if re.search( "No such device", output ):
                 main.log.error( "Error in getting ports" )
                 return ( output, "Error" )
-            else:
-                return output
+            return output
         except AssertionError:
             main.log.exception( "" )
             return None
@@ -3052,12 +3099,12 @@
             dpid = str( dpid )
             cmdStr = "onos:links " + dpid + " | grep ACTIVE | wc -l"
             output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             if re.search( "No such device", output ):
                 main.log.error( "Error in getting ports " )
                 return ( output, "Error " )
-            else:
-                return output
+            return output
         except AssertionError:
             main.log.exception( "" )
             return None
@@ -3081,12 +3128,12 @@
         try:
             cmdStr = "onos:intents | grep id="
             output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             if re.search( "Error", output ):
                 main.log.error( "Error in getting ports" )
                 return ( output, "Error" )
-            else:
-                return output
+            return output
         except AssertionError:
             main.log.exception( "" )
             return None
@@ -3139,6 +3186,7 @@
             if jsonFormat:
                 cmdStr += " -j"
             output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             return output
         except AssertionError:
@@ -3168,6 +3216,7 @@
             if jsonFormat:
                 cmdStr += " -j"
             output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             return output
         except AssertionError:
@@ -3196,6 +3245,7 @@
         try:
             cmdStr = "onos:leaders -j"
             rawOutput = self.sendline( cmdStr )
+            assert rawOutput is not None, "Error in sendline"
             assert "Command not found:" not in rawOutput, rawOutput
             output = json.loads( rawOutput )
             results = []
@@ -3231,6 +3281,7 @@
             if jsonFormat:
                 cmdStr += " -j"
             output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             return output
         except AssertionError:
@@ -3269,6 +3320,7 @@
             if jsonFormat:
                 cmdStr += " -j"
             output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             return output
         except AssertionError:
@@ -3302,6 +3354,7 @@
             if jsonFormat:
                 cmdStr += " -j"
             output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             assert "Error executing command" not in output, output
             return output
@@ -3608,6 +3661,7 @@
             if jsonFormat:
                 cmdStr += " -j"
             output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             assert "Error executing command" not in output, output
             return output
@@ -3745,6 +3799,7 @@
             elif short:
                 baseStr += " -s"
             output = self.sendline( baseStr + cmdStr + componentStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             assert "Error executing command" not in output, output
             return output
@@ -3786,6 +3841,7 @@
             if value is not None:
                 cmdStr += " " + str( value )
             output = self.sendline( baseStr + cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             assert "Error executing command" not in output, output
             if value and check:
@@ -3837,6 +3893,7 @@
         try:
             cmdStr = "set-test-add " + str( setName ) + " " + str( values )
             output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             try:
                 # TODO: Maybe make this less hardcoded
@@ -3852,6 +3909,7 @@
                                "seconds before retrying." )
                 time.sleep( retryTime )  # Due to change in mastership
                 output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Error executing command" not in output
             positiveMatch = "\[(.*)\] was added to the set " + str( setName )
             negativeMatch = "\[(.*)\] was already in set " + str( setName )
@@ -3906,6 +3964,7 @@
                 cmdStr += str( setName ) + " " + str( values )
             output = self.sendline( cmdStr )
             try:
+                assert output is not None, "Error in sendline"
                 # TODO: Maybe make this less hardcoded
                 # ConsistentMap Exceptions
                 assert "org.onosproject.store.service" not in output
@@ -3919,6 +3978,7 @@
                                "seconds before retrying." )
                 time.sleep( retryTime )  # Due to change in mastership
                 output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             assert "Error executing command" not in output, output
             main.log.info( self.name + ": " + output )
@@ -4005,6 +4065,7 @@
             cmdStr += setName + " " + values
             output = self.sendline( cmdStr )
             try:
+                assert output is not None, "Error in sendline"
                 # TODO: Maybe make this less hardcoded
                 # ConsistentMap Exceptions
                 assert "org.onosproject.store.service" not in output
@@ -4018,6 +4079,7 @@
                                "seconds before retrying." )
                 time.sleep( retryTime )  # Due to change in mastership
                 output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             assert "Error executing command" not in output, output
             main.log.info( self.name + ": " + output )
@@ -4098,6 +4160,7 @@
             cmdStr += setName
             output = self.sendline( cmdStr )
             try:
+                assert output is not None, "Error in sendline"
                 # TODO: Maybe make this less hardcoded
                 # ConsistentMap Exceptions
                 assert "org.onosproject.store.service" not in output
@@ -4111,6 +4174,7 @@
                                "seconds before retrying." )
                 time.sleep( retryTime )  # Due to change in mastership
                 output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             assert "Error executing command" not in output, output
             main.log.info( self.name + ": " + output )
@@ -4164,6 +4228,7 @@
             if jsonFormat:
                 cmdStr += " -j"
             output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             assert "Error executing command" not in output, output
             main.log.info( self.name + ": " + output )
@@ -4204,6 +4269,7 @@
                 cmdStr += " " + str( delta )
             output = self.sendline( cmdStr )
             try:
+                assert output is not None, "Error in sendline"
                 # TODO: Maybe make this less hardcoded
                 # ConsistentMap Exceptions
                 assert "org.onosproject.store.service" not in output
@@ -4217,6 +4283,7 @@
                                "seconds before retrying." )
                 time.sleep( retryTime )  # Due to change in mastership
                 output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             assert "Error executing command" not in output, output
             main.log.info( self.name + ": " + output )
@@ -4266,6 +4333,7 @@
                 cmdStr += " " + str( delta )
             output = self.sendline( cmdStr )
             try:
+                assert output is not None, "Error in sendline"
                 # TODO: Maybe make this less hardcoded
                 # ConsistentMap Exceptions
                 assert "org.onosproject.store.service" not in output
@@ -4279,6 +4347,7 @@
                                "seconds before retrying." )
                 time.sleep( retryTime )  # Due to change in mastership
                 output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             assert "Error executing command" not in output, output
             main.log.info( self.name + ": " + output )
@@ -4320,6 +4389,7 @@
             if jsonFormat:
                 cmdStr += " -j"
             handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             assert "Error:" not in handle, handle
             if not handle:
@@ -4359,6 +4429,7 @@
             cmdStr = "transactional-map-test-get "
             cmdStr += keyName
             output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             try:
                 # TODO: Maybe make this less hardcoded
@@ -4425,6 +4496,7 @@
             cmdStr = "transactional-map-test-put "
             cmdStr += numKeys + " " + value
             output = self.sendline( cmdStr )
+            assert output is not None, "Error in sendline"
             assert "Command not found:" not in output, output
             try:
                 # TODO: Maybe make this less hardcoded
@@ -4482,6 +4554,7 @@
             if jsonFormat:
                 cmdStr += " -j"
             handle = self.sendline( cmdStr )
+            assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             return handle
         except AssertionError:
@@ -4509,6 +4582,7 @@
             if jsonFormat:
                 cmd += "-j "
             response = self.sendline( cmd + uri )
+            assert response is not None, "Error in sendline"
             assert "Command not found:" not in response, response
             return response
         except AssertionError:
@@ -4571,6 +4645,7 @@
                 else:
                     cmd += " {}:{}:{}".format( proto, item, port )
             response = self.sendline( cmd )
+            assert response is not None, "Error in sendline"
             assert "Command not found:" not in response, response
             if "Error" in response:
                 main.log.error( response )
@@ -4611,6 +4686,7 @@
             for d in device:
                 time.sleep( 1 )
                 response = self.sendline( "device-remove {}".format( d ) )
+                assert response is not None, "Error in sendline"
                 assert "Command not found:" not in response, response
                 if "Error" in response:
                     main.log.warn( "Error for device: {}\nResponse: {}".format( d, response ) )
@@ -4651,6 +4727,7 @@
             for h in host:
                 time.sleep( 1 )
                 response = self.sendline( "host-remove {}".format( h ) )
+                assert response is not None, "Error in sendline"
                 assert "Command not found:" not in response, response
                 if "Error" in response:
                     main.log.warn( "Error for host: {}\nResponse: {}".format( h, response ) )
@@ -4686,6 +4763,7 @@
         try:
             cmd =  "null-link null:{} null:{} {}".format( begin, end, state )
             response = self.sendline( cmd, showResponse=True )
+            assert response is not None, "Error in sendline"
             assert "Command not found:" not in response, response
             if "Error" in response or "Failure" in response:
                 main.log.error( response )
diff --git a/TestON/tests/CHOTestMonkey/CHOTestMonkey.params b/TestON/tests/CHOTestMonkey/CHOTestMonkey.params
index 7d7457b..c3a7346 100644
--- a/TestON/tests/CHOTestMonkey/CHOTestMonkey.params
+++ b/TestON/tests/CHOTestMonkey/CHOTestMonkey.params
@@ -19,14 +19,14 @@
     # 100. Do something else
     # Sample sequence: 0,1,2,3,[10,30,21,31,10,32,21,33,50,10,30,21,31,10,32,21,33,51,40,60,10,30,21,31,10,32,21,33,50,10,30,21,31,10,32,21,33,51,41,60]*500,100
     <testcases>
-        0,1,2,3,100,[10,40,60,10,30,21,31,41,90,60]*500,100
+        0,1,2,3,10,[30,21,31,32,21,33,50,30,21,31,32,21,33,51]*500,100
     </testcases>
 
     <TEST>
         <topo>1</topo>
         <IPv6>on</IPv6>
         <numCtrl>3</numCtrl>
-        <pauseTest>off</pauseTest>
+        <pauseTest>on</pauseTest>
         <caseSleep>0</caseSleep>
         <setIPv6CfgSleep>5</setIPv6CfgSleep>
         <loadTopoSleep>5</loadTopoSleep>
@@ -84,6 +84,16 @@
             <maxRerunNum>5</maxRerunNum>
         </IntentCheck>
 
+        <FlowCheck>
+            <status>on</status>
+            <typeIndex>11</typeIndex>
+            <typeString>CHECK_FLOW</typeString>
+            <CLI>check-flow</CLI>
+            <CLIParamNum>0</CLIParamNum>
+            <rerunInterval>5</rerunInterval>
+            <maxRerunNum>5</maxRerunNum>
+        </FlowCheck>
+
         <TrafficCheck>
             <status>on</status>
             <typeIndex>12</typeIndex>
diff --git a/TestON/tests/CHOTestMonkey/dependencies/EventGenerator.py b/TestON/tests/CHOTestMonkey/dependencies/EventGenerator.py
index fb72d00..de32193 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/EventGenerator.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/EventGenerator.py
@@ -446,6 +446,7 @@
             sleepTime = int( main.params[ 'EVENT' ][ 'installAllHostIntents' ][ 'sleepBeforeCheck' ] )
             main.eventScheduler.scheduleEvent( EventType().TEST_SLEEP, EventScheduleMethod().RUN_BLOCK, [ sleepTime ] )
             main.eventScheduler.scheduleEvent( EventType().CHECK_INTENT, EventScheduleMethod().RUN_NON_BLOCK )
+            main.eventScheduler.scheduleEvent( EventType().CHECK_FLOW, EventScheduleMethod().RUN_NON_BLOCK )
             main.eventScheduler.scheduleEvent( EventType().CHECK_TRAFFIC, EventScheduleMethod().RUN_NON_BLOCK )
             if scheduleMethod == EventScheduleMethod().RUN_BLOCK:
                 main.eventScheduler.scheduleEvent( EventType().NULL, EventScheduleMethod().RUN_BLOCK )
@@ -482,6 +483,7 @@
             sleepTime = int( main.params[ 'EVENT' ][ 'removeAllHostIntents' ][ 'sleepBeforeCheck' ] )
             main.eventScheduler.scheduleEvent( EventType().TEST_SLEEP, EventScheduleMethod().RUN_BLOCK, [ sleepTime ] )
             main.eventScheduler.scheduleEvent( EventType().CHECK_INTENT, EventScheduleMethod().RUN_NON_BLOCK )
+            main.eventScheduler.scheduleEvent( EventType().CHECK_FLOW, EventScheduleMethod().RUN_NON_BLOCK )
             main.eventScheduler.scheduleEvent( EventType().CHECK_TRAFFIC, EventScheduleMethod().RUN_NON_BLOCK )
             if scheduleMethod == EventScheduleMethod().RUN_BLOCK:
                 main.eventScheduler.scheduleEvent( EventType().NULL, EventScheduleMethod().RUN_BLOCK )
@@ -518,6 +520,7 @@
             sleepTime = int( main.params[ 'EVENT' ][ 'installAllPointIntents' ][ 'sleepBeforeCheck' ] )
             main.eventScheduler.scheduleEvent( EventType().TEST_SLEEP, EventScheduleMethod().RUN_BLOCK, [ sleepTime ] )
             main.eventScheduler.scheduleEvent( EventType().CHECK_INTENT, EventScheduleMethod().RUN_NON_BLOCK )
+            main.eventScheduler.scheduleEvent( EventType().CHECK_FLOW, EventScheduleMethod().RUN_NON_BLOCK )
             main.eventScheduler.scheduleEvent( EventType().CHECK_TRAFFIC, EventScheduleMethod().RUN_NON_BLOCK )
             if scheduleMethod == EventScheduleMethod().RUN_BLOCK:
                 main.eventScheduler.scheduleEvent( EventType().NULL, EventScheduleMethod().RUN_BLOCK )
@@ -554,6 +557,7 @@
             sleepTime = int( main.params[ 'EVENT' ][ 'removeAllPointIntents' ][ 'sleepBeforeCheck' ] )
             main.eventScheduler.scheduleEvent( EventType().TEST_SLEEP, EventScheduleMethod().RUN_BLOCK, [ sleepTime ] )
             main.eventScheduler.scheduleEvent( EventType().CHECK_INTENT, EventScheduleMethod().RUN_NON_BLOCK )
+            main.eventScheduler.scheduleEvent( EventType().CHECK_FLOW, EventScheduleMethod().RUN_NON_BLOCK )
             main.eventScheduler.scheduleEvent( EventType().CHECK_TRAFFIC, EventScheduleMethod().RUN_NON_BLOCK )
             if scheduleMethod == EventScheduleMethod().RUN_BLOCK:
                 main.eventScheduler.scheduleEvent( EventType().NULL, EventScheduleMethod().RUN_BLOCK )
diff --git a/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py b/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py
index 699a17d..6831811 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/elements/ONOSElement.py
@@ -33,6 +33,7 @@
         self.default = ''
         self.type = 'INTENT'
         self.id = id
+        self.expectedState = 'INSTALLED'
 
     def isHostIntent( self ):
         return self.type == 'INTENT_HOST'
@@ -40,12 +41,26 @@
     def isPointIntent( self ):
         return self.type == 'INTENT_POINT'
 
+    def isFailed( self ):
+        return self.expectedState == 'FAILED'
+
+    def isInstalled( self ):
+        return self.expectedState == 'INSTALLED'
+
+    def setFailed( self ):
+        self.expectedState = 'FAILED'
+
+    def setInstalled( self ):
+        self.expectedState = 'INSTALLED'
+
 class HostIntent( Intent ):
     def __init__( self, id, hostA, hostB ):
         Intent.__init__( self, id )
         self.type = 'INTENT_HOST'
         self.hostA = hostA
         self.hostB = hostB
+        self.deviceA = hostA.device
+        self.deviceB = hostB.device
 
     def __str__( self ):
         return "ID: " + self.id
diff --git a/TestON/tests/CHOTestMonkey/dependencies/events/CheckEvent.py b/TestON/tests/CHOTestMonkey/dependencies/events/CheckEvent.py
index b22e65c..d0408f9 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/events/CheckEvent.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/events/CheckEvent.py
@@ -25,25 +25,55 @@
 
     def startCheckEvent( self, args=None ):
         checkResult = EventStates().PASS
-        intentIDs = []
+        intentDict = {}
         for intent in main.intents:
-            if intent.isHostIntent():
-                deviceA = intent.hostA.device
-                deviceB = intent.hostB.device
-            elif intent.isPointIntent():
-                deviceA = intent.deviceA
-                deviceB = intent.deviceB
-            # Exclude the intents that are to or from removed devices/hosts
-            if not deviceA.isRemoved() and not deviceB.isRemoved():
-                intentIDs.append( intent.id )
+            intentDict[ intent.id ] = intent.expectedState
         for controller in main.controllers:
             if controller.isUp():
                 with controller.CLILock:
-                    intentState = controller.CLI.checkIntentState( intentsId=intentIDs )
+                    intentState = controller.CLI.compareIntent( intentDict )
                 if not intentState:
-                    main.log.warn( "Intent Check - Not all intents are in INSTALLED state on ONOS%s" % ( controller.index ) )
+                    main.log.warn( "Intent Check - not all intent ids and states match that on ONOS%s" % ( controller.index ) )
                     checkResult = EventStates().FAIL
-        #TODO: check flows?
+        return checkResult
+
+class FlowCheck( CheckEvent ):
+    def __init__( self ):
+        CheckEvent.__init__( self )
+        self.typeString = main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeString' ]
+        self.typeIndex = int( main.params[ 'EVENT' ][ self.__class__.__name__ ][ 'typeIndex' ] )
+
+    def startCheckEvent( self, args=None ):
+        import json
+        checkResult = EventStates().PASS
+        for controller in main.controllers:
+            if controller.isUp():
+                with controller.CLILock:
+                    flows = controller.CLI.flows()
+                    try:
+                        flows = json.loads( flows )
+                    except ( TypeError, ValueError ):
+                        main.log.exception( "Flow Check - Object not as expected: {!r}".format( flows ) )
+                        return EventStates().FAIL
+                    # Compare flow IDs in ONOS and Mininet
+                    flowIDList = []
+                    for item in flows:
+                        for flow in item[ "flows" ]:
+                            flowIDList.append( hex( int( flow[ 'id' ] ) ) )
+                    main.log.info( "Flow Check - current flow number on ONOS%s: %s" % ( controller.index, len( flowIDList ) ) )
+                    switchList = []
+                    for device in main.devices:
+                        switchList.append( device.name )
+                    with main.mininetLock:
+                        flowCompareResult = main.Mininet1.checkFlowId( switchList, flowIDList, debug=False )
+                    if not flowCompareResult:
+                        main.log.warn( "Flow Check - flows on ONOS%s do not match that in Mininet" % ( controller.index ) )
+                        checkResult = EventStates().FAIL
+                    # Check flow state
+                    flowState = controller.CLI.checkFlowsState( isPENDING=False )
+                    if not flowState:
+                        main.log.warn( "Flow Check - not all flows are in ADDED state on ONOS%s" % ( controller.index ) )
+                        checkResult = EventStates().FAIL
         return checkResult
 
 class TopoCheck( CheckEvent ):
@@ -78,33 +108,37 @@
                     #    main.log.warn( "Topo Check - link or device number discoverd by ONOS%s is incorrect" % ( controller.index ) )
                     #    checkResult = EventStates().FAIL
                     # Check links
-                    links = controller.CLI.links()
-                    links = json.loads( links )
-                    if not len( links ) == upLinkNum:
-                        checkResult = EventStates().FAIL
-                        main.log.warn( "Topo Check - link number discoverd by ONOS%s is incorrect: %s expected and %s actual" % ( controller.index, upLinkNum, len( links ) ) )
-                    # Check devices
-                    devices = controller.CLI.devices()
-                    devices = json.loads( devices )
-                    availableDeviceNum = 0
-                    for device in devices:
-                        if device[ 'available' ] == True:
-                            availableDeviceNum += 1
-                    if not availableDeviceNum == upDeviceNum:
-                        checkResult = EventStates().FAIL
-                        main.log.warn( "Topo Check - device number discoverd by ONOS%s is incorrect: %s expected and %s actual" % ( controller.index, upDeviceNum, availableDeviceNum ) )
-                    # Check hosts
-                    hosts = controller.CLI.hosts()
-                    hosts = json.loads( hosts )
-                    if not len( hosts ) == upHostNum:
-                        checkResult = EventStates().FAIL
-                        main.log.warn( "Topo Check - host number discoverd by ONOS%s is incorrect: %s expected and %s actual" % ( controller.index, upHostNum, len( hosts ) ) )
-                    # Check clusters
-                    clusters = controller.CLI.clusters()
-                    clusters = json.loads( clusters )
-                    if not len( clusters ) == clusterNum:
-                        checkResult = EventStates().FAIL
-                        main.log.warn( "Topo Check - cluster number discoverd by ONOS%s is incorrect: %s expected and %s actual" % ( controller.index, clusterNum, len( clusters ) ) )
+                    try:
+                        links = controller.CLI.links()
+                        links = json.loads( links )
+                        if not len( links ) == upLinkNum:
+                            checkResult = EventStates().FAIL
+                            main.log.warn( "Topo Check - link number discoverd by ONOS%s is incorrect: %s expected and %s actual" % ( controller.index, upLinkNum, len( links ) ) )
+                        # Check devices
+                        devices = controller.CLI.devices()
+                        devices = json.loads( devices )
+                        availableDeviceNum = 0
+                        for device in devices:
+                            if device[ 'available' ] == True:
+                                availableDeviceNum += 1
+                        if not availableDeviceNum == upDeviceNum:
+                            checkResult = EventStates().FAIL
+                            main.log.warn( "Topo Check - device number discoverd by ONOS%s is incorrect: %s expected and %s actual" % ( controller.index, upDeviceNum, availableDeviceNum ) )
+                        # Check hosts
+                        hosts = controller.CLI.hosts()
+                        hosts = json.loads( hosts )
+                        if not len( hosts ) == upHostNum:
+                            checkResult = EventStates().FAIL
+                            main.log.warn( "Topo Check - host number discoverd by ONOS%s is incorrect: %s expected and %s actual" % ( controller.index, upHostNum, len( hosts ) ) )
+                        # Check clusters
+                        clusters = controller.CLI.clusters()
+                        clusters = json.loads( clusters )
+                        if not len( clusters ) == clusterNum:
+                            checkResult = EventStates().FAIL
+                            main.log.warn( "Topo Check - cluster number discoverd by ONOS%s is incorrect: %s expected and %s actual" % ( controller.index, clusterNum, len( clusters ) ) )
+                    except ( TypeError, ValueError ):
+                        main.log.exception( "Flow Check - Object not as expected" )
+                        return EventStates().FAIL
         return checkResult
 
 class ONOSCheck( CheckEvent ):
@@ -132,44 +166,48 @@
         for controller in main.controllers:
             if controller.isUp():
                 # Check mastership
-                with controller.CLILock:
-                    roles = controller.CLI.roles()
-                roles = json.loads( roles )
-                for device in roles:
-                    dpid = device[ 'id' ]
-                    if dpidToMaster[ dpid ] == 'unknown':
-                        dpidToMaster[ dpid ] = device[ 'master' ]
-                    elif dpidToMaster[ dpid ] != device[ 'master' ]:
-                        checkResult = EventStates().FAIL
-                        main.log.warn( "ONOS Check - Mastership of %s on ONOS%s is inconsistent with that on ONOS1" % ( dpid, controller.index ) )
-                    if dpidToAvailability[ dpid ] and device[ 'master' ] == "none":
-                        checkResult = EventStates().FAIL
-                        main.log.warn( "ONOS Check - Device %s has no master on ONOS%s" % ( dpid, controller.index ) )
-                # Check leaders
-                with controller.CLILock:
-                    leaders = controller.CLI.leaders()
-                leaders = json.loads( leaders )
-                ONOSTopics = [ j['topic'] for j in leaders ]
-                for topic in topics:
-                    if topic not in ONOSTopics:
-                        checkResult = EventStates().FAIL
-                        main.log.warn( "ONOS Check - Topic %s not in leaders on ONOS%s" % ( topic, controller.index ) )
-                # Check node state
-                with controller.CLILock:
-                    nodes = controller.CLI.nodes()
-                nodes = json.loads( nodes )
-                ipToState = {}
-                for node in nodes:
-                    ipToState[ node[ 'ip' ] ] = node[ 'state' ]
-                for c in main.controllers:
-                    if c.isUp() and ipToState[ c.ip ] == 'READY':
-                        pass
-                    elif not c.isUp() and ipToState[ c.ip ] == 'INACTIVE':
-                        pass
-                    else:
-                        checkResult = EventStates().FAIL
-                        main.log.warn( "ONOS Check - ONOS%s shows wrong node state: ONOS%s is %s but state is %s" % ( controller.index, c.index, c.status, ipToState[ c.ip ] ) )
-                # TODO: check partitions?
+                try:
+                    with controller.CLILock:
+                        roles = controller.CLI.roles()
+                    roles = json.loads( roles )
+                    for device in roles:
+                        dpid = device[ 'id' ]
+                        if dpidToMaster[ dpid ] == 'unknown':
+                            dpidToMaster[ dpid ] = device[ 'master' ]
+                        elif dpidToMaster[ dpid ] != device[ 'master' ]:
+                            checkResult = EventStates().FAIL
+                            main.log.warn( "ONOS Check - Mastership of %s on ONOS%s is inconsistent with that on ONOS1" % ( dpid, controller.index ) )
+                        if dpidToAvailability[ dpid ] and device[ 'master' ] == "none":
+                            checkResult = EventStates().FAIL
+                            main.log.warn( "ONOS Check - Device %s has no master on ONOS%s" % ( dpid, controller.index ) )
+                    # Check leaders
+                    with controller.CLILock:
+                        leaders = controller.CLI.leaders()
+                    leaders = json.loads( leaders )
+                    ONOSTopics = [ j['topic'] for j in leaders ]
+                    for topic in topics:
+                        if topic not in ONOSTopics:
+                            checkResult = EventStates().FAIL
+                            main.log.warn( "ONOS Check - Topic %s not in leaders on ONOS%s" % ( topic, controller.index ) )
+                    # Check node state
+                    with controller.CLILock:
+                        nodes = controller.CLI.nodes()
+                    nodes = json.loads( nodes )
+                    ipToState = {}
+                    for node in nodes:
+                        ipToState[ node[ 'ip' ] ] = node[ 'state' ]
+                    for c in main.controllers:
+                        if c.isUp() and ipToState[ c.ip ] == 'READY':
+                            pass
+                        elif not c.isUp() and ipToState[ c.ip ] == 'INACTIVE':
+                            pass
+                        else:
+                            checkResult = EventStates().FAIL
+                            main.log.warn( "ONOS Check - ONOS%s shows wrong node state: ONOS%s is %s but state is %s" % ( controller.index, c.index, c.status, ipToState[ c.ip ] ) )
+                    # TODO: check partitions?
+                except ( TypeError, ValueError ):
+                    main.log.exception( "ONOS Check - Object not as expected" )
+                    return EventStates().FAIL
         return checkResult
 
 class TrafficCheck( CheckEvent ):
diff --git a/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py b/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py
index 46b37e7..7247ecf 100644
--- a/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py
+++ b/TestON/tests/CHOTestMonkey/dependencies/events/NetworkEvent.py
@@ -208,6 +208,9 @@
                 link.backwardLink.setRemoved()
             for host in self.device.hosts:
                 host.setRemoved()
+            for intent in main.intents:
+                if intent.deviceA == self.device or intent.deviceB == self.device:
+                    intent.setFailed()
         return EventStates().PASS
 
 class DeviceUp( DeviceEvent ):
@@ -256,6 +259,11 @@
             with main.variableLock:
                 link.bringUp()
                 link.backwardLink.bringUp()
+                for intent in main.intents:
+                    if intent.isFailed():
+                        if intent.deviceA == self.device and intent.deviceB.isUp() or\
+                        intent.deviceB == self.device and intent.deviceA.isUp():
+                            intent.setInstalled()
         # Re-assign mastership for the device
         with main.mininetLock:
             main.Mininet1.assignSwController( sw=self.device.name, ip=main.onosIPs )
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.py b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
index 1bff0f1..e81b5fa 100644
--- a/TestON/tests/FUNC/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
@@ -864,6 +864,36 @@
                                  onpass=main.assertReturnString,
                                  onfail=main.assertReturnString)
 
+        main.step( "VLAN2: Add vlan host intents between h4 and h13" )
+        main.assertReturnString = "Assertion Result vlan IPV4\n"
+        host1 = { "name":"h5", "vlan":"200" }
+        host2 = { "name":"h12", "vlan":"100" }
+        testResult = main.FALSE
+        installResult = main.FALSE
+        installResult = main.intentFunction.installHostIntent( main,
+                                              name='VLAN2',
+                                              onosNode='0',
+                                              host1=host1,
+                                              host2=host2)
+
+        if installResult:
+            testResult = main.intentFunction.testHostIntent( main,
+                                              name='VLAN2',
+                                              intentId = installResult,
+                                              onosNode='0',
+                                              host1=host1,
+                                              host2=host2,
+                                              sw1='s5',
+                                              sw2='s2',
+                                              expectedLink = 18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=testResult,
+                                 onpass=main.assertReturnString,
+                                 onfail=main.assertReturnString)
+
         main.step( "Confirm that ONOS leadership is unchanged")
         intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
         main.intentFunction.checkLeaderChange( intentLeadersOld,
@@ -1076,7 +1106,8 @@
                                          recipients=recipients,
                                          sw1="s5",
                                          sw2="s2",
-                                         expectedLink=18)
+                                         expectedLink=18,
+                                         useTCP=True)
         else:
             main.CLIs[ 0 ].removeAllIntents( purge=True )
 
@@ -1183,6 +1214,39 @@
                                  onpass=main.assertReturnString,
                                  onfail=main.assertReturnString )
 
+        main.step( "VLAN: Add point intents between h5 and h21" )
+        main.assertReturnString = "Assertion Result for VLAN IPV4 point intents with VLAN treatment\n"
+        senders = [
+            { "name":"h4", "vlan":"100" }
+        ]
+        recipients = [
+            { "name":"h21", "vlan":"200" }
+        ]
+        testResult = main.FALSE
+        installResult = main.FALSE
+        installResult = main.intentFunction.installPointIntent(
+                                       main,
+                                       name="VLAN2",
+                                       senders=senders,
+                                       recipients=recipients,
+                                       setVlan=200)
+
+        if installResult:
+            testResult = main.intentFunction.testPointIntent(
+                                         main,
+                                         intentId=installResult,
+                                         name="VLAN2",
+                                         senders=senders,
+                                         recipients=recipients,
+                                         sw1="s5",
+                                         sw2="s2",
+                                         expectedLink=18)
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=testResult,
+                                 onpass=main.assertReturnString,
+                                 onfail=main.assertReturnString )
+
         main.step( "1HOP: Add point intents between h1 and h3" )
         main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n"
         senders = [
@@ -1441,6 +1505,48 @@
                                  onpass=main.assertReturnString,
                                  onfail=main.assertReturnString )
 
+        main.step( "VLAN: Add single point to multi point intents" )
+        main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n"
+        senders = [
+            { "name":"h5", "vlan":"200" }
+        ]
+        recipients = [
+            { "name":"h12", "device":"of:0000000000000006/4", "mac":"00:00:00:00:00:0C", "vlan":"100" },
+            { "name":"h20", "device":"of:0000000000000007/4", "mac":"00:00:00:00:00:14", "vlan":"100" }
+        ]
+        badSenders=[ { "name":"h13" } ]  # Senders that are not in the intent
+        badRecipients=[ { "name":"h21" } ]  # Recipients that are not in the intent
+        testResult = main.FALSE
+        installResult = main.FALSE
+        installResult = main.intentFunction.installSingleToMultiIntent(
+                                         main,
+                                         name="VLAN2",
+                                         senders=senders,
+                                         recipients=recipients,
+                                         sw1="s5",
+                                         sw2="s2",
+                                         setVlan=100)
+
+        if installResult:
+            testResult = main.intentFunction.testPointIntent(
+                                         main,
+                                         intentId=installResult,
+                                         name="VLAN2",
+                                         senders=senders,
+                                         recipients=recipients,
+                                         badSenders=badSenders,
+                                         badRecipients=badRecipients,
+                                         sw1="s5",
+                                         sw2="s2",
+                                         expectedLink=18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=testResult,
+                                 onpass=main.assertReturnString,
+                                 onfail=main.assertReturnString )
+
         main.intentFunction.report( main )
 
     def CASE4000( self, main ):
@@ -1664,6 +1770,49 @@
                                  onpass=main.assertReturnString,
                                  onfail=main.assertReturnString )
 
+        # Right now this fails because of this bug: https://jira.onosproject.org/browse/ONOS-4383
+        main.step( "VLAN: Add multi point to single point intents" )
+        main.assertReturnString = "Assertion results for multi to single point intent with VLAN ID treatment\n"
+        senders = [
+            { "name":"h13", "device":"of:0000000000000006/5", "vlan":"200" },
+            { "name":"h21", "device":"of:0000000000000007/5", "vlan":"200" }
+        ]
+        recipients = [
+            { "name":"h4", "vlan":"100" }
+        ]
+        badSenders=[ { "name":"h12" } ]  # Senders that are not in the intent
+        badRecipients=[ { "name":"h20" } ]  # Recipients that are not in the intent
+        testResult = main.FALSE
+        installResult = main.FALSE
+        installResult = main.intentFunction.installMultiToSingleIntent(
+                                         main,
+                                         name="VLAN2",
+                                         senders=senders,
+                                         recipients=recipients,
+                                         sw1="s5",
+                                         sw2="s2",
+                                         setVlan=100)
+
+        if installResult:
+            testResult = main.intentFunction.testPointIntent(
+                                         main,
+                                         intentId=installResult,
+                                         name="VLAN2",
+                                         senders=senders,
+                                         recipients=recipients,
+                                         badSenders=badSenders,
+                                         badRecipients=badRecipients,
+                                         sw1="s5",
+                                         sw2="s2",
+                                         expectedLink=18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=testResult,
+                                 onpass=main.assertReturnString,
+                                 onfail=main.assertReturnString )
+
         main.intentFunction.report( main )
 
     def CASE5000( self, main ):
diff --git a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
index dede2c8..c3104a5 100644
--- a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
+++ b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
@@ -22,7 +22,8 @@
                        ipAddresses="",
                        tcp="",
                        sw1="",
-                       sw2="" ):
+                       sw2="",
+                       setVlan="" ):
     """
     Installs a Host Intent
 
@@ -78,7 +79,8 @@
         vlanId = host1.get( "vlan" )
         intentId = main.CLIs[ onosNode ].addHostIntent( hostIdOne=host1.get( "id" ),
                                                         hostIdTwo=host2.get( "id" ),
-                                                        vlanId=vlanId )
+                                                        vlanId=vlanId,
+                                                        setVlan=setVlan )
     except (KeyError, TypeError):
         errorMsg = "There was a problem loading the hosts data."
         if intentId:
@@ -296,7 +298,8 @@
                         ipSrc="",
                         ipDst="",
                         tcpSrc="",
-                        tcpDst=""):
+                        tcpDst="",
+                        setVlan=""):
     """
     Installs a Single to Single Point Intent
 
@@ -384,7 +387,8 @@
                                             ipDst=ipDst,
                                             tcpSrc=tcpSrc,
                                             tcpDst=tcpDst,
-                                            vlanId=vlanId )
+                                            vlanId=vlanId,
+                                            setVlan=setVlan )
     except (KeyError, TypeError):
         errorMsg = "There was a problem loading the hosts data."
         if intentId:
@@ -694,7 +698,8 @@
                                 ipAddresses="",
                                 tcp="",
                                 sw1="",
-                                sw2=""):
+                                sw2="",
+                                setVlan=""):
     """
     Installs a Single to Multi Point Intent
 
@@ -781,7 +786,8 @@
                                             ipDst="",
                                             tcpSrc="",
                                             tcpDst="",
-                                            vlanId=vlanId )
+                                            vlanId=vlanId,
+                                            setVlan=setVlan )
     except (KeyError, TypeError):
         errorMsg = "There was a problem loading the hosts data."
         if intentId:
@@ -808,7 +814,8 @@
                                 ipAddresses="",
                                 tcp="",
                                 sw1="",
-                                sw2=""):
+                                sw2="",
+                                setVlan=""):
     """
     Installs a Multi to Single Point Intent
 
@@ -894,7 +901,8 @@
                                             ipDst="",
                                             tcpSrc="",
                                             tcpDst="",
-                                            vlanId=vlanId )
+                                            vlanId=vlanId,
+                                            setVlan=setVlan )
     except (KeyError, TypeError):
         errorMsg = "There was a problem loading the hosts data."
         if intentId:
@@ -925,7 +933,8 @@
                      tcp="",
                      sw1="s5",
                      sw2="s2",
-                     expectedLink=0):
+                     expectedLink=0,
+                     useTCP=False):
     """
     Test a Point Intent
 
@@ -1026,7 +1035,7 @@
         testResult = main.FALSE
 
     # Check Connectivity
-    if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ), attempts=3, sleep=5 ):
+    if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId, useTCP ), attempts=3, sleep=5 ):
         main.assertReturnString += 'Initial Ping Passed\n'
     else:
         main.assertReturnString += 'Initial Ping Failed\n'
@@ -1080,7 +1089,7 @@
             testResult = main.FALSE
 
         # Check Connection
-        if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ):
+        if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId, useTCP ) ):
             main.assertReturnString += 'Link Down Pingall Passed\n'
         else:
             main.assertReturnString += 'Link Down Pingall Failed\n'
@@ -1118,7 +1127,7 @@
             testResult = main.FALSE
 
         # Check Connection
-        if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId ) ):
+        if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, args=( main, senderNames, recipientNames, vlanId, useTCP ) ):
             main.assertReturnString += 'Link Up Scapy Packet Received Passed\n'
         else:
             main.assertReturnString += 'Link Up Scapy Packet Recieved Failed\n'
@@ -1303,7 +1312,7 @@
     # Check Connectivity
     # First check connectivity of any isolated senders to recipients
     if isolatedSenderNames:
-        if scapyCheckConnection( main, isolatedSenderNames, recipientNames, None, None, None, main.TRUE ):
+        if scapyCheckConnection( main, isolatedSenderNames, recipientNames, None, None, None, None, main.TRUE ):
             main.assertReturnString += 'Isolation link Down Connectivity Check Passed\n'
         else:
             main.assertReturnString += 'Isolation link Down Connectivity Check Failed\n'
@@ -1311,7 +1320,7 @@
 
     # Next check connectivity of senders to any isolated recipients
     if isolatedRecipientNames:
-        if scapyCheckConnection( main, senderNames, isolatedRecipientNames, None, None, None, main.TRUE ):
+        if scapyCheckConnection( main, senderNames, isolatedRecipientNames, None, None, None, None, main.TRUE ):
             main.assertReturnString += 'Isolation link Down Connectivity Check Passed\n'
         else:
             main.assertReturnString += 'Isolation link Down Connectivity Check Failed\n'
@@ -1592,7 +1601,7 @@
 def checkFlowsState( main ):
 
     main.log.info( itemName + ": Check flows state" )
-    checkFlowsResult = main.CLIs[ 0 ].checkFlowsState()
+    checkFlowsResult = main.CLIs[ 0 ].checkFlowsState( isPENDING=False )
     return checkFlowsResult
 
 def link( main, sw1, sw2, option):
@@ -1603,7 +1612,7 @@
     linkResult = main.Mininet1.link( end1=sw1, end2=sw2, option=option )
     return linkResult
 
-def scapyCheckConnection( main, senders, recipients, vlanId=None, packet=None, packetFilter=None, expectFailure=False ):
+def scapyCheckConnection( main, senders, recipients, vlanId=None, useTCP=False, packet=None, packetFilter=None, expectFailure=False ):
     """
         Checks the connectivity between all given sender hosts and all given recipient hosts
         Packet may be specified. Defaults to Ether/IP packet
@@ -1617,7 +1626,8 @@
 
     if not packetFilter:
         packetFilter = 'ether host {}'
-
+    if useTCP:
+        packetFilter += ' ip proto \\tcp tcp port {}'.format(main.params[ 'SDNIP' ][ 'dstPort' ])
     if expectFailure:
         timeout = 1
     else:
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
index 6aee29e..608f0e6 100644
--- a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
+++ b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
@@ -419,6 +419,8 @@
 
         # make sure the checkInterval divisible batchSize
         main.checkInterval = int( int( main.checkInterval / main.batchSize ) * main.batchSize )
+        flowTemp=0
+        totalFlows=0
         for i in range(limit):
 
             # Threads pool
@@ -463,22 +465,27 @@
                     temp = 0
                     intentsState = main.CLIs[0].checkIntentSummary(timeout=600)
                     if intentsState:
-                        totalIntents = main.CLIs[0].getTotalIntentsNum(timeout=600)
-                        if temp < totalIntents:
-                            temp = totalIntents
+                        verifyTotalIntents = main.CLIs[0].getTotalIntentsNum(timeout=600)
+                        if temp < verifyTotalIntents:
+                            temp = verifyTotalIntents 
                         else:
-                            totalIntents = temp
+                            verifytotalIntents = temp
+                        main.log.info("Total Intents: {}".format( verifyTotalIntents ) )
                         break
-                        main.log.info("Total Intents: {}".format( totalIntents) )
                     k = k+1
-                
+
+                totalFlows = main.CLIs[0].getTotalFlowsNum( timeout=600, noExit=True )
+                if flowTemp < totalFlows:
+                    flowTemp = totalFlows
+                else:
+                    totalFlows = flowTemp 
+
                 if not intentsState:
                     # If some intents are not installed, grep the previous flows list, and finished this test case
                     main.log.warn( "Some intens did not install" )
-                    main.log.info("Total Intents: {}".format( totalIntents) )
+                    main.log.info("Total Intents: {}".format( verifyTotalIntents) )
                     break
 
-        totalFlows = main.CLIs[0].getTotalFlowsNum(timeout=600, noExit=True)
         del main.scale[0]
         utilities.assert_equals( expect = main.TRUE,
                                  actual = intentsState,
@@ -496,7 +503,7 @@
             temp = str(main.numCtrls)
             temp += ",'" + "baremetal1" + "'"
             # how many intents we installed before crash
-            temp += "," + str(totalIntents)
+            temp += "," + str(verifyTotalIntents)
             # how many flows we installed before crash
             temp += "," + str(totalFlows)
             # other columns in database, but we didn't use in this test
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/SCPFscalingMaxIntentsWithFlowObj.py b/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/SCPFscalingMaxIntentsWithFlowObj.py
index 7e6753e..97dc6f3 100644
--- a/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/SCPFscalingMaxIntentsWithFlowObj.py
+++ b/TestON/tests/SCPF/SCPFscalingMaxIntentsWithFlowObj/SCPFscalingMaxIntentsWithFlowObj.py
@@ -421,6 +421,9 @@
 
         # make sure the checkInterval divisible batchSize
         main.checkInterval = int( int( main.checkInterval / main.batchSize ) * main.batchSize )
+        flowTemp=0
+        totalFlows=0
+        verifyTotalIntents=0
         for i in range(limit):
 
             # Threads pool
@@ -465,22 +468,27 @@
                     temp = 0
                     intentsState = main.CLIs[0].checkIntentSummary(timeout=600)
                     if intentsState:
-                        totalIntents = main.CLIs[0].getTotalIntentsNum(timeout=600)
-                        if temp < totalIntents:
-                            temp = totalIntents
+                        verifyTotalIntents = main.CLIs[0].getTotalIntentsNum(timeout=600)
+                        if temp < verifyTotalIntents:
+                            temp = verifyTotalIntents
                         else:
-                            totalIntents = temp
+                            verifyTotalIntents = temp
                         break
                         main.log.info("Total Intents: {}".format( totalIntents) )
                     k = k+1
-                
+
+                totalFlows = main.CLIs[0].getTotalFlowsNum( timeout=600, noExit=True )
+                if flowTemp<totalFlows:
+                    flowTemp = totalFlows
+                else:
+                    totalFlows = flowTemp
+
                 if not intentsState:
                     # If some intents are not installed, grep the previous flows list, and finished this test case
                     main.log.warn( "Some intens did not install" )
                     main.log.info("Total Intents: {}".format( totalIntents) )
                     break
 
-        totalFlows = main.CLIs[0].getTotalFlowsNum(timeout=600, noExit=True)
         del main.scale[0]
         utilities.assert_equals( expect = main.TRUE,
                                  actual = intentsState,
diff --git a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py b/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py
index 9822b8b..bfdff59 100644
--- a/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py
+++ b/TestON/tests/USECASE/USECASE_SegmentRouting/USECASE_SegmentRouting.py
@@ -286,21 +286,31 @@
             onpass="Flow status is correct!",
             onfail="Flow status is wrong!" )
         main.ONOSbench.dumpFlows( main.ONOSip[0],
-                 main.logdir, "flows" + main.jsonFile)
+                 main.logdir, "flowsBefore" + main.jsonFile)
         #time.sleep( 3*main.startUpSleep)
 
     def CASE4( self, main ):
         main.case( "Check full connectivity" )
         main.log.report( "Check full connectivity" )
 
-        main.step("Check full connectivity")
+        main.step("1st Check full connectivity")
         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, "flows" + main.jsonFile)
+                 main.logdir, "flowsAfter" + main.jsonFile)
+
+        main.step("2nd Check full connectivity")
+        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, "flowsAfter2nd" + main.jsonFile)
+
         main.ONOSbench.onosStop( main.ONOSip[0] )
         main.Mininet1.stopNet()