Merge "Test Bandwidth Allocation with Intents"
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 5961a15..b208b3c 100755
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -29,7 +29,8 @@
 import os
 from drivers.common.clidriver import CLI
 from core.graph import Graph
-
+from cStringIO import StringIO
+from itertools import izip
 
 class OnosCliDriver( CLI ):
 
@@ -446,13 +447,15 @@
                 main.cleanup()
                 main.exit()
 
-    def sendline( self, cmdStr, showResponse=False, debug=False, timeout=10, noExit=False ):
+    def sendline( self, cmdStr, showResponse=False, debug=False, timeout=10, noExit=False, dollarSign=False ):
         """
         Send a completely user specified string to
         the onos> prompt. Use this function if you have
         a very specific command to send.
 
         if noExit is True, TestON will not exit, and return None
+        if dollarSign is True, TestON will not expect for '$' as a new CLI or onos> prompt
+        since '$' can be in the output.
 
         Warning: There are no sanity checking to commands
         sent using this method.
@@ -490,7 +493,10 @@
                 logStr = "\"Sending CLI command: '" + cmdStr + "'\""
                 self.log( logStr, noExit=noExit )
             self.handle.sendline( cmdStr )
-            i = self.handle.expect( ["onos>", "\$"], timeout )
+            if dollarSign:
+                i = self.handle.expect( ["onos>"], timeout )
+            else:
+                i = self.handle.expect( ["onos>", "\$"], timeout )
             response = self.handle.before
             # TODO: do something with i
             main.log.info( "Command '" + str( cmdStr ) + "' sent to "
@@ -1172,7 +1178,7 @@
             main.cleanup()
             main.exit()
 
-    def addHostIntent( self, hostIdOne, hostIdTwo, vlanId="", setVlan="", encap="" ):
+    def addHostIntent( self, hostIdOne, hostIdTwo, vlanId="", setVlan="", encap="", bandwidth="" ):
         """
         Required:
             * hostIdOne: ONOS host id for host1
@@ -1195,6 +1201,8 @@
                 cmdStr += "--setVlan " + str( vlanId ) + " "
             if encap:
                 cmdStr += "--encapsulation " + str( encap ) + " "
+            if bandwidth:
+                cmdStr += "-b " + str( bandwidth ) + " "
             cmdStr += str( hostIdOne ) + " " + str( hostIdTwo )
             handle = self.sendline( cmdStr )
             assert handle is not None, "Error in sendline"
@@ -2057,6 +2065,36 @@
             main.cleanup()
             main.exit()
 
+    #=============Function to check Bandwidth allocation========
+    def allocations( self, jsonFormat = True, dollarSign = True ):
+        """
+        Description:
+            Obtain Bandwidth Allocation Information from ONOS cli.
+        """
+        try:
+            cmdStr = "allocations"
+            if jsonFormat:
+                cmdStr += " -j"
+            handle = self.sendline( cmdStr, timeout=300, dollarSign=True )
+            assert handle is not None, "Error in sendline"
+            assert "Command not found:" not in handle, handle
+            return handle
+        except AssertionError:
+            main.log.exception( "" )
+            return None
+        except ( TypeError, ValueError ):
+            main.log.exception( "{}: Object not as expected: {!r}".format( self.name, handle ) )
+            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 intents( self, jsonFormat = True, summary = False, **intentargs):
         """
         Description:
@@ -2073,7 +2111,7 @@
                 cmdStr += " -s"
             if jsonFormat:
                 cmdStr += " -j"
-            handle = self.sendline( cmdStr )
+            handle = self.sendline( cmdStr, timeout=300 )
             assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             args = utilities.parse_args( [ "TYPE" ], **intentargs )
@@ -2122,6 +2160,7 @@
             and each dictionary maps 'id' to the Intent ID and 'state' to
             corresponding intent state.
         """
+
         try:
             state = "State is Undefined"
             if not intentsJson:
@@ -2166,13 +2205,15 @@
             main.cleanup()
             main.exit()
 
-    def checkIntentState( self, intentsId, expectedState='INSTALLED' ):
+    def checkIntentState( self, intentsId, bandwidthFlag=False, expectedState='INSTALLED' ):
         """
         Description:
             Check intents state
         Required:
             intentsId - List of intents ID to be checked
         Optional:
+            bandwidthFlag - Check the bandwidth allocations. If bandwidth is
+                                specified, then check for bandwidth allocations
             expectedState - Check the expected state(s) of each intents
                             state in the list.
                             *NOTE: You can pass in a list of expected state,
@@ -2190,6 +2231,34 @@
                                "getting intents state" )
                 return main.FALSE
 
+            failFlag = False
+            if bandwidthFlag:
+                rawAlloc = self.allocations()
+                expectedFormat = open( os.path.dirname( main.testFile ) + main.params[ 'DEPENDENCY' ][ 'filePath' ], 'r' )
+                ONOSOutput = StringIO(rawAlloc)
+
+                for actual,expected in izip(ONOSOutput,expectedFormat):
+                    actual = actual.rstrip()
+                    expected = expected.rstrip()
+                    if actual != expected and 'allocated' in actual and 'allocated' in expected:
+                        marker1 = actual.find('allocated')
+                        m1 = actual[:marker1]
+                        marker2 = expected.find('allocated')
+                        m2 = expected[:marker2]
+                        if m1 != m2:
+                            failFlag = True
+                    elif actual != expected and 'allocated' not in actual and 'allocated' not in expected:
+                        failFlag = True
+
+                expectedFormat.close()
+                ONOSOutput.close()
+                bandwidthFlag = False
+
+            if failFlag:
+                main.log.error("Bandwidth not allocated correctly using Intents!!")
+                returnValue = main.FALSE
+                return returnValue
+
             if isinstance( expectedState, types.StringType ):
                 for intents in intentsDict:
                     if intents.get( 'state' ) != expectedState:
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.params b/TestON/tests/FUNC/FUNCintent/FUNCintent.params
index e579b8b..b9b8ff7 100644
--- a/TestON/tests/FUNC/FUNCintent/FUNCintent.params
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.params
@@ -29,6 +29,7 @@
 
     <DEPENDENCY>
         <path>/tests/FUNC/FUNCintent/dependencies/</path>
+        <filePath>/dependencies/allocations.txt</filePath>
         <wrapper1>startUp</wrapper1>
         <wrapper2>FuncIntentFunction</wrapper2>
         <wrapper3>topo</wrapper3>
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.py b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
index f96ef73..8c9f07d 100644
--- a/TestON/tests/FUNC/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
@@ -1433,6 +1433,41 @@
                                  onpass=main.assertReturnString,
                                  onfail=main.assertReturnString )
 
+        main.step( "BANDWIDTH ALLOCATION: Checking bandwidth allocation for point intents between h1 and h9" )
+        main.assertReturnString = "Assertion Result for BANDWIDTH ALLOCATION for point intent\n"
+        senders = [
+            { "name":"h1","device":"of:0000000000000005/1" }
+        ]
+        recipients = [
+            { "name":"h9","device":"of:0000000000000006/1" }
+        ]
+        testResult = main.FALSE
+        installResult = main.intentFunction.installPointIntent(
+                                      main,
+                                      name="NOOPTION",
+                                      senders=senders,
+                                      recipients=recipients,
+                                      bandwidth=100,
+                                      bandwidthFlag=True )
+
+        if installResult:
+            testResult = main.intentFunction.testPointIntent(
+                                         main,
+                                         intentId=installResult,
+                                         name="NOOPTION",
+                                         senders=senders,
+                                         recipients=recipients,
+                                         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 )
+
         # Testing MPLS would require kernel version of 4.1 or higher (Current version is 3.13)
         # main.step( "Add point to point intents using MPLS Encapsulation" )
         # main.assertReturnString = "Assertion Result for MPLS Encapsulation Point Intent"
diff --git a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
index 48c0f27..1334c9f 100755
--- a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
+++ b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
@@ -10,6 +10,11 @@
 def __init__( self ):
     self.default = ''
 
+hostIntentFailFlag = False
+pointIntentFailFlag = False
+singleToMultiFailFlag = False
+multiToSingleFailFlag = False
+
 def installHostIntent( main,
                        name,
                        host1,
@@ -24,7 +29,8 @@
                        sw1="",
                        sw2="",
                        setVlan="",
-                       encap="" ):
+                       encap="",
+                       bandwidthFlag=False ):
     """
     Installs a Host Intent
 
@@ -64,6 +70,9 @@
     global itemName  # The name of this run. Used for logs.
     itemName = name
 
+    global hostIntentFailFlag
+    hostIntentFailFlag = False
+
     main.log.info( itemName + ": Adding single point to multi point intents" )
     try:
         if not host1.get( "id" ):
@@ -91,7 +100,7 @@
 
     # Check intents state
     if utilities.retry( f=checkIntentState, retValue=main.FALSE,
-                        args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=50 ):
+                        args=( main, [ intentId ], bandwidthFlag ), sleep=main.checkIntentSleep, attempts=50 ):
         main.assertReturnString += 'Install Intent State Passed\n'
 
         #Check VLAN if test encapsulation
@@ -110,6 +119,7 @@
 
     else:
         main.log.error( "Host Intent did not install correctly" )
+        hostIntentFailFlag = True
         main.assertReturnString += 'Install Intent State Failed\n'
         return main.FALSE
 
@@ -174,6 +184,8 @@
     global itemName
     itemName = name
 
+    global hostIntentFailFlag
+
     main.log.info( itemName + ": Testing Host Intent" )
 
     try:
@@ -197,12 +209,17 @@
     main.log.info( itemName + ": Testing Host to Host intents" )
 
     # Check intent state
+    if hostIntentFailFlag:
+        attempts = 1
+    else:
+        attempts = 50
     if utilities.retry( f=checkIntentState, retValue=main.FALSE,
-                        args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=50 ):
+                        args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=attempts ):
         main.assertReturnString += 'Initial Intent State Passed\n'
     else:
         main.assertReturnString += 'Initial Intent State Failed\n'
         testResult = main.FALSE
+        attempts = 1
 
     # Check flows count in each node
     if utilities.retry( f=checkFlowsCount, retValue=main.FALSE,
@@ -215,7 +232,7 @@
         testResult = main.FALSE
 
     # Check Connectivity
-    if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, attempts=50, sleep=main.checkConnectionSleep,
+    if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, attempts=attempts, sleep=main.checkConnectionSleep,
                         args=( main, senderNames, recipientNames, vlanId ) ):
         main.assertReturnString += 'Initial Ping Passed\n'
     else:
@@ -233,7 +250,7 @@
 
         # Check intent state
         if utilities.retry( f=checkIntentState, retValue=main.FALSE,
-                            args=( main, [ intentId ] ), sleep=main.checkIntentHostSleep, attempts=5 * 20 ):
+                            args=( main, [ intentId ] ), sleep=main.checkIntentHostSleep, attempts=attempts ):
             main.assertReturnString += 'Link Down Intent State Passed\n'
         else:
             main.assertReturnString += 'Link Down Intent State Failed\n'
@@ -241,8 +258,8 @@
 
         # Check flows count in each node
         if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=main.checkFlowCountSleep,
-                            attempts=200 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ],
-                                                                sleep=main.checkFlowCountSleep, attempts=200 ):
+                            attempts=attempts ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ],
+                                                                sleep=main.checkFlowCountSleep, attempts=attempts ):
             main.assertReturnString += 'Link Down Flow State Passed\n'
         else:
             main.assertReturnString += 'Link Down Flow State Failed\n'
@@ -258,7 +275,7 @@
         # Check Connection
         if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE,
                             args=( main, senderNames, recipientNames, vlanId ),
-                            sleep=main.checkConnectionSleep, attempts=5 * 20 ):
+                            sleep=main.checkConnectionSleep, attempts=attempts ):
             main.assertReturnString += 'Link Down Pingall Passed\n'
         else:
             main.assertReturnString += 'Link Down Pingall Failed\n'
@@ -275,7 +292,7 @@
         time.sleep( main.rerouteSleep )
 
         # Check Intents
-        if utilities.retry( f=checkIntentState, retValue=main.FALSE, attempts=100,
+        if utilities.retry( f=checkIntentState, retValue=main.FALSE, attempts=attempts * 2,
                             args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
             main.assertReturnString += 'Link Up Intent State Passed\n'
         else:
@@ -329,7 +346,8 @@
                         tcpSrc="",
                         tcpDst="",
                         setVlan="",
-                        encap="" ):
+                        encap="",
+                        bandwidthFlag=False ):
     """
     Installs a Single to Single Point Intent
 
@@ -374,6 +392,9 @@
     global itemName  # The name of this run. Used for logs.
     itemName = name
 
+    global pointIntentFailFlag
+    pointIntentFailFlag = False
+
     main.log.info( itemName + ": Adding point to point intents" )
 
     try:
@@ -429,9 +450,12 @@
 
     # Check intents state
     if utilities.retry( f=checkIntentState, retValue=main.FALSE,
-                        args=( main, [ intentId ] ), sleep=main.checkIntentSleep*2, attempts=50 ):
+            args=( main, [ intentId ], bandwidthFlag ), sleep=main.checkIntentSleep*2, attempts=50 ):
         main.assertReturnString += 'Install Intent State Passed\n'
 
+        if bandwidth != "":
+            main.assertReturnString += 'Bandwidth Allocation Passed\n'
+
         # Check VLAN if test encapsulation
         if encap != "":
             if EncapsulatedIntentCheck( main, tag=encap ):
@@ -446,7 +470,10 @@
             main.assertReturnString += 'Flow duration check failed\n'
             return main.FALSE
     else:
+        if bandwidth != "":
+            main.assertReturnString += 'Bandwidth Allocation Failed\n'
         main.log.error( "Point Intent did not install correctly" )
+        pointIntentFailFlag = True
         return main.FALSE
 
 def pointIntentTcp( main,
@@ -745,7 +772,8 @@
                                 sw2="",
                                 setVlan="",
                                 partial=False,
-                                encap="" ):
+                                encap="",
+                                bandwidthFlag=False ):
     """
     Installs a Single to Multi Point Intent
 
@@ -791,6 +819,9 @@
     global itemName  # The name of this run. Used for logs.
     itemName = name
 
+    global singleToMultiFailFlag
+    singleToMultiFailFlag = False
+
     main.log.info( itemName + ": Adding single point to multi point intents" )
 
     try:
@@ -840,11 +871,17 @@
         if intentId:
             errorMsg += "  There was a problem installing Singlepoint to Multipoint intent."
         main.log.error( errorMsg )
+        singleToMultiFailFlag = True
         return main.FALSE
 
     # Check intents state
+    if singleToMultiFailFlag:
+        attempts = 5
+    else:
+        attempts = 50
+
     if utilities.retry( f=checkIntentState, retValue=main.FALSE,
-                        args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=50 ):
+                        args=( main, [ intentId ], bandwidthFlag ), sleep=main.checkIntentSleep, attempts=attempts ):
         main.assertReturnString += 'Install Intent State Passed\n'
         if flowDuration( main ):
             main.assertReturnString += 'Flow duration check Passed\n'
@@ -854,6 +891,7 @@
             return main.FALSE
     else:
         main.log.error( "Single to Multi Intent did not install correctly" )
+        singleToMultiFailFlag = True
         return main.FALSE
 
 def installMultiToSingleIntent( main,
@@ -871,7 +909,8 @@
                                 sw2="",
                                 setVlan="",
                                 partial=False,
-                                encap="" ):
+                                encap="",
+                                bandwidthFlag=False ):
     """
     Installs a Multi to Single Point Intent
 
@@ -917,6 +956,9 @@
     global itemName  # The name of this run. Used for logs.
     itemName = name
 
+    global multiToSingleFailFlag
+    multiToSingleFailFlag = False
+
     main.log.info( itemName + ": Adding mutli to single point intents" )
 
     try:
@@ -965,11 +1007,17 @@
         if intentId:
             errorMsg += "  There was a problem installing Multipoint to Singlepoint intent."
         main.log.error( errorMsg )
+        multiToSingleFailFlag = True
         return main.FALSE
 
     # Check intents state
+    if multiToSingleFailFlag:
+        attempts = 5
+    else:
+        attempts = 50
+
     if utilities.retry( f=checkIntentState, retValue=main.FALSE,
-                        args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=50 ):
+                        args=( main, [ intentId ], bandwidthFlag ), sleep=main.checkIntentSleep, attempts=attempts ):
         main.assertReturnString += 'Install Intent State Passed\n'
         if flowDuration( main ):
             main.assertReturnString += 'Flow duration check Passed\n'
@@ -979,6 +1027,7 @@
             return main.FALSE
     else:
         main.log.error( "Multi to Single Intent did not install correctly" )
+        multiToSingleFailFlag = True
         return main.FALSE
 
 def testPointIntent( main,
@@ -1057,6 +1106,10 @@
     global itemName
     itemName = name
 
+    global pointIntentFailFlag
+    global singleToMultiFailFlag
+    global multiToSingleFailFlag
+
     main.log.info( itemName + ": Testing Point Intent" )
 
     try:
@@ -1083,13 +1136,19 @@
     testResult = main.TRUE
     main.log.info( itemName + ": Adding single point to multi point intents" )
 
+    if pointIntentFailFlag or singleToMultiFailFlag or multiToSingleFailFlag:
+        attempts = 1
+    else:
+        attempts = 50
+
     # Check intent state
     if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ),
-                        sleep=main.checkIntentSleep, attempts=50 ):
+                        sleep=main.checkIntentSleep, attempts=attempts ):
         main.assertReturnString += 'Initial Intent State Passed\n'
     else:
         main.assertReturnString += 'Initial Intent State Failed\n'
         testResult = main.FALSE
+        attempts = 1
 
     # Check flows count in each node
     if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ],
@@ -1103,7 +1162,7 @@
     # Check Connectivity
     if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE,
                         args=( main, senderNames, recipientNames, vlanId, useTCP ),
-                        attempts=50, sleep=main.checkConnectionSleep ):
+                        attempts=attempts, sleep=main.checkConnectionSleep ):
         main.assertReturnString += 'Initial Ping Passed\n'
     else:
         main.assertReturnString += 'Initial Ping Failed\n'
@@ -1152,7 +1211,7 @@
 
         # Check intent state
         if utilities.retry( f=checkIntentState, retValue=main.FALSE, args=( main, [ intentId ] ),
-                            sleep=main.checkIntentPointSleep, attempts=5 * 20 ):
+                            sleep=main.checkIntentPointSleep, attempts=attempts ):
             main.assertReturnString += 'Link Down Intent State Passed\n'
         else:
             main.assertReturnString += 'Link Down Intent State Failed\n'
@@ -1160,8 +1219,8 @@
 
         # Check flows count in each node
         if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=main.checkFlowCountSleep,
-                            attempts=200 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ],
-                                                                sleep=main.checkFlowCountSleep, attempts=200 ):
+                            attempts=attempts * 2 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ],
+                                                                sleep=main.checkFlowCountSleep, attempts=attempts * 2 ):
             main.assertReturnString += 'Link Down Flow State Passed\n'
         else:
             main.assertReturnString += 'Link Down Flow State Failed\n'
@@ -1177,7 +1236,7 @@
         # Check Connection
         if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE,
                             args=( main, senderNames, recipientNames, vlanId, useTCP ),
-                            sleep=main.checkConnectionSleep, attempts=5 * 10 ):
+                            sleep=main.checkConnectionSleep, attempts=attempts ):
             main.assertReturnString += 'Link Down Pingall Passed\n'
         else:
             main.assertReturnString += 'Link Down Pingall Failed\n'
@@ -1194,7 +1253,7 @@
         time.sleep( main.rerouteSleep )
 
         # Check Intents
-        if utilities.retry( f=checkIntentState, retValue=main.FALSE, attempts=100, args=( main, [ intentId ] ),
+        if utilities.retry( f=checkIntentState, retValue=main.FALSE, attempts=attempts * 2, args=( main, [ intentId ] ),
                             sleep=main.checkIntentSleep ):
             main.assertReturnString += 'Link Up Intent State Passed\n'
         else:
@@ -1268,6 +1327,9 @@
     global itemName
     itemName = name
 
+    global singleToMultiFailFlag
+    global multiToSingleFailFlag
+
     main.log.info( itemName + ": Testing Point Intent" )
 
     try:
@@ -1297,12 +1359,18 @@
     main.log.info( itemName + ": Adding multi point to single point intents" )
 
     # Check intent state
+    if singleToMultiFailFlag or multiToSingleFailFlag:
+        attempts = 1
+    else:
+        attempts = 50
+
     if utilities.retry( f=checkIntentState, retValue=main.FALSE,
-                        args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=50 ):
+                        args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=attempts ):
         main.assertReturnString += 'Initial Intent State Passed\n'
     else:
         main.assertReturnString += 'Initial Intent State Failed\n'
         testResult = main.FALSE
+        attempts = 1
 
     # Check flows count in each node
     if utilities.retry( f=checkFlowsCount, retValue=main.FALSE,
@@ -1338,7 +1406,7 @@
         testResult = main.FALSE
 
     # Check intent state
-    if utilities.retry( f=checkIntentState, retValue=main.FALSE, attempts=100,
+    if utilities.retry( f=checkIntentState, retValue=main.FALSE, attempts=attempts,
                         args=( main, [ intentId ] ), sleep=main.checkIntentSleep ):
         main.assertReturnString += 'Link Down Intent State Passed\n'
     else:
@@ -1346,9 +1414,9 @@
         testResult = main.FALSE
 
     # Check flows count in each node
-    if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, sleep=1, attempts=30,
+    if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, sleep=1, attempts=attempts,
                         args=[ main ] ) and utilities.retry( f=checkFlowsState,
-                                                             retValue=main.FALSE, sleep=1, attempts=30, args=[ main ] ):
+                                                             retValue=main.FALSE, sleep=1, attempts=attempts, args=[ main ] ):
         main.assertReturnString += 'Link Down Flow State Passed\n'
     else:
         main.assertReturnString += 'Link Down Flow State Failed\n'
@@ -1379,7 +1447,7 @@
     if partial:
         # Check intent state
         if utilities.retry( f=checkIntentState, retValue=main.FALSE,
-                            args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=50 ):
+                            args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=attempts ):
             main.assertReturnString += 'Partial failure isolation link Down Intent State Passed\n'
         else:
             main.assertReturnString += 'Partial failure isolation link Down Intent State Failed\n'
@@ -1420,7 +1488,7 @@
                 testResult = main.FALSE
 
         # Next check connectivity of connected senders and recipients
-        if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, attempts=50,
+        if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, attempts=attempts,
                             args=( main, connectedSenderNames , connectedRecipientNames ) ):
             main.assertReturnString += 'Partial failure isolation link Down Connectivity Check Passed\n'
         else:
@@ -1429,7 +1497,7 @@
     else:
         # Check intent state
         if not utilities.retry( f=checkIntentState, retValue=main.TRUE,
-                            args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=50 ):
+                            args=( main, [ intentId ] ), sleep=main.checkIntentSleep, attempts=attempts ):
             main.assertReturnString += 'Isolation link Down Intent State Passed\n'
         else:
             main.assertReturnString += 'Isolation link Down Intent State Failed\n'
@@ -1503,7 +1571,7 @@
     time.sleep( main.rerouteSleep )
 
     # Check Intents
-    if utilities.retry( f=checkIntentState, retValue=main.FALSE, attempts=5 * 20,
+    if utilities.retry( f=checkIntentState, retValue=main.FALSE, attempts=attempts,
                         args=( main, [ intentId ] ), sleep=main.checkIntentHostSleep ):
         main.assertReturnString += 'Link Up Intent State Passed\n'
     else:
@@ -1514,7 +1582,7 @@
     if utilities.retry( f=checkFlowsCount, retValue=main.FALSE,
                         args=[ main ], sleep=5, attempts=5*20 ) and utilities.retry( f=checkFlowsState,
                                                                          retValue=main.FALSE,
-                                                                         args=[ main ], sleep=5, attempts=5*20 ):
+                                                                         args=[ main ], sleep=5, attempts=attempts ):
         main.assertReturnString += 'Link Up Flow State Passed\n'
     else:
         main.assertReturnString += 'Link Up Flow State Failed\n'
@@ -1528,7 +1596,7 @@
         testResult = main.FALSE
 
     # Check Connection
-    if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, sleep=main.checkConnectionSleep, attempts= 100,
+    if utilities.retry( f=scapyCheckConnection, retValue=main.FALSE, sleep=main.checkConnectionSleep, attempts= attempts,
                         args=( main, senderNames, recipientNames ) ):
         main.assertReturnString += 'Link Up Scapy Packet Received Passed\n'
     else:
@@ -1699,7 +1767,7 @@
         main.log.info( itemName + ": Topology match" )
     return statusResult
 
-def checkIntentState( main, intentsId ):
+def checkIntentState( main, intentsId, bandwidthFlag=False ):
     """
         This function will check intent state to make sure all the intents
         are in INSTALLED state
@@ -1709,7 +1777,7 @@
     results = []
 
     for i in range( main.numCtrls ):
-        tempResult = main.CLIs[ i ].checkIntentState( intentsId=intentsId )
+        tempResult = main.CLIs[ i ].checkIntentState( intentsId=intentsId, bandwidthFlag=bandwidthFlag )
         results.append( tempResult )
 
     if all( result == main.TRUE for result in results ):
diff --git a/TestON/tests/FUNC/FUNCintent/dependencies/allocations.txt b/TestON/tests/FUNC/FUNCintent/dependencies/allocations.txt
new file mode 100644
index 0000000..760fcdd
--- /dev/null
+++ b/TestON/tests/FUNC/FUNCintent/dependencies/allocations.txt
@@ -0,0 +1,65 @@
+ROOT
+ of:0000000000000003
+  PortNumber:LOCAL
+  PortNumber:1
+  PortNumber:2
+  PortNumber:3
+  PortNumber:4
+ of:0000000000000004
+  PortNumber:LOCAL
+  PortNumber:1
+  PortNumber:2
+  PortNumber:3
+ of:0000000000000001
+  PortNumber:LOCAL
+  PortNumber:1
+  PortNumber:2
+  PortNumber:3
+  PortNumber:4
+ of:0000000000000002
+  PortNumber:LOCAL
+  PortNumber:1
+  PortNumber:2
+  PortNumber:3
+   100.0 allocated by
+  PortNumber:4
+   100.0 allocated by
+ of:0000000000000007
+  PortNumber:LOCAL
+  PortNumber:1
+  PortNumber:2
+  PortNumber:3
+  PortNumber:4
+  PortNumber:5
+  PortNumber:6
+  PortNumber:7
+  PortNumber:8
+  PortNumber:9
+ of:0000000000000005
+  PortNumber:LOCAL
+  PortNumber:1
+   100.0 allocated by
+  PortNumber:2
+  PortNumber:3
+  PortNumber:4
+  PortNumber:5
+  PortNumber:6
+  PortNumber:7
+  PortNumber:8
+  PortNumber:9
+  PortNumber:10
+   100.0 allocated by org.onosproject.net
+ of:0000000000000006
+  PortNumber:LOCAL
+  PortNumber:1
+   100.0 allocated by org.onosproject.net
+  PortNumber:2
+  PortNumber:3
+  PortNumber:4
+  PortNumber:5
+  PortNumber:6
+  PortNumber:7
+  PortNumber:8
+  PortNumber:9
+   100.0 allocated by org.onosproject.net
+  PortNumber:10