blob: 8092185192b62431931df89615a71766256aa8f5 [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
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070045 global commit
46
cameron@onlab.us61e06032015-04-02 10:54:26 -070047 clusterCount = 0
48 ONOSIp = [ 0 ]
49 scale = (main.params[ 'SCALE' ]).split(",")
50 clusterCount = int(scale[0])
cameron@onlab.us1201bc42015-04-01 16:30:05 -070051
cameron@onlab.us61e06032015-04-02 10:54:26 -070052 #Populate ONOSIp with ips from params
53 for i in range(1, maxNodes + 1):
54 ipString = 'ip' + str(i)
55 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
56
57 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
58 if skipMvn != "yes":
59 mvnResult = main.ONOSbench.cleanInstall()
cameron@onlab.us1201bc42015-04-01 16:30:05 -070060
cameron@onlab.us1201bc42015-04-01 16:30:05 -070061 #git
62 main.step( "Git checkout and pull " + checkoutBranch )
63 if gitPull == 'on':
64 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
65 pullResult = main.ONOSbench.gitPull()
66
67 else:
68 checkoutResult = main.TRUE
69 pullResult = main.TRUE
70 main.log.info( "Skipped git checkout and pull" )
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070071
72 commit = main.ONOSbench.getVersion()
73 commit = (commit.split(" "))[1]
74
75 resultsDB = open("IntentInstallWithdrawLatDB", "w+")
76 resultsDB.close()
77
cameron@onlab.us61e06032015-04-02 10:54:26 -070078 # -- END OF INIT SECTION --#
79
80 clusterCount = int(scale[0])
81 scale.remove(scale[0])
cameron@onlab.us1201bc42015-04-01 16:30:05 -070082
cameron@onlab.us61e06032015-04-02 10:54:26 -070083 #kill off all onos processes
84 main.log.step("Safety check, killing all ONOS processes")
85 main.log.step("before initiating enviornment setup")
86 for node in range(1, maxNodes + 1):
87 main.ONOSbench.onosDie(ONOSIp[node])
88
89 #Uninstall everywhere
90 main.log.step( "Cleaning Enviornment..." )
91 for i in range(1, maxNodes + 1):
92 main.log.info(" Uninstalling ONOS " + str(i) )
93 main.ONOSbench.onosUninstall( ONOSIp[i] )
94
95 #construct the cell file
cameron@onlab.us1201bc42015-04-01 16:30:05 -070096 main.log.info("Creating cell file")
cameron@onlab.us1201bc42015-04-01 16:30:05 -070097 cellIp = []
98 for node in range (1, clusterCount + 1):
99 cellIp.append(ONOSIp[node])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700100
cameron@onlab.us61e06032015-04-02 10:54:26 -0700101 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700102
cameron@onlab.us61e06032015-04-02 10:54:26 -0700103 main.step( "Set Cell" )
104 main.ONOSbench.setCell(cellName)
105
cameron@onlab.us61e06032015-04-02 10:54:26 -0700106 main.step( "Creating ONOS package" )
107 packageResult = main.ONOSbench.onosPackage()
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700108
cameron@onlab.us61e06032015-04-02 10:54:26 -0700109 main.step( "verify cells" )
110 verifyCellResult = main.ONOSbench.verifyCell()
111
112 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700113 for node in range(1, clusterCount + 1):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700114 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
115 main.ONOSbench.onosInstall( ONOSIp[node])
116
117 for node in range(1, clusterCount + 1):
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700118 for i in range( 2 ):
119 isup = main.ONOSbench.isup( ONOSIp[node] )
120 if isup:
121 main.log.info("ONOS " + str(node) + " is up\n")
122 break
123 if not isup:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700124 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700125
cameron@onlab.us61e06032015-04-02 10:54:26 -0700126 main.ONOS1cli.startOnosCli( ONOSIp[1] )
127 main.log.info("Startup sequence complete")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700128
129 time.sleep(30)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700130
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700131 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount """ + str(switchCount) + """ " """)
132 main.ONOSbench.handle.expect(":~")
133 print main.ONOSbench.handle.before
cameron@onlab.us768363a2015-05-06 13:55:17 -0700134 time.sleep(3)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700135 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
136 main.ONOSbench.handle.expect(":~")
137 print main.ONOSbench.handle.before
cameron@onlab.us768363a2015-05-06 13:55:17 -0700138 time.sleep(3)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700139 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
140 main.ONOSbench.handle.expect(":~")
141 print main.ONOSbench.handle.before
cameron@onlab.us768363a2015-05-06 13:55:17 -0700142 time.sleep(3)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700143 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
144 main.ONOSbench.handle.expect(":~")
145 print main.ONOSbench.handle.before
cameron@onlab.us768363a2015-05-06 13:55:17 -0700146 time.sleep(3)
147
148 for i in range(0,5):
149 main.ONOSbench.handle.sendline("onos $OC1 summary")
150 main.ONOSbench.handle.expect(":~")
151 check = main.ONOSbench.handle.before
152 if "devices=7," in check:
153 main.log.info("startup successful")
154 break
155 else:
156 main.log.error(check)
157 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation stop" """)
158 main.ONOSbench.handle.expect(":~")
159 time.sleep(6)
160 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
161 main.ONOSbench.handle.expect(":~")
162 time.sleep(2)
cameron@onlab.us61e06032015-04-02 10:54:26 -0700163
164 def CASE2( self, main ):
165
166 import time
167 import numpy
168
169 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700170 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
171 intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",")
172 switchCount = int(main.params[ 'TEST' ][ 'switchCount' ])
173 debug = main.params[ 'TEST' ][ 'switchCount' ]
cameron@onlab.us768363a2015-05-06 13:55:17 -0700174 print("0")
175
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700176 for i in range(0,len(intentsList)):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700177 intentsList[i] = int(intentsList[i])
cameron@onlab.us768363a2015-05-06 13:55:17 -0700178 main.log.info("Intents list: " + str(intentsList))
cameron@onlab.us61e06032015-04-02 10:54:26 -0700179
cameron@onlab.us768363a2015-05-06 13:55:17 -0700180 print("1")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700181 if debug == "True":
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700182 debug = True
cameron@onlab.us61e06032015-04-02 10:54:26 -0700183 else:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700184 debug = False
cameron@onlab.us768363a2015-05-06 13:55:17 -0700185
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700186 linkCount = 0
187 for i in range(0,10):
188 main.ONOSbench.handle.sendline("onos $OC1 links|wc -l")
189 main.ONOSbench.handle.expect(":~")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700190 linkCount = main.ONOSbench.handle.before
191 if debug: main.log.info("Link Count check: " + linkCount)
192 if str((switchCount*2)-2) in linkCount:
193 break
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700194 time.sleep(2)
cameron@onlab.us61e06032015-04-02 10:54:26 -0700195 links = "--"
cameron@onlab.us768363a2015-05-06 13:55:17 -0700196 x = 0
197 print("2")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700198 while "=null:" not in links:
cameron@onlab.us768363a2015-05-06 13:55:17 -0700199 if x >= 20:
200 main.log.error("link check failure")
201 break
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700202 if debug: main.log.info("top of loop")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700203 main.ONOSbench.handle.sendline("onos $OC1 links")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700204 main.ONOSbench.handle.expect(":~")
205 links = main.ONOSbench.handle.before
cameron@onlab.us61e06032015-04-02 10:54:26 -0700206 if debug: main.log.info(str(links))
207 time.sleep(1)
cameron@onlab.us768363a2015-05-06 13:55:17 -0700208 x += 1
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700209 links = links.splitlines()
cameron@onlab.us61e06032015-04-02 10:54:26 -0700210 templinks = links
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700211 tempDevices = []
cameron@onlab.us61e06032015-04-02 10:54:26 -0700212 for line in links:
213 temp = line.split(" ")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700214 temp[0].replace("src=","")
215 temp[0] = (temp[0].split("/"))[0]
cameron@onlab.us61e06032015-04-02 10:54:26 -0700216 tempDevices.append(temp[0])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700217
cameron@onlab.us768363a2015-05-06 13:55:17 -0700218 print("3")
219
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700220 tempDevices.sort()
221 devices = []
cameron@onlab.us61e06032015-04-02 10:54:26 -0700222 for i in tempDevices:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700223 if "src=null" in i:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700224 devices.append(i.replace("src=", ""))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700225 if debug: main.log.info(str(devices))
226
cameron@onlab.us768363a2015-05-06 13:55:17 -0700227 print("4")
228
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700229 ingress = devices[0]
cameron@onlab.us61e06032015-04-02 10:54:26 -0700230 egress = devices.pop()
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700231 if debug: main.log.info(ingress)
232 if debug: main.log.info(egress)
233
cameron@onlab.us768363a2015-05-06 13:55:17 -0700234 print("5")
235
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700236 for intentSize in intentsList:
237 cmd = "onos $OC1 push-test-intents "
238 cmd += ingress + "/6 "
239 cmd += egress + "/5 "
240 cmd += str(intentSize) + " 1"
cameron@onlab.us768363a2015-05-06 13:55:17 -0700241 main.log.info("COMMAND: " + cmd)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700242 installed = []
243 withdrawn = []
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700244 for run in range(0, (warmUp + sampleSize)):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700245 if run > warmUp:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700246 time.sleep(5)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700247 myRawResult = "--"
248 while "ms" not in myRawResult:
249 main.ONOSbench.handle.sendline(cmd)
250 main.ONOSbench.handle.expect(":~")
251 myRawResult = main.ONOSbench.handle.before
cameron@onlab.us768363a2015-05-06 13:55:17 -0700252 main.log.info(myRawResult)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700253
cameron@onlab.us61e06032015-04-02 10:54:26 -0700254 if debug: main.log.info(myRawResult)
cameron@onlab.us61e06032015-04-02 10:54:26 -0700255 if run >= warmUp:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700256 myRawResult = myRawResult.splitlines()
257 for line in myRawResult:
258 if "install" in line:
cameron@onlab.us768363a2015-05-06 13:55:17 -0700259 print(line)
cameron@onlab.us61e06032015-04-02 10:54:26 -0700260 installed.append(int(line.split(" ")[5]))
261
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700262 for line in myRawResult:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700263 if "withdraw" in line:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700264 withdrawn.append(int(line.split(" ")[5]))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700265 print("installed: " + str(installed))
266 print("withraw: " + str(withdrawn) + "\n")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700267
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700268 main.log.report("----------------------------------------------------")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700269 main.log.report("Scale: " + str(clusterCount) + "\tIntent batch size: " + str(intentSize))
270 main.log.report("Data samples: " + str(sampleSize) + "\tWarm up tests: " + str(warmUp))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700271 main.log.report("Installed average: " + str(numpy.mean(installed)))
272 main.log.report("Installed standard deviation: " + str(numpy.std(installed)))
273 main.log.report("Withdraw average: " + str(numpy.mean(withdrawn)))
274 main.log.report("Withdraw standard deviation: " + str(numpy.std(withdrawn)))
275 main.log.report(" ")
276
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700277 resultString = "'" + commit + "',"
278 resultString += str(clusterCount) + ","
279 resultString += str(intentSize) + ","
280 resultString += str(numpy.mean(installed)) + ","
281 resultString += str(numpy.std(installed)) + ","
282 resultString += str(numpy.mean(withdrawn)) + ","
283 resultString += str(numpy.std(withdrawn)) + "\n"
cameron@onlab.us768363a2015-05-06 13:55:17 -0700284 resultsDB = open("IntentInstallWithdrawLatDB", "a")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700285 resultsDB.write(resultString)
286 resultsDB.close()