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