Revised script
diff --git a/TestON/tests/IntentEventTP/IntentEventTP.py b/TestON/tests/IntentEventTP/IntentEventTP.py
index c40ebf9..b1f0e91 100644
--- a/TestON/tests/IntentEventTP/IntentEventTP.py
+++ b/TestON/tests/IntentEventTP/IntentEventTP.py
@@ -1,242 +1,397 @@
-# ScaleOutTemplate -> NullProviderTest
+# ScaleOutTemplate --> IntentEventTP
#
# CASE1 starts number of nodes specified in param file
#
# cameron@onlab.us
+import sys
+import os
+import time
+
class IntentEventTP:
def __init__( self ):
self.default = ''
- def CASE1( self, main ):
- import os.path
- global clusterCount
- global ONOSIp
+ def CASE1( self, main ): #This is the initialization case
+ import os.path #this case will clean up all nodes
+ import time #but only node 1 is started in this case
+
+ global clusterCount #number of nodes running
+ global ONOSIp #list of ONOS IP addresses
clusterCount = 1
- ONOSIp = []
+ ONOSIp = [ 0 ]
+
+ #Load values from params file
checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
gitPull = main.params[ 'GIT' ][ 'autopull' ]
cellName = main.params[ 'ENV' ][ 'cellName' ]
+ Features= main.params[ 'ENV' ][ 'cellFeatures' ]
BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
BENCHUser = main.params[ 'BENCH' ][ 'user' ]
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOSIp.append(ONOS1Ip)
- ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOSIp.append(ONOS2Ip)
- ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
- ONOSIp.append(ONOS3Ip)
- MN1Ip = main.params[ 'MN' ][ 'ip1' ]
- Features= main.params[ 'ENV' ][ 'cellFeatures' ]
+ maxNodes = int(main.params[ 'availableNodes' ])
+ MNip = main.params[ 'MN' ][ 'ip1' ]
+ skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
+ numSwitches = main.params[ 'TEST' ][ 'numSwitches' ]
+
+ homeDir = os.path.expanduser('~')
+ main.ONOSbench.handle.sendline("export TERM=vt100")
+ dump = main.ONOSbench.handle.expect(":~")
- main.ONOSbench.createCellFile(BENCHIp, cellName, MN1Ip,str(Features), ONOS1Ip, ONOS2Ip, ONOS3Ip)
+ #Populate ONOSIp with ips from params
+ for i in range(1, maxNodes + 1):
+ ipString = 'ip' + str(i)
+ ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
+
+ #kill off all onos processes
+ main.log.step("Safety check, killing all ONOS processes")
+ main.log.step("before initiating enviornment setup")
+ for node in range(1, maxNodes + 1):
+ main.log.info("killing node " + str(node))
+ main.ONOSbench.onosDie(ONOSIp[node])
+ #construct the cell file
+ main.log.info("Creating cell file")
+ exec "a = main.ONOSbench.createCellFile"
+ cellIp = []
+ for node in range (1, clusterCount + 1):
+ cellIp.append(ONOSIp[node])
+ a(BENCHIp,cellName,MNip,str(Features), *cellIp)
+
+ main.step( "Set Cell" )
+ main.ONOSbench.setCell(cellName)
+
+ #Uninstall everywhere
main.log.step( "Cleaning Enviornment..." )
- main.ONOSbench.onosUninstall( ONOS1Ip )
- main.ONOSbench.onosUninstall( ONOS2Ip )
- main.ONOSbench.onosUninstall( ONOS3Ip )
+ for i in range(1, maxNodes + 1):
+ main.log.info(" Uninstalling ONOS " + str(i) )
+ main.ONOSbench.onosUninstall( ONOSIp[i] )
+ #git
main.step( "Git checkout and pull " + checkoutBranch )
if gitPull == 'on':
checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
pullResult = main.ONOSbench.gitPull()
-
else:
checkoutResult = main.TRUE
pullResult = main.TRUE
main.log.info( "Skipped git checkout and pull" )
+
+ #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
+ if skipMvn != "yes":
+ mvnResult = main.ONOSbench.cleanInstall()
+
+ #configure null device provider
+ switchList = [0,int(numSwitches),0,0,0,0,0,0]
+ devicesString = ""
+ for node in range(1, maxNodes + 1):
+ devicesString += (ONOSIp[node] + ":" + str(switchList[node] ))
+ if node < maxNodes:
+ devicesString += (",")
- #mvnResult = main.ONOSbench.cleanInstall()
-
- main.step( "Set cell for ONOS cli env" )
- main.ONOS1cli.setCell( cellName )
- main.ONOS2cli.setCell( cellName )
- main.ONOS3cli.setCell( cellName )
-
- main.log.info("Modifying org.onosproject.provider.nil.link.impl.NullLinkProvider.cfg: Turning off flicker ")
- homeDir = os.path.expanduser('~')
- main.log.info(homeDir)
- localPath = "/ONOS/tools/package/etc/org.onosproject.provider.nil.link.impl.NullLinkProvider.cfg"
+ main.log.info("Configuring device provider: ONOS 1 with " + (numSwitches) + " switches")
+ localPath = "/onos/tools/package/etc/org.onosproject.provider.nil.device.impl.NullDeviceProvider.cfg"
filePath = homeDir + localPath
main.log.info(filePath)
configFile = open(filePath, 'w+')
- main.log.info("file opened")
- configFile.write("# Sample configurations for the NullLinkProvider.\n")
- configFile.write("# \n")
- configFile.write("# If enabled, generates LinkDetected and LinkVanished events\n")
- configFile.write("# to make the link appear to be flapping.\n")
- configFile.write("#\n")
- configFile.write("# flicker = true\n")
- configFile.write("#\n")
- configFile.write("# If enabled, sets the time between LinkEvent generation,\n")
- configFile.write("# in milliseconds.\n")
- configFile.write("#\n")
- configFile.write("# eventRate = 2000\n")
-
+ configFile.write("devConfigs = " + devicesString + "\n")
+ configFile.write("#numPorts = 8")
configFile.close()
- main.log.info("Closing config file")
+ main.log.info("DevConfig = " + devicesString)
+ main.log.info("Device provider file written and closed")
+
+ ## configuring null link provider
+ main.log.info(" Configuring null provider to disable flicker" )
+ homeDir = os.path.expanduser('~')
+ main.log.info(homeDir)
+ localPath = "/onos/tools/package/etc/org.onosproject.provider.nil.link.impl.NullLinkProvider.cfg"
+ filePath = homeDir + localPath
+ main.log.info(filePath)
+
+ neighborsString = ""
+ for node in range(1, maxNodes + 1):
+ neighborsString += ONOSIp[node]
+ if node < maxNodes:
+ neighborsString += ","
+
+ configFile = open(filePath, 'w+')
+ configFile.write("#eventRate =\n")
+ configFile.write("#cfgFile = /tmp/foo.cfg #If enabled, points to the full path to the topology file.\n")
+ configFile.write("#neighbors = ")
+ configFile.close()
+ main.log.info("Configuration completed")
+
+ main.log.info("Writing link graph configuration file..." )
+ homeDir = os.path.expanduser('~')
+ localPath = "/onos/tools/package/etc/linkGraph.cfg"
+ filePath = homeDir + localPath
+ linkGraph = open(filePath, 'w+')
+ linkGraph.write("# NullLinkProvider topology description (config file).\n")
+ linkGraph.write("# The NodeId is only added if the destination is another node's device.\n")
+ linkGraph.write("# Bugs: Comments cannot be appended to a line to be read.\n")
+
+ myPort = 6
+ for node in range(1, clusterCount+1):
+ linkGraph.write("graph " + ONOSIp[node] + " {\n")
+ for switch in range (0, switchList[node]-1):
+ line = ""
+ line = ("\t" + str(switch) + ":" + str(myPort))
+ line += " -- "
+ line += (str(switch+1) + ":" + str(myPort-1) + "\n")
+ linkGraph.write(line)
+ linkGraph.write("}")
+ linkGraph.close()
main.step( "Creating ONOS package" )
packageResult = main.ONOSbench.onosPackage()
main.step( "Installing ONOS package" )
- install1Result = main.ONOSbench.onosInstall( node=ONOS1Ip )
+ install1Result = main.ONOSbench.onosInstall( node=ONOSIp[1] )
- cellName = main.params[ 'ENV' ][ 'cellName' ]
- main.step( "Applying cell file to environment" )
- cellApplyResult = main.ONOSbench.setCell( cellName )
main.step( "verify cells" )
verifyCellResult = main.ONOSbench.verifyCell()
- main.step( "Set cell for ONOS cli env" )
- cli1 = main.ONOS1cli.startOnosCli( ONOS1Ip )
+ main.step( "Checking if ONOS is up yet" )
+ for i in range( 2 ):
+ isup = main.ONOSbench.isup( ONOSIp[1] )
+ if isup:
+ break
+ if not isup:
+ main.log.report( "ONOS1 didn't start!" )
- ###### UPGRADE FOR SCALABLILTY ######
- jenkinsReport = open('IntentEventTP.csv', 'w')
- jenkinsReport.write("T1 - Node 1, T2 - Node 1, T2 - Node 2, T3 - Node 1, T3 - Node 2, T3 - Node 3\n")
- jenkinsReport.close
- #####################################
+ lastOutput = "--"
+ origin = time.time()
+ clockStarted = False
+ while True:
+ main.ONOSbench.handle.sendline("onos $OC1 summary")
+ main.ONOSbench.handle.expect(":~")
+ clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3]
+ print("\nBefore: " + str(clusterCheck))
+ if "SCC(s)=1," in clusterCheck and ("devices=" + str(numSwitches)) in clusterCheck: #check for links and devices too
+ 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)
+
+
def CASE2( self, main ):
- ''
+ # This case increases the cluster size by whatever scale is
+ # Note: 'scale' is the size of the step
+ # if scaling is not a part of your test, simply run this case
+ # once after CASE1 to set up your enviornment for your desired
+ # cluster size. If scaling is a part of you test call this case each time
+ # you want to increase cluster size
+
+ ''
'Increase number of nodes and initiate CLI'
''
import time
-
+ import os.path
global clusterCount
-
- ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
- ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
- ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
- #ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
- #ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
- #ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
- #ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
+
+ Features= main.params[ 'ENV' ][ 'cellFeatures' ]
cellName = main.params[ 'ENV' ][ 'cellName' ]
+ MNip = main.params[ 'MN' ][ 'ip1' ]
+ BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
+ numSwitches = int(main.params[ 'TEST' ][ 'numSwitches' ])
scale = int( main.params[ 'SCALE' ] )
-
- # Cluster size increased everytime the case is defined
+ maxNodes = int(main.params[ 'availableNodes' ])
clusterCount += scale
+ homeDir = os.path.expanduser('~')
- main.log.report( "Increasing cluster size to " +
- str( clusterCount ) )
- installResult = main.FALSE
+ #kill off all onos processes
+ main.log.step("Safety check, killing all ONOS processes")
+ main.log.step("before initiating enviornment setup")
+ for node in range(1, maxNodes + 1):
+ main.ONOSbench.onosDie(ONOSIp[node])
- if scale == 2:
- if clusterCount == 3:
- main.log.info( "Installing nodes 2 and 3" )
- install2Result = main.ONOSbench.onosInstall( node=ONOS2Ip )
- install3Result = main.ONOSbench.onosInstall( node=ONOS3Ip )
- cli2 = main.ONOS2cli.startOnosCli(ONOS2Ip)
- cli3 = main.ONOS3cli.startOnosCli(ONOS3Ip)
+ #Uninstall everywhere
+ main.log.step( "Cleaning Enviornment..." )
+ for i in range(1, maxNodes + 1):
+ main.log.info(" Uninstalling ONOS " + str(i) )
+ main.ONOSbench.onosUninstall( ONOSIp[i] )
+
+ #construct the cell file
+ main.log.info("Creating cell file")
+ exec "a = main.ONOSbench.createCellFile"
+ cellIp = []
+ for node in range (1, clusterCount + 1):
+ cellIp.append(ONOSIp[node])
+ a(BENCHIp,cellName,MNip,str(Features), *cellIp)
+ main.step( "Set Cell" )
+ main.ONOSbench.setCell(cellName)
+
+ baselineSwitchCount = numSwitches/clusterCount
+ switchList = [0,0,0,0,0,0,0,0]
+
+ for node in range(1, clusterCount + 1):
+ switchList[node] = baselineSwitchCount
- #elif clusterCount == 5:
+ for node in range(1, (numSwitches%clusterCount)+1):
+ switchList[node] += 1
+
+ devicesString = ""
+ for node in range(1, maxNodes + 1):
+ devicesString += (ONOSIp[node] + ":" + str(switchList[node] ))
+ if node < maxNodes:
+ devicesString += (",")
- # main.log.info( "Installing nodes 4 and 5" )
- # node4Result = main.ONOSbench.onosInstall( node=ONOS4Ip )
- # node5Result = main.ONOSbench.onosInstall( node=ONOS5Ip )
- # installResult = node4Result and node5Result
- # time.sleep( 5 )
+ main.log.info("Configuring device provider")
+ localPath = "/onos/tools/package/etc/org.onosproject.provider.nil.device.impl.NullDeviceProvider.cfg"
+ filePath = homeDir + localPath
+ main.log.info(filePath)
- # main.ONOS4cli.startOnosCli( ONOS4Ip )
- # main.ONOS5cli.startOnosCli( ONOS5Ip )
+ configFile = open(filePath, 'w+')
+ configFile.write("devConfigs = " + devicesString +"\n")
+ configFile.write("# numPorts = 8")
+ configFile.close()
+ main.log.info("DevConfig = " + devicesString)
+ main.log.info("Device provider file written and closed")
- #elif clusterCount == 7:
+ main.log.info("Writing link graph configuration file..." )
+ homeDir = os.path.expanduser('~')
+ localPath = "/onos/tools/package/etc/linkGraph.cfg"
+ filePath = homeDir + localPath
+ linkGraph = open(filePath, 'w+')
+ linkGraph.write("# NullLinkProvider topology description (config file).\n")
+ linkGraph.write("# The NodeId is only added if the destination is another node's device.\n")
+ linkGraph.write("# Bugs: Comments cannot be appended to a line to be read.\n")
- # main.log.info( "Installing nodes 4 and 5" )
- # node6Result = main.ONOSbench.onosInstall( node=ONOS6Ip )
- # node7Result = main.ONOSbench.onosInstall( node=ONOS7Ip )
- # installResult = node6Result and node7Result
- # time.sleep( 5 )
+ myPort = 6
+ for node in range(1, clusterCount+1):
+ linkGraph.write("graph " + ONOSIp[node] + " {\n")
+ for switch in range (0, switchList[node]-1):
+ line = ""
+ line = ("\t" + str(switch) + ":" + str(myPort))
+ line += " -- "
+ line += (str(switch+1) + ":" + str(myPort-1) + "\n")
+ linkGraph.write(line)
+ linkGraph.write("}\n")
+ linkGraph.close()
+
+ main.step( "Creating ONOS package, preparing to reinstall" )
+ packageResult = main.ONOSbench.onosPackage()
+
+ main.log.report( "Reinstalling on all nodes and increasing cluster size to " + str( clusterCount ) )
+ for node in range(1, clusterCount + 1):
+ main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
+ main.ONOSbench.onosInstall( ONOSIp[node])
- # main.ONOS6cli.startOnosCli( ONOS6Ip )
- # main.ONOS7cli.startOnosCli( ONOS7Ip )
- #
-
- if scale == 1:
- if clusterCount == 2:
- main.log.info( "Installing node 2" )
- install2Result = main.ONOSbench.onosInstall( node=ONOS2Ip )
- cli2 = main.ONOS2cli.startOnosCli(ONOS2Ip)
-
- if clusterCount == 3: main.log.info( "Installing node 3" )
- install3Result = main.ONOSbench.onosInstall( node=ONOS3Ip )
- cli3 = main.ONOS3cli.startOnosCli(ONOS3Ip)
-
-
- def CASE3( self, main ):
+ for i in range( 2 ):
+ isup = main.ONOSbench.isup( ONOSIp[node] )
+ if isup:
+ main.log.info("ONOS " + str(node) + " is up\n")
+ break
+ if not isup:
+ main.log.report( "ONOS " + str(node) + " didn't start!" )
- import os.path
- import sys
+ lastOutput = "--"
+ origin = time.time()
+ clockStarted = False
+ while True:
+ main.ONOSbench.handle.sendline("onos $OC1 summary")
+ main.ONOSbench.handle.expect(":~")
+ clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3]
+ print("\nBefore: " + str(clusterCheck))
+ if "SCC(s)=1," in clusterCheck and ("nodes=" + str(clusterCount)) in clusterCheck and ("devices=" + str(numSwitches)) in clusterCheck:
+ break
+ if clusterCheck != lastOutput:
+ sameOutput = False
+ elif clusterCheck == lastOutput:
+ if clockStarted == False:
+ start = time.time()
+ clockStarted = True
+ if time.time() > (start + 60):
+ main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...")
+ break
+ lastOutput = clusterCheck
+ time.sleep(5)
+
+
+ def CASE3( self, main ):
+ import time
import json
- import time
-
+ import string
+ import csv
+
main.log.info("Cluster Count = " + str(clusterCount))
- defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
- intentsRate = main.params['JSON']['intents_rate']
+ intentsRate = main.params['METRICS']['intents_rate']
+ intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ]
+ intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ]
+ testDuration = main.params[ 'TEST' ][ 'duration' ]
+ logInterval = main.params[ 'TEST' ][ 'log_interval' ]
+ debug = main.params[ 'debugMode' ]
+
+ metricList = [intentsRate, intentsWithdrawn, intentsFailed]
- for i in range( 0,clusterCount ): #iterates over nodes
- switchNum = i
- while switchNum < 7: #iterates over applicable switches
- main.Mininet1.assignSwController(sw = switchNum + 1, ip1 = ONOSIp[i], port1 = defaultSwPort)
- main.log.info("ONOS " + str(i + 1) + " assigned switch : " + str(switchNum+1))
- switchNum += clusterCount
-
- main.log.info("running arping")
- mnArp = main.params['TEST']['arping']
- main.Mininet1.handle.sendline( mnArp )
-
- generateLoad = main.params[ 'TEST' ][ 'loadstart' ]
+ tempsleep =40
+ main.log.info("sleeping " + str(tempsleep))
+ time.sleep(tempsleep)
+
+ loadFrom = ['0']
+ loadFrom.extend((main.params[ 'TEST' ][ 'loadFrom' ]).split(","))
for node in range(1, clusterCount+1):
- exec "a = main.ONOS%s.handle.sendline" %str(node)
- a(generateLoad)
- main.log.info("Load initiated on node " + str(node))
-
- #
- # TODO: Confirm Load somehow
- #
-
- getMetric = main.params[ 'TEST' ][ 'metric1' ]
- testDuration = main.params[ 'TEST' ][ 'duration' ]
+ if loadFrom[node] == "1":
+ cmd = "onos $OC" + str(node) + " feature:install onos-app-intent-perf"
+ main.ONOSbench.handle.sendline(cmd)
+ main.ONOSbench.handle.expect(":~")
+ main.log.info("Load initiated on node " + str(node))
+
+ main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" )
stop = time.time() + float( testDuration )
-
- main.log.info( "Starting test loop for " + str(testDuration) + " seconds..." )
- logInterval = main.params[ 'TEST' ][ 'log_interval' ]
-
-
- rateResult = [0,0,0,0,0,0,0,0]
+
while time.time() < stop:
time.sleep( float( logInterval ) )
for node in range (1, clusterCount + 1):
- exec "a = main.ONOS%scli.intentsEventsMetrics" %str(node)
- intentsJsonObj = json.loads(a())
-
- main.log.info( "Node " + str(node) + " rate: " + str( intentsJsonObj[ intentsRate ][ 'm1_rate' ] ) )
- rateResult[node] = round(intentsJsonObj[ intentsRate ][ 'm1_rate' ], 2)
+ myResults = ['0','0','0']
+ for metric in metricList:
+
+ onosEnv = "onos $OC" + str(node)
+ cmd = onosEnv + " " + metric
+ main.log.info("COMMAND: " + cmd)
+ main.ONOSbench.handle.sendline( cmd )
+ time.sleep(10)
+ main.ONOSbench.handle.expect(":~")
+ rawResult = main.ONOSbench.handle.before
+ rawResult = (rawResult.splitlines())
+
+ tempResult = "--"
+ for word in rawResult:
+ if debug: print("word: " + word)
+ if "m1" in str(word):
+ tempResult = word
+ break
+
+ if tempResult == "--":
+ main.log.error("WRONG pexepct.before data\n" + str(rawResult))
+ main.log.info("retrying command... ")
+ main.ONOSbench.handle.sendline(cmd)
+ main.ONOSbench.handle.expect(":~")
+ test = main.ONOSbench.handle.before
+ print ("\n\n" + str(test))
+
+ tempResult = round(float(tempResult.replace("m1=","")),1)
+ tempResult = str(tempResult) # easy way to clean up number/prep to log
+ resultIndex = metricList.index(metric)
+ myResults[resultIndex] = tempResult
- stopLoad = main.params[ 'TEST' ][ 'loadstop' ]
-
- jenkinsReport = open('IntentEventTP.csv', 'a')
- for node in range(1, clusterCount + 1):
- main.log.report("Cluster Size = " + str(clusterCount) + " Final on node " + str(node) + ": " + str(rateResult[node]))
- exec "a = main.ONOS%s.handle.sendline" %str(node)
- a(stopLoad)
- jenkinsReport.write(str(rateResult[node]))
- jenkinsReport.write(", ")
- jenkinsReport.close()
-
-
-
-
-
-
-
-
-
+ main.log.info("\tNode " + str(node))
+ main.log.info("Installed\tWithdrawn\tFailed")
+ main.log.info(myResults[0] + "\t\t " + myResults[1] + "\t\t" + myResults[2] + "\n")
+