blob: 3c1805ab62fd321a971ecce899171dfbfdc99e4d [file] [log] [blame]
cameron@onlab.us946d99c2015-07-08 15:34:37 -07001# ScaleOutTemplate -> flowTP
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 SCPFflowTp1g:
12
13 def __init__( self ):
14 self.default = ''
15
16 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
26 #Load values from params file
27 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
28 gitPull = main.params[ 'GIT' ][ 'autopull' ]
29 cellName = main.params[ 'ENV' ][ 'cellName' ]
30 Apps = main.params[ 'ENV' ][ 'cellApps' ]
31 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
cameron@onlab.usb3aa4982015-07-13 15:20:41 -070032 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
33 main.maxNodes = int(main.params[ 'max' ])
cameron@onlab.us946d99c2015-07-08 15:34:37 -070034 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
35 cellName = main.params[ 'ENV' ][ 'cellName' ]
36
37 main.log.info("==========DEBUG VERSION 3===========")
38
cameron@onlab.us946d99c2015-07-08 15:34:37 -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 global commit
46
47 clusterCount = 0
48 ONOSIp = [ 0 ]
49 scale = (main.params[ 'SCALE' ]).split(",")
50 clusterCount = int(scale[0])
51
52 #Populate ONOSIp with ips from params
cameron@onlab.usb3aa4982015-07-13 15:20:41 -070053 for i in range(1, main.maxNodes + 1):
cameron@onlab.us946d99c2015-07-08 15:34:37 -070054 ipString = 'ip' + str(i)
55 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
56
57 ONOSIp = [0]
58 ONOSIp.extend(main.ONOSbench.getOnosIps())
59
60 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
61 if skipMvn != "yes":
62 mvnResult = main.ONOSbench.cleanInstall()
63
64 #git
65 main.step( "Git checkout and pull " + checkoutBranch )
66 if gitPull == 'on':
67 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
68 pullResult = main.ONOSbench.gitPull()
69
70 else:
71 checkoutResult = main.TRUE
72 pullResult = main.TRUE
73 main.log.info( "Skipped git checkout and pull" )
74
75 commit = main.ONOSbench.getVersion()
76 commit = (commit.split(" "))[1]
77
suibine1e58772015-07-15 09:52:59 -070078 resultsDB = open("/tmp/flowTP1gDB", "w+")
cameron@onlab.us946d99c2015-07-08 15:34:37 -070079 resultsDB.close()
80
81 # -- END OF INIT SECTION --#
82
83 clusterCount = int(scale[0])
84 scale.remove(scale[0])
85 main.log.info("CLUSTER COUNT: " + str(clusterCount))
86
cameron@onlab.us946d99c2015-07-08 15:34:37 -070087 #kill off all onos processes
88 main.log.step("Safety check, killing all ONOS processes")
89 main.log.step("before initiating enviornment setup")
cameron@onlab.usb3aa4982015-07-13 15:20:41 -070090 for node in range(1, main.maxNodes + 1):
cameron@onlab.us946d99c2015-07-08 15:34:37 -070091 main.ONOSbench.onosDie(ONOSIp[node])
92
93 #Uninstall everywhere
94 main.log.step( "Cleaning Enviornment..." )
cameron@onlab.usb3aa4982015-07-13 15:20:41 -070095 for i in range(1, main.maxNodes + 1):
cameron@onlab.us946d99c2015-07-08 15:34:37 -070096 main.log.info(" Uninstalling ONOS " + str(i) )
97 main.ONOSbench.onosUninstall( ONOSIp[i] )
98
99 #construct the cell file
100 main.log.info("Creating cell file")
101 cellIp = []
102 for node in range (1, clusterCount + 1):
103 cellIp.append(ONOSIp[node])
104
cameron@onlab.usb3aa4982015-07-13 15:20:41 -0700105 main.ONOSbench.createCellFile(BENCHIp,cellName,"localhost",str(Apps), cellIp)
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700106 main.log.info("Cell Ip list: " + str(cellIp))
107
108 main.step( "Set Cell" )
109 main.ONOSbench.setCell(cellName)
110
111 main.step( "Creating ONOS package" )
112 packageResult = main.ONOSbench.onosPackage()
113
114 main.step( "verify cells" )
115 verifyCellResult = main.ONOSbench.verifyCell()
116
117 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
118 for node in range(1, clusterCount + 1):
119 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
120 main.ONOSbench.onosInstall( ONOSIp[node])
121
122 for node in range(1, clusterCount + 1):
123 for i in range( 2 ):
124 isup = main.ONOSbench.isup( ONOSIp[node] )
125 if isup:
126 main.log.info("ONOS " + str(node) + " is up\n")
127 break
128 if not isup:
129 main.log.report( "ONOS " + str(node) + " didn't start!" )
130
131 for node in range(1, clusterCount + 1):
132 exec "a = main.ONOS%scli.startOnosCli" %str(node)
133 a(ONOSIp[node])
134
135 main.log.info("Startup sequence complete")
cameron@onlab.usb3aa4982015-07-13 15:20:41 -0700136 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700137 def CASE2( self, main ):
138 #
139 # This is the flow TP test
140 #
141 import os.path
142 import numpy
143 import math
144 import time
145 import datetime
146 import traceback
147
148 global currentNeighbors
149 try:
150 currentNeighbors
151 except:
152 currentNeighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")[0]
153 else:
154 if currentNeighbors == "r": #reset
155 currentNeighbors = "0"
156 else:
157 currentNeighbors = "a"
158
159 testCMD = [ 0,0,0,0 ]
160 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
161 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
162 switches = int(main.params[ 'TEST' ][ 'switches' ])
163 neighborList = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
164 testCMD[0] = main.params[ 'TEST' ][ 'testCMD0' ]
165 testCMD[1] = main.params[ 'TEST' ][ 'testCMD1' ]
cameron@onlab.usb3aa4982015-07-13 15:20:41 -0700166 main.maxNodes = main.params[ 'max' ]
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700167 onBaremetal = main.params['isOnBaremetal']
168 cooldown = main.params[ 'TEST' ][ 'cooldown' ]
169 cellName = main.params[ 'ENV' ][ 'cellName' ]
170 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
171 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
172 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700173 homeDir = os.path.expanduser('~')
174 flowRuleBackup = str(main.params[ 'TEST' ][ 'enableFlowRuleStoreBackup' ])
175 main.log.info("Flow Rule Backup is set to:" + flowRuleBackup)
176
177 servers = str(clusterCount)
178
179 if clusterCount == 1:
180 neighborList = ['0']
181 currentNeighbors = "r"
182 else:
183 if currentNeighbors == "a":
184 neighborList = [str(clusterCount-1)]
185 currentNeighbors = "r"
186 else:
187 neighborList = ['0']
188
189 main.log.info("neightborlist: " + str(neighborList))
190
191 ts = time.time()
192 st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
193
194 #write file to change mem limit to 32 gigs (BAREMETAL ONLY!)
195 if onBaremetal == "true":
cameron@onlab.usb3aa4982015-07-13 15:20:41 -0700196 main.ONOSbench.jvmSet()
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700197
198 for n in neighborList:
199 main.log.step("\tSTARTING TEST")
200 main.log.step("\tLOADING FROM SERVERS: \t" + str(clusterCount) )
201 main.log.step("\tNEIGHBORS:\t" + n )
202 main.log.info("=============================================================")
203 main.log.info("=============================================================")
204 #write file to configure nil link
205 ipCSV = ""
cameron@onlab.usb3aa4982015-07-13 15:20:41 -0700206 for i in range (1, int(main.maxNodes) + 1):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700207 tempstr = "ip" + str(i)
208 ipCSV += main.params[ 'CTRL' ][ tempstr ]
cameron@onlab.usb3aa4982015-07-13 15:20:41 -0700209 if i < int(main.maxNodes):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700210 ipCSV +=","
211
212 for i in range(3):
213 main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "deviceCount 35")
214 main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "topoShape linear")
215 main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "enabled true")
216
217 time.sleep(5)
218 main.ONOSbench.handle.sendline("onos $OC1 summary")
219 main.ONOSbench.handle.expect(":~")
220 check = main.ONOSbench.handle.before
221 main.log.info("\nStart up check: \n" + check + "\n")
222 if "SCC(s)=1," in check:
223 break
224 time.sleep(5)
225
226 #devide flows
227 flows = int(main.params[ 'TEST' ][ 'flows' ])
228 main.log.info("Flow Target = " + str(flows))
229
230 flows = (flows *max(int(n)+1,int(servers)))/((int(n) + 1)*int(servers)*(switches))
231
232 main.log.info("Flows per switch = " + str(flows))
233
234 #build list of servers in "$OC1, $OC2...." format
235 serverEnvVars = ""
236 for i in range (1,int(servers)+1):
237 serverEnvVars += ("-s " + ONOSIp[i] + " ")
238
239 data = [[""]*int(servers)]*int(sampleSize)
240 maxes = [""]*int(sampleSize)
241
242 flowCMD = "python3 " + homeDir + "/onos/tools/test/bin/"
243 flowCMD += testCMD[0] + " " + str(flows) + " " + testCMD[1]
244 flowCMD += " " + str(n) + " " + str(serverEnvVars) + "-j"
245
246 main.log.info(flowCMD)
247 #time.sleep(60)
248
249 for test in range(0, warmUp + sampleSize):
250 if test < warmUp:
251 main.log.info("Warm up " + str(test + 1) + " of " + str(warmUp))
252 else:
253 main.log.info("====== Test run: " + str(test-warmUp+1) + " ======")
254
255 main.ONOSbench.handle.sendline(flowCMD)
256 main.ONOSbench.handle.expect(":~")
257 rawResult = main.ONOSbench.handle.before
258 main.log.info("Raw results: \n" + rawResult + "\n")
259
260 if "failed" in rawResult:
261 main.log.report("FLOW_TESTER.PY FAILURE")
262 main.log.report( " \n" + rawResult + " \n")
263 for i in range(clusterCount):
264 main.log.report("=======================================================")
265 main.log.report(" ONOS " + str(i) + "LOG REPORT")
266 main.ONOSbench.logReport(ONOSIp[i], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
267 main.ONOSbench.handle.sendline("onos $OC1 flows")
268 main.ONOSbench.handle.expect(":~")
269 main.log.info(main.ONOSbench.handle.before)
270
271 break
272
273 ########################################################################################
274 result = [""]*(clusterCount)
275
276 #print("rawResult: " + rawResult)
277
278 rawResult = rawResult.splitlines()
279
280 for node in range(1, clusterCount + 1):
281 for line in rawResult:
282 #print("line: " + line)
283 if ONOSIp[node] in line and "server" in line:
284 temp = line.split(" ")
285 for word in temp:
286 #print ("word: " + word)
287 if "elapsed" in repr(word):
288 index = temp.index(word) + 1
289 myParsed = (temp[index]).replace(",","")
290 myParsed = myParsed.replace("}","")
291 myParsed = int(myParsed)
292 result[node-1] = myParsed
293 main.log.info( ONOSIp[node] + " : " + str(myParsed))
294 break
295
296 if test >= warmUp:
297 for i in result:
298 if i == "":
cameron@onlab.usb3aa4982015-07-13 15:20:41 -0700299 main.log.error("Missing data point, critical failure incoming")
300
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700301 print result
302 maxes[test-warmUp] = max(result)
303 main.log.info("Data collection iteration: " + str(test-warmUp) + " of " + str(sampleSize))
304 main.log.info("Throughput time: " + str(maxes[test-warmUp]) + "(ms)")
305
306 data[test-warmUp] = result
307
308 # wait for flows = 0
309 for checkCount in range(0,5):
310 time.sleep(10)
311 main.ONOSbench.handle.sendline("onos $OC1 summary")
312 main.ONOSbench.handle.expect(":~")
313 flowCheck = main.ONOSbench.handle.before
314 if "flows=0," in flowCheck:
315 main.log.info("Flows removed")
316 break
317 else:
318 for line in flowCheck.splitlines():
319 if "flows=" in line:
320 main.log.info("Current Summary: " + line)
321 if checkCount == 2:
322 main.log.info("Flows are stuck, moving on ")
323
324
325 time.sleep(5)
326
327 main.log.info("raw data: " + str(data))
328 main.log.info("maxes:" + str(maxes))
329
330
331 # report data
332 print("")
333 main.log.info("\t Results (measurments are in milliseconds)")
334 print("")
335
336 nodeString = ""
337 for i in range(1, int(servers) + 1):
338 nodeString += ("\tNode " + str(i))
339
340 for test in range(0, sampleSize ):
341 main.log.info("\t Test iteration " + str(test + 1) )
342 main.log.info("\t------------------")
343 main.log.info(nodeString)
344 resultString = ""
345
346 for i in range(0, int(servers) ):
347 resultString += ("\t" + str(data[test][i]) )
348 main.log.info(resultString)
349
350 print("\n")
351
352 avgOfMaxes = numpy.mean(maxes)
353 main.log.info("Average of max value from each test iteration: " + str(avgOfMaxes))
354
355 stdOfMaxes = numpy.std(maxes)
356 main.log.info("Standard Deviation of max values: " + str(stdOfMaxes))
357 print("\n\n")
358
359 avgTP = int(main.params[ 'TEST' ][ 'flows' ]) / avgOfMaxes #result in kflows/second
360
361 tp = []
362 for i in maxes:
363 tp.append((int(main.params[ 'TEST' ][ 'flows' ]) / i ))
364
365 stdTP = numpy.std(tp)
366
367 main.log.info("Average thoughput: " + str(avgTP) + " Kflows/second" )
368 main.log.info("Standard deviation of throughput: " + str(stdTP) + " Kflows/second")
369
suibin584c0702015-07-14 15:57:27 -0700370 resultsLog = open("/tmp/flowTP1gDB","a")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700371 resultString = ("'" + commit + "',")
372 resultString += ("'1gig',")
373 resultString += ((main.params[ 'TEST' ][ 'flows' ]) + ",")
374 resultString += (str(clusterCount) + ",")
375 resultString += (str(n) + ",")
376 resultString += (str(avgTP) + "," + str(stdTP) + "\n")
377 resultsLog.write(resultString)
378 resultsLog.close()
379
380 main.log.report("Result line to file: " + resultString)
381
382 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")