Test Bandwidth Allocation with Intents
Change-Id: I5f47cdd8a50d34f12a2cb4b16de3a4f3b0b64043
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