blob: cbea03975ed854e6fd02957d549293e5b15d38f4 [file] [log] [blame]
pingping-lin763ee042015-05-20 17:45:30 -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 flowTP1g:
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 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
32 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
33 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
34 maxNodes = int(main.params[ 'availableNodes' ])
35 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
36 cellName = main.params[ 'ENV' ][ 'cellName' ]
37
38 main.log.info("==========DEBUG VERSION 3===========")
39
40 main.exceptions = [0]*11
41 main.warnings = [0]*11
42 main.errors = [0]*11
43
44 # -- INIT SECTION, ONLY RUNS ONCE -- #
45 if init == False:
46 init = True
47 global clusterCount #number of nodes running
48 global ONOSIp #list of ONOS IP addresses
49 global scale
50 global commit
51
52 clusterCount = 0
53 ONOSIp = [ 0 ]
54 scale = (main.params[ 'SCALE' ]).split(",")
55 clusterCount = int(scale[0])
56
57 #Populate ONOSIp with ips from params
58 for i in range(1, maxNodes + 1):
59 ipString = 'ip' + str(i)
60 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
61
62 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
63 if skipMvn != "yes":
64 mvnResult = main.ONOSbench.cleanInstall()
65
66 #git
67 main.step( "Git checkout and pull " + checkoutBranch )
68 if gitPull == 'on':
69 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
70 pullResult = main.ONOSbench.gitPull()
71
72 else:
73 checkoutResult = main.TRUE
74 pullResult = main.TRUE
75 main.log.info( "Skipped git checkout and pull" )
76
77 commit = main.ONOSbench.getVersion()
78 commit = (commit.split(" "))[1]
79
80 resultsDB = open("flowTP1gDB", "w+")
81 resultsDB.close()
82
83 # -- END OF INIT SECTION --#
84
85 clusterCount = int(scale[0])
86 scale.remove(scale[0])
87 main.log.info("CLUSTER COUNT: " + str(clusterCount))
88
89 #kill off all onos processes
90 main.log.step("Safety check, killing all ONOS processes")
91 main.log.step("before initiating enviornment setup")
92 for node in range(1, maxNodes + 1):
93 main.ONOSbench.onosDie(ONOSIp[node])
94
95 #Uninstall everywhere
96 main.log.step( "Cleaning Enviornment..." )
97 for i in range(1, maxNodes + 1):
98 main.log.info(" Uninstalling ONOS " + str(i) )
99 main.ONOSbench.onosUninstall( ONOSIp[i] )
100
101 #construct the cell file
102 main.log.info("Creating cell file")
103 cellIp = []
104 for node in range (1, clusterCount + 1):
105 cellIp.append(ONOSIp[node])
106
107 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
108 main.log.info("Cell Ip list: " + str(cellIp))
109
110 main.step( "Set Cell" )
111 main.ONOSbench.setCell(cellName)
112
113 main.step( "Creating ONOS package" )
114 packageResult = main.ONOSbench.onosPackage()
115
116 main.step( "verify cells" )
117 verifyCellResult = main.ONOSbench.verifyCell()
118
119 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
120 for node in range(1, clusterCount + 1):
121 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
122 main.ONOSbench.onosInstall( ONOSIp[node])
123
124 for node in range(1, clusterCount + 1):
125 for i in range( 2 ):
126 isup = main.ONOSbench.isup( ONOSIp[node] )
127 if isup:
128 main.log.info("ONOS " + str(node) + " is up\n")
129 break
130 if not isup:
131 main.log.report( "ONOS " + str(node) + " didn't start!" )
132
133 for node in range(1, clusterCount + 1):
134 exec "a = main.ONOS%scli.startOnosCli" %str(node)
135 a(ONOSIp[node])
136
137 main.log.info("Startup sequence complete")
138 main.ONOSbench.onosErrorLog(ONOSIp[1])
139
140 def CASE2( self, main ):
141 #
142 # This is the flow TP test
143 #
144 import os.path
145 import numpy
146 import math
147 import time
148 import datetime
149 import traceback
150
151 global currentNeighbors
152 try:
153 currentNeighbors
154 except:
155 currentNeighbors = "0"
156 else:
157 if currentNeighbors == "r": #reset
158 currentNeighbors = "0"
159 else:
160 currentNeighbors = "a"
161
162 testCMD = [ 0,0,0,0 ]
163 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
164 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
165 switches = int(main.params[ 'TEST' ][ 'switches' ])
166 neighborList = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
167 testCMD[0] = main.params[ 'TEST' ][ 'testCMD0' ]
168 testCMD[1] = main.params[ 'TEST' ][ 'testCMD1' ]
169 maxNodes = main.params[ 'availableNodes' ]
170 onBaremetal = main.params['isOnBaremetal']
171 cooldown = main.params[ 'TEST' ][ 'cooldown' ]
172 cellName = main.params[ 'ENV' ][ 'cellName' ]
173 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
174 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
175 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
176 maxNodes = int(main.params[ 'availableNodes' ])
177 homeDir = os.path.expanduser('~')
178 flowRuleBackup = str(main.params[ 'TEST' ][ 'enableFlowRuleStoreBackup' ])
179 main.log.info("Flow Rule Backup is set to:" + flowRuleBackup)
180
181 servers = str(clusterCount)
182
183 if clusterCount == 1:
184 neighborList = ['0']
185 currentNeighbors = "r"
186 else:
187 if currentNeighbors == "a":
188 neighborList = [str(clusterCount-1)]
189 currentNeighbors = "r"
190 else:
191 neighborList = ['0']
192
193 main.log.info("neightborlist: " + str(neighborList))
194
195 ts = time.time()
196 st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
197
198 #write file to change mem limit to 32 gigs (BAREMETAL ONLY!)
199 if onBaremetal == "true":
200 filename = "/onos/tools/package/bin/onos-service"
201 serviceConfig = open(homeDir + filename, 'w+')
202 serviceConfig.write("#!/bin/bash\n ")
203 serviceConfig.write("#------------------------------------- \n ")
204 serviceConfig.write("# Starts ONOS Apache Karaf container\n ")
205 serviceConfig.write("#------------------------------------- \n ")
206 serviceConfig.write("#export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}\n ")
207 serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G}" \n """)
208 serviceConfig.write("")
209 serviceConfig.write("ONOS_HOME=/opt/onos \n ")
210 serviceConfig.write("")
211 serviceConfig.write("[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..\n")
212 serviceConfig.write("""${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf "$@" \n """)
213 serviceConfig.close()
214
215 for n in neighborList:
216 main.log.step("\tSTARTING TEST")
217 main.log.step("\tLOADING FROM SERVERS: \t" + str(clusterCount) )
218 main.log.step("\tNEIGHBORS:\t" + n )
219 main.log.info("=============================================================")
220 main.log.info("=============================================================")
221 #write file to configure nil link
222 ipCSV = ""
223 for i in range (1, int(maxNodes) + 1):
224 tempstr = "ip" + str(i)
225 ipCSV += main.params[ 'CTRL' ][ tempstr ]
226 if i < int(maxNodes):
227 ipCSV +=","
228
229
230 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount 35" """)
231 main.ONOSbench.handle.expect(":~")
232 time.sleep(3)
233 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
234 main.ONOSbench.handle.expect(":~")
235 time.sleep(3)
236 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
237 main.ONOSbench.handle.expect(":~")
238 time.sleep(3)
239 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
240 main.ONOSbench.handle.expect(":~")
241 time.sleep(3)
242 main.log.info("""onos $OC1 "cfg set org.onosproject.store.flow.impl.NewDistributedFlowRuleStore backupEnabled """ + flowRuleBackup + """" """)
243 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.store.flow.impl.NewDistributedFlowRuleStore backupEnabled """ + flowRuleBackup + """" """)
244 main.ONOSbench.handle.expect(":~")
245
246 main.ONOSbench.handle.sendline("onos $OC1 summary")
247 main.ONOSbench.handle.expect(":~")
248 check = main.ONOSbench.handle.before
249
250 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get" """)
251 main.ONOSbench.handle.expect(":~")
252 check = main.ONOSbench.handle.before
253 main.log.info("\nStart up check: \n" + check + "\n")
254
255 #devide flows
256 flows = int(main.params[ 'TEST' ][ 'flows' ])
257 main.log.info("Flow Target = " + str(flows))
258
259 flows = (flows *max(int(n)+1,int(servers)))/((int(n) + 1)*int(servers)*(switches))
260
261 main.log.info("Flows per switch = " + str(flows))
262
263 #build list of servers in "$OC1, $OC2...." format
264 serverEnvVars = ""
265 for i in range (1,int(servers)+1):
266 serverEnvVars += ("-s " + ONOSIp[i] + " ")
267
268 data = [[""]*int(servers)]*int(sampleSize)
269 maxes = [""]*int(sampleSize)
270
271 flowCMD = "python3 " + homeDir + "/onos/tools/test/bin/"
272 flowCMD += testCMD[0] + " " + str(flows) + " " + testCMD[1]
273 flowCMD += " " + str(n) + " " + str(serverEnvVars) + "-j"
274
275 main.log.info(flowCMD)
276 #time.sleep(60)
277
278 for test in range(0, warmUp + sampleSize):
279 if test < warmUp:
280 main.log.info("Warm up " + str(test + 1) + " of " + str(warmUp))
281 else:
282 main.log.info("====== Test run: " + str(test-warmUp+1) + " ======")
283
284 main.ONOSbench.handle.sendline(flowCMD)
285 main.ONOSbench.handle.expect(":~")
286 rawResult = main.ONOSbench.handle.before
287 main.log.info("Raw results: \n" + rawResult + "\n")
288
289 if "failed" in rawResult:
290 main.log.report("FLOW_TESTER.PY FAILURE")
291 main.log.report( " \n" + rawResult + " \n")
292 break
293
294 ########################################################################################
295 result = [""]*(clusterCount)
296 rawResult = rawResult.splitlines()
297
298 for node in range(1, clusterCount + 1):
299 for line in rawResult:
300 #print("line: " + line)
301 if ONOSIp[node] in line and "server" in line:
302 temp = line.split(" ")
303 for word in temp:
304 #print ("word: " + word)
305 if "elapsed" in repr(word):
306 #print("in elapsed ==========")
307 index = temp.index(word) + 1
308 #print ("index: " + str(index))
309 #print ("temp[index]: " + temp[index])
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.onosErrorLog(ONOSIp[1])