blob: 946864c9c2c45ee55a586b84f81c4a9d7b8b4fa8 [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' ]
37
38 #----do i need this line?
39 #main.ONOSbench.handle.sendline("export TERM=vt100")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -070040
cameron@onlab.us19494212015-04-01 16:12:07 -070041 # -- INIT SECTION, ONLY RUNS ONCE -- #
42 if init == False:
43 init = True
44 global clusterCount #number of nodes running
45 global ONOSIp #list of ONOS IP addresses
46 global scale
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" )
72
cameron@onlab.us19494212015-04-01 16:12:07 -070073 # -- END OF INIT SECTION --#
andrew@onlab.us5cdb2852015-03-11 15:11:10 -070074
cameron@onlab.us19494212015-04-01 16:12:07 -070075 clusterCount = int(scale[0])
76 scale.remove(scale[0])
77 main.log.info("CLUSTER COUNT: " + str(clusterCount))
78
79 #kill off all onos processes
80 main.log.step("Safety check, killing all ONOS processes")
81 main.log.step("before initiating enviornment setup")
82 for node in range(1, maxNodes + 1):
83 main.ONOSbench.onosDie(ONOSIp[node])
84
85 #Uninstall everywhere
86 main.log.step( "Cleaning Enviornment..." )
87 for i in range(1, maxNodes + 1):
88 main.log.info(" Uninstalling ONOS " + str(i) )
89 main.ONOSbench.onosUninstall( ONOSIp[i] )
90
91 #construct the cell file
92 main.log.info("Creating cell file")
93 cellIp = []
94 for node in range (1, clusterCount + 1):
95 cellIp.append(ONOSIp[node])
andrew@onlab.us5cdb2852015-03-11 15:11:10 -070096
cameron@onlab.us19494212015-04-01 16:12:07 -070097 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
98 main.log.info("Cell Ip list: " + str(cellIp))
99
100 main.step( "Set Cell" )
101 main.ONOSbench.setCell(cellName)
102
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700103 main.step( "Creating ONOS package" )
104 packageResult = main.ONOSbench.onosPackage()
105
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700106 main.step( "verify cells" )
107 verifyCellResult = main.ONOSbench.verifyCell()
108
cameron@onlab.us19494212015-04-01 16:12:07 -0700109 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
110 for node in range(1, clusterCount + 1):
111 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
112 main.ONOSbench.onosInstall( ONOSIp[node])
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700113
cameron@onlab.us19494212015-04-01 16:12:07 -0700114 for node in range(1, clusterCount + 1):
115 for i in range( 2 ):
116 isup = main.ONOSbench.isup( ONOSIp[node] )
117 if isup:
118 main.log.info("ONOS " + str(node) + " is up\n")
119 break
120 if not isup:
121 main.log.report( "ONOS " + str(node) + " didn't start!" )
122
123 for node in range(1, clusterCount + 1):
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700124 exec "a = main.ONOS%scli.startOnosCli" %str(node)
125 a(ONOSIp[node])
cameron@onlab.us19494212015-04-01 16:12:07 -0700126
127 main.log.info("Startup sequence complete")
128
129
130 def CASE2( self, main ):
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700131 #
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' ])
cameron@onlab.us19494212015-04-01 16:12:07 -0700145 neighborList = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700146 testCMD[0] = main.params[ 'TEST' ][ 'testCMD0' ]
147 testCMD[1] = main.params[ 'TEST' ][ 'testCMD1' ]
148 maxNodes = main.params[ 'availableNodes' ]
149 onBaremetal = main.params['isOnBaremetal']
150
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700151 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700152 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
153 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
154 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
155 maxNodes = int(main.params[ 'availableNodes' ])
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700156 homeDir = os.path.expanduser('~')
cameron@onlab.us19494212015-04-01 16:12:07 -0700157
158 servers = str(clusterCount)
159 for i in range(0, len(neighborList)):
160 if neighborList[i] == 'a':
161 neighborList[i] = str(clusterCount - 1)
162
163 if clusterCount == 1:
164 neighborList = ['0']
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700165 main.log.info("neightborlist: " + str(neighborList))
166
167 ts = time.time()
168 st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
169 logFileName = "../logs/flowTPResultsLog" + str(st)
170
171 #initialize log file, remove any previous data
172 resultsLog = open("flowTPResultsLog","w+")
173 resultsLog.close()
174
175 #write file to change mem limit to 32 gigs (BAREMETAL ONLY!)
176 if onBaremetal == "true":
177 filename = "/onos/tools/package/bin/onos-service"
178 serviceConfig = open(homeDir + filename, 'w+')
179 serviceConfig.write("#!/bin/bash\n ")
180 serviceConfig.write("#------------------------------------- \n ")
181 serviceConfig.write("# Starts ONOS Apache Karaf container\n ")
182 serviceConfig.write("#------------------------------------- \n ")
183 serviceConfig.write("#export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}\n ")
jenkins399e2512015-03-24 10:31:57 -0700184 serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G}" \n """)
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700185 serviceConfig.write("")
186 serviceConfig.write("ONOS_HOME=/opt/onos \n ")
187 serviceConfig.write("")
188 serviceConfig.write("[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..\n")
189 serviceConfig.write("""${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf "$@" \n """)
190 serviceConfig.close()
191
192 for n in neighborList:
cameron@onlab.us19494212015-04-01 16:12:07 -0700193 main.log.step("\tSTARTING TEST")
194 main.log.step("\tLOADING FROM SERVERS: \t" + str(clusterCount) )
195 main.log.step("\tNEIGHBORS:\t" + n )
196 main.log.info("=============================================================")
197 main.log.info("=============================================================")
198 #write file to configure nil link
199 ipCSV = ""
200 for i in range (1, int(maxNodes) + 1):
201 tempstr = "ip" + str(i)
202 ipCSV += main.params[ 'CTRL' ][ tempstr ]
203 if i < int(maxNodes):
204 ipCSV +=","
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700205
cameron@onlab.us19494212015-04-01 16:12:07 -0700206 filename = "/onos/tools/package/etc/org.onosproject.provider.nil.link.impl.NullLinkProvider.cfg"
207 linkConfig = open(homeDir + filename,'w+')
208 linkConfig.write("# eventRate = 2000\n")
209 linkConfig.write("neighbors = " + ipCSV)
210 main.log.info(" NullLinkProvider.cfg: " + ipCSV)
211 linkConfig.close()
212
213 #config null device
214 cellIp = []
215 for node in range(1, clusterCount + 1):
216 cellIp.append(ONOSIp[node])
217 main.log.info(" NullDeviceProvider.cfg: " + str(cellIp))
218 main.ONOSbench.configNullDev(cellIp, switches)
219
220 #devide flows
221 flows = int(main.params[ 'TEST' ][ 'flows' ])
222 main.log.info("Flow Target = " + str(flows))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700223
cameron@onlab.us19494212015-04-01 16:12:07 -0700224 flows = (flows *max(int(n)+1,int(servers)))/((int(n) + 1)*int(servers)*(switches))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700225
cameron@onlab.us19494212015-04-01 16:12:07 -0700226 main.log.info("Flows per switch = " + str(flows))
227 #main.log.info("Total flows = " + str(switches * flows))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700228
cameron@onlab.us19494212015-04-01 16:12:07 -0700229 #build list of servers in "$OC1, $OC2...." format
230 serverEnvVars = ""
231 for i in range (1,int(servers)+1):
232 serverEnvVars += ("-s " + ONOSIp[i] + " ")
233
234 data = [[""]*int(servers)]*int(sampleSize)
235 maxes = [""]*int(sampleSize)
236
237 for test in range(0, (warmUp + sampleSize)):
238 flowCMD = "python3 " + homeDir + "/onos/tools/test/bin/"
239 flowCMD += testCMD[0] + " " + str(flows) + " " + testCMD[1]
240 flowCMD += " " + str(n) + " " + str(serverEnvVars)
241 print("\n")
242 main.log.info("COMMAND: " + flowCMD)
243 main.log.info("Executing command")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700244
cameron@onlab.us19494212015-04-01 16:12:07 -0700245 for i in range(0,15):
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700246 main.ONOSbench.handle.sendline(flowCMD)
cameron@onlab.us19494212015-04-01 16:12:07 -0700247 time.sleep(1)
248 main.ONOSbench.handle.expect(":~")
249 rawResult = main.ONOSbench.handle.before
250 if " -> " in rawResult:
251 break
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700252
cameron@onlab.us19494212015-04-01 16:12:07 -0700253 result = [""]*(clusterCount)
254 rawResult = rawResult.splitlines()
255 print(rawResult)
256 for node in range(1, clusterCount + 1):
257 for line in rawResult
258 if ONOSIp[node] in line and " -> " in line:
259 myLine = line.split(" ")
260 for word in myLine:
261 if "ms" in word:
262 result[node-1] = int(word.replace("ms",""))
263 main.log.info("Parsed result: " + str(result[node-1]))
264 break
265 break
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700266
cameron@onlab.us19494212015-04-01 16:12:07 -0700267 if test >= warmUp:
268 for i in result:
269 if i == "":
270 main.log.error("Missing data point, critical failure incoming")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700271
cameron@onlab.us19494212015-04-01 16:12:07 -0700272 print result
273 maxes[test-warmUp] = max(result)
274 main.log.info("Data collection iteration: " + str(test-warmUp) + " of " + str(sampleSize))
275 main.log.info("Throughput time: " + str(maxes[test-warmUp]) + "(ms)")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700276
cameron@onlab.us19494212015-04-01 16:12:07 -0700277 if test >= warmUp:
278 data[test-warmUp] = result
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700279
cameron@onlab.us19494212015-04-01 16:12:07 -0700280 # wait for flows = 0
281 removedFlows = False
282 repeat = 0
283 time.sleep(3)
284 while ( removedFlows == False and repeat <= 10 ):
285 main.ONOSbench.handle.sendline("onos $OC1 summary| cut -d ' ' -f6")
286 main.ONOSbench.handle.expect("~")
287 before = main.ONOSbench.handle.before
288 parseTest = before.splitlines()
289 flowsummary = ""
290 for line in parseTest:
291 if "flow" in str(line):
292 flowsummary = line
293 break
294 currentflow = ""
295 for word in flowsummary.split(" "):
296 if "flow" in str(word):
297 currentflow = str(word)
298 currentflow = currentflow.replace(",","")
299 currentflow = currentflow.replace("\n","")
300 #main.log.info(currentflow)
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700301
cameron@onlab.us19494212015-04-01 16:12:07 -0700302 zeroFlow = "flows=0"
303 if zeroFlow in before:
304 removedFlows = True
305 main.log.info("\t Wait 5 sec of cool down...")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700306 time.sleep(5)
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700307
cameron@onlab.us19494212015-04-01 16:12:07 -0700308 time.sleep(5)
309 repeat +=1
310
311 main.log.info("raw data: " + str(data))
312 main.log.info("maxes:" + str(maxes))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700313
cameron@onlab.us19494212015-04-01 16:12:07 -0700314
315 # report data
316 print("")
317 main.log.info("\t Results (measurments are in milliseconds)")
318 print("")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700319
cameron@onlab.us19494212015-04-01 16:12:07 -0700320 nodeString = ""
321 for i in range(1, int(servers) + 1):
322 nodeString += ("\tNode " + str(i))
323
324 for test in range(0, sampleSize ):
325 main.log.info("\t Test iteration " + str(test + 1) )
326 main.log.info("\t------------------")
327 main.log.info(nodeString)
328 resultString = ""
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700329
cameron@onlab.us19494212015-04-01 16:12:07 -0700330 for i in range(0, int(servers) ):
331 resultString += ("\t" + str(data[test][i]) )
332 main.log.info(resultString)
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700333
cameron@onlab.us19494212015-04-01 16:12:07 -0700334 print("\n")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700335
cameron@onlab.us19494212015-04-01 16:12:07 -0700336 avgOfMaxes = numpy.mean(maxes)
337 main.log.info("Average of max value from each test iteration: " + str(avgOfMaxes))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700338
cameron@onlab.us19494212015-04-01 16:12:07 -0700339 stdOfMaxes = numpy.std(maxes)
340 main.log.info("Standard Deviation of max values: " + str(stdOfMaxes))
341 print("\n\n")
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700342
cameron@onlab.us19494212015-04-01 16:12:07 -0700343 avgTP = int(main.params[ 'TEST' ][ 'flows' ]) / avgOfMaxes #result in kflows/second
344
345 tp = []
346 for i in maxes:
347 tp.append((int(main.params[ 'TEST' ][ 'flows' ]) / i ))
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700348
cameron@onlab.us19494212015-04-01 16:12:07 -0700349 stdTP = numpy.std(tp)
andrew@onlab.us5cdb2852015-03-11 15:11:10 -0700350
cameron@onlab.us19494212015-04-01 16:12:07 -0700351 main.log.info("Average thoughput: " + str(avgTP) + " Kflows/second" )
352 main.log.info("Standard deviation of throughput: " + str(stdTP) + " Kflows/second")
353
354 resultsLog = open(logFileName,"a")
355 resultsLog.write(str(main.params[ 'TEST' ][ 'flows' ]) + "," + n + "," + str(servers) + str(switches) + "," + str(warmUp))
356 resultsLog.write("," +str(sampleSize) + "," + str(avgTP) + "," + str(stdTP) + "\n")
357 resultsLog.close()
358
359