blob: 24fa8d66feb4219d36f4aa4d0c67efdbf3c2e9ff [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
cameron@onlab.us19494212015-04-01 16:12:07 -070016 def CASE1( self, main ):
andrew@onlab.us5cdb2852015-03-11 15:11:10 -070017
cameron@onlab.us19494212015-04-01 16:12:07 -070018 import time
19 global init
20 try:
21 if type(init) is not bool:
22 init = False
23 except NameError:
24 init = False
andrew@onlab.us5cdb2852015-03-11 15:11:10 -070025
26 #Load values from params file
27 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
28 gitPull = main.params[ 'GIT' ][ 'autopull' ]
29 cellName = main.params[ 'ENV' ][ 'cellName' ]
cameron@onlab.us19494212015-04-01 16:12:07 -070030 Apps = main.params[ 'ENV' ][ 'cellApps' ]
andrew@onlab.us5cdb2852015-03-11 15:11:10 -070031 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
32 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
33 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
34 maxNodes = int(main.params[ 'availableNodes' ])
andrew@onlab.us5cdb2852015-03-11 15:11:10 -070035 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
cameron@onlab.us19494212015-04-01 16:12:07 -070036 cellName = main.params[ 'ENV' ][ 'cellName' ]
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -070037
38 main.log.info("==========DEBUG VERSION 3===========")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -070039
cameron@onlab.us19494212015-04-01 16:12:07 -070040 # -- INIT SECTION, ONLY RUNS ONCE -- #
41 if init == False:
42 init = True
43 global clusterCount #number of nodes running
44 global ONOSIp #list of ONOS IP addresses
45 global scale
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070046 global commit
andrew@onlab.us5cdb2852015-03-11 15:11:10 -070047
cameron@onlab.us19494212015-04-01 16:12:07 -070048 clusterCount = 0
49 ONOSIp = [ 0 ]
50 scale = (main.params[ 'SCALE' ]).split(",")
51 clusterCount = int(scale[0])
andrew@onlab.us5cdb2852015-03-11 15:11:10 -070052
cameron@onlab.us19494212015-04-01 16:12:07 -070053 #Populate ONOSIp with ips from params
54 for i in range(1, maxNodes + 1):
55 ipString = 'ip' + str(i)
56 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
andrew@onlab.us5cdb2852015-03-11 15:11:10 -070057
cameron@onlab.us19494212015-04-01 16:12:07 -070058 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
59 if skipMvn != "yes":
60 mvnResult = main.ONOSbench.cleanInstall()
andrew@onlab.us5cdb2852015-03-11 15:11:10 -070061
andrew@onlab.us5cdb2852015-03-11 15:11:10 -070062 #git
63 main.step( "Git checkout and pull " + checkoutBranch )
64 if gitPull == 'on':
65 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
66 pullResult = main.ONOSbench.gitPull()
67
68 else:
69 checkoutResult = main.TRUE
70 pullResult = main.TRUE
71 main.log.info( "Skipped git checkout and pull" )
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070072
73 commit = main.ONOSbench.getVersion()
74 commit = (commit.split(" "))[1]
75
76 resultsDB = open("flowTP1gDB", "w+")
77 resultsDB.close()
andrew@onlab.us5cdb2852015-03-11 15:11:10 -070078
cameron@onlab.us19494212015-04-01 16:12:07 -070079 # -- END OF INIT SECTION --#
andrew@onlab.us5cdb2852015-03-11 15:11:10 -070080
cameron@onlab.us19494212015-04-01 16:12:07 -070081 clusterCount = int(scale[0])
82 scale.remove(scale[0])
83 main.log.info("CLUSTER COUNT: " + str(clusterCount))
84
85 #kill off all onos processes
86 main.log.step("Safety check, killing all ONOS processes")
87 main.log.step("before initiating enviornment setup")
88 for node in range(1, maxNodes + 1):
89 main.ONOSbench.onosDie(ONOSIp[node])
90
91 #Uninstall everywhere
92 main.log.step( "Cleaning Enviornment..." )
93 for i in range(1, maxNodes + 1):
94 main.log.info(" Uninstalling ONOS " + str(i) )
95 main.ONOSbench.onosUninstall( ONOSIp[i] )
96
97 #construct the cell file
98 main.log.info("Creating cell file")
99 cellIp = []
100 for node in range (1, clusterCount + 1):
101 cellIp.append(ONOSIp[node])
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700102
cameron@onlab.us19494212015-04-01 16:12:07 -0700103 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
104 main.log.info("Cell Ip list: " + str(cellIp))
105
106 main.step( "Set Cell" )
107 main.ONOSbench.setCell(cellName)
108
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700109 main.step( "Creating ONOS package" )
110 packageResult = main.ONOSbench.onosPackage()
111
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700112 main.step( "verify cells" )
113 verifyCellResult = main.ONOSbench.verifyCell()
114
cameron@onlab.us19494212015-04-01 16:12:07 -0700115 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
116 for node in range(1, clusterCount + 1):
117 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
118 main.ONOSbench.onosInstall( ONOSIp[node])
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700119
cameron@onlab.us19494212015-04-01 16:12:07 -0700120 for node in range(1, clusterCount + 1):
121 for i in range( 2 ):
122 isup = main.ONOSbench.isup( ONOSIp[node] )
123 if isup:
124 main.log.info("ONOS " + str(node) + " is up\n")
125 break
126 if not isup:
127 main.log.report( "ONOS " + str(node) + " didn't start!" )
128
129 for node in range(1, clusterCount + 1):
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700130 exec "a = main.ONOS%scli.startOnosCli" %str(node)
131 a(ONOSIp[node])
cameron@onlab.us19494212015-04-01 16:12:07 -0700132
133 main.log.info("Startup sequence complete")
134
135
136 def CASE2( self, main ):
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700137 #
138 # This is the flow TP test
139 #
140 import os.path
141 import numpy
142 import math
143 import time
144 import datetime
145 import traceback
146
cameron@onlab.us50dacf82015-05-08 14:56:42 -0700147 global currentNeighbors
148 try:
149 currentNeighbors
150 except:
151 currentNeighbors = "0"
152 else:
153 if currentNeighbors == "r": #reset
154 currentNeighbors = "0"
155 else:
156 currentNeighbors = "a"
157
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700158 testCMD = [ 0,0,0,0 ]
159 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
160 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
161 switches = int(main.params[ 'TEST' ][ 'switches' ])
cameron@onlab.us19494212015-04-01 16:12:07 -0700162 neighborList = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700163 testCMD[0] = main.params[ 'TEST' ][ 'testCMD0' ]
164 testCMD[1] = main.params[ 'TEST' ][ 'testCMD1' ]
165 maxNodes = main.params[ 'availableNodes' ]
166 onBaremetal = main.params['isOnBaremetal']
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700167 cooldown = main.params[ 'TEST' ][ 'cooldown' ]
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700168 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700169 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
170 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
171 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
172 maxNodes = int(main.params[ 'availableNodes' ])
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700173 homeDir = os.path.expanduser('~')
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700174 flowRuleBackup = str(main.params[ 'TEST' ][ 'enableFlowRuleStoreBackup' ])
175 print flowRuleBackup
176
177
cameron@onlab.us19494212015-04-01 16:12:07 -0700178 servers = str(clusterCount)
cameron@onlab.us50dacf82015-05-08 14:56:42 -0700179 #for i in range(0, len(neighborList)):
180 # if neighborList[i] == 'a':
181 # neighborList[i] = str(clusterCount - 1)
cameron@onlab.us19494212015-04-01 16:12:07 -0700182
183 if clusterCount == 1:
184 neighborList = ['0']
cameron@onlab.us50dacf82015-05-08 14:56:42 -0700185 currentNeighbors = "r"
186 else:
187 if currentNeighbors == "a":
188 neighborList = [str(clusterCount-1)]
189 currentNeughbors = "r"
190 else:
191 neighborList = ['0']
192
193 #main.log.info("neightborlist: " + str(neighborList))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700194
195 ts = time.time()
196 st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700197
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700198 #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 ")
jenkins399e2512015-03-24 10:31:57 -0700207 serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G}" \n """)
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700208 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:
cameron@onlab.us19494212015-04-01 16:12:07 -0700216 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 +=","
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700228
229
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700230 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount 35" """)
231 main.ONOSbench.handle.expect(":~")
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700232 time.sleep(3)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700233 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
234 main.ONOSbench.handle.expect(":~")
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700235 time.sleep(3)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700236 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
237 main.ONOSbench.handle.expect(":~")
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700238 time.sleep(3)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700239 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
240 main.ONOSbench.handle.expect(":~")
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700241 time.sleep(3)
242 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.store.flow.impl.DistributedFlowRuleStore backupEnabled """ + str(flowRuleBackup) + """ " """)
243 main.ONOSbench.handle.expect(":~")
244
245 main.ONOSbench.handle.sendline("onos $OC1 summary")
246 main.ONOSbench.handle.expect(":~")
247 check = main.ONOSbench.handle.before
248 main.log.info("\nStart up check: \n" + check + "\n")
249
cameron@onlab.us19494212015-04-01 16:12:07 -0700250 #devide flows
251 flows = int(main.params[ 'TEST' ][ 'flows' ])
252 main.log.info("Flow Target = " + str(flows))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700253
cameron@onlab.us19494212015-04-01 16:12:07 -0700254 flows = (flows *max(int(n)+1,int(servers)))/((int(n) + 1)*int(servers)*(switches))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700255
cameron@onlab.us19494212015-04-01 16:12:07 -0700256 main.log.info("Flows per switch = " + str(flows))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700257
cameron@onlab.us19494212015-04-01 16:12:07 -0700258 #build list of servers in "$OC1, $OC2...." format
259 serverEnvVars = ""
260 for i in range (1,int(servers)+1):
261 serverEnvVars += ("-s " + ONOSIp[i] + " ")
262
263 data = [[""]*int(servers)]*int(sampleSize)
264 maxes = [""]*int(sampleSize)
265
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700266 flowCMD = "python3 " + homeDir + "/onos/tools/test/bin/"
267 flowCMD += testCMD[0] + " " + str(flows) + " " + testCMD[1]
268 flowCMD += " " + str(n) + " " + str(serverEnvVars) + "-j"
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700269
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700270 main.log.info(flowCMD)
271 #time.sleep(60)
272
273 for test in range(0, warmUp + sampleSize):
274 if test < warmUp:
275 main.log.info("Warm up " + str(test + 1) + " of " + str(warmUp))
276 else:
277 main.log.info("====== Test run: " + str(test-warmUp+1) + " ======")
278
279 main.ONOSbench.handle.sendline(flowCMD)
280 main.ONOSbench.handle.expect(":~")
281 rawResult = main.ONOSbench.handle.before
282 main.log.info("Raw results: \n" + rawResult + "\n")
283
284 if "failed" in rawResult:
285 main.log.report("FLOW_TESTER.PY FAILURE")
286 main.log.report( " \n" + rawResult + " \n")
287 break
288
289 ########################################################################################
cameron@onlab.us19494212015-04-01 16:12:07 -0700290 result = [""]*(clusterCount)
291 rawResult = rawResult.splitlines()
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700292
cameron@onlab.us19494212015-04-01 16:12:07 -0700293 for node in range(1, clusterCount + 1):
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700294 for line in rawResult:
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700295 #print("line: " + line)
296 if ONOSIp[node] in line and "server" in line:
297 temp = line.split(" ")
298 for word in temp:
299 #print ("word: " + word)
300 if "elapsed" in repr(word):
301 #print("in elapsed ==========")
302 index = temp.index(word) + 1
303 #print ("index: " + str(index))
304 #print ("temp[index]: " + temp[index])
305 myParsed = (temp[index]).replace(",","")
306 myParsed = myParsed.replace("}","")
307 myParsed = int(myParsed)
308 result[node-1] = myParsed
309 main.log.info( ONOSIp[node] + " : " + str(myParsed))
310 break
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700311
cameron@onlab.us19494212015-04-01 16:12:07 -0700312 if test >= warmUp:
313 for i in result:
314 if i == "":
315 main.log.error("Missing data point, critical failure incoming")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700316
cameron@onlab.us19494212015-04-01 16:12:07 -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)")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700321
cameron@onlab.us19494212015-04-01 16:12:07 -0700322 data[test-warmUp] = result
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700323
cameron@onlab.us19494212015-04-01 16:12:07 -0700324 # wait for flows = 0
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700325 for checkCount in range(0,3):
326 time.sleep(6)
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 ")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700339
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700340
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700341 time.sleep(5)
342
cameron@onlab.us19494212015-04-01 16:12:07 -0700343 main.log.info("raw data: " + str(data))
344 main.log.info("maxes:" + str(maxes))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700345
cameron@onlab.us19494212015-04-01 16:12:07 -0700346
347 # report data
348 print("")
349 main.log.info("\t Results (measurments are in milliseconds)")
350 print("")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700351
cameron@onlab.us19494212015-04-01 16:12:07 -0700352 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 = ""
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700361
cameron@onlab.us19494212015-04-01 16:12:07 -0700362 for i in range(0, int(servers) ):
363 resultString += ("\t" + str(data[test][i]) )
364 main.log.info(resultString)
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700365
cameron@onlab.us19494212015-04-01 16:12:07 -0700366 print("\n")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700367
cameron@onlab.us19494212015-04-01 16:12:07 -0700368 avgOfMaxes = numpy.mean(maxes)
369 main.log.info("Average of max value from each test iteration: " + str(avgOfMaxes))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700370
cameron@onlab.us19494212015-04-01 16:12:07 -0700371 stdOfMaxes = numpy.std(maxes)
372 main.log.info("Standard Deviation of max values: " + str(stdOfMaxes))
373 print("\n\n")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700374
cameron@onlab.us19494212015-04-01 16:12:07 -0700375 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 ))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700380
cameron@onlab.us19494212015-04-01 16:12:07 -0700381 stdTP = numpy.std(tp)
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700382
cameron@onlab.us19494212015-04-01 16:12:07 -0700383 main.log.info("Average thoughput: " + str(avgTP) + " Kflows/second" )
384 main.log.info("Standard deviation of throughput: " + str(stdTP) + " Kflows/second")
385
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700386 resultsLog = open("flowTP1gDB","a")
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700387 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)
cameron@onlab.us19494212015-04-01 16:12:07 -0700394 resultsLog.close()
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700395
396 main.log.report("Result line to file: " + resultString)
397
398