blob: 8261a47eab40dc29004ea9d2c7b147cb7cd88646 [file] [log] [blame]
andrew@onlab.us5cdb2852015-03-11 15:11:10 -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 ): #This is the initialization case
17 #this case will clean up all nodes
18 #but only node 1 is started in this case
19
20 global clusterCount #number of nodes running
21 global ONOSIp #list of ONOS IP addresses
22 clusterCount = 1
23 ONOSIp = [ 0 ]
24
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 Features= main.params[ 'ENV' ][ 'cellFeatures' ]
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 Features = main.params[ 'ENV' ][ 'cellFeatures' ]
36 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
37
38 main.ONOSbench.handle.sendline("export TERM=vt100")
39
40 #Populate ONOSIp with ips from params
41 for i in range(1, maxNodes + 1):
42 ipString = 'ip' + str(i)
43 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
44
45 #kill off all onos processes
46 main.log.step("Safety check, killing all ONOS processes")
47 main.log.step("before initiating enviornment setup")
48 for node in range(1, maxNodes + 1):
49 main.ONOSbench.onosDie(ONOSIp[node])
50
51
52 #construct the cell file
53 main.log.info("Creating initial cell file")
54 exec "a = main.ONOSbench.createCellFile"
55 cellIp = []
56 for node in range(1, 2):
57 #for node in range (1, maxNodes + 1):
58 cellIp.append(ONOSIp[node])
59 a(BENCHIp,cellName,MN1Ip,str(Features), *cellIp)
60
61 main.log.info(cellIp)
62
63 #Uninstall everywhere
64 #main.log.step( "Cleaning Enviornment..." )
65 #for i in range(1, maxNodes + 1):
66 # main.log.info(" Uninstalling ONOS " + str(i) )
67 # main.ONOSbench.onosUninstall( ONOSIp[i] )
68
69 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
70 if skipMvn != "yes":
71 mvnResult = main.ONOSbench.cleanInstall()
72
73 #git
74 main.step( "Git checkout and pull " + checkoutBranch )
75 if gitPull == 'on':
76 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
77 pullResult = main.ONOSbench.gitPull()
78
79 else:
80 checkoutResult = main.TRUE
81 pullResult = main.TRUE
82 main.log.info( "Skipped git checkout and pull" )
83
84
85 #main.step( "Set cell for ONOS cli env" )
86 #main.ONOS1cli.setCell( cellName )
87
88 main.step( "Creating ONOS package" )
89 packageResult = main.ONOSbench.onosPackage()
90
91 #main.step( "Installing ONOS package" )
92 #install1Result = main.ONOSbench.onosInstall( node=ONOSIp[1] )
93
94 cellName = main.params[ 'ENV' ][ 'cellName' ]
95 main.step( "Applying cell file to environment" )
96 cellApplyResult = main.ONOSbench.setCell( cellName )
97 main.step( "verify cells" )
98 verifyCellResult = main.ONOSbench.verifyCell()
99
100 #main.step( "Set cell for ONOS cli env" )
101 #cli1 = main.ONOS1cli.startOnosCli( node=ONOSIp[1] )
102
103 def CASE2( self, main ):
104 # This case increases the cluster size by whatever scale is
105 # Note: 'scale' is the size of the step
106 # if scaling is not a part of your test, simply run this case
107 # once after CASE1 to set up your enviornment for your desired
108 # cluster size. If scaling is a part of you test call this case each time
109 # you want to increase cluster size
110
111 ''
112 'Increase number of nodes and initiate CLI'
113 ''
114 import time
115 global clusterCount
116
117 scale = int( main.params[ 'SCALE' ] )
118 clusterCount += scale
119
120 main.log.report( "Increasing cluster size to " + str( clusterCount ) )
121 for node in range((clusterCount - scale) + 1, clusterCount + 1):
122 main.ONOSbench.onosDie(ONOSIp[node])
123 time.sleep(10)
124 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
125 main.ONOSbench.onosInstall( node=ONOSIp[node])
126 exec "a = main.ONOS%scli.startOnosCli" %str(node)
127 a(ONOSIp[node])
128
129
130 def CASE3( self, main ):
131 #
132 # This is the flow TP test
133 #
134 import os.path
135 import numpy
136 import math
137 import time
138 import datetime
139 import traceback
140
141 testCMD = [ 0,0,0,0 ]
142 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
143 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
144 switches = int(main.params[ 'TEST' ][ 'switches' ])
145 neighborList = main.params[ 'TEST' ][ 'neighbors' ]
146 serverList = main.params[ 'TEST' ][ 'servers' ]
147 #flows = int(main.params[ 'TEST' ][ 'flows' ])
148 testCMD[0] = main.params[ 'TEST' ][ 'testCMD0' ]
149 testCMD[1] = main.params[ 'TEST' ][ 'testCMD1' ]
150 maxNodes = main.params[ 'availableNodes' ]
151 onBaremetal = main.params['isOnBaremetal']
152
153
154 cellName = main.params[ 'ENV' ][ 'cellName' ]
155 Features= main.params[ 'ENV' ][ 'cellFeatures' ]
156 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
157 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
158 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
159 maxNodes = int(main.params[ 'availableNodes' ])
160 Features = main.params[ 'ENV' ][ 'cellFeatures' ]
161 homeDir = os.path.expanduser('~')
162
163 serverList = serverList.split(",")
164 main.log.info("serverlist: " + str(serverList))
165 neighborList = neighborList.split(",")
166 main.log.info("neightborlist: " + str(neighborList))
167
168 ts = time.time()
169 st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
170 logFileName = "../logs/flowTPResultsLog" + str(st)
171
172 #initialize log file, remove any previous data
173 resultsLog = open("flowTPResultsLog","w+")
174 resultsLog.close()
175
176 #write file to change mem limit to 32 gigs (BAREMETAL ONLY!)
177 if onBaremetal == "true":
178 filename = "/onos/tools/package/bin/onos-service"
179 serviceConfig = open(homeDir + filename, 'w+')
180 serviceConfig.write("#!/bin/bash\n ")
181 serviceConfig.write("#------------------------------------- \n ")
182 serviceConfig.write("# Starts ONOS Apache Karaf container\n ")
183 serviceConfig.write("#------------------------------------- \n ")
184 serviceConfig.write("#export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}\n ")
jenkins399e2512015-03-24 10:31:57 -0700185 serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G}" \n """)
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700186 serviceConfig.write("")
187 serviceConfig.write("ONOS_HOME=/opt/onos \n ")
188 serviceConfig.write("")
189 serviceConfig.write("[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..\n")
190 serviceConfig.write("""${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf "$@" \n """)
191 serviceConfig.close()
192
193 for n in neighborList:
194 for servers in serverList:
195 main.log.step("\tSTARTING TEST")
196 main.log.step("\tSERVERS: \t" + servers )
197 main.log.step("\tNEIGHBORS:\t" + n )
198 main.log.info("=============================================================")
199 main.log.info("=============================================================")
200 #write file to configure nil link
201 ipCSV = ""
202 for i in range (1, int(maxNodes) + 1):
203 tempstr = "ip" + str(i)
204 ipCSV += main.params[ 'CTRL' ][ tempstr ]
205 if i < int(maxNodes):
206 ipCSV +=","
207
208 filename = "/onos/tools/package/etc/org.onosproject.provider.nil.link.impl.NullLinkProvider.cfg"
209 linkConfig = open(homeDir + filename,'w+')
210 linkConfig.write("# eventRate = 2000\n")
211 linkConfig.write("neighbors = " + ipCSV)
212 main.log.info(" NullLinkProvider.cfg: " + ipCSV)
213 linkConfig.close()
214
215
216 #write file for null device
217 filename = "/onos/tools/package/etc/org.onosproject.provider.nil.device.impl.NullDeviceProvider.cfg"
218 deviceConfig = open(homeDir + filename,'w+')
219
220 serversToRun = max(int(servers), (int(n) + 1))
221
222 switchDistribution = [(switches/int(serversToRun))]*int(serversToRun)
223 main.log.info("Switch distribution init: " + str(switchDistribution))
224 remainder = switches % int(serversToRun)
225 for r in range(0, remainder):
226 switchDistribution[r] += 1
227 main.log.info("Switch distribution: " + str(switchDistribution))
228
229 deviceSettings = ""
230 for i in range(0, serversToRun):
231 deviceSettings += (ONOSIp[i+1] + ":" + str(switchDistribution[i]))
232 if i < int(serversToRun)-1:
233 deviceSettings +=","
234
235 deviceConfig.write("devConfigs = " + deviceSettings)
236 main.log.info(" NullDeviceProvider.cfg: " + deviceSettings)
237 deviceConfig.close()
238
239 main.log.info("Creating cell file for this step")
240 exec "a = main.ONOSbench.createCellFile"
241 cellIp = []
242 for node in range (1, serversToRun + 1):
243 cellIp.append(ONOSIp[node])
244 main.log.info("Cells are: " + str(cellIp) )
245 a(BENCHIp,cellName,MN1Ip,str(Features), *cellIp)
246 main.step( "Applying cell file to environment for this step" )
247 cellApplyResult = main.ONOSbench.setCell( cellName )
248 main.step( "verify cells for this step" )
249 verifyCellResult = main.ONOSbench.verifyCell()
250
251 #devide flows
252 flows = int(main.params[ 'TEST' ][ 'flows' ])
253 main.log.info("Flow Target = " + str(flows))
254
255 flows = (flows *max(int(n)+1,int(servers)))/((int(n) + 1)*int(servers)*(switches))
256
257 main.log.info("Flows per switch = " + str(flows))
258 #main.log.info("Total flows = " + str(switches * flows))
259
260
261 #kill off all onos processes
262 main.log.step("Safety check, killing all ONOS processes")
263 for node in range(1, int(maxNodes) + 1):
264 main.ONOSbench.onosDie(ONOSIp[node])
265
266 #Uninstall everywhere
267 main.log.step( "Cleaning Enviornment..." )
268 for i in range(1, int(maxNodes) + 1):
269 main.log.info(" Uninstalling ONOS " + str(i) )
270 main.ONOSbench.onosUninstall( ONOSIp[i] )
271
272 #package
273 main.log.step( "Repackaging onos to reflect config file changes" )
274 main.ONOSbench.onosPackage()
275
276 # install on relevant nodes
277 startNodes = max(int(n), serversToRun)
278 main.log.step( "Reinstalling ONOS on relevant nodes (1-" + str(startNodes) + ")" )
279 for s in range(1, startNodes + 1):
280 main.ONOSbench.onosInstall( node=ONOSIp[s])
281 exec "a = main.ONOS%scli.startOnosCli" %str(s)
282 a(ONOSIp[s])
283
284 main.log.info("sleeping 30 second waiting for null provider bundle...")
285 time.sleep(30)
286
287 #build list of servers in "$OC1, $OC2...." format
288 serverEnvVars = ""
289 for i in range (1,int(servers)+1):
290 serverEnvVars += ("-s " + ONOSIp[i] + " ")
291
292 data = [[""]*int(servers)]*int(sampleSize)
293 maxes = [""]*int(sampleSize)
294
295 for test in range(0, (warmUp + sampleSize)):
296 flowCMD = "python3 " + homeDir + "/onos/tools/test/bin/"
297 flowCMD += testCMD[0] + " " + str(flows) + " " + testCMD[1]
298 flowCMD += " " + str(n) + " " + str(serverEnvVars)
299 print("\n")
300 main.log.info("COMMAND: " + flowCMD)
301 main.log.info("Executing command")
302 main.ONOSbench.handle.sendline(flowCMD)
303 result = []
304 for s in range(0, int(servers)):
305 result.append("q")
306
307 for s in range(0, int(servers)):
308 main.ONOSbench.handle.expect("ms")
309 rawResult = ((main.ONOSbench.handle.before).splitlines())
310
311 rawResult = ((rawResult.pop()).split(" "))
312 main.log.info("Debug: rawResult: " + str(rawResult))
313
314 myresult = int(rawResult[2])
315 main.log.info("Result: " + str(myresult))
316
317 myIp = rawResult[0]
318 main.log.info("myIp: " + myIp)
319
320 serverIndex = int(ONOSIp.index(myIp))
321 main.log.info("server index = " + str(serverIndex))
322
323 result[serverIndex - 1] = myresult
324
325 if test >= warmUp:
326 maxes[test-warmUp] = max(result)
327 main.log.info("Data collection iteration: " + str(test-warmUp) + " of " + str(sampleSize))
328 main.log.info("Throughput time: " + str(maxes[test-warmUp]) + "(ms)")
329
330 if test >= warmUp:
331 data[test-warmUp] = result
332
333 # wait for flows = 0
334 removedFlows = False
335 repeat = 0
336 time.sleep(3)
337 while removedFlows == False & repeat <= 10:
338 main.ONOSbench.handle.sendline("onos $OC1 summary| cut -d ' ' -f6")
339 main.ONOSbench.handle.expect("~")
340 before = main.ONOSbench.handle.before
341 parseTest = before.splitlines()
342 flowsummary = ""
343 for line in parseTest:
344 if "flow" in str(line):
345 flowsummary = line
346 break
347 currentflow = ""
348 for word in flowsummary.split(" "):
349 if "flow" in str(word):
350 currentflow = str(word)
351 currentflow = currentflow.replace(",","")
352 currentflow = currentflow.replace("\n","")
353 main.log.info(currentflow)
354
355 zeroFlow = "flows=0"
356 if zeroFlow in before:
357 removedFlows = True
358 main.log.info("\t Wait 5 sec of cool down...")
359 time.sleep(5)
360
361 time.sleep(5)
362 repeat +=1
363
364 main.log.info("raw data: " + str(data))
365 main.log.info("maxes:" + str(maxes))
366
367
368 # report data
369 print("")
370 main.log.info("\t Results (measurments are in milliseconds)")
371 print("")
372
373 nodeString = ""
374 for i in range(1, int(servers) + 1):
375 nodeString += ("\tNode " + str(i))
376
377 for test in range(0, sampleSize ):
378 main.log.info("\t Test iteration " + str(test + 1) )
379 main.log.info("\t------------------")
380 main.log.info(nodeString)
381 resultString = ""
382
383 for i in range(0, int(servers) ):
384 resultString += ("\t" + str(data[test][i]) )
385 main.log.info(resultString)
386
387 print("\n")
388
389 avgOfMaxes = numpy.mean(maxes)
390 main.log.info("Average of max value from each test iteration: " + str(avgOfMaxes))
391
392 stdOfMaxes = numpy.std(maxes)
393 main.log.info("Standard Deviation of max values: " + str(stdOfMaxes))
394 print("\n\n")
395
396 avgTP = int(main.params[ 'TEST' ][ 'flows' ]) / avgOfMaxes #result in kflows/second
397
398 tp = []
399 for i in maxes:
400 tp.append((int(main.params[ 'TEST' ][ 'flows' ]) / i ))
401
402 stdTP = numpy.std(tp)
403
404 main.log.info("Average thoughput: " + str(avgTP) + " Kflows/second" )
405 main.log.info("Standard deviation of throughput: " + str(stdTP) + " Kflows/second")
406
407 resultsLog = open(logFileName,"a")
408 resultsLog.write(str(main.params[ 'TEST' ][ 'flows' ]) + "," + n + "," + str(servers) + str(switches) + "," + str(warmUp))
409 resultsLog.write("," +str(sampleSize) + "," + str(avgTP) + "," + str(stdTP) + "\n")
410 resultsLog.close()
411
412