blob: 0a3e0aa465d9ab8f6ed3a89c9c87f45db518d9d7 [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
cameron@onlab.us946d99c2015-07-08 15:34:37 -070038 # -- INIT SECTION, ONLY RUNS ONCE -- #
39 if init == False:
40 init = True
41 global clusterCount #number of nodes running
42 global ONOSIp #list of ONOS IP addresses
43 global scale
44 global commit
45
46 clusterCount = 0
47 ONOSIp = [ 0 ]
48 scale = (main.params[ 'SCALE' ]).split(",")
49 clusterCount = int(scale[0])
50
51 #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 ONOSIp = [0]
57 ONOSIp.extend(main.ONOSbench.getOnosIps())
58
59 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
60 if skipMvn != "yes":
61 mvnResult = main.ONOSbench.cleanInstall()
62
63 #git
64 main.step( "Git checkout and pull " + checkoutBranch )
65 if gitPull == 'on':
66 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
67 pullResult = main.ONOSbench.gitPull()
68
69 else:
70 checkoutResult = main.TRUE
71 pullResult = main.TRUE
72 main.log.info( "Skipped git checkout and pull" )
73
74 commit = main.ONOSbench.getVersion()
75 commit = (commit.split(" "))[1]
76
77 resultsDB = open("flowTP1gDB", "w+")
78 resultsDB.close()
79
80 # -- END OF INIT SECTION --#
81
82 clusterCount = int(scale[0])
83 scale.remove(scale[0])
84 main.log.info("CLUSTER COUNT: " + str(clusterCount))
85
86 MN1Ip = ONOSIp[len(ONOSIp)-1]
87 BENCHIp = ONOSIp[len(ONOSIp)-2]
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 = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")[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 for i in range(3):
230 main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "deviceCount 35")
231 main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "topoShape linear")
232 main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "enabled true")
233
234 time.sleep(5)
235 main.ONOSbench.handle.sendline("onos $OC1 summary")
236 main.ONOSbench.handle.expect(":~")
237 check = main.ONOSbench.handle.before
238 main.log.info("\nStart up check: \n" + check + "\n")
239 if "SCC(s)=1," in check:
240 break
241 time.sleep(5)
242
243 #devide flows
244 flows = int(main.params[ 'TEST' ][ 'flows' ])
245 main.log.info("Flow Target = " + str(flows))
246
247 flows = (flows *max(int(n)+1,int(servers)))/((int(n) + 1)*int(servers)*(switches))
248
249 main.log.info("Flows per switch = " + str(flows))
250
251 #build list of servers in "$OC1, $OC2...." format
252 serverEnvVars = ""
253 for i in range (1,int(servers)+1):
254 serverEnvVars += ("-s " + ONOSIp[i] + " ")
255
256 data = [[""]*int(servers)]*int(sampleSize)
257 maxes = [""]*int(sampleSize)
258
259 flowCMD = "python3 " + homeDir + "/onos/tools/test/bin/"
260 flowCMD += testCMD[0] + " " + str(flows) + " " + testCMD[1]
261 flowCMD += " " + str(n) + " " + str(serverEnvVars) + "-j"
262
263 main.log.info(flowCMD)
264 #time.sleep(60)
265
266 for test in range(0, warmUp + sampleSize):
267 if test < warmUp:
268 main.log.info("Warm up " + str(test + 1) + " of " + str(warmUp))
269 else:
270 main.log.info("====== Test run: " + str(test-warmUp+1) + " ======")
271
272 main.ONOSbench.handle.sendline(flowCMD)
273 main.ONOSbench.handle.expect(":~")
274 rawResult = main.ONOSbench.handle.before
275 main.log.info("Raw results: \n" + rawResult + "\n")
276
277 if "failed" in rawResult:
278 main.log.report("FLOW_TESTER.PY FAILURE")
279 main.log.report( " \n" + rawResult + " \n")
280 for i in range(clusterCount):
281 main.log.report("=======================================================")
282 main.log.report(" ONOS " + str(i) + "LOG REPORT")
283 main.ONOSbench.logReport(ONOSIp[i], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
284 main.ONOSbench.handle.sendline("onos $OC1 flows")
285 main.ONOSbench.handle.expect(":~")
286 main.log.info(main.ONOSbench.handle.before)
287
288 break
289
290 ########################################################################################
291 result = [""]*(clusterCount)
292
293 #print("rawResult: " + rawResult)
294
295 rawResult = rawResult.splitlines()
296
297 for node in range(1, clusterCount + 1):
298 for line in rawResult:
299 #print("line: " + line)
300 if ONOSIp[node] in line and "server" in line:
301 temp = line.split(" ")
302 for word in temp:
303 #print ("word: " + word)
304 if "elapsed" in repr(word):
305 index = temp.index(word) + 1
306 myParsed = (temp[index]).replace(",","")
307 myParsed = myParsed.replace("}","")
308 myParsed = int(myParsed)
309 result[node-1] = myParsed
310 main.log.info( ONOSIp[node] + " : " + str(myParsed))
311 break
312
313 if test >= warmUp:
314 for i in result:
315 if i == "":
cameron@onlab.us904afd92015-07-09 13:32:44 -0700316 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700317 print result
318 maxes[test-warmUp] = max(result)
319 main.log.info("Data collection iteration: " + str(test-warmUp) + " of " + str(sampleSize))
320 main.log.info("Throughput time: " + str(maxes[test-warmUp]) + "(ms)")
321
322 data[test-warmUp] = result
323
324 # wait for flows = 0
325 for checkCount in range(0,5):
326 time.sleep(10)
327 main.ONOSbench.handle.sendline("onos $OC1 summary")
328 main.ONOSbench.handle.expect(":~")
329 flowCheck = main.ONOSbench.handle.before
330 if "flows=0," in flowCheck:
331 main.log.info("Flows removed")
332 break
333 else:
334 for line in flowCheck.splitlines():
335 if "flows=" in line:
336 main.log.info("Current Summary: " + line)
337 if checkCount == 2:
338 main.log.info("Flows are stuck, moving on ")
339
340
341 time.sleep(5)
342
343 main.log.info("raw data: " + str(data))
344 main.log.info("maxes:" + str(maxes))
345
346
347 # report data
348 print("")
349 main.log.info("\t Results (measurments are in milliseconds)")
350 print("")
351
352 nodeString = ""
353 for i in range(1, int(servers) + 1):
354 nodeString += ("\tNode " + str(i))
355
356 for test in range(0, sampleSize ):
357 main.log.info("\t Test iteration " + str(test + 1) )
358 main.log.info("\t------------------")
359 main.log.info(nodeString)
360 resultString = ""
361
362 for i in range(0, int(servers) ):
363 resultString += ("\t" + str(data[test][i]) )
364 main.log.info(resultString)
365
366 print("\n")
367
368 avgOfMaxes = numpy.mean(maxes)
369 main.log.info("Average of max value from each test iteration: " + str(avgOfMaxes))
370
371 stdOfMaxes = numpy.std(maxes)
372 main.log.info("Standard Deviation of max values: " + str(stdOfMaxes))
373 print("\n\n")
374
375 avgTP = int(main.params[ 'TEST' ][ 'flows' ]) / avgOfMaxes #result in kflows/second
376
377 tp = []
378 for i in maxes:
379 tp.append((int(main.params[ 'TEST' ][ 'flows' ]) / i ))
380
381 stdTP = numpy.std(tp)
382
383 main.log.info("Average thoughput: " + str(avgTP) + " Kflows/second" )
384 main.log.info("Standard deviation of throughput: " + str(stdTP) + " Kflows/second")
385
386 resultsLog = open("flowTP1gDB","a")
387 resultString = ("'" + commit + "',")
388 resultString += ("'1gig',")
389 resultString += ((main.params[ 'TEST' ][ 'flows' ]) + ",")
390 resultString += (str(clusterCount) + ",")
391 resultString += (str(n) + ",")
392 resultString += (str(avgTP) + "," + str(stdTP) + "\n")
393 resultsLog.write(resultString)
394 resultsLog.close()
395
396 main.log.report("Result line to file: " + resultString)
397
398 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")