blob: 4d319fb0dee4e586f14f6d128fa99691fbc1256d [file] [log] [blame]
cameron@onlab.us50dacf82015-05-08 14:56:42 -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 # -- 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 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
57 if skipMvn != "yes":
58 mvnResult = main.ONOSbench.cleanInstall()
59
60 #git
61 main.step( "Git checkout and pull " + checkoutBranch )
62 if gitPull == 'on':
63 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
64 pullResult = main.ONOSbench.gitPull()
65
66 else:
67 checkoutResult = main.TRUE
68 pullResult = main.TRUE
69 main.log.info( "Skipped git checkout and pull" )
70
71 commit = main.ONOSbench.getVersion()
72 commit = (commit.split(" "))[1]
73
74 resultsDB = open("flowTP1gDB", "w+")
75 resultsDB.close()
76
77 # -- END OF INIT SECTION --#
78
79 clusterCount = int(scale[0])
80 scale.remove(scale[0])
81 main.log.info("CLUSTER COUNT: " + str(clusterCount))
82
83 #kill off all onos processes
84 main.log.step("Safety check, killing all ONOS processes")
85 main.log.step("before initiating enviornment setup")
86 for node in range(1, maxNodes + 1):
87 main.ONOSbench.onosDie(ONOSIp[node])
88
89 #Uninstall everywhere
90 main.log.step( "Cleaning Enviornment..." )
91 for i in range(1, maxNodes + 1):
92 main.log.info(" Uninstalling ONOS " + str(i) )
93 main.ONOSbench.onosUninstall( ONOSIp[i] )
94
95 #construct the cell file
96 main.log.info("Creating cell file")
97 cellIp = []
98 for node in range (1, clusterCount + 1):
99 cellIp.append(ONOSIp[node])
100
101 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
102 main.log.info("Cell Ip list: " + str(cellIp))
103
104 main.step( "Set Cell" )
105 main.ONOSbench.setCell(cellName)
106
107 main.step( "Creating ONOS package" )
108 packageResult = main.ONOSbench.onosPackage()
109
110 main.step( "verify cells" )
111 verifyCellResult = main.ONOSbench.verifyCell()
112
113 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
114 for node in range(1, clusterCount + 1):
115 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
116 main.ONOSbench.onosInstall( ONOSIp[node])
117
118 for node in range(1, clusterCount + 1):
119 for i in range( 2 ):
120 isup = main.ONOSbench.isup( ONOSIp[node] )
121 if isup:
122 main.log.info("ONOS " + str(node) + " is up\n")
123 break
124 if not isup:
125 main.log.report( "ONOS " + str(node) + " didn't start!" )
126
127 for node in range(1, clusterCount + 1):
128 exec "a = main.ONOS%scli.startOnosCli" %str(node)
129 a(ONOSIp[node])
130
131 main.log.info("Startup sequence complete")
132
133
134 def CASE2( self, main ):
135 #
136 # This is the flow TP test
137 #
138 import os.path
139 import numpy
140 import math
141 import time
142 import datetime
143 import traceback
144
145 testCMD = [ 0,0,0,0 ]
146 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
147 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
148 switches = int(main.params[ 'TEST' ][ 'switches' ])
149 neighborList = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
150 testCMD[0] = main.params[ 'TEST' ][ 'testCMD0' ]
151 testCMD[1] = main.params[ 'TEST' ][ 'testCMD1' ]
152 maxNodes = main.params[ 'availableNodes' ]
153 onBaremetal = main.params['isOnBaremetal']
154 cooldown = main.params[ 'TEST' ][ 'cooldown' ]
155 cellName = main.params[ 'ENV' ][ 'cellName' ]
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 homeDir = os.path.expanduser('~')
161
162 servers = str(clusterCount)
163 for i in range(0, len(neighborList)):
164 if neighborList[i] == 'a':
165 neighborList[i] = str(clusterCount - 1)
166
167 if clusterCount == 1:
168 neighborList = ['0']
169 main.log.info("neightborlist: " + str(neighborList))
170
171 ts = time.time()
172 st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
173
174 #write file to change mem limit to 32 gigs (BAREMETAL ONLY!)
175 if onBaremetal == "true":
176 filename = "/onos/tools/package/bin/onos-service"
177 serviceConfig = open(homeDir + filename, 'w+')
178 serviceConfig.write("#!/bin/bash\n ")
179 serviceConfig.write("#------------------------------------- \n ")
180 serviceConfig.write("# Starts ONOS Apache Karaf container\n ")
181 serviceConfig.write("#------------------------------------- \n ")
182 serviceConfig.write("#export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}\n ")
183 serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G}" \n """)
184 serviceConfig.write("")
185 serviceConfig.write("ONOS_HOME=/opt/onos \n ")
186 serviceConfig.write("")
187 serviceConfig.write("[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..\n")
188 serviceConfig.write("""${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf "$@" \n """)
189 serviceConfig.close()
190
191 for n in neighborList:
192 main.log.step("\tSTARTING TEST")
193 main.log.step("\tLOADING FROM SERVERS: \t" + str(clusterCount) )
194 main.log.step("\tNEIGHBORS:\t" + n )
195 main.log.info("=============================================================")
196 main.log.info("=============================================================")
197 #write file to configure nil link
198 ipCSV = ""
199 for i in range (1, int(maxNodes) + 1):
200 tempstr = "ip" + str(i)
201 ipCSV += main.params[ 'CTRL' ][ tempstr ]
202 if i < int(maxNodes):
203 ipCSV +=","
204
205 main.ONOSbench.handle.sendline("""onos $OC1 "cfg setorg.onosproject.provider.nil.NullProviders enabled true" """)
206 main.ONOSbench.handle.expect(":~")
207 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount 35" """)
208 main.ONOSbench.handle.expect(":~")
209 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
210 main.ONOSbench.handle.expect(":~")
211 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
212 main.ONOSbench.handle.expect(":~")
213 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
214 main.ONOSbench.handle.expect(":~")
215
216 #devide flows
217 flows = int(main.params[ 'TEST' ][ 'flows' ])
218 main.log.info("Flow Target = " + str(flows))
219
220 flows = (flows *max(int(n)+1,int(servers)))/((int(n) + 1)*int(servers)*(switches))
221
222 main.log.info("Flows per switch = " + str(flows))
223
224 #build list of servers in "$OC1, $OC2...." format
225 serverEnvVars = ""
226 for i in range (1,int(servers)+1):
227 serverEnvVars += ("-s " + ONOSIp[i] + " ")
228
229 data = [[""]*int(servers)]*int(sampleSize)
230 maxes = [""]*int(sampleSize)
231
232 for test in range(0, (warmUp + sampleSize)):
233 flowCMD = "python3 " + homeDir + "/onos/tools/test/bin/"
234 flowCMD += testCMD[0] + " " + str(flows) + " " + testCMD[1]
235 flowCMD += " " + str(n) + " " + str(serverEnvVars)
236 print("\n")
237 main.log.info("COMMAND: " + flowCMD)
238 main.log.info("Executing command")
239
240 for i in range(0,15):
241 main.ONOSbench.handle.sendline(flowCMD)
242 time.sleep(5)
243 main.ONOSbench.handle.expect(":~")
244 rawResult = main.ONOSbench.handle.before
245 if " -> " in rawResult:
246 break
247
248 result = [""]*(clusterCount)
249 rawResult = rawResult.splitlines()
250 print(rawResult)
251 for node in range(1, clusterCount + 1):
252 for line in rawResult:
253 if ONOSIp[node] in line and " -> " in line:
254 myLine = line.split(" ")
255 for word in myLine:
256 if "ms" in word:
257 result[node-1] = int(word.replace("ms",""))
258 main.log.info("Parsed result: " + str(result[node-1]))
259 break
260 break
261
262 if test >= warmUp:
263 for i in result:
264 if i == "":
265 main.log.error("Missing data point, critical failure incoming")
266
267 print result
268 maxes[test-warmUp] = max(result)
269 main.log.info("Data collection iteration: " + str(test-warmUp) + " of " + str(sampleSize))
270 main.log.info("Throughput time: " + str(maxes[test-warmUp]) + "(ms)")
271
272 if test >= warmUp:
273 data[test-warmUp] = result
274
275 # wait for flows = 0
276 removedFlows = False
277 repeat = 0
278 time.sleep(3)
279 while ( removedFlows == False and repeat <= 10 ):
280 main.ONOSbench.handle.sendline("onos $OC1 summary| cut -d ' ' -f6")
281 main.ONOSbench.handle.expect("~")
282 before = main.ONOSbench.handle.before
283 parseTest = before.splitlines()
284 flowsummary = ""
285 for line in parseTest:
286 if "flow" in str(line):
287 flowsummary = line
288 break
289 currentflow = ""
290 for word in flowsummary.split(" "):
291 if "flow" in str(word):
292 currentflow = str(word)
293 currentflow = currentflow.replace(",","")
294 currentflow = currentflow.replace("\n","")
295 #main.log.info(currentflow)
296
297 zeroFlow = "flows=0"
298 if zeroFlow in before:
299 removedFlows = True
300 main.log.info("\t Wait " + cooldown + " sec of cool down...")
301 time.sleep(int(cooldown))
302
303 time.sleep(5)
304 repeat +=1
305
306 main.log.info("raw data: " + str(data))
307 main.log.info("maxes:" + str(maxes))
308
309
310 # report data
311 print("")
312 main.log.info("\t Results (measurments are in milliseconds)")
313 print("")
314
315 nodeString = ""
316 for i in range(1, int(servers) + 1):
317 nodeString += ("\tNode " + str(i))
318
319 for test in range(0, sampleSize ):
320 main.log.info("\t Test iteration " + str(test + 1) )
321 main.log.info("\t------------------")
322 main.log.info(nodeString)
323 resultString = ""
324
325 for i in range(0, int(servers) ):
326 resultString += ("\t" + str(data[test][i]) )
327 main.log.info(resultString)
328
329 print("\n")
330
331 avgOfMaxes = numpy.mean(maxes)
332 main.log.info("Average of max value from each test iteration: " + str(avgOfMaxes))
333
334 stdOfMaxes = numpy.std(maxes)
335 main.log.info("Standard Deviation of max values: " + str(stdOfMaxes))
336 print("\n\n")
337
338 avgTP = int(main.params[ 'TEST' ][ 'flows' ]) / avgOfMaxes #result in kflows/second
339
340 tp = []
341 for i in maxes:
342 tp.append((int(main.params[ 'TEST' ][ 'flows' ]) / i ))
343
344 stdTP = numpy.std(tp)
345
346 main.log.info("Average thoughput: " + str(avgTP) + " Kflows/second" )
347 main.log.info("Standard deviation of throughput: " + str(stdTP) + " Kflows/second")
348
349 resultsLog = open("flowTP1gDB","a")
350 resultString = ("'" + commit + "',")
351 resultString += ("'1gig',")
352 resultString += ((main.params[ 'TEST' ][ 'flows' ]) + ",")
353 resultString += (str(clusterCount) + ",")
354 resultString += (str(n) + ",")
355 resultString += (str(avgTP) + "," + str(stdTP) + "\n")
356 resultsLog.write(resultString)
357 resultsLog.close()
358
359 main.log.report("Result line to file: " + resultString)