blob: 6d0e2b393f048f155156cb1a612a530b195c00b1 [file] [log] [blame]
cameron@onlab.us1201bc42015-04-01 16:30:05 -07001# ScaleOutTemplate
2#
3# CASE1 starts number of nodes specified in param file
4#
5# cameron@onlab.us
6
7import sys
8import os.path
9
10
11class IntentInstallWithdrawLat:
12
13 def __init__( self ):
14 self.default = ''
15
cameron@onlab.us61e06032015-04-02 10:54:26 -070016 def CASE1( self, main ):
17
18 import time
19 global init
20 try:
21 if type(init) is not bool:
22 init = False
23 except NameError:
24 init = False
25
cameron@onlab.us1201bc42015-04-01 16:30:05 -070026 #Load values from params file
27 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
28 gitPull = main.params[ 'GIT' ][ 'autopull' ]
29 cellName = main.params[ 'ENV' ][ 'cellName' ]
cameron@onlab.us61e06032015-04-02 10:54:26 -070030 Apps = main.params[ 'ENV' ][ 'cellApps' ]
cameron@onlab.us1201bc42015-04-01 16:30:05 -070031 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
32 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
33 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
34 maxNodes = int(main.params[ 'availableNodes' ])
cameron@onlab.us1201bc42015-04-01 16:30:05 -070035 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
cameron@onlab.us61e06032015-04-02 10:54:26 -070036 cellName = main.params[ 'ENV' ][ 'cellName' ]
cameron@onlab.us1201bc42015-04-01 16:30:05 -070037 switchCount = main.params[ 'TEST' ][ 'switchCount' ]
38
cameron@onlab.us61e06032015-04-02 10:54:26 -070039 # -- INIT SECTION, ONLY RUNS ONCE -- #
40 if init == False:
41 init = True
42 global clusterCount #number of nodes running
43 global ONOSIp #list of ONOS IP addresses
44 global scale
45
46 clusterCount = 0
47 ONOSIp = [ 0 ]
48 scale = (main.params[ 'SCALE' ]).split(",")
49 clusterCount = int(scale[0])
cameron@onlab.us1201bc42015-04-01 16:30:05 -070050
cameron@onlab.us61e06032015-04-02 10:54:26 -070051 #Populate ONOSIp with ips from params
52 for i in range(1, maxNodes + 1):
53 ipString = 'ip' + str(i)
54 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
55
56 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
57 if skipMvn != "yes":
58 mvnResult = main.ONOSbench.cleanInstall()
cameron@onlab.us1201bc42015-04-01 16:30:05 -070059
cameron@onlab.us1201bc42015-04-01 16:30:05 -070060 #git
61 main.step( "Git checkout and pull " + checkoutBranch )
62 if gitPull == 'on':
63 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
64 pullResult = main.ONOSbench.gitPull()
65
66 else:
67 checkoutResult = main.TRUE
68 pullResult = main.TRUE
69 main.log.info( "Skipped git checkout and pull" )
cameron@onlab.us1201bc42015-04-01 16:30:05 -070070
cameron@onlab.us61e06032015-04-02 10:54:26 -070071 # -- END OF INIT SECTION --#
72
73 clusterCount = int(scale[0])
74 scale.remove(scale[0])
cameron@onlab.us1201bc42015-04-01 16:30:05 -070075
cameron@onlab.us61e06032015-04-02 10:54:26 -070076 #kill off all onos processes
77 main.log.step("Safety check, killing all ONOS processes")
78 main.log.step("before initiating enviornment setup")
79 for node in range(1, maxNodes + 1):
80 main.ONOSbench.onosDie(ONOSIp[node])
81
82 #Uninstall everywhere
83 main.log.step( "Cleaning Enviornment..." )
84 for i in range(1, maxNodes + 1):
85 main.log.info(" Uninstalling ONOS " + str(i) )
86 main.ONOSbench.onosUninstall( ONOSIp[i] )
87
88 #construct the cell file
cameron@onlab.us1201bc42015-04-01 16:30:05 -070089 main.log.info("Creating cell file")
cameron@onlab.us1201bc42015-04-01 16:30:05 -070090 cellIp = []
91 for node in range (1, clusterCount + 1):
92 cellIp.append(ONOSIp[node])
cameron@onlab.us1201bc42015-04-01 16:30:05 -070093
cameron@onlab.us61e06032015-04-02 10:54:26 -070094 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
cameron@onlab.us1201bc42015-04-01 16:30:05 -070095
cameron@onlab.us61e06032015-04-02 10:54:26 -070096 main.step( "Set Cell" )
97 main.ONOSbench.setCell(cellName)
98
99 main.ONOSbench.createLinkGraphFile(BENCHIp, cellIp, switchCount)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700100
cameron@onlab.us61e06032015-04-02 10:54:26 -0700101 main.step( "Creating ONOS package" )
102 packageResult = main.ONOSbench.onosPackage()
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700103
cameron@onlab.us61e06032015-04-02 10:54:26 -0700104 main.step( "verify cells" )
105 verifyCellResult = main.ONOSbench.verifyCell()
106
107 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700108 for node in range(1, clusterCount + 1):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700109 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
110 main.ONOSbench.onosInstall( ONOSIp[node])
111
112 for node in range(1, clusterCount + 1):
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700113 for i in range( 2 ):
114 isup = main.ONOSbench.isup( ONOSIp[node] )
115 if isup:
116 main.log.info("ONOS " + str(node) + " is up\n")
117 break
118 if not isup:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700119 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700120
cameron@onlab.us61e06032015-04-02 10:54:26 -0700121 main.ONOS1cli.startOnosCli( ONOSIp[1] )
122 main.log.info("Startup sequence complete")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700123
cameron@onlab.us61e06032015-04-02 10:54:26 -0700124 main.ONOSbench.configNullDev(cellIp, switchCount)
125
126 def CASE2( self, main ):
127
128 import time
129 import numpy
130
131 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700132 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
133 intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",")
134 switchCount = int(main.params[ 'TEST' ][ 'switchCount' ])
135 debug = main.params[ 'TEST' ][ 'switchCount' ]
136 for i in range(0,len(intentsList)):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700137 intentsList[i] = int(intentsList[i])
138
139 if debug == "True":
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700140 debug = True
cameron@onlab.us61e06032015-04-02 10:54:26 -0700141 else:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700142 debug = False
cameron@onlab.us61e06032015-04-02 10:54:26 -0700143
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700144 linkCount = 0
145 for i in range(0,10):
146 main.ONOSbench.handle.sendline("onos $OC1 links|wc -l")
147 main.ONOSbench.handle.expect(":~")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700148 linkCount = main.ONOSbench.handle.before
149 if debug: main.log.info("Link Count check: " + linkCount)
150 if str((switchCount*2)-2) in linkCount:
151 break
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700152 time.sleep(2)
cameron@onlab.us61e06032015-04-02 10:54:26 -0700153
154 links = "--"
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700155 while "=null:" not in links:
156 if debug: main.log.info("top of loop")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700157 main.ONOSbench.handle.sendline("onos $OC1 links")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700158 main.ONOSbench.handle.expect(":~")
159 links = main.ONOSbench.handle.before
cameron@onlab.us61e06032015-04-02 10:54:26 -0700160 if debug: main.log.info(str(links))
161 time.sleep(1)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700162 links = links.splitlines()
cameron@onlab.us61e06032015-04-02 10:54:26 -0700163 templinks = links
164
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700165 tempDevices = []
cameron@onlab.us61e06032015-04-02 10:54:26 -0700166 for line in links:
167 temp = line.split(" ")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700168 temp[0].replace("src=","")
169 temp[0] = (temp[0].split("/"))[0]
cameron@onlab.us61e06032015-04-02 10:54:26 -0700170 tempDevices.append(temp[0])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700171
172 tempDevices.sort()
173 devices = []
cameron@onlab.us61e06032015-04-02 10:54:26 -0700174 for i in tempDevices:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700175 if "src=null" in i:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700176 devices.append(i.replace("src=", ""))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700177 if debug: main.log.info(str(devices))
178
179 ingress = devices[0]
cameron@onlab.us61e06032015-04-02 10:54:26 -0700180 egress = devices.pop()
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700181 if debug: main.log.info(ingress)
182 if debug: main.log.info(egress)
183
184 for intentSize in intentsList:
185 cmd = "onos $OC1 push-test-intents "
186 cmd += ingress + "/6 "
187 cmd += egress + "/5 "
188 cmd += str(intentSize) + " 1"
189 installed = []
190 withdrawn = []
191
192 for run in range(0, (warmUp + sampleSize)):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700193 if run > warmUp:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700194 time.sleep(5)
cameron@onlab.us61e06032015-04-02 10:54:26 -0700195
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700196 myRawResult = "--"
197 while "ms" not in myRawResult:
198 main.ONOSbench.handle.sendline(cmd)
199 main.ONOSbench.handle.expect(":~")
200 myRawResult = main.ONOSbench.handle.before
201 if debug: main.log.info(myRawResult)
202
cameron@onlab.us61e06032015-04-02 10:54:26 -0700203 if debug: main.log.info(myRawResult)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700204
cameron@onlab.us61e06032015-04-02 10:54:26 -0700205 if run >= warmUp:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700206 myRawResult = myRawResult.splitlines()
207 for line in myRawResult:
208 if "install" in line:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700209 installed.append(int(line.split(" ")[5]))
210
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700211 for line in myRawResult:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700212 if "withdraw" in line:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700213 withdrawn.append(int(line.split(" ")[5]))
214
215 print("installed: " + str(installed))
216 print("withraw: " + str(withdrawn) + "\n")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700217
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700218 main.log.report("----------------------------------------------------")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700219 main.log.report("Scale: " + str(clusterCount) + "\tIntent batch size: " + str(intentSize))
220 main.log.report("Data samples: " + str(sampleSize) + "\tWarm up tests: " + str(warmUp))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700221 main.log.report("Installed average: " + str(numpy.mean(installed)))
222 main.log.report("Installed standard deviation: " + str(numpy.std(installed)))
223 main.log.report("Withdraw average: " + str(numpy.mean(withdrawn)))
224 main.log.report("Withdraw standard deviation: " + str(numpy.std(withdrawn)))
225 main.log.report(" ")
226