Merge "Fix exception when assert is called before a step"
diff --git a/TestON/tests/CHOtest/CHOtest.params b/TestON/tests/CHOtest/CHOtest.params
index d4199ad..1efb9bd 100644
--- a/TestON/tests/CHOtest/CHOtest.params
+++ b/TestON/tests/CHOtest/CHOtest.params
@@ -90,7 +90,7 @@
         <LinkDiscovery>15</LinkDiscovery>
         <SwitchDiscovery>10</SwitchDiscovery>
         <IntentPurgeDelay>15</IntentPurgeDelay>
-        <CheckIntentDelay>40</CheckIntentDelay>
+        <CheckIntentDelay>5</CheckIntentDelay>
     </timers>
 
 </PARAMS>
diff --git a/TestON/tests/CHOtest/CHOtest.py b/TestON/tests/CHOtest/CHOtest.py
index fbe51cd..01a3544 100644
--- a/TestON/tests/CHOtest/CHOtest.py
+++ b/TestON/tests/CHOtest/CHOtest.py
@@ -993,23 +993,24 @@
 
         # Giving onos 3 chances to install intents
         for i in range(3):
-            intentsJson = main.ONOScli1.intents()
-            getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
-                                                                intentsJson = intentsJson)
-            main.log.info("Waiting for onos to get intents...")
+            if i != 0:
+                main.log.warn( "Verification failed. Retrying..." )
+            main.log.info("Waiting for onos to install intents...")
             time.sleep( main.checkIntentsDelay )
 
             intentState = main.TRUE
-            failedIntents = 0
-            for intent in getIntentStateResult:
-                state = intent.items()[0][1]
-                if state != 'INSTALLED':
-                    main.log.info("Intent State: " + state)
-                    failedIntents += 1
-                    intentState = main.FALSE
+            for e in range(int(main.numCtrls)):
+                main.log.info( "Checking intents on CLI %s" % (e+1) )
+                intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+                        intentState
+                if not intentState:
+                    main.log.warn( "Not all intents installed" )
             if intentState:
                 break
-            main.log.error("Total # of intents not in an INSTALLED state: " + str(failedIntents))
+        else:
+            #Dumping intent summary
+            main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
+
 
         utilities.assert_equals( expect=main.TRUE, actual=intentState,
                                  onpass="INTENTS INSTALLED",
@@ -1079,24 +1080,23 @@
 
         # Giving onos 3 chances to install intents
         for i in range(3):
-            intentsJson = main.ONOScli1.intents()
-            getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
-                                                                intentsJson = intentsJson)
-            main.log.info("Waiting for onos to get intents...")
+            if i != 0:
+                main.log.warn( "Verification failed. Retrying..." )
+            main.log.info("Waiting for onos to install intents...")
             time.sleep( main.checkIntentsDelay )
 
             intentState = main.TRUE
-            failedIntents = 0
-            for intent in getIntentStateResult:
-                state = intent.items()[0][1]
-                if state != 'INSTALLED':
-                    main.log.info("Intent State: " + state)
-                    failedIntents += 1
-                    intentState = main.FALSE
+            for e in range(int(main.numCtrls)):
+                main.log.info( "Checking intents on CLI %s" % (e+1) )
+                intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+                        intentState
+                if not intentState:
+                    main.log.warn( "Not all intents installed" )
             if intentState:
                 break
-            main.log.error("Total # of intents not in an INSTALLED state: " + str(failedIntents))
-
+        else:
+            #Dumping intent summary
+            main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
 
         utilities.assert_equals( expect=main.TRUE, actual=intentState,
                                  onpass="INTENTS INSTALLED",
@@ -1164,25 +1164,25 @@
 
         main.step("Verify intents are installed")
 
-        # Giving onos 5 chances to install intents
-        for i in range(5):
-            intentsJson = main.ONOScli1.intents()
-            getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
-                                                                intentsJson = intentsJson)
-            main.log.info("Waiting for onos to get intents...")
+        # Giving onos 3 chances to install intents
+        for i in range(3):
+            if i != 0:
+                main.log.warn( "Verification failed. Retrying..." )
+            main.log.info("Waiting for onos to install intents...")
             time.sleep( main.checkIntentsDelay )
 
             intentState = main.TRUE
-            failedIntents = 0
-            for intent in getIntentStateResult:
-                state = intent.items()[0][1]
-                if state != 'INSTALLED':
-                    main.log.info("Intent State: " + state)
-                    failedIntents += 1
-                    intentState = main.FALSE
+            for e in range(int(main.numCtrls)):
+                main.log.info( "Checking intents on CLI %s" % (e+1) )
+                intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+                        intentState
+                if not intentState:
+                    main.log.warn( "Not all intents installed" )
             if intentState:
                 break
-            main.log.error("Total # of intents not in an INSTALLED state: " + str(failedIntents))
+        else:
+            #Dumping intent summary
+            main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
 
         utilities.assert_equals( expect=main.TRUE, actual=intentState,
                                  onpass="INTENTS INSTALLED",
@@ -2614,33 +2614,33 @@
                 intentIdList.append(thread.result)
         time2 = time.time()
         main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
-        intentResult = main.TRUE
-        intentsJson = main.ONOScli1.intents()
-        getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
-                intentsJson = intentsJson)
-        # Takes awhile for all the onos to get the intents
-        time.sleep(60)
 
         main.step("Verify intents are installed")
+
+        # Giving onos 3 chances to install intents
         for i in range(3):
+            if i != 0:
+                main.log.warn( "Verification failed. Retrying..." )
+            main.log.info("Waiting for onos to install intents...")
+            time.sleep( main.checkIntentsDelay )
+
             intentState = main.TRUE
-            failedIntents = 0
-            for intent in getIntentStateResult:
-                state = intent.items()[0][1]
-                if state != 'INSTALLED':
-                    main.log.info("Intent State: " + state)
-                    failedIntents += 1
-                    intentState = main.FALSE
+            for e in range(int(main.numCtrls)):
+                main.log.info( "Checking intents on CLI %s" % (e+1) )
+                intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+                        intentState
+                if not intentState:
+                    main.log.warn( "Not all intents installed" )
             if intentState:
                 break
-            main.log.error("Total: " + str(failedIntents))
-            time.sleep(5)
+        else:
+            #Dumping intent summary
+            main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
 
         utilities.assert_equals( expect=main.TRUE, actual=intentState,
                                  onpass="INTENTS INSTALLED",
                                  onfail="SOME INTENTS NOT INSTALLED" )
 
-
         main.step( "Verify Ping across all hosts" )
         pingResult = main.FALSE
         time1 = time.time()
@@ -2655,7 +2655,7 @@
                                  onpass="PING tALL PASS",
                                  onfail="PING ALL FAIL" )
 
-        case90Result = ( intentResult and pingResult )
+        case90Result = ( intentState and pingResult )
 
         utilities.assert_equals(
             expect=main.TRUE,
@@ -2697,33 +2697,33 @@
                 intentIdList.append(thread.result)
         time2 = time.time()
         main.log.info( "Time for adding point intents: %2f seconds" %(time2-time1) )
-        intentResult = main.TRUE
-        intentsJson = main.ONOScli1.intents()
-        getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
-                intentsJson = intentsJson)
-        # Takes awhile for all the onos to get the intents
-        time.sleep(30)
 
         main.step("Verify intents are installed")
+
+        # Giving onos 3 chances to install intents
         for i in range(3):
+            if i != 0:
+                main.log.warn( "Verification failed. Retrying..." )
+            main.log.info("Waiting for onos to install intents...")
+            time.sleep( main.checkIntentsDelay )
+
             intentState = main.TRUE
-            failedIntents = 0
-            for intent in getIntentStateResult:
-                state = intent.items()[0][1]
-                if state != 'INSTALLED':
-                    main.log.info("Intent State: " + state)
-                    failedIntents += 1
-                    intentState = main.FALSE
+            for e in range(int(main.numCtrls)):
+                main.log.info( "Checking intents on CLI %s" % (e+1) )
+                intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+                        intentState
+                if not intentState:
+                    main.log.warn( "Not all intents installed" )
             if intentState:
                 break
-            main.log.error("Total: " + str(failedIntents))
-            time.sleep(5)
+        else:
+            #Dumping intent summary
+            main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
 
         utilities.assert_equals( expect=main.TRUE, actual=intentState,
                                  onpass="INTENTS INSTALLED",
                                  onfail="SOME INTENTS NOT INSTALLED" )
 
-
         main.step( "Verify Ping across all hosts" )
         pingResult = main.FALSE
         time1 = time.time()
@@ -2738,7 +2738,7 @@
                                  onpass="PING ALL PASS",
                                  onfail="PING ALL FAIL" )
 
-        case91Result = ( intentResult and pingResult )
+        case91Result = ( intentState and pingResult )
 
         utilities.assert_equals(
             expect=main.TRUE,
@@ -2783,34 +2783,33 @@
                 intentIdList.append(thread.result)
         time2 = time.time()
         main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
-        intentResult = main.TRUE
-        intentsJson = main.ONOScli1.intents()
-        getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
-                intentsJson = intentsJson)
-        #print getIntentStateResult
-        # Takes awhile for all the onos to get the intents
-        time.sleep(60)
 
         main.step("Verify intents are installed")
+
+        # Giving onos 3 chances to install intents
         for i in range(3):
+            if i != 0:
+                main.log.warn( "Verification failed. Retrying..." )
+            main.log.info("Waiting for onos to install intents...")
+            time.sleep( main.checkIntentsDelay )
+
             intentState = main.TRUE
-            failedIntents = 0
-            for intent in getIntentStateResult:
-                state = intent.items()[0][1]
-                if state != 'INSTALLED':
-                    main.log.info("Intent State: " + state)
-                    failedIntents += 1
-                    intentState = main.FALSE
+            for e in range(int(main.numCtrls)):
+                main.log.info( "Checking intents on CLI %s" % (e+1) )
+                intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+                        intentState
+                if not intentState:
+                    main.log.warn( "Not all intents installed" )
             if intentState:
                 break
-            main.log.error("Total: " + str(failedIntents))
-            time.sleep(5)
+        else:
+            #Dumping intent summary
+            main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
 
         utilities.assert_equals( expect=main.TRUE, actual=intentState,
                                  onpass="INTENTS INSTALLED",
                                  onfail="SOME INTENTS NOT INSTALLED" )
 
-
         main.step( "Verify Ping across all hosts" )
         pingResult = main.FALSE
         time1 = time.time()
@@ -2825,7 +2824,7 @@
                                  onpass="PING ALL PASS",
                                  onfail="PING ALL FAIL" )
 
-        case92Result = ( intentResult and pingResult )
+        case92Result = ( intentState and pingResult )
 
         utilities.assert_equals(
             expect=main.TRUE,
@@ -2840,13 +2839,14 @@
         """
         import copy
         import time
+        from collections import Counter
         main.log.report( "Install multi-single point intents and verify Ping all" )
         main.log.report( "___________________________________________" )
         main.case( "Install multi-single point intents and Ping all" )
         deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
         portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
         intentIdList = []
-        print "MACsDict", main.MACsDict
+        main.log.info( "MACsDict" + str(main.MACsDict) )
         time1 = time.time()
         for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
             pool = []
@@ -2861,7 +2861,6 @@
                         name="addMultipointToSinglepointIntent",
                         args =[ingressDeviceList,egressDevice,portIngressList,'1','','',main.MACsDict.get(egressDevice)])
                 pool.append(t)
-                #time.sleep(1)
                 t.start()
                 i = i + 1
                 main.threadID = main.threadID + 1
@@ -2870,38 +2869,55 @@
                 intentIdList.append(thread.result)
         time2 = time.time()
         main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
-        time.sleep(30)
-        print "getting all intents ID"
-        intentIdTemp = main.ONOScli1.getAllIntentsId()
-        print intentIdTemp
-        print len(intentIdList)
-        print intentIdList
-        checkIntentStateResult = main.TRUE
-        print "Checking intents state"
-        checkIntentStateResult = main.ONOScli1.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
-        checkIntentStateResult = main.ONOScli2.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
-        checkIntentStateResult = main.ONOScli3.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
-        checkIntentStateResult = main.ONOScli4.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
-        checkIntentStateResult = main.ONOScli5.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
 
-        if checkIntentStateResult:
-            main.log.info( "All intents are installed correctly " )
+        main.step("Verify intents are installed")
 
-        print "Checking flows state "
+        # Giving onos 3 chances to install intents
+        for i in range(3):
+            if i != 0:
+                main.log.warn( "Verification failed. Retrying..." )
+            main.log.info("Waiting for onos to install intents...")
+            time.sleep( main.checkIntentsDelay )
+
+            intentState = main.TRUE
+            for e in range(int(main.numCtrls)):
+                main.log.info( "Checking intents on CLI %s" % (e+1) )
+                intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+                        intentState
+                if not intentState:
+                    main.log.warn( "Not all intents installed" )
+            if intentState:
+                break
+        else:
+            #Dumping intent summary
+            main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
+
+        utilities.assert_equals( expect=main.TRUE, actual=intentState,
+                                 onpass="INTENTS INSTALLED",
+                                 onfail="SOME INTENTS NOT INSTALLED" )
+
+        main.log.info( "Checking flows state" )
         checkFlowsState = main.ONOScli1.checkFlowsState()
+        # Giving onos time to return the state of the flows
         time.sleep(50)
+
         main.step( "Verify Ping across all hosts" )
         pingResult = main.FALSE
         time1 = time.time()
-        pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+        pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+        if not pingResult:
+            time1 = time.time()
+            main.log.warn("First pingall failed. Retrying")
+            pingResult = main.Mininet1.pingall( timeout=main.pingTimeout )
+
         time2 = time.time()
         timeDiff = round( ( time2 - time1 ), 2 )
         main.log.report(
             "Time taken for Ping All: " +
             str( timeDiff ) +
             " seconds" )
-        checkFlowsState = main.ONOScli1.checkFlowsState()
-        case93Result = pingResult
+
+        case93Result = ( checkFlowsState and pingResult and intentState )
         utilities.assert_equals(
             expect=main.TRUE,
             actual=case93Result,
@@ -2936,7 +2952,6 @@
                         name="addMultipointToSinglepointIntent",
                         args =[ingressDeviceList,egressDevice,portIngressList,'1','','',main.MACsDict.get(egressDevice)])
                 pool.append(t)
-                #time.sleep(1)
                 t.start()
                 i = i + 1
                 main.threadID = main.threadID + 1
@@ -2945,11 +2960,42 @@
                 intentIdList.append(thread.result)
         time2 = time.time()
         main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
-        time.sleep(5)
+
+        main.step("Verify intents are installed")
+
+        # Giving onos 3 chances to install intents
+        for i in range(3):
+            if i != 0:
+                main.log.warn( "Verification failed. Retrying..." )
+            main.log.info("Waiting for onos to install intents...")
+            time.sleep( main.checkIntentsDelay )
+
+            intentState = main.TRUE
+            for e in range(int(main.numCtrls)):
+                main.log.info( "Checking intents on CLI %s" % (e+1) )
+                intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+                        intentState
+                if not intentState:
+                    main.log.warn( "Not all intents installed" )
+            if intentState:
+                break
+        else:
+            #Dumping intent summary
+            main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
+
+
+        utilities.assert_equals( expect=main.TRUE, actual=intentState,
+                                 onpass="INTENTS INSTALLED",
+                                 onfail="SOME INTENTS NOT INSTALLED" )
+
         main.step( "Verify Ping across all hosts" )
         pingResult = main.FALSE
         time1 = time.time()
-        pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+        pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+        if not pingResult:
+            main.log.info( "First pingall failed. Retrying..." )
+            time1 = time.time()
+            pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
         time2 = time.time()
         timeDiff = round( ( time2 - time1 ), 2 )
         main.log.report(
@@ -2957,7 +3003,8 @@
             str( timeDiff ) +
             " seconds" )
 
-        case94Result = pingResult
+
+        case94Result = ( pingResult and intentState )
         utilities.assert_equals(
             expect=main.TRUE,
             actual=case94Result,
@@ -2993,7 +3040,6 @@
                         name="addSinglepointToMultipointIntent",
                         args =[ingressDevice,egressDeviceList,'1',portEgressList,'',main.MACsDict.get(ingressDevice)])
                 pool.append(t)
-                #time.sleep(1)
                 t.start()
                 i = i + 1
                 main.threadID = main.threadID + 1
@@ -3002,11 +3048,42 @@
                 intentIdList.append(thread.result)
         time2 = time.time()
         main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
-        time.sleep(5)
+
+        main.step("Verify intents are installed")
+
+        # Giving onos 3 chances to install intents
+        for i in range(3):
+            if i != 0:
+                main.log.warn( "Verification failed. Retrying..." )
+            main.log.info("Waiting for onos to install intents...")
+            time.sleep( main.checkIntentsDelay )
+
+            intentState = main.TRUE
+            for e in range(int(main.numCtrls)):
+                main.log.info( "Checking intents on CLI %s" % (e+1) )
+                intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+                        intentState
+                if not intentState:
+                    main.log.warn( "Not all intents installed" )
+            if intentState:
+                break
+        else:
+            #Dumping intent summary
+            main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
+
+
+        utilities.assert_equals( expect=main.TRUE, actual=intentState,
+                                 onpass="INTENTS INSTALLED",
+                                 onfail="SOME INTENTS NOT INSTALLED" )
+
         main.step( "Verify Ping across all hosts" )
         pingResult = main.FALSE
         time1 = time.time()
-        pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+        pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+        if not pingResult:
+            main.log.info( "First pingall failed. Retrying..." )
+            time1 = time.time()
+            pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
         time2 = time.time()
         timeDiff = round( ( time2 - time1 ), 2 )
         main.log.report(
@@ -3014,7 +3091,7 @@
             str( timeDiff ) +
             " seconds" )
 
-        case96Result = pingResult
+        case96Result = ( pingResult and intentState )
         utilities.assert_equals(
             expect=main.TRUE,
             actual=case96Result,
@@ -3048,7 +3125,6 @@
                         name="addSinglepointToMultipointIntent",
                         args =[ingressDevice,egressDeviceList,'1',portEgressList,'',main.MACsDict.get(ingressDevice),''])
                 pool.append(t)
-                #time.sleep(1)
                 t.start()
                 i = i + 1
                 main.threadID = main.threadID + 1
@@ -3057,11 +3133,42 @@
                 intentIdList.append(thread.result)
         time2 = time.time()
         main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
-        time.sleep(5)
+
+        main.step("Verify intents are installed")
+
+        # Giving onos 3 chances to install intents
+        for i in range(3):
+            if i != 0:
+                main.log.warn( "Verification failed. Retrying..." )
+            main.log.info("Waiting for onos to install intents...")
+            time.sleep( main.checkIntentsDelay )
+
+            intentState = main.TRUE
+            for e in range(int(main.numCtrls)):
+                main.log.info( "Checking intents on CLI %s" % (e+1) )
+                intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+                        intentState
+                if not intentState:
+                    main.log.warn( "Not all intents installed" )
+            if intentState:
+                break
+        else:
+            #Dumping intent summary
+            main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
+
+
+        utilities.assert_equals( expect=main.TRUE, actual=intentState,
+                                 onpass="INTENTS INSTALLED",
+                                 onfail="SOME INTENTS NOT INSTALLED" )
+
         main.step( "Verify Ping across all hosts" )
         pingResult = main.FALSE
         time1 = time.time()
-        pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+        pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+        if not pingResult:
+            main.log.info( "First pingall failed. Retrying..." )
+            time1 = time.time()
+            pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
         time2 = time.time()
         timeDiff = round( ( time2 - time1 ), 2 )
         main.log.report(
@@ -3069,7 +3176,7 @@
             str( timeDiff ) +
             " seconds" )
 
-        case97Result = pingResult
+        case97Result = ( pingResult and intentState )
         utilities.assert_equals(
             expect=main.TRUE,
             actual=case97Result,
@@ -3110,7 +3217,6 @@
                         name="addSinglepointToMultipointIntent",
                         args =[ingressDevice,egressDeviceList,'1',portEgressList,'',MACsDictCopy.get(ingressDevice),''])
                 pool.append(t)
-                #time.sleep(1)
                 t.start()
                 i = i + 1
                 main.threadID = main.threadID + 1
@@ -3119,11 +3225,42 @@
                 intentIdList.append(thread.result)
         time2 = time.time()
         main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
-        time.sleep(5)
+
+        main.step("Verify intents are installed")
+
+        # Giving onos 3 chances to install intents
+        for i in range(3):
+            if i != 0:
+                main.log.warn( "Verification failed. Retrying..." )
+            main.log.info("Waiting for onos to install intents...")
+            time.sleep( main.checkIntentsDelay )
+
+            intentState = main.TRUE
+            for e in range(int(main.numCtrls)):
+                main.log.info( "Checking intents on CLI %s" % (e+1) )
+                intentState = main.CLIs[e].checkIntentState( intentsId = intentIdList ) and\
+                        intentState
+                if not intentState:
+                    main.log.warn( "Not all intents installed" )
+            if intentState:
+                break
+        else:
+            #Dumping intent summary
+            main.log.info( "Intents:\n" + str( main.ONOScli1.intents( jsonFormat=False, summary=True ) ) )
+
+
+        utilities.assert_equals( expect=main.TRUE, actual=intentState,
+                                 onpass="INTENTS INSTALLED",
+                                 onfail="SOME INTENTS NOT INSTALLED" )
+
         main.step( "Verify Ping across all hosts" )
         pingResult = main.FALSE
         time1 = time.time()
-        pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
+        pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
+        if not pingResult:
+            main.log.info( "First pingall failed. Retrying..." )
+            time1 = time.time()
+            pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
         time2 = time.time()
         timeDiff = round( ( time2 - time1 ), 2 )
         main.log.report(
@@ -3131,7 +3268,7 @@
             str( timeDiff ) +
             " seconds" )
 
-        case98Result = pingResult
+        case98Result = ( pingResult and intentState )
         utilities.assert_equals(
             expect=main.TRUE,
             actual=case98Result,
diff --git a/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py
index 7577d49..4bbc0bb 100644
--- a/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py
+++ b/TestON/tests/FUNCvirNetNB/FUNCvirNetNB.py
@@ -404,12 +404,12 @@
         Getstatus, result = main.ONOSrest.send( ctrlip, port, network.id, path+'networks/',
                                                 'GET', None, None )
         utilities.assert_equals(
-                expect='The tenantNetwork does not exists',
+                expect='Network is not found',
                 actual=result,
                 onpass="Get Success",
                 onfail="Get Failed " + str( Getstatus ) + str( result ) )
 
-        if result != 'The tenantNetwork does not exists':
+        if result != 'Network is not found':
             main.log.error( "Delete Network failed" )
 
     def CASE5( self, main ):
@@ -675,12 +675,12 @@
         Getstatus, result = main.ONOSrest.send( ctrlip, port, subnet.id, path + 'subnets/',
                                                  'GET', None, None )
         utilities.assert_equals(
-                expect='The subnet does not exists',
+                expect='Subnet is not found',
                 actual=result,
                 onpass="Get Subnet Success",
                 onfail="Get Subnet Failed " + str( Getstatus ) + str( result ) )
 
-        if result != 'The subnet does not exists':
+        if result != 'Subnet is not found':
             main.log.error( "Delete Subnet failed" )
 
     def CASE8( self, main ):
@@ -998,12 +998,12 @@
         Getstatus, result = main.ONOSrest.send( ctrlip, httpport, port.id, path + 'ports/',
                                                  'GET', None, None )
         utilities.assert_equals(
-                expect='The virtualPort does not exists',
+                expect='VirtualPort is not found',
                 actual=result,
                 onpass="Get Port Success",
                 onfail="Get Port Failed " + str( Getstatus ) + "," + str( result ) )
 
-        if result != 'The virtualPort does not exists':
+        if result != 'VirtualPort is not found':
             main.log.error( "Delete Port failed" )
 
         main.step( "Clean Data via HTTP" )
diff --git a/TestON/tests/USECASE_SdnipFunction/Dependency/Functions.py b/TestON/tests/USECASE_SdnipFunction/Dependency/Functions.py
index 8d99934..dcb2390 100644
--- a/TestON/tests/USECASE_SdnipFunction/Dependency/Functions.py
+++ b/TestON/tests/USECASE_SdnipFunction/Dependency/Functions.py
@@ -135,7 +135,9 @@
                              onpass = "Ping test results are expected",
                              onfail = "Ping test results are Not expected" )
 
+    '''
     if result == False:
         main.cleanup()
         main.exit()
+    '''
 
diff --git a/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.params b/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.params
index 5ba6b2d..6e00c17 100644
--- a/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.params
+++ b/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.params
@@ -37,6 +37,7 @@
 
     <timers>
         <SdnIpSetup>10</SdnIpSetup>
+        <TopoDiscovery>60</TopoDiscovery>
         <PingTestWithRoutes>20</PingTestWithRoutes>
         <PingTestWithoutRoutes>100</PingTestWithoutRoutes>
         <RouteDelivery>60</RouteDelivery>
diff --git a/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.py b/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.py
index 65166e8..9e160d3 100644
--- a/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.py
+++ b/TestON/tests/USECASE_SdnipFunction/USECASE_SdnipFunction.py
@@ -161,7 +161,7 @@
                          onfail = "ONOS CLI is NOT ready" )
 
         caseResult = ( cellResult and verifyResult and
-                       gitPullResult and mciResult and packageResult and
+                       gitPullResult2 and mciResult and packageResult and
                        onos1InstallResult and onos1UpResult and cliResult )
 
         utilities.assert_equals( expect = main.TRUE, actual = caseResult,
@@ -169,10 +169,21 @@
                                  onfail = "ONOS startup NOT successful" )
 
         if caseResult == main.FALSE:
+            main.log.info( "ONOS startup failed!" )
             main.cleanup()
             main.exit()
 
         main.log.info( "Get links in the network" )
+        time.sleep( int ( main.params['timers']['TopoDiscovery'] ) )
+        summaryResult = main.ONOScli.summary()
+        linkNum = json.loads( summaryResult )[ "links" ]
+        if linkNum < 100:
+            main.log.info( "Link number is wrong!" )
+            listResult = main.ONOScli.links( jsonFormat = False )
+            main.log.info( listResult )
+            main.cleanup()
+            main.exit()
+
         listResult = main.ONOScli.links( jsonFormat = False )
         main.log.info( listResult )
 
@@ -182,6 +193,11 @@
                                  actual = activeSDNIPresult,
                                  onpass = "Activate SDN-IP succeeded",
                                  onfail = "Activate SDN-IP failed" )
+        if not activeSDNIPresult:
+            main.log.info( "Activate SDN-IP failed!" )
+            main.cleanup()
+            main.exit()
+
 
         main.log.info( "Wait SDN-IP to finish installing connectivity intents \
         and the BGP paths in data plane are ready..." )
@@ -450,11 +466,9 @@
         main.case( "Stop edge sw32,check P-2-P and M-2-S intents, ping test" )
         main.step( "Stop sw32" )
         result = main.Mininet.switch( SW = "sw32", OPTION = "stop" )
-        utilities.assertEquals( \
-            expect = main.TRUE,
-            actual = result,
-            onpass = "Stopping switch succeeded!",
-            onfail = "Stopping switch failed!" )
+        utilities.assertEquals( expect = main.TRUE, actual = result,
+                                onpass = "Stopping switch succeeded!",
+                                onfail = "Stopping switch failed!" )
 
         if result == main.TRUE:
             time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
@@ -560,7 +574,7 @@
         main.case( "Stop sw11 located in best path, \
         check route number, P2P intent number, M2S intent number, ping test" )
 
-        main.step( "Check the flow number correctness before stopping sw11" )
+        main.log.info( "Check the flow number correctness before stopping sw11" )
         main.Functions.checkFlowNum( main, "sw11", 13 )
         main.Functions.checkFlowNum( main, "sw1", 3 )
         main.Functions.checkFlowNum( main, "sw7", 3 )
@@ -570,11 +584,9 @@
 
         main.step( "Stop sw11" )
         result = main.Mininet.switch( SW = "sw11", OPTION = "stop" )
-        utilities.assertEquals( \
-            expect = main.TRUE,
-            actual = result,
-            onpass = "Stopping switch succeeded!",
-            onfail = "Stopping switch failed!" )
+        utilities.assertEquals( expect = main.TRUE, actual = result,
+                                onpass = "Stopping switch succeeded!",
+                                onfail = "Stopping switch failed!" )
         if result:
             time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
             time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
@@ -609,7 +621,7 @@
         main.case( "Start sw11 which was stopped in CASE9, \
         check route number, P2P intent number, M2S intent number, ping test" )
 
-        main.step( "Check the flow status before starting sw11" )
+        main.log.info( "Check the flow status before starting sw11" )
         main.Functions.checkFlowNum( main, "sw1", 11 )
         main.Functions.checkFlowNum( main, "sw7", 5 )
         main.log.info( main.Mininet.checkFlows( "sw1" ) )
@@ -617,27 +629,22 @@
 
         main.step( "Start sw11" )
         result1 = main.Mininet.switch( SW = "sw11", OPTION = "start" )
-        utilities.assertEquals( \
-            expect = main.TRUE,
-            actual = result1,
-            onpass = "Starting switch succeeded!",
-            onfail = "Starting switch failed!" )
+        utilities.assertEquals( expect = main.TRUE, actual = result1,
+                                onpass = "Starting switch succeeded!",
+                                onfail = "Starting switch failed!" )
         result2 = main.Mininet.assignSwController( "sw11", ONOS1Ip )
-        utilities.assertEquals( \
-            expect = main.TRUE,
-            actual = result2,
-            onpass = "Connect switch to ONOS succeeded!",
-            onfail = "Connect switch to ONOS failed!" )
+        utilities.assertEquals( expect = main.TRUE, actual = result2,
+                                onpass = "Connect switch to ONOS succeeded!",
+                                onfail = "Connect switch to ONOS failed!" )
         if result1 and result2:
             time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
             main.Functions.checkRouteNum( main, 3 )
             main.Functions.checkM2SintentNum( main, 3 )
             main.Functions.checkP2PintentNum( main, 18 )
 
-            # log for debug
-            main.log.info( main.Mininet.checkFlows( "sw11" ) )
-            main.log.info( main.Mininet.checkFlows( "sw1" ) )
-            main.log.info( main.Mininet.checkFlows( "sw7" ) )
+            main.log.debug( main.Mininet.checkFlows( "sw11" ) )
+            main.log.debug( main.Mininet.checkFlows( "sw1" ) )
+            main.log.debug( main.Mininet.checkFlows( "sw7" ) )
         else:
             main.log.info( "Starting switch failed!" )
             main.cleanup()