Refactored test
Change-Id: If1e16719fc5adbdfea24ce2cdaa0186ce8edfd17
diff --git a/TestON/tests/SCPFmaxIntents/Dependency/maxIntentFunctions.py b/TestON/tests/SCPFmaxIntents/Dependency/maxIntentFunctions.py
index 87f2015..268279c 100644
--- a/TestON/tests/SCPFmaxIntents/Dependency/maxIntentFunctions.py
+++ b/TestON/tests/SCPFmaxIntents/Dependency/maxIntentFunctions.py
@@ -72,7 +72,7 @@
main.log.exception("Timeout exception caught in pushIntents")
return main.FALSE
-def verifyFlows( main, expectedFlows, state="ADDED", sleep=1, timeout=120):
+def verifyFlows( main, expectedFlows, state="ADDED", sleep=1, numcheck=10, timeout=120):
'''
This function returns main.TRUE if the number of expected flows are in
the specified state
@@ -80,17 +80,19 @@
@params
expectedFlows: the flows you expect to see in the specified state
state: the state of the flow to check for
+ sleep: how long it should sleep for each check
+ numcheck: how many times it should check
timeout: the timeout for pexpect
'''
cmd = "flows | grep " + state + " | wc -l"
- for i in range(10):
+ for i in range(numcheck):
flows = getFlows( main, state, sleep, timeout )
if expectedFlows == flows:
return main.TRUE
return main.FALSE
-def verifyIntents( main, expectedIntents, state="INSTALLED", sleep=1, timeout=120):
+def verifyIntents( main, expectedIntents, state="INSTALLED", sleep=1, numcheck=10, timeout=120):
'''
This function returns main.TRUE if the number of expected intents are in
the specified state
@@ -98,12 +100,15 @@
@params
expectedFlows: the intents you expect to see in the specified state
state: the state of the intent to check for
+ sleep: how long it should sleep for each check
+ numcheck: how many times it should check
timeout: the timeout for pexpect
'''
cmd = "intents | grep " + state + " | wc -l"
- for i in range(10):
+ for i in range(numcheck):
intents = getIntents( main, state, sleep, timeout )
if expectedIntents == intents:
return main.TRUE
+ time.sleep(sleep)
return main.FALSE
diff --git a/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.params b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.params
index a4231d9..7c999f8 100755
--- a/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.params
+++ b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.params
@@ -1,9 +1,12 @@
<PARAMS>
- # 0-init, 1-setup, 10-null provider setup,
- # 11-mininet setup, 20-pushing intents,
+ # 0-init
+ # 1-setup
+ # 10-null provider setup
+ # 11-mininet setup
+ # 20-pushing intents,
# 21-rerouting intents
- # 0,1,10,20,1,11,20,1,10,21,1,11,21,100
+ # 0,1,11,20,1,11,21,1,10,20,1,10,21,100
<testcases>0,1,11,20,1,11,21,1,10,20,1,10,21,100</testcases>
<SCALE>
@@ -34,23 +37,24 @@
<SLEEP>
<startup>3</startup>
- <install>5</install>
- <verify>15</verify>
- <reroute>15</reroute>
+ <install>0</install>
+ <verify>0</verify>
+ <reroute>3</reroute>
# timeout for pexpect
<timeout>120</timeout>
</SLEEP>
<DATABASE>
+ <file>MaxIntentDB</file>
<nic>1gig</nic>
<node>baremetal</node>
</DATABASE>
<TEST>
- <batch_size>1000</batch_size>
+ <batch_size>10000</batch_size>
<min_intents>800000</min_intents>
<max_intents>1000000</max_intents>
- <check_interval>10000</check_interval>
+ <check_interval>20000</check_interval>
</TEST>
</PARAMS>
diff --git a/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py
index 762f6fd..a790864 100644
--- a/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py
+++ b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py
@@ -37,7 +37,6 @@
main.params['DEPENDENCY']['path']
main.cellName = main.params[ 'ENV' ][ 'cellName' ]
main.apps = main.params[ 'ENV' ][ 'cellApps' ]
- gitBranch = main.params[ 'GIT' ][ 'branch' ]
main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," )
main.maxNodes = int( main.params[ 'SCALE' ][ 'max' ] )
@@ -46,32 +45,42 @@
main.minIntents = int(main.params['TEST']['min_intents'])
main.maxIntents = int(main.params['TEST']['max_intents'])
main.checkInterval = int(main.params['TEST']['check_interval'])
- wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
- wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] )
main.rerouteSleep = int ( main.params['SLEEP']['reroute'] )
- gitPull = main.params[ 'GIT' ][ 'pull' ]
main.batchSize = int(main.params['TEST']['batch_size'])
- nic = main.params['DATABASE']['nic']
- node = main.params['DATABASE']['node']
+ main.dbFileName = main.params['DATABASE']['file']
main.cellData = {} # for creating cell file
main.CLIs = []
main.ONOSip = []
main.maxNumBatch = 0
-
main.ONOSip = main.ONOSbench.getOnosIps()
main.log.info(main.ONOSip)
+ main.setupSkipped = False
+
+ wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
+ wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
+ gitBranch = main.params[ 'GIT' ][ 'branch' ]
+ gitPull = main.params[ 'GIT' ][ 'pull' ]
+ nic = main.params['DATABASE']['nic']
+ node = main.params['DATABASE']['node']
+ nic = main.params['DATABASE']['nic']
+ node = main.params['DATABASE']['node']
# main.scale[ 0 ] determines the current number of ONOS controller
main.numCtrls = int( main.scale[ 0 ] )
- # Assigning ONOS cli handles to a list
- for i in range( 1, main.maxNodes + 1 ):
- main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+ main.log.info("Creating list of ONOS cli handles")
+ for i in range(main.maxNodes):
+ main.CLIs.append( getattr( main, 'ONOScli' + str( i+1 )))
- # -- INIT SECTION, ONLY RUNS ONCE -- #
+ if not main.CLIs:
+ main.log.error("Failed to create the list of ONOS cli handles")
+ main.cleanup()
+ main.exit()
+
+ main.log.info("Loading wrapper files")
main.startUp = imp.load_source( wrapperFile1,
main.dependencyPath +
wrapperFile1 +
@@ -87,43 +96,26 @@
main.Mininet1.user_name,
main.Mininet1.ip_address )
- if main.CLIs:
- stepResult = main.TRUE
- else:
- main.log.error( "Did not properly created list of ONOS CLI handle" )
- stepResult = main.FALSE
-
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully construct " +
- "test variables ",
- onfail="Failed to construct test variables" )
+ commit = main.ONOSbench.getVersion(report=True)
+ commit = commit.split(" ")[1]
if gitPull == 'True':
- main.step( "Building ONOS in " + gitBranch + " branch" )
- onosBuildResult = main.startUp.onosBuild( main, gitBranch )
- stepResult = onosBuildResult
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully compiled " +
- "latest ONOS",
- onfail="Failed to compile " +
- "latest ONOS" )
+ if not main.startUp.onosBuild( main, gitBranch ):
+ main.log.error("Failed to build ONOS")
+ main.cleanup()
+ main.exit()
else:
main.log.warn( "Did not pull new code so skipping mvn " +
"clean install" )
- main.case( "Starting up " + str( main.numCtrls ) +
- " node(s) ONOS cluster" )
-
- # kill off all onos processes
+ main.log.info( "Starting up %s node(s) ONOS cluster" % main.numCtrls)
main.log.info( "Safety check, killing all ONOS processes" +
" before initiating enviornment setup" )
for i in range( main.maxNodes ):
main.ONOSbench.onosDie( main.ONOSip[ i ] )
- main.log.info( "NODE COUNT = " + str( main.numCtrls))
+ main.log.info( "NODE COUNT = %s" % main.numCtrls)
tempOnosIp = []
for i in range( main.numCtrls ):
@@ -135,42 +127,27 @@
main.apps,
tempOnosIp )
- main.step( "Apply cell to environment" )
- cellResult = main.ONOSbench.setCell( "temp" )
- verifyResult = main.ONOSbench.verifyCell()
- stepResult = cellResult and verifyResult
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully applied cell to " + \
- "environment",
- onfail="Failed to apply cell to environment " )
+ main.log.info( "Applying cell to environment" )
+ cell = main.ONOSbench.setCell( "temp" )
+ verify = main.ONOSbench.verifyCell()
+ if not cell or not verify:
+ main.log.error("Failed to apply cell to environment")
+ main.cleanup()
+ main.exit()
- main.step( "Creating ONOS package" )
- packageResult = main.ONOSbench.onosPackage()
- stepResult = packageResult
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully created ONOS package",
- onfail="Failed to create ONOS package" )
-
- commit = main.ONOSbench.getVersion()
- commit = commit.split(" ")[1]
+ main.log.info( "Creating ONOS package" )
+ if not main.ONOSbench.onosPackage():
+ main.log.error("Failed to create ONOS package")
+ main.cleanup()
+ main.exit()
main.log.info("Creating DB file")
- nic = main.params['DATABASE']['nic']
- node = main.params['DATABASE']['node']
-
- try:
- dbFileName="/tmp/MaxIntentDB"
- dbfile = open(dbFileName, "w+")
+ with open(main.dbFileName, "w+") as dbFile:
temp = "'" + commit + "',"
temp += "'" + nic + "',"
temp += str(main.numCtrls) + ","
temp += "'" + node + "1" + "'"
- dbfile.write(temp)
- dbfile.close()
- except IOError:
- main.log.warn("Error opening " + dbFileName + " to write results.")
+ dbFile.write(temp)
def CASE1( self, main ):
"""
@@ -179,63 +156,37 @@
- Install ONOS cluster
- Connect to cli
"""
- main.step( "Uninstalling ONOS package" )
- onosUninstallResult = main.TRUE
+
+ main.log.info( "Uninstalling ONOS package" )
+ main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[i] )
for i in range( main.maxNodes ):
- onosUninstallResult = onosUninstallResult and \
- main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] )
- stepResult = onosUninstallResult
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully uninstalled ONOS package",
- onfail="Failed to uninstall ONOS package" )
+ if not main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[i] ):
+ main.log.error("Failed to uninstall onos on node %s" % (i+1))
+ main.cleanup()
+ main.exit()
- time.sleep( main.startUpSleep )
- main.step( "Installing ONOS package" )
- onosInstallResult = main.TRUE
+ main.log.info( "Installing ONOS package" )
for i in range( main.numCtrls ):
- onosInstallResult = onosInstallResult and \
- main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
- stepResult = onosInstallResult
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully installed ONOS package",
- onfail="Failed to install ONOS package" )
+ if not main.ONOSbench.onosInstall( node=main.ONOSip[i] ):
+ main.log.error("Failed to install onos on node %s" % (i+1))
+ main.cleanup()
+ main.exit()
- main.step( "Starting ONOS service" )
- stopResult = main.TRUE
- startResult = main.TRUE
- onosIsUp = main.TRUE
-
+ main.log.info( "Starting ONOS service" )
for i in range( main.numCtrls ):
- onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
- if onosIsUp == main.TRUE:
- main.log.report( "ONOS instance is up and ready" )
- else:
- main.log.report( "ONOS instance may not be up, stop and " +
- "start ONOS again " )
- for i in range( main.numCtrls ):
- stopResult = stopResult and \
- main.ONOSbench.onosStop( main.ONOSip[ i ] )
- for i in range( main.numCtrls ):
- startResult = startResult and \
- main.ONOSbench.onosStart( main.ONOSip[ i ] )
- stepResult = onosIsUp and stopResult and startResult
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="ONOS service is ready",
- onfail="ONOS service did not start properly" )
+ start = main.ONOSbench.onosStart( main.ONOSip[i] )
+ isup = main.ONOSbench.isup( main.ONOSip[i] )
+ if not start or not isup:
+ main.log.error("Failed to start onos service on node %s" % (i+1))
+ main.cleanup()
+ main.exit()
- main.step( "Start ONOS cli" )
- cliResult = main.TRUE
+ main.log.info( "Starting ONOS cli" )
for i in range( main.numCtrls ):
- cliResult = cliResult and \
- main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
- stepResult = cliResult
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully start ONOS cli",
- onfail="Failed to start ONOS cli" )
+ if not main.CLIs[i].startOnosCli( main.ONOSip[i] ):
+ main.log.error("Failed to start onos cli on node %s" % (i+1))
+ main.cleanup()
+ main.exit()
def CASE10( self, main ):
"""
@@ -245,49 +196,36 @@
import pexpect
# Activate apps
- main.log.step("Activating apps")
- stepResult = main.CLIs[0].activateApp('org.onosproject.null')
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully activated null-provider",
- onfail="Failed to activate null-provider")
+ main.log.info("Activating null-provider")
+ appStatus = main.CLIs[0].activateApp('org.onosproject.null')
+ if not appStatus:
+ main.log.error("Failed to activate null-provider")
# Setup the null-provider
- main.log.step("Configuring null-provider")
- stepResult = main.FALSE
- for i in range(3):
- main.ONOSbench.onosCfgSet( main.ONOSip[0],
- 'org.onosproject.provider.nil.NullProviders',
- 'deviceCount 3' )
- main.ONOSbench.onosCfgSet( main.ONOSip[0],
- 'org.onosproject.provider.nil.NullProviders',
- 'topoShape reroute' )
- main.ONOSbench.onosCfgSet( main.ONOSip[0],
- 'org.onosproject.provider.nil.NullProviders',
- 'enabled true' )
- # give onos some time to settle
- time.sleep(main.startUpSleep)
- jsonSum = json.loads(main.CLIs[0].summary())
- if jsonSum['devices'] == 3 and jsonSum['SCC(s)'] == 1:
- stepResult = main.TRUE
- break
- utilities.assert_equals( expect=stepResult,
- actual=stepResult,
- onpass="Successfully configured the null-provider",
- onfail="Failed to configure the null-provider")
+ main.log.info("Configuring null-provider")
+ cfgStatus = main.ONOSbench.onosCfgSet( main.ONOSip[0],
+ 'org.onosproject.provider.nil.NullProviders', 'deviceCount 3' )
+ cfgStatus = cfgStatus and main.ONOSbench.onosCfgSet( main.ONOSip[0],
+ 'org.onosproject.provider.nil.NullProviders', 'topoShape reroute' )
+ cfgStatus = cfgStatus and main.ONOSbench.onosCfgSet( main.ONOSip[0],
+ 'org.onosproject.provider.nil.NullProviders', 'enabled true' )
+ if not cfgStatus:
+ main.log.error("Failed to configure null-provider")
- main.log.step("Get default flows")
- jsonSum = json.loads(main.CLIs[0].summary())
+ # give onos some time to settle
+ time.sleep(main.startUpSleep)
- # flows installed by the null-provider
- main.defaultFlows = jsonSum["flows"]
+ main.defaultFlows = 0
main.ingress = ":0000000000000001/3"
main.egress = ":0000000000000003/2"
main.switch = "null"
main.linkUpCmd = "null-link null:0000000000000001/3 null:0000000000000003/1 up"
main.linkDownCmd = "null-link null:0000000000000001/3 null:0000000000000003/1 down"
+ if not appStatus or not cfgStatus:
+ main.setupSkipped = True
+
def CASE11( self, main ):
'''
Setting up mininet
@@ -295,37 +233,33 @@
import json
import time
- # Activate apps
- main.log.step("Activating apps")
- stepResult = main.CLIs[0].activateApp('org.onosproject.openflow')
+ main.log.step("Activating openflow")
+ appStatus = main.CLIs[0].activateApp('org.onosproject.openflow')
+ if appStatus:
+ main.log.error("Failed to activate openflow")
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully activated openflow",
- onfail="Failed to activate openflow")
- # give onos some time settle
time.sleep(main.startUpSleep)
- main.log.step('Starting mininet topology')
- main.Mininet1.startNet(topoFile='~/mininet/custom/rerouteTopo.py')
- main.Mininet1.assignSwController(sw='s1', ip=main.ONOSip[0])
- main.Mininet1.assignSwController(sw='s2', ip=main.ONOSip[0])
- main.Mininet1.assignSwController(sw='s3', ip=main.ONOSip[0])
+ main.log.info('Starting mininet topology')
+ mnStatus = main.Mininet1.startNet(topoFile='~/mininet/custom/rerouteTopo.py')
+ if mnStatus:
+ main.log.error("Failed to start mininet")
+
+ main.log.info("Assinging masters to switches")
+ swStatus = main.Mininet1.assignSwController(sw='s1', ip=main.ONOSip[0])
+ swStatus = swStatus and main.Mininet1.assignSwController(sw='s2', ip=main.ONOSip[0])
+ swStatus = swStatus and main.Mininet1.assignSwController(sw='s3', ip=main.ONOSip[0])
+ if not swStatus:
+ main.log.info("Failed to assign masters to switches")
+
time.sleep(main.startUpSleep)
jsonSum = json.loads(main.CLIs[0].summary())
- if jsonSum['devices'] == 3 and jsonSum['SCC(s)'] == 1:
- stepResult = main.TRUE
+ sumStatus = (jsonSum['devices'] == 3 and jsonSum['SCC(s)'] == 1)
- utilities.assert_equals( expect=stepResult,
- actual=stepResult,
- onpass="Successfully assigned switches to their master",
- onfail="Failed to assign switches")
-
- main.log.step("Get default flows")
+ main.log.step("Getting default flows")
jsonSum = json.loads(main.CLIs[0].summary())
- # flows installed by the null-provider
main.defaultFlows = jsonSum["flows"]
main.ingress = ":0000000000000001/3"
main.egress = ":0000000000000003/2"
@@ -333,12 +267,20 @@
main.linkDownCmd = 'link s1 s3 down'
main.linkUpCmd = 'link s1 s3 up'
+ if not appStatus or not mnStatus or not swStatus or not sumStatus:
+ main.setupSkipped = True
def CASE20( self, main ):
import pexpect
'''
Pushing intents
'''
+
+ # check if the setup case has been skipped
+ if main.setupSkipped:
+ main.setupSkipped = False
+ main.skipCase()
+
# the index where the next intents will be installed
offset = 0
# the number of intents we expect to be in the installed state
@@ -354,77 +296,52 @@
for i in range(limit):
# Push intents
- main.log.step("Pushing intents")
- stepResult = main.intentFunctions.pushIntents( main,
- main.switch,
- main.ingress,
- main.egress,
- main.batchSize,
- offset,
- sleep=main.installSleep,
- timeout=main.timeout,
- options="-i" )
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully pushed intents",
- onfail="Failed to push intents")
- if stepResult == main.FALSE:
- break
+ main.log.info("Pushing intents")
+ main.intentFunctions.pushIntents( main,
+ main.switch,
+ main.ingress,
+ main.egress,
+ main.batchSize,
+ offset,
+ sleep=main.installSleep,
+ timeout=main.timeout,
+ options="-i" )
offset += main.batchSize
expectedIntents = offset
expectedFlows += main.batchSize*2
+ main.log.info("Grabbing number of installed intents and flows")
maxIntents = main.intentFunctions.getIntents( main )
maxFlows = main.intentFunctions.getFlows( main )
if offset >= main.minIntents and offset % main.checkInterval == 0 or expectedIntents == main.maxIntents:
# Verifying intents
- main.log.step("Verifying intents")
- main.log.info("Expected intents: " + str(expectedIntents))
- stepResult = main.intentFunctions.verifyIntents( main,
- expectedIntents,
- sleep=main.verifySleep,
- timeout=main.timeout)
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully verified intents",
- onfail="Failed to verify intents")
-
- if stepResult == main.FALSE:
- break
-
+ main.log.info("Verifying intents\nExpected intents: " + str(expectedIntents))
+ intentStatus = main.intentFunctions.verifyIntents( main,
+ expectedIntents,
+ sleep=main.verifySleep,
+ timeout=main.timeout)
# Verfying flows
- main.log.step("Verifying flows")
- main.log.info("Expected Flows: " + str(expectedFlows))
- stepResult = main.intentFunctions.verifyFlows( main,
+ main.log.info("Verifying flows\nExpected Flows: " + str(expectedFlows))
+ flowStatus = main.intentFunctions.verifyFlows( main,
expectedFlows,
sleep=main.verifySleep,
timeout=main.timeout)
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully verified flows",
- onfail="Failed to verify flows")
-
- if stepResult == main.FALSE:
+ if not flowStatus or not intentsStataus:
+ main.log.error("Failed to verify")
break
- main.log.report("Done pushing intents")
main.log.info("Summary: Intents=" + str(expectedIntents) + " Flows=" + str(expectedFlows))
main.log.info("Installed intents: " + str(maxIntents) +
" Added flows: " + str(maxFlows))
main.log.info("Writing results to DB file")
- try:
- dbFileName="/tmp/MaxIntentDB"
- dbfile = open(dbFileName, "a")
+ with open(dbFileName, "a") as dbFile:
temp = "," + str(maxIntents)
temp += "," + str(maxFlows)
- dbfile.write(temp)
- dbfile.close()
- except IOError:
- main.log.warn("Error opening " + dbFileName + " to write results.")
+ dbFile.write(temp)
# Stopping mininet
if main.switch == "of":
@@ -437,6 +354,12 @@
'''
Reroute
'''
+
+ # check if the setup case has been skipped
+ if main.setupSkipped:
+ main.setupSkipped = False
+ main.skipCase()
+
# the index where the next intents will be installed
offset = 0
# the number of intents we expect to be in the installed state
@@ -452,59 +375,41 @@
for i in range(limit):
# Push intents
- main.log.step("Pushing intents")
- stepResult = main.intentFunctions.pushIntents( main,
- main.switch,
- main.ingress,
- main.egress,
- main.batchSize,
- offset,
- sleep=main.installSleep,
- options="-i",
- timeout=main.timeout )
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully pushed intents",
- onfail="Failed to push intents")
- if stepResult == main.FALSE:
- break
-
- maxIntents = main.intentFunctions.getIntents( main )
- maxFlows = main.intentFunctions.getFlows( main )
+ main.log.info("Pushing intents")
+ main.intentFunctions.pushIntents( main,
+ main.switch,
+ main.ingress,
+ main.egress,
+ main.batchSize,
+ offset,
+ sleep=main.installSleep,
+ timeout=main.timeout,
+ options="-i" )
offset += main.batchSize
expectedIntents = offset
expectedFlows += main.batchSize*2
+ main.log.info("Grabbing number of installed intents and flows")
+ maxIntents = main.intentFunctions.getIntents( main )
+ maxFlows = main.intentFunctions.getFlows( main )
+
# Verifying intents
- main.log.step("Verifying intents")
- main.log.info("Expected intents: " + str(expectedIntents))
- stepResult = main.intentFunctions.verifyIntents( main,
- expectedIntents,
- sleep=main.verifySleep,
- timeout=main.timeout )
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully verified intents",
- onfail="Failed to verify intents")
-
- if stepResult == main.FALSE:
- break
-
+ main.log.info("Verifying intents\n\tExpected intents: " + str(expectedIntents))
+ intentStatus = main.intentFunctions.verifyIntents( main,
+ expectedIntents,
+ sleep=main.verifySleep,
+ timeout=main.timeout)
# Verfying flows
- main.log.step("Verifying flows")
- main.log.info("Expected Flows: " + str(expectedFlows))
- stepResult = main.intentFunctions.verifyFlows( main,
+ main.log.info("Verifying flows\n\tExpected Flows: " + str(expectedFlows))
+ flowStatus = main.intentFunctions.verifyFlows( main,
expectedFlows,
sleep=main.verifySleep,
- timeout=main.timeout )
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully verified flows",
- onfail="Failed to verify flows")
+ timeout=main.timeout)
- if stepResult == main.FALSE:
- break
+ if not flowStatus or not intentsStataus:
+ main.log.error("Failed to verify\n\tSkipping case")
+ main.log.skipCase()
# tear down a link
main.log.step("Tearing down link")
@@ -516,28 +421,27 @@
main.log.info("Sending: " + main.linkDownCmd)
main.CLIs[0].handle.sendline(main.linkDownCmd)
main.CLIs[0].handle.expect('onos>')
+
time.sleep(main.rerouteSleep)
# rerouting adds a 1000 flows
expectedFlows += 1000
+ main.log.info("Grabbing number of added flows")
+ maxFlows = main.intentFunctions.getFlows( main )
+
# Verfying flows
- main.log.step("Verifying flows")
- main.log.info("Expected Flows: " + str(expectedFlows))
- stepResult = main.intentFunctions.verifyFlows( main,
+ main.log.info("Verifying flows\n\tExpected Flows: " + str(expectedFlows))
+ flowStatus = main.intentFunctions.verifyFlows( main,
expectedFlows,
sleep=main.verifySleep,
timeout=main.timeout)
- utilities.assert_equals( expect=main.TRUE,
- actual=stepResult,
- onpass="Successfully verified flows",
- onfail="Failed to verify flows")
-
- if stepResult == main.FALSE:
- break
+ if not flowStatus:
+ main.log.error("Failed to verify flows\n\tSkipping case")
+ main.skipCase()
# Bring link back up
- main.log.step("Tearing down link")
+ main.log.step("Bringing link back up")
if main.switch == "of":
main.log.info("Sending: " + main.linkUpCmd)
main.Mininet1.handle.sendline(main.linkUpCmd)
@@ -546,22 +450,17 @@
main.log.info("Sending: " + main.linkUpCmd)
main.CLIs[0].handle.sendline(main.linkUpCmd)
main.CLIs[0].handle.expect('onos>')
+
time.sleep(main.rerouteSleep)
- main.log.report("Done pushing intents")
main.log.info("Summary: Intents=" + str(expectedIntents) + " Flows=" + str(expectedFlows))
main.log.info("Installed intents: " + str(maxIntents) +
" Added flows: " + str(maxFlows))
- try:
- dbFileName="/tmp/MaxIntentDB"
- dbfile = open(dbFileName, "a")
+ with open(main.dbFileName, "a") as dbFile:
temp = "," + str(maxIntents)
temp += "," + str(maxFlows)
- dbfile.write(temp)
- dbfile.close()
- except IOError:
- main.log.warn("Error opening " + dbFileName + " to write results.")
+ dbFile.write(temp)
# Stopping mininet
if main.switch == "of":