Merge "Disabled Single to Multi NOOPTION test subcase. Added exception handling for json loads to CASE8."
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 1d75ae4..1e22267 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -1235,6 +1235,29 @@
main.exit()
return main.TRUE
+ def switch( self, **switchargs ):
+ """
+ start/stop a switch
+ """
+ args = utilities.parse_args( [ "SW", "OPTION" ], **switchargs )
+ sw = args[ "SW" ] if args[ "SW" ] is not None else ""
+ option = args[ "OPTION" ] if args[ "OPTION" ] is not None else ""
+ command = "switch " + str( sw ) + " " + str( option )
+ main.log.info( command )
+ try:
+ self.handle.sendline( command )
+ self.handle.expect( "mininet>" )
+ except pexpect.TIMEOUT:
+ main.log.error( self.name + ": pexpect.TIMEOUT found" )
+ main.cleanup()
+ main.exit()
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanup()
+ main.exit()
+ return main.TRUE
+
def yank( self, **yankargs ):
"""
yank a mininet switch interface to a host"""
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index a361aca..32aef33 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -1787,43 +1787,35 @@
main.cleanup()
main.exit()
- def intents( self, jsonFormat=True ):
+ def intents( self, jsonFormat = True, summary = False, **intentargs):
"""
Optional:
* jsonFormat: enable output formatting in json
+ * summary: whether only output the intent summary
+ * type: only output a certain type of intent
+ This options is valid only when jsonFormat is true and summary is
+ true
Description:
- Obtain intents currently installed
+ Obtain intents
"""
try:
cmdStr = "intents"
+ if summary:
+ cmdStr += " -s"
if jsonFormat:
cmdStr += " -j"
handle = self.sendline( cmdStr )
- return handle
- except TypeError:
- main.log.exception( self.name + ": Object not as expected" )
- 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 m2SIntentInstalledNumber( self ):
- """
- Description:
- Obtain the number of multiple point to single point intents
- installed
- """
- try:
- cmdStr = "intents -s -j"
- handle = self.sendline( cmdStr )
- jsonResult = json.loads( handle )
- return jsonResult['multiPointToSinglePoint']['installed']
+ args = utilities.parse_args( [ "TYPE" ], **intentargs )
+ type = args[ "TYPE" ] if args[ "TYPE" ] is not None else ""
+ if jsonFormat and summary and ( type != "" ):
+ jsonResult = json.loads( handle )
+ if type in jsonResult.keys():
+ return jsonResult[ type ]
+ else:
+ main.log.error( "unknown TYPE, return all types of intents" )
+ return handle
+ else:
+ return handle
except TypeError:
main.log.exception( self.name + ": Object not as expected" )
@@ -1838,6 +1830,7 @@
main.cleanup()
main.exit()
+
def getIntentState(self, intentsId, intentsJson=None):
"""
Check intent state.
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 2b37186..6c36394 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -711,6 +711,7 @@
"=" + "\"" + arg + "\"" + "\n" )
tempCount = tempCount + 1
+ cellFile.write( "export OCI=$OC1" )
cellFile.write( mnString + "\"" + mnIpAddrs + "\"" + "\n" )
cellFile.write( appString + "\n" )
cellFile.close()
@@ -1435,9 +1436,9 @@
self.handle.expect( "\$" )
self.handle.sendline( "tshark -i " + str( interface ) + " -t e -w " + str( dirFile ) + " &" )
- self.handle.sendline( "\r" )
+ self.handle.sendline( "\n" )
self.handle.expect( "Capturing on" )
- self.handle.sendline( "\r" )
+ self.handle.sendline( "\n" )
self.handle.expect( "\$" )
main.log.info( "Tshark started capturing files on " +
@@ -1661,7 +1662,7 @@
cmd += " old"
self.handle.sendline( cmd )
self.handle.expect( cmd )
- self.handle.expect( "\$" )
+ self.handle.expect( "\$ " )
response = self.handle.before
return response
except pexpect.EOF:
@@ -1730,7 +1731,6 @@
* This function uses root privilege iptables command which may result
in unwanted network errors. USE WITH CAUTION
"""
- import time
# NOTE*********
# The strict checking methods of this driver function is intentional
diff --git a/TestON/drivers/common/clidriver.py b/TestON/drivers/common/clidriver.py
index fd1a401..b6be81a 100644
--- a/TestON/drivers/common/clidriver.py
+++ b/TestON/drivers/common/clidriver.py
@@ -232,7 +232,7 @@
i = handle.expect( [ ".ssword:*", default, pexpect.EOF ] )
if i == 0:
handle.sendline( pwd )
- handle.sendline( "\r" )
+ handle.sendline( "\n" )
if i == 1:
handle.expect( default )
diff --git a/TestON/tests/HAclusterRestart/HAclusterRestart.params b/TestON/tests/HAclusterRestart/HAclusterRestart.params
index 627bec2..0f37220 100644
--- a/TestON/tests/HAclusterRestart/HAclusterRestart.params
+++ b/TestON/tests/HAclusterRestart/HAclusterRestart.params
@@ -40,7 +40,7 @@
<port7>6633</port7>
</CTRL>
<BACKUP>
- <ENABLED> False </ENABLED>
+ <ENABLED>True</ENABLED>
<TESTONUSER>admin</TESTONUSER>
<TESTONIP>10.128.30.9</TESTONIP>
</BACKUP>
diff --git a/TestON/tests/HAclusterRestart/HAclusterRestart.py b/TestON/tests/HAclusterRestart/HAclusterRestart.py
index b5ebe7d..f7eceb3 100644
--- a/TestON/tests/HAclusterRestart/HAclusterRestart.py
+++ b/TestON/tests/HAclusterRestart/HAclusterRestart.py
@@ -1717,6 +1717,11 @@
main.case( "Restart entire ONOS cluster" )
+ main.step( "Checking ONOS Logs for errors" )
+ for node in main.nodes:
+ main.log.debug( "Checking logs for errors on " + node.name + ":" )
+ main.log.warn( main.ONOSbench.checkLogs( node.ip_address ) )
+
main.step( "Killing ONOS nodes" )
killResults = main.TRUE
killTime = time.time()
@@ -2694,7 +2699,8 @@
main.Mininet2.stopTcpdump()
testname = main.TEST
- if main.params[ 'BACKUP' ] == "True":
+ main.log.error( main.params[ 'BACKUP' ][ 'ENABLED' ] )
+ if main.params[ 'BACKUP' ][ 'ENABLED' ] == "True":
main.step( "Copying MN pcap and ONOS log files to test station" )
teststationUser = main.params[ 'BACKUP' ][ 'TESTONUSER' ]
teststationIP = main.params[ 'BACKUP' ][ 'TESTONIP' ]
@@ -2707,36 +2713,38 @@
logFolder = "/opt/onos/log/"
logFiles = [ "karaf.log", "karaf.log.1" ]
# NOTE: must end in /
- dstDir = "~/packet_captures/"
for f in logFiles:
for node in main.nodes:
main.ONOSbench.handle.sendline( "scp sdn@" + node.ip_address +
":" + logFolder + f + " " +
teststationUser + "@" +
teststationIP + ":" +
- dstDir + str( testname ) +
- "-" + node.name + "-" + f )
- main.ONOSbench.handle.expect( "\$" )
+ main.logdir + "/" +
+ node.name + "-" + f )
+ main.ONOSbench.handle.expect( "\$ " )
+ print main.ONOSbench.handle.before
# std*.log's
# NOTE: must end in /
logFolder = "/opt/onos/var/"
logFiles = [ "stderr.log", "stdout.log" ]
# NOTE: must end in /
- dstDir = "~/packet_captures/"
for f in logFiles:
for node in main.nodes:
main.ONOSbench.handle.sendline( "scp sdn@" + node.ip_address +
":" + logFolder + f + " " +
teststationUser + "@" +
teststationIP + ":" +
- dstDir + str( testname ) +
- "-" + node.name + "-" + f )
- main.ONOSbench.handle.expect( "\$" )
+ main.logdir + "/" +
+ node.name + "-" + f )
+ main.ONOSbench.handle.expect( "\$ " )
+ print main.ONOSbench.handle.before
# sleep so scp can finish
time.sleep( 10 )
- main.step( "Packing and rotating pcap archives" )
- os.system( "~/TestON/dependencies/rotate.sh " + str( testname ) )
+ # main.step( "Packing and rotating pcap archives" )
+ # os.system( "~/TestON/dependencies/rotate.sh " + str( testname ) )
+ else:
+ main.log.debug( "skipping saving log files" )
main.step( "Stopping Mininet" )
mnResult = main.Mininet1.stopNet()
@@ -2746,9 +2754,8 @@
main.step( "Checking ONOS Logs for errors" )
for node in main.nodes:
- print colors[ 'purple' ] + "Checking logs for errors on " + \
- node.name + ":" + colors[ 'end' ]
- print main.ONOSbench.checkLogs( node.ip_address, restart=True )
+ main.log.debug( "Checking logs for errors on " + node.name + ":" )
+ main.log.warn( main.ONOSbench.checkLogs( node.ip_address ) )
try:
timerLog = open( main.logdir + "/Timers.csv", 'w')
diff --git a/TestON/tests/SCPFintentEventTp/SCPFintentEventTp.py b/TestON/tests/SCPFintentEventTp/SCPFintentEventTp.py
index bc7d17e..eb581ea 100644
--- a/TestON/tests/SCPFintentEventTp/SCPFintentEventTp.py
+++ b/TestON/tests/SCPFintentEventTp/SCPFintentEventTp.py
@@ -22,7 +22,7 @@
global init
try:
if type(init) is not bool:
- init = Fals
+ init = False
except NameError:
init = False
@@ -178,34 +178,17 @@
main.ONOSbench.handle.expect(":~")
print main.ONOSbench.handle.before
- lastOutput = "--"
- origin = time.time()
- clockStarted = False
- while True:
-
- main.ONOSbench.handle.sendline("")
- main.ONOSbench.handle.expect(":~")
-
- main.ONOSbench.handle.sendline("onos $OC1 summary")
- main.ONOSbench.handle.expect(":~")
-
- main.log.info("before" + main.ONOSbench.handle.before)
- clusterCheck = main.ONOSbench.handle.before
- print("\nBefore: " + str(clusterCheck))
- if ("SCC(s)=1,") in clusterCheck:
+ for i in range(3):
+ passed = main.ONOSbench.verifySummary( ONOSIp[0] )
+ if passed:
+ main.log.info("Clusters have converged")
break
- if clusterCheck != lastOutput:
- sameOutput = False
- elif clusterCheck == lastOutput:
- if clockStarted == False:
- start = time.time()
- clockStarted = True
- if time.time() > (start + 30):
- main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...")
- break
- lastOutput = clusterCheck
- time.sleep(5)
+ else:
+ main.log.error("Clusters have not converged, retying...")
+ time.sleep(3)
+
main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
+
def CASE2( self, main ):
import time
import json
@@ -322,17 +305,16 @@
main.ONOSbench.handle.expect(":~")
main.log.info("Stopping intentperf" )
- resultsDB = open("/tmp/IntentEventTPDB", "a")
- for node in groupResult:
-
- resultString = "'" + commit + "',"
- resultString += "'1gig',"
- resultString += str(clusterCount) + ","
- resultString += "'baremetal" + str(int(groupResult.index(node)) + 1) + "',"
- resultString += n + ","
- resultString += str(node) + ","
- resultString += str(0) + "\n" #no stddev
- resultsDB.write(resultString)
+ with open("/tmp/IntentEventTPDB", "a") as resultsDB:
+ for node in groupResult:
+ resultString = "'" + commit + "',"
+ resultString += "'1gig',"
+ resultString += str(clusterCount) + ","
+ resultString += "'baremetal" + str(int(groupResult.index(node)) + 1) + "',"
+ resultString += n + ","
+ resultString += str(node) + ","
+ resultString += str(0) + "\n" #no stddev
+ resultsDB.write(resultString)
resultsDB.close()
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":
diff --git a/TestON/tests/USECASE_SdnipI2/Dependency/Functions.py b/TestON/tests/USECASE_SdnipI2/Dependency/Functions.py
new file mode 100644
index 0000000..732ff41
--- /dev/null
+++ b/TestON/tests/USECASE_SdnipI2/Dependency/Functions.py
@@ -0,0 +1,41 @@
+
+def checkRouteNum( main, routeNumExpected ):
+ main.step( "Check routes installed" )
+ main.log.info( "Route number expected:" )
+ main.log.info( routeNumExpected )
+ main.log.info( "Route number from ONOS CLI:" )
+
+ routeNumActual = main.ONOScli.ipv4RouteNumber()
+ main.log.info( routeNumActual )
+ utilities.assertEquals( \
+ expect = routeNumExpected, actual = routeNumActual,
+ onpass = "***Route number is correct!***",
+ onfail = "***Route number is wrong!***" )
+
+def checkM2SintentNum( main, intentNumExpected ):
+ main.step( "Check M2S intents installed" )
+ main.log.info( "Intent number expected:" )
+ main.log.info( intentNumExpected )
+ main.log.info( "Intent number from ONOS CLI:" )
+ jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True,
+ TYPE = "multiPointToSinglePoint" )
+ intentNumActual = jsonResult['installed']
+ main.log.info( intentNumActual )
+ utilities.assertEquals( \
+ expect = intentNumExpected, actual = intentNumActual,
+ onpass = "***M2S intent number is correct!***",
+ onfail = "***M2S intent number is wrong!***" )
+
+def checkP2PintentNum( main, intentNumExpected ):
+ main.step( "Check P2P intents installed" )
+ main.log.info( "Intent number expected:" )
+ main.log.info( intentNumExpected )
+ main.log.info( "Intent number from ONOS CLI:" )
+ jsonResult = main.ONOScli.intents( jsonFormat = True, summary = True,
+ TYPE = "pointToPoint" )
+ intentNumActual = jsonResult['installed']
+ main.log.info( intentNumActual )
+ utilities.assertEquals( \
+ expect = intentNumExpected, actual = intentNumActual,
+ onpass = "***P2P intent number is correct!***",
+ onfail = "***P2P intent number is wrong!***" )
diff --git a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.params b/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.params
index b13806a..fd65488 100644
--- a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.params
+++ b/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.params
@@ -1,6 +1,6 @@
<PARAMS>
- <testcases>100, 101, 1, 4</testcases>
+ <testcases>100, 101, 102, 7, 8, 1, 4</testcases>
#Environment variables
<ENV>
@@ -27,6 +27,7 @@
<DEPENDENCY>
<path>/USECASE_SdnipI2/Dependency/</path>
<topology>USECASE_SdnipI2MN.py</topology>
+ <wrapper1>Functions</wrapper1>
</DEPENDENCY>
<config>
diff --git a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.py b/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.py
index d7b8802..6808576 100644
--- a/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.py
+++ b/TestON/tests/USECASE_SdnipI2/USECASE_SdnipI2.py
@@ -11,6 +11,7 @@
Start mininet
"""
import os
+ import imp
main.log.case( "Start Mininet topology" )
main.dependencyPath = main.testDir + \
main.params[ 'DEPENDENCY' ][ 'path' ]
@@ -123,6 +124,19 @@
time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
+ def CASE102( self, main ):
+ '''
+ This test case is to load the methods from other Python files.
+ '''
+ main.case( "Loading the methods from other Python file" )
+ # load the methods from other file
+ wrapperFile = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
+ main.Functions = imp.load_source( wrapperFile,
+ main.dependencyPath +
+ wrapperFile +
+ ".py" )
+
+
def CASE1( self, main ):
'''
ping test from 3 bgp peers to BGP speaker
@@ -235,3 +249,180 @@
if caseResult == main.FALSE:
main.cleanup()
main.exit()
+
+
+ def CASE5( self, main ):
+ '''
+ Cut links to peers one by one, check routes/intents
+ '''
+ import time
+ main.case( "This case is to bring down links and check routes/intents" )
+ main.step( "Bring down the link between sw32 and peer64514" )
+ result = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
+ OPTION = "down" )
+ if result == main.TRUE:
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ main.Functions.checkRouteNum( main, 2 )
+ main.Functions.checkM2SintentNum( main, 2 )
+ else:
+ main.log.info( "Bring down link failed!!!" )
+ main.exit();
+
+ main.step( "Bring down the link between sw8 and peer64515" )
+ result = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
+ OPTION = "down" )
+ if result == main.TRUE:
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ main.Functions.checkRouteNum( main, 1 )
+ main.Functions.checkM2SintentNum( main, 1 )
+ else:
+ main.log.info( "Bring down link failed!!!" )
+ main.exit();
+
+ main.step( "Bring down the link between sw28 and peer64516" )
+ result = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
+ OPTION = "down" )
+ if result == main.TRUE:
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ main.Functions.checkRouteNum( main, 0 )
+ main.Functions.checkM2SintentNum( main, 0 )
+ else:
+ main.log.info( "Bring down link failed!!!" )
+ main.exit();
+
+
+ def CASE6(self, main):
+ '''
+ Recover links to peers one by one, check routes/intents
+ '''
+ import time
+ main.case( "This case is to bring up links and check routes/intents" )
+ main.step( "Bring up the link between sw32 and peer64514" )
+ result = main.Mininet.link( END1 = "sw32", END2 = "peer64514",
+ OPTION = "up" )
+ if result == main.TRUE:
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ main.Functions.checkRouteNum( main, 1 )
+ main.Functions.checkM2SintentNum( main, 1 )
+ else:
+ main.log.info( "Bring up link failed!!!" )
+ main.exit();
+
+ main.step( "Bring up the link between sw8 and peer64515" )
+ result = main.Mininet.link( END1 = "sw8", END2 = "peer64515",
+ OPTION = "up" )
+ if result == main.TRUE:
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ main.Functions.checkRouteNum( main, 2 )
+ main.Functions.checkM2SintentNum( main, 2 )
+ else:
+ main.log.info( "Bring up link failed!!!" )
+ main.exit();
+
+ main.step( "Bring up the link between sw28 and peer64516" )
+ result = main.Mininet.link( END1 = "sw28", END2 = "peer64516",
+ OPTION = "up" )
+ if result == main.TRUE:
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ main.Functions.checkRouteNum( main, 3 )
+ main.Functions.checkM2SintentNum( main, 3 )
+ else:
+ main.log.info( "Bring up link failed!!!" )
+ main.exit();
+ '''
+ Note: at the end of this test case, we should carry out ping test.
+ So we run CASE4 again after CASE6
+ '''
+
+
+ def CASE7(self, main):
+ '''
+ shut down a edge switch, check P-2-P and M-2-S intents, ping test
+ '''
+ import time
+ main.case( "This case is to stop 1 edge switch,\
+ check P-2-P and M-2-S intents, ping test")
+ main.step( "Stop sw32" )
+ result = main.Mininet.switch( SW = "sw32", OPTION = "stop" )
+ if result == main.TRUE:
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ main.Functions.checkRouteNum( main, 2 )
+ main.Functions.checkM2SintentNum( main, 2 )
+ main.Functions.checkP2PintentNum( main, 12 )
+ else:
+ main.log.info( "Stop switch failed!!!" )
+ main.exit();
+
+ '''
+ main.step( "Stop sw8" )
+ result = main.Mininet.switch( SW = "sw8", OPTION = "stop" )
+ if result == main.TRUE:
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ main.Functions.checkRouteNum( main, 1 )
+
+ # Note: there should be 0 M2S intent, not 1.
+ main.Functions.checkM2SintentNum( main, 0 )
+ main.Functions.checkP2PintentNum( main, 6 )
+ else:
+ main.log.info( "Stop switch failed!!!" )
+ main.exit();
+
+ main.step( "Stop sw28" )
+ result = main.Mininet.switch( SW = "sw28", OPTION = "stop" )
+ if result == main.TRUE:
+ time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
+ main.Functions.checkRouteNum( main, 0 )
+ main.Functions.checkM2SintentNum( main, 0 )
+ main.Functions.checkP2PintentNum( main, 0 )
+ else:
+ main.log.info( "Stop switch failed!!!" )
+ main.exit();
+ '''
+ '''
+ ping test between BGP speaker and BGP peers, ping test between hosts
+ behind BGP peers ===
+ '''
+
+ def CASE8( self, main ):
+ main.case( "This case is to bring up 1 edge switch,\
+ check P-2-P and M-2-S intents, ping test" )
+
+
+ def CASE20( self, main ):
+ '''
+ ping test from 3 bgp peers to BGP speaker
+ '''
+ main.case( "This case is to check ping between BGP peers and speakers" )
+ result1 = main.Mininet.pingHost( src = "speaker1", target = "peer64514" )
+ result2 = main.Mininet.pingHost( src = "speaker1", target = "peer64515" )
+ result3 = main.Mininet.pingHost( src = "speaker1", target = "peer64516" )
+
+
+ caseResult = result1 or result2 or result3
+ utilities.assert_equals( expect = main.FALSE, actual = caseResult,
+ onpass = "Speaker1 failed to ping all peers - Correct",
+ onfail = "Speaker1 did not fail to ping all peers- NOT Correct" )
+
+ if caseResult == main.TRUE:
+ main.cleanup()
+ main.exit()
+
+
+ def CASE21( self, main ):
+ '''
+ Ping test in data plane for each route
+ '''
+ main.case( "This case is to check ping for each route" )
+ result1 = main.Mininet.pingHost( src = "host64514", target = "host64515" )
+ result2 = main.Mininet.pingHost( src = "host64515", target = "host64516" )
+ result3 = main.Mininet.pingHost( src = "host64514", target = "host64516" )
+
+ caseResult = result1 or result2 or result3
+ utilities.assert_equals( expect = main.FALSE, actual = caseResult,
+ onpass = "Ping test for all routes failed- Correct",
+ onfail = "Ping test for all routes NOT failed- NOT Correct" )
+
+ if caseResult == main.TRUE:
+ main.cleanup()
+ main.exit()
+