blob: 291586418e9b68281c629d89a6a801565f1b68fa [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
Jon Hall4ba53f02015-07-29 13:07:41 -070016 def CASE1( self, main ):
cameron@onlab.us946d99c2015-07-08 15:34:37 -070017
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' ]
cameron@onlab.usb3aa4982015-07-13 15:20:41 -070032 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
33 main.maxNodes = int(main.params[ 'max' ])
cameron@onlab.us946d99c2015-07-08 15:34:37 -070034 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
Jon Hall4ba53f02015-07-29 13:07:41 -070035 cellName = main.params[ 'ENV' ][ 'cellName' ]
36
cameron@onlab.us946d99c2015-07-08 15:34:37 -070037 main.log.info("==========DEBUG VERSION 3===========")
38
cameron@onlab.us946d99c2015-07-08 15:34:37 -070039 # -- INIT SECTION, ONLY RUNS ONCE -- #
40 if init == False:
41 init = True
42 global clusterCount #number of nodes running
43 global ONOSIp #list of ONOS IP addresses
44 global scale
45 global commit
46
47 clusterCount = 0
48 ONOSIp = [ 0 ]
49 scale = (main.params[ 'SCALE' ]).split(",")
50 clusterCount = int(scale[0])
51
52 #Populate ONOSIp with ips from params
cameron@onlab.usb3aa4982015-07-13 15:20:41 -070053 for i in range(1, main.maxNodes + 1):
cameron@onlab.us946d99c2015-07-08 15:34:37 -070054 ipString = 'ip' + str(i)
55 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
56
57 ONOSIp = [0]
58 ONOSIp.extend(main.ONOSbench.getOnosIps())
59
60 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
61 if skipMvn != "yes":
62 mvnResult = main.ONOSbench.cleanInstall()
63
64 #git
65 main.step( "Git checkout and pull " + checkoutBranch )
66 if gitPull == 'on':
67 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
68 pullResult = main.ONOSbench.gitPull()
69
70 else:
71 checkoutResult = main.TRUE
72 pullResult = main.TRUE
73 main.log.info( "Skipped git checkout and pull" )
Jon Hall4ba53f02015-07-29 13:07:41 -070074
cameron@onlab.us946d99c2015-07-08 15:34:37 -070075 commit = main.ONOSbench.getVersion()
76 commit = (commit.split(" "))[1]
77
suibine1e58772015-07-15 09:52:59 -070078 resultsDB = open("/tmp/flowTP1gDB", "w+")
cameron@onlab.us946d99c2015-07-08 15:34:37 -070079 resultsDB.close()
80
81 # -- END OF INIT SECTION --#
82
83 clusterCount = int(scale[0])
84 scale.remove(scale[0])
85 main.log.info("CLUSTER COUNT: " + str(clusterCount))
86
Jon Hall4ba53f02015-07-29 13:07:41 -070087 #kill off all onos processes
Jon Hall6509dbf2016-06-21 17:01:17 -070088 main.step("Safety check, killing all ONOS processes")
89 main.step("before initiating environment setup")
cameron@onlab.usb3aa4982015-07-13 15:20:41 -070090 for node in range(1, main.maxNodes + 1):
cameron@onlab.us946d99c2015-07-08 15:34:37 -070091 main.ONOSbench.onosDie(ONOSIp[node])
92
93 #Uninstall everywhere
Jon Hall6509dbf2016-06-21 17:01:17 -070094 main.step( "Cleaning Enviornment..." )
cameron@onlab.usb3aa4982015-07-13 15:20:41 -070095 for i in range(1, main.maxNodes + 1):
cameron@onlab.us946d99c2015-07-08 15:34:37 -070096 main.log.info(" Uninstalling ONOS " + str(i) )
97 main.ONOSbench.onosUninstall( ONOSIp[i] )
98
99 #construct the cell file
100 main.log.info("Creating cell file")
101 cellIp = []
102 for node in range (1, clusterCount + 1):
Jon Hall4ba53f02015-07-29 13:07:41 -0700103 cellIp.append(ONOSIp[node])
104
cameron@onlab.usb3aa4982015-07-13 15:20:41 -0700105 main.ONOSbench.createCellFile(BENCHIp,cellName,"localhost",str(Apps), cellIp)
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700106 main.log.info("Cell Ip list: " + str(cellIp))
Jon Hall4ba53f02015-07-29 13:07:41 -0700107
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700108 main.step( "Set Cell" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700109 main.ONOSbench.setCell(cellName)
110
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700111 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700112 packageResult = main.ONOSbench.buckBuild()
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700113
114 main.step( "verify cells" )
115 verifyCellResult = main.ONOSbench.verifyCell()
116
117 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
118 for node in range(1, clusterCount + 1):
119 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
120 main.ONOSbench.onosInstall( ONOSIp[node])
121
122 for node in range(1, clusterCount + 1):
You Wangf5de25b2017-01-06 15:13:01 -0800123 secureSshResult = main.ONOSbench.onosSecureSSH( ONOSIp[node] )
124
125 for node in range(1, clusterCount + 1):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700126 for i in range( 2 ):
127 isup = main.ONOSbench.isup( ONOSIp[node] )
128 if isup:
129 main.log.info("ONOS " + str(node) + " is up\n")
130 break
131 if not isup:
132 main.log.report( "ONOS " + str(node) + " didn't start!" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700133
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700134 for node in range(1, clusterCount + 1):
135 exec "a = main.ONOS%scli.startOnosCli" %str(node)
136 a(ONOSIp[node])
Jon Hall4ba53f02015-07-29 13:07:41 -0700137
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700138 main.log.info("Startup sequence complete")
Jon Hall4ba53f02015-07-29 13:07:41 -0700139 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
Chiyu Chengef109502016-11-21 15:51:38 -0800140
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700141 def CASE2( self, main ):
142 #
Jon Hall4ba53f02015-07-29 13:07:41 -0700143 # This is the flow TP test
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700144 #
Jon Hall4ba53f02015-07-29 13:07:41 -0700145 import os.path
146 import numpy
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700147 import math
Jon Hall4ba53f02015-07-29 13:07:41 -0700148 import time
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700149 import datetime
150 import traceback
151
152 global currentNeighbors
153 try:
154 currentNeighbors
155 except:
156 currentNeighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")[0]
157 else:
158 if currentNeighbors == "r": #reset
159 currentNeighbors = "0"
160 else:
161 currentNeighbors = "a"
162
163 testCMD = [ 0,0,0,0 ]
164 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
165 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
166 switches = int(main.params[ 'TEST' ][ 'switches' ])
167 neighborList = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
168 testCMD[0] = main.params[ 'TEST' ][ 'testCMD0' ]
169 testCMD[1] = main.params[ 'TEST' ][ 'testCMD1' ]
cameron@onlab.usb3aa4982015-07-13 15:20:41 -0700170 main.maxNodes = main.params[ 'max' ]
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700171 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' ]
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700176 homeDir = os.path.expanduser('~')
177 flowRuleBackup = str(main.params[ 'TEST' ][ 'enableFlowRuleStoreBackup' ])
178 main.log.info("Flow Rule Backup is set to:" + flowRuleBackup)
179
Jon Hall4ba53f02015-07-29 13:07:41 -0700180 servers = str(clusterCount)
181
182 if clusterCount == 1:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700183 neighborList = ['0']
184 currentNeighbors = "r"
185 else:
186 if currentNeighbors == "a":
187 neighborList = [str(clusterCount-1)]
188 currentNeighbors = "r"
189 else:
Jon Hall4ba53f02015-07-29 13:07:41 -0700190 neighborList = ['0']
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700191
192 main.log.info("neightborlist: " + str(neighborList))
193
194 ts = time.time()
195 st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
196
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700197 for n in neighborList:
Jon Hall6509dbf2016-06-21 17:01:17 -0700198 main.step("\tSTARTING TEST")
199 main.step("\tLOADING FROM SERVERS: \t" + str(clusterCount) )
200 main.step("\tNEIGHBORS:\t" + n )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700201 main.log.info("=============================================================")
202 main.log.info("=============================================================")
203 #write file to configure nil link
204 ipCSV = ""
cameron@onlab.usb3aa4982015-07-13 15:20:41 -0700205 for i in range (1, int(main.maxNodes) + 1):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700206 tempstr = "ip" + str(i)
Jon Hall4ba53f02015-07-29 13:07:41 -0700207 ipCSV += main.params[ 'CTRL' ][ tempstr ]
cameron@onlab.usb3aa4982015-07-13 15:20:41 -0700208 if i < int(main.maxNodes):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700209 ipCSV +=","
Jon Hall4ba53f02015-07-29 13:07:41 -0700210
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700211 for i in range(3):
212 main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "deviceCount 35")
213 main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "topoShape linear")
Jon Hall4ba53f02015-07-29 13:07:41 -0700214 main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "enabled true")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700215
216 time.sleep(5)
217 main.ONOSbench.handle.sendline("onos $OC1 summary")
218 main.ONOSbench.handle.expect(":~")
219 check = main.ONOSbench.handle.before
Jon Hall4ba53f02015-07-29 13:07:41 -0700220 main.log.info("\nStart up check: \n" + check + "\n")
221 if "SCC(s)=1," in check:
suibin zhanga3746bf2015-09-05 09:36:39 -0700222 main.ONOSbench.handle.sendline( "onos $OC1 balance-masters" )
suibin zhang45efc1b2015-09-04 16:48:10 -0700223 main.ONOSbench.handle.expect( ":~" )
224 time.sleep(5)
225 main.ONOSbench.handle.sendline( "onos $OC1 roles ")
226 main.ONOSbench.handle.expect ( ":~" )
227 main.log.info( "switch masterships:" + str( main.ONOSbench.handle.before ) )
Jon Hall4ba53f02015-07-29 13:07:41 -0700228 break
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700229 time.sleep(5)
Jon Hall4ba53f02015-07-29 13:07:41 -0700230
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700231 #devide flows
232 flows = int(main.params[ 'TEST' ][ 'flows' ])
233 main.log.info("Flow Target = " + str(flows))
234
235 flows = (flows *max(int(n)+1,int(servers)))/((int(n) + 1)*int(servers)*(switches))
236
237 main.log.info("Flows per switch = " + str(flows))
238
239 #build list of servers in "$OC1, $OC2...." format
240 serverEnvVars = ""
241 for i in range (1,int(servers)+1):
242 serverEnvVars += ("-s " + ONOSIp[i] + " ")
Jon Hall4ba53f02015-07-29 13:07:41 -0700243
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700244 data = [[""]*int(servers)]*int(sampleSize)
245 maxes = [""]*int(sampleSize)
246
247 flowCMD = "python3 " + homeDir + "/onos/tools/test/bin/"
248 flowCMD += testCMD[0] + " " + str(flows) + " " + testCMD[1]
Jon Hall4ba53f02015-07-29 13:07:41 -0700249 flowCMD += " " + str(n) + " " + str(serverEnvVars) + "-j"
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700250
251 main.log.info(flowCMD)
252 #time.sleep(60)
Jon Hall4ba53f02015-07-29 13:07:41 -0700253
254 for test in range(0, warmUp + sampleSize):
255 if test < warmUp:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700256 main.log.info("Warm up " + str(test + 1) + " of " + str(warmUp))
Jon Hall4ba53f02015-07-29 13:07:41 -0700257 else:
258 main.log.info("====== Test run: " + str(test-warmUp+1) + " ======")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700259
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
Jon Hall4ba53f02015-07-29 13:07:41 -0700265 if "failed" in rawResult:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700266 main.log.report("FLOW_TESTER.PY FAILURE")
267 main.log.report( " \n" + rawResult + " \n")
YPZhang325822f2016-06-17 16:01:45 -0700268 for i in range(1, clusterCount+1):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700269 main.log.report("=======================================================")
Jon Hall4ba53f02015-07-29 13:07:41 -0700270 main.log.report(" ONOS " + str(i) + "LOG REPORT")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700271 main.ONOSbench.logReport(ONOSIp[i], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
Jon Hall4ba53f02015-07-29 13:07:41 -0700272 main.ONOSbench.handle.sendline("onos $OC1 flows")
273 main.ONOSbench.handle.expect(":~")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700274 main.log.info(main.ONOSbench.handle.before)
275
276 break
Jon Hall4ba53f02015-07-29 13:07:41 -0700277
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700278 ########################################################################################
279 result = [""]*(clusterCount)
Jon Hall4ba53f02015-07-29 13:07:41 -0700280
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700281 #print("rawResult: " + rawResult)
282
283 rawResult = rawResult.splitlines()
284
Jon Hall4ba53f02015-07-29 13:07:41 -0700285 for node in range(1, clusterCount + 1):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700286 for line in rawResult:
Jon Hall4ba53f02015-07-29 13:07:41 -0700287 #print("line: " + line)
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700288 if ONOSIp[node] in line and "server" in line:
Jon Hall4ba53f02015-07-29 13:07:41 -0700289 temp = line.split(" ")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700290 for word in temp:
Jon Hall4ba53f02015-07-29 13:07:41 -0700291 #print ("word: " + word)
292 if "elapsed" in repr(word):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700293 index = temp.index(word) + 1
294 myParsed = (temp[index]).replace(",","")
295 myParsed = myParsed.replace("}","")
296 myParsed = int(myParsed)
297 result[node-1] = myParsed
298 main.log.info( ONOSIp[node] + " : " + str(myParsed))
Jon Hall4ba53f02015-07-29 13:07:41 -0700299 break
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700300
301 if test >= warmUp:
Jon Hall4ba53f02015-07-29 13:07:41 -0700302 for i in result:
303 if i == "":
cameron@onlab.usb3aa4982015-07-13 15:20:41 -0700304 main.log.error("Missing data point, critical failure incoming")
305
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700306 print result
307 maxes[test-warmUp] = max(result)
308 main.log.info("Data collection iteration: " + str(test-warmUp) + " of " + str(sampleSize))
Jon Hall4ba53f02015-07-29 13:07:41 -0700309 main.log.info("Throughput time: " + str(maxes[test-warmUp]) + "(ms)")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700310
311 data[test-warmUp] = result
312
Jon Hall4ba53f02015-07-29 13:07:41 -0700313 # wait for flows = 0
314 for checkCount in range(0,5):
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700315 time.sleep(10)
316 main.ONOSbench.handle.sendline("onos $OC1 summary")
317 main.ONOSbench.handle.expect(":~")
318 flowCheck = main.ONOSbench.handle.before
Jon Hall4ba53f02015-07-29 13:07:41 -0700319 if "flows=0," in flowCheck:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700320 main.log.info("Flows removed")
321 break
Jon Hall4ba53f02015-07-29 13:07:41 -0700322 else:
323 for line in flowCheck.splitlines():
324 if "flows=" in line:
325 main.log.info("Current Summary: " + line)
326 if checkCount == 2:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700327 main.log.info("Flows are stuck, moving on ")
328
329
330 time.sleep(5)
Jon Hall4ba53f02015-07-29 13:07:41 -0700331
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700332 main.log.info("raw data: " + str(data))
333 main.log.info("maxes:" + str(maxes))
334
Jon Hall4ba53f02015-07-29 13:07:41 -0700335
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700336 # report data
337 print("")
338 main.log.info("\t Results (measurments are in milliseconds)")
339 print("")
340
341 nodeString = ""
342 for i in range(1, int(servers) + 1):
Jon Hall4ba53f02015-07-29 13:07:41 -0700343 nodeString += ("\tNode " + str(i))
344
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700345 for test in range(0, sampleSize ):
346 main.log.info("\t Test iteration " + str(test + 1) )
347 main.log.info("\t------------------")
Jon Hall4ba53f02015-07-29 13:07:41 -0700348 main.log.info(nodeString)
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700349 resultString = ""
350
351 for i in range(0, int(servers) ):
Jon Hall4ba53f02015-07-29 13:07:41 -0700352 resultString += ("\t" + str(data[test][i]) )
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700353 main.log.info(resultString)
354
355 print("\n")
356
357 avgOfMaxes = numpy.mean(maxes)
358 main.log.info("Average of max value from each test iteration: " + str(avgOfMaxes))
359
360 stdOfMaxes = numpy.std(maxes)
Jon Hall4ba53f02015-07-29 13:07:41 -0700361 main.log.info("Standard Deviation of max values: " + str(stdOfMaxes))
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700362 print("\n\n")
363
364 avgTP = int(main.params[ 'TEST' ][ 'flows' ]) / avgOfMaxes #result in kflows/second
Jon Hall4ba53f02015-07-29 13:07:41 -0700365
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700366 tp = []
Jon Hall4ba53f02015-07-29 13:07:41 -0700367 for i in maxes:
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700368 tp.append((int(main.params[ 'TEST' ][ 'flows' ]) / i ))
369
370 stdTP = numpy.std(tp)
371
372 main.log.info("Average thoughput: " + str(avgTP) + " Kflows/second" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700373 main.log.info("Standard deviation of throughput: " + str(stdTP) + " Kflows/second")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700374
suibin584c0702015-07-14 15:57:27 -0700375 resultsLog = open("/tmp/flowTP1gDB","a")
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700376 resultString = ("'" + commit + "',")
377 resultString += ("'1gig',")
378 resultString += ((main.params[ 'TEST' ][ 'flows' ]) + ",")
379 resultString += (str(clusterCount) + ",")
380 resultString += (str(n) + ",")
381 resultString += (str(avgTP) + "," + str(stdTP) + "\n")
Jon Hall4ba53f02015-07-29 13:07:41 -0700382 resultsLog.write(resultString)
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700383 resultsLog.close()
Jon Hall4ba53f02015-07-29 13:07:41 -0700384
cameron@onlab.us946d99c2015-07-08 15:34:37 -0700385 main.log.report("Result line to file: " + resultString)
Jon Hall4ba53f02015-07-29 13:07:41 -0700386
387 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")