blob: cbbf2dd49d8188a733db4519e8d7f861d012b08d [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
147 testCMD = [ 0,0,0,0 ]
148 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
149 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
150 switches = int(main.params[ 'TEST' ][ 'switches' ])
cameron@onlab.us19494212015-04-01 16:12:07 -0700151 neighborList = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700152 testCMD[0] = main.params[ 'TEST' ][ 'testCMD0' ]
153 testCMD[1] = main.params[ 'TEST' ][ 'testCMD1' ]
154 maxNodes = main.params[ 'availableNodes' ]
155 onBaremetal = main.params['isOnBaremetal']
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700156 cooldown = main.params[ 'TEST' ][ 'cooldown' ]
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700157 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700158 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
159 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
160 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
161 maxNodes = int(main.params[ 'availableNodes' ])
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700162 homeDir = os.path.expanduser('~')
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700163 flowRuleBackup = str(main.params[ 'TEST' ][ 'enableFlowRuleStoreBackup' ])
164 print flowRuleBackup
165
166
cameron@onlab.us19494212015-04-01 16:12:07 -0700167 servers = str(clusterCount)
168 for i in range(0, len(neighborList)):
169 if neighborList[i] == 'a':
170 neighborList[i] = str(clusterCount - 1)
171
172 if clusterCount == 1:
173 neighborList = ['0']
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700174 main.log.info("neightborlist: " + str(neighborList))
175
176 ts = time.time()
177 st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700178
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700179 #write file to change mem limit to 32 gigs (BAREMETAL ONLY!)
180 if onBaremetal == "true":
181 filename = "/onos/tools/package/bin/onos-service"
182 serviceConfig = open(homeDir + filename, 'w+')
183 serviceConfig.write("#!/bin/bash\n ")
184 serviceConfig.write("#------------------------------------- \n ")
185 serviceConfig.write("# Starts ONOS Apache Karaf container\n ")
186 serviceConfig.write("#------------------------------------- \n ")
187 serviceConfig.write("#export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}\n ")
jenkins399e2512015-03-24 10:31:57 -0700188 serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G}" \n """)
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700189 serviceConfig.write("")
190 serviceConfig.write("ONOS_HOME=/opt/onos \n ")
191 serviceConfig.write("")
192 serviceConfig.write("[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..\n")
193 serviceConfig.write("""${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf "$@" \n """)
194 serviceConfig.close()
195
196 for n in neighborList:
cameron@onlab.us19494212015-04-01 16:12:07 -0700197 main.log.step("\tSTARTING TEST")
198 main.log.step("\tLOADING FROM SERVERS: \t" + str(clusterCount) )
199 main.log.step("\tNEIGHBORS:\t" + n )
200 main.log.info("=============================================================")
201 main.log.info("=============================================================")
202 #write file to configure nil link
203 ipCSV = ""
204 for i in range (1, int(maxNodes) + 1):
205 tempstr = "ip" + str(i)
206 ipCSV += main.params[ 'CTRL' ][ tempstr ]
207 if i < int(maxNodes):
208 ipCSV +=","
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700209
210
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700211 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount 35" """)
212 main.ONOSbench.handle.expect(":~")
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700213 time.sleep(3)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700214 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
215 main.ONOSbench.handle.expect(":~")
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700216 time.sleep(3)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700217 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
218 main.ONOSbench.handle.expect(":~")
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700219 time.sleep(3)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700220 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
221 main.ONOSbench.handle.expect(":~")
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700222 time.sleep(3)
223 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.store.flow.impl.DistributedFlowRuleStore backupEnabled """ + str(flowRuleBackup) + """ " """)
224 main.ONOSbench.handle.expect(":~")
225
226 main.ONOSbench.handle.sendline("onos $OC1 summary")
227 main.ONOSbench.handle.expect(":~")
228 check = main.ONOSbench.handle.before
229 main.log.info("\nStart up check: \n" + check + "\n")
230
cameron@onlab.us19494212015-04-01 16:12:07 -0700231 #devide flows
232 flows = int(main.params[ 'TEST' ][ 'flows' ])
233 main.log.info("Flow Target = " + str(flows))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700234
cameron@onlab.us19494212015-04-01 16:12:07 -0700235 flows = (flows *max(int(n)+1,int(servers)))/((int(n) + 1)*int(servers)*(switches))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700236
cameron@onlab.us19494212015-04-01 16:12:07 -0700237 main.log.info("Flows per switch = " + str(flows))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700238
cameron@onlab.us19494212015-04-01 16:12:07 -0700239 #build list of servers in "$OC1, $OC2...." format
240 serverEnvVars = ""
241 for i in range (1,int(servers)+1):
242 serverEnvVars += ("-s " + ONOSIp[i] + " ")
243
244 data = [[""]*int(servers)]*int(sampleSize)
245 maxes = [""]*int(sampleSize)
246
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700247 flowCMD = "python3 " + homeDir + "/onos/tools/test/bin/"
248 flowCMD += testCMD[0] + " " + str(flows) + " " + testCMD[1]
249 flowCMD += " " + str(n) + " " + str(serverEnvVars) + "-j"
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700250
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700251 main.log.info(flowCMD)
252 #time.sleep(60)
253
254 for test in range(0, warmUp + sampleSize):
255 if test < warmUp:
256 main.log.info("Warm up " + str(test + 1) + " of " + str(warmUp))
257 else:
258 main.log.info("====== Test run: " + str(test-warmUp+1) + " ======")
259
260 main.ONOSbench.handle.sendline(flowCMD)
261 main.ONOSbench.handle.expect(":~")
262 rawResult = main.ONOSbench.handle.before
263 main.log.info("Raw results: \n" + rawResult + "\n")
264
265 if "failed" in rawResult:
266 main.log.report("FLOW_TESTER.PY FAILURE")
267 main.log.report( " \n" + rawResult + " \n")
268 break
269
270 ########################################################################################
cameron@onlab.us19494212015-04-01 16:12:07 -0700271 result = [""]*(clusterCount)
272 rawResult = rawResult.splitlines()
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700273
cameron@onlab.us19494212015-04-01 16:12:07 -0700274 for node in range(1, clusterCount + 1):
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700275 for line in rawResult:
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700276 #print("line: " + line)
277 if ONOSIp[node] in line and "server" in line:
278 temp = line.split(" ")
279 for word in temp:
280 #print ("word: " + word)
281 if "elapsed" in repr(word):
282 #print("in elapsed ==========")
283 index = temp.index(word) + 1
284 #print ("index: " + str(index))
285 #print ("temp[index]: " + temp[index])
286 myParsed = (temp[index]).replace(",","")
287 myParsed = myParsed.replace("}","")
288 myParsed = int(myParsed)
289 result[node-1] = myParsed
290 main.log.info( ONOSIp[node] + " : " + str(myParsed))
291 break
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700292
cameron@onlab.us19494212015-04-01 16:12:07 -0700293 if test >= warmUp:
294 for i in result:
295 if i == "":
296 main.log.error("Missing data point, critical failure incoming")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700297
cameron@onlab.us19494212015-04-01 16:12:07 -0700298 print result
299 maxes[test-warmUp] = max(result)
300 main.log.info("Data collection iteration: " + str(test-warmUp) + " of " + str(sampleSize))
301 main.log.info("Throughput time: " + str(maxes[test-warmUp]) + "(ms)")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700302
cameron@onlab.us19494212015-04-01 16:12:07 -0700303 data[test-warmUp] = result
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700304
cameron@onlab.us19494212015-04-01 16:12:07 -0700305 # wait for flows = 0
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700306 for checkCount in range(0,3):
307 time.sleep(6)
308 main.ONOSbench.handle.sendline("onos $OC1 summary")
309 main.ONOSbench.handle.expect(":~")
310 flowCheck = main.ONOSbench.handle.before
311 if "flows=0," in flowCheck:
312 main.log.info("Flows removed")
313 break
314 else:
315 for line in flowCheck.splitlines():
316 if "flows=" in line:
317 main.log.info("Current Summary: " + line)
318 if checkCount == 2:
319 main.log.info("Flows are stuck, moving on ")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700320
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700321
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700322 time.sleep(5)
323
cameron@onlab.us19494212015-04-01 16:12:07 -0700324 main.log.info("raw data: " + str(data))
325 main.log.info("maxes:" + str(maxes))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700326
cameron@onlab.us19494212015-04-01 16:12:07 -0700327
328 # report data
329 print("")
330 main.log.info("\t Results (measurments are in milliseconds)")
331 print("")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700332
cameron@onlab.us19494212015-04-01 16:12:07 -0700333 nodeString = ""
334 for i in range(1, int(servers) + 1):
335 nodeString += ("\tNode " + str(i))
336
337 for test in range(0, sampleSize ):
338 main.log.info("\t Test iteration " + str(test + 1) )
339 main.log.info("\t------------------")
340 main.log.info(nodeString)
341 resultString = ""
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700342
cameron@onlab.us19494212015-04-01 16:12:07 -0700343 for i in range(0, int(servers) ):
344 resultString += ("\t" + str(data[test][i]) )
345 main.log.info(resultString)
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700346
cameron@onlab.us19494212015-04-01 16:12:07 -0700347 print("\n")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700348
cameron@onlab.us19494212015-04-01 16:12:07 -0700349 avgOfMaxes = numpy.mean(maxes)
350 main.log.info("Average of max value from each test iteration: " + str(avgOfMaxes))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700351
cameron@onlab.us19494212015-04-01 16:12:07 -0700352 stdOfMaxes = numpy.std(maxes)
353 main.log.info("Standard Deviation of max values: " + str(stdOfMaxes))
354 print("\n\n")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700355
cameron@onlab.us19494212015-04-01 16:12:07 -0700356 avgTP = int(main.params[ 'TEST' ][ 'flows' ]) / avgOfMaxes #result in kflows/second
357
358 tp = []
359 for i in maxes:
360 tp.append((int(main.params[ 'TEST' ][ 'flows' ]) / i ))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700361
cameron@onlab.us19494212015-04-01 16:12:07 -0700362 stdTP = numpy.std(tp)
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700363
cameron@onlab.us19494212015-04-01 16:12:07 -0700364 main.log.info("Average thoughput: " + str(avgTP) + " Kflows/second" )
365 main.log.info("Standard deviation of throughput: " + str(stdTP) + " Kflows/second")
366
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700367 resultsLog = open("flowTP1gDB","a")
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700368 resultString = ("'" + commit + "',")
369 resultString += ("'1gig',")
370 resultString += ((main.params[ 'TEST' ][ 'flows' ]) + ",")
371 resultString += (str(clusterCount) + ",")
372 resultString += (str(n) + ",")
373 resultString += (str(avgTP) + "," + str(stdTP) + "\n")
374 resultsLog.write(resultString)
cameron@onlab.us19494212015-04-01 16:12:07 -0700375 resultsLog.close()
cameron@onlab.usb5eb9f42015-05-06 13:55:45 -0700376
377 main.log.report("Result line to file: " + resultString)
378
379