blob: 863599c4e0ae601c7263fc0b1c6a6ee10ec20477 [file] [log] [blame]
andrew@onlab.us10332202015-03-11 15:04:43 -07001# ScaleOutTemplate --> IntentEventTP
andrew@onlab.us2ae3a112015-02-02 11:24:32 -08002#
3# CASE1 starts number of nodes specified in param file
4#
5# cameron@onlab.us
6
andrew@onlab.us10332202015-03-11 15:04:43 -07007import sys
8import os
9import time
10
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080011
12class IntentEventTP:
13
14 def __init__( self ):
15 self.default = ''
16
andrew@onlab.us10332202015-03-11 15:04:43 -070017 def CASE1( self, main ): #This is the initialization case
18 import os.path #this case will clean up all nodes
19 import time #but only node 1 is started in this case
20
21 global clusterCount #number of nodes running
22 global ONOSIp #list of ONOS IP addresses
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080023 clusterCount = 1
andrew@onlab.us10332202015-03-11 15:04:43 -070024 ONOSIp = [ 0 ]
25
26 #Load values from params file
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080027 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
28 gitPull = main.params[ 'GIT' ][ 'autopull' ]
29 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrew@onlab.us10332202015-03-11 15:04:43 -070030 Features= main.params[ 'ENV' ][ 'cellFeatures' ]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080031 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
32 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
andrew@onlab.us10332202015-03-11 15:04:43 -070033 maxNodes = int(main.params[ 'availableNodes' ])
34 MNip = main.params[ 'MN' ][ 'ip1' ]
35 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
jenkins3af0cd82015-03-24 10:27:16 -070036 numSwitches = (main.params[ 'TEST' ][ 'numSwitches' ]).split(",")
andrew@onlab.us10332202015-03-11 15:04:43 -070037
38 homeDir = os.path.expanduser('~')
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080039
andrew@onlab.us10332202015-03-11 15:04:43 -070040 main.ONOSbench.handle.sendline("export TERM=vt100")
41 dump = main.ONOSbench.handle.expect(":~")
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080042
andrew@onlab.us10332202015-03-11 15:04:43 -070043 #Populate ONOSIp with ips from params
44 for i in range(1, maxNodes + 1):
45 ipString = 'ip' + str(i)
46 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
47
48 #kill off all onos processes
49 main.log.step("Safety check, killing all ONOS processes")
50 main.log.step("before initiating enviornment setup")
51 for node in range(1, maxNodes + 1):
52 main.log.info("killing node " + str(node))
53 main.ONOSbench.onosDie(ONOSIp[node])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080054
andrew@onlab.us10332202015-03-11 15:04:43 -070055 #construct the cell file
56 main.log.info("Creating cell file")
57 exec "a = main.ONOSbench.createCellFile"
58 cellIp = []
59 for node in range (1, clusterCount + 1):
60 cellIp.append(ONOSIp[node])
61 a(BENCHIp,cellName,MNip,str(Features), *cellIp)
62
63 main.step( "Set Cell" )
64 main.ONOSbench.setCell(cellName)
65
66 #Uninstall everywhere
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080067 main.log.step( "Cleaning Enviornment..." )
andrew@onlab.us10332202015-03-11 15:04:43 -070068 for i in range(1, maxNodes + 1):
69 main.log.info(" Uninstalling ONOS " + str(i) )
70 main.ONOSbench.onosUninstall( ONOSIp[i] )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080071
andrew@onlab.us10332202015-03-11 15:04:43 -070072 #git
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080073 main.step( "Git checkout and pull " + checkoutBranch )
74 if gitPull == 'on':
75 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
76 pullResult = main.ONOSbench.gitPull()
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080077 else:
78 checkoutResult = main.TRUE
79 pullResult = main.TRUE
80 main.log.info( "Skipped git checkout and pull" )
andrew@onlab.us10332202015-03-11 15:04:43 -070081
82 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
83 if skipMvn != "yes":
84 mvnResult = main.ONOSbench.cleanInstall()
85
jenkins3af0cd82015-03-24 10:27:16 -070086 #null link
87 #null provider
88 #linkgraph
89 #intentPerf
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080090
jenkins3af0cd82015-03-24 10:27:16 -070091 myDistribution = []
92 for node in range (1, clusterCount + 1):
93 myDistribution.append(numSwitches[node-1])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080094
jenkins3af0cd82015-03-24 10:27:16 -070095 main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
96 main.ONOSbench.createNullDevProviderFile( BENCHIp, cellIp, myDistribution)
97 main.ONOSbench.createNullLinkProviderFile(BENCHIp)
andrew@onlab.us10332202015-03-11 15:04:43 -070098
jenkins3af0cd82015-03-24 10:27:16 -070099 main.log.step("Writing IntentPerf config file")
100 intentPerfConfig = open( homeDir + "/onos/tools/package/etc/org.onosproject.intentperf.IntentPerfInstaller.cfg", "w+")
101 intentPerfConfig.write("numKeys = 40000\n")
102 intentPerfConfig.write("cyclePeriod = 1000\n")
103 intentPerfConfig.write("numNeighors = 0\n")
104 intentPerfConfig.close()
andrew@onlab.us10332202015-03-11 15:04:43 -0700105
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800106 main.step( "Creating ONOS package" )
107 packageResult = main.ONOSbench.onosPackage()
108
109 main.step( "Installing ONOS package" )
andrew@onlab.us10332202015-03-11 15:04:43 -0700110 install1Result = main.ONOSbench.onosInstall( node=ONOSIp[1] )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800111
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800112 main.step( "verify cells" )
113 verifyCellResult = main.ONOSbench.verifyCell()
114
andrew@onlab.us10332202015-03-11 15:04:43 -0700115 main.step( "Checking if ONOS is up yet" )
116 for i in range( 2 ):
117 isup = main.ONOSbench.isup( ONOSIp[1] )
118 if isup:
119 break
120 if not isup:
121 main.log.report( "ONOS1 didn't start!" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800122
andrew@onlab.us10332202015-03-11 15:04:43 -0700123 lastOutput = "--"
124 origin = time.time()
125 clockStarted = False
126 while True:
127 main.ONOSbench.handle.sendline("onos $OC1 summary")
128 main.ONOSbench.handle.expect(":~")
129 clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3]
130 print("\nBefore: " + str(clusterCheck))
jenkins3af0cd82015-03-24 10:27:16 -0700131 if "SCC(s)=1," in clusterCheck:
andrew@onlab.us10332202015-03-11 15:04:43 -0700132 break
133 if clusterCheck != lastOutput:
134 sameOutput = False
135 elif clusterCheck == lastOutput:
136 if clockStarted == False:
137 start = time.time()
138 clockStarted = True
139 if time.time() > (start + 30):
140 main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...")
141 break
142 lastOutput = clusterCheck
143 time.sleep(5)
144
145
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800146
147 def CASE2( self, main ):
andrew@onlab.us10332202015-03-11 15:04:43 -0700148 # This case increases the cluster size by whatever scale is
149 # Note: 'scale' is the size of the step
150 # if scaling is not a part of your test, simply run this case
151 # once after CASE1 to set up your enviornment for your desired
152 # cluster size. If scaling is a part of you test call this case each time
153 # you want to increase cluster size
154
155 ''
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800156 'Increase number of nodes and initiate CLI'
157 ''
158 import time
andrew@onlab.us10332202015-03-11 15:04:43 -0700159 import os.path
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800160 global clusterCount
andrew@onlab.us10332202015-03-11 15:04:43 -0700161
162 Features= main.params[ 'ENV' ][ 'cellFeatures' ]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800163 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrew@onlab.us10332202015-03-11 15:04:43 -0700164 MNip = main.params[ 'MN' ][ 'ip1' ]
165 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
jenkins3af0cd82015-03-24 10:27:16 -0700166 numSwitches = (main.params[ 'TEST' ][ 'numSwitches' ]).split(",")
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800167 scale = int( main.params[ 'SCALE' ] )
andrew@onlab.us10332202015-03-11 15:04:43 -0700168 maxNodes = int(main.params[ 'availableNodes' ])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800169 clusterCount += scale
andrew@onlab.us10332202015-03-11 15:04:43 -0700170 homeDir = os.path.expanduser('~')
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800171
andrew@onlab.us10332202015-03-11 15:04:43 -0700172 #kill off all onos processes
173 main.log.step("Safety check, killing all ONOS processes")
174 main.log.step("before initiating enviornment setup")
175 for node in range(1, maxNodes + 1):
176 main.ONOSbench.onosDie(ONOSIp[node])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800177
andrew@onlab.us10332202015-03-11 15:04:43 -0700178 #Uninstall everywhere
179 main.log.step( "Cleaning Enviornment..." )
180 for i in range(1, maxNodes + 1):
181 main.log.info(" Uninstalling ONOS " + str(i) )
182 main.ONOSbench.onosUninstall( ONOSIp[i] )
183
184 #construct the cell file
185 main.log.info("Creating cell file")
186 exec "a = main.ONOSbench.createCellFile"
187 cellIp = []
188 for node in range (1, clusterCount + 1):
189 cellIp.append(ONOSIp[node])
190 a(BENCHIp,cellName,MNip,str(Features), *cellIp)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800191
andrew@onlab.us10332202015-03-11 15:04:43 -0700192 main.step( "Set Cell" )
193 main.ONOSbench.setCell(cellName)
194
jenkins3af0cd82015-03-24 10:27:16 -0700195 myDistribution = []
196 for node in range (1, clusterCount + 1):
197 myDistribution.append(numSwitches[node-1])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800198
jenkins3af0cd82015-03-24 10:27:16 -0700199 main.ONOSbench.createLinkGraphFile( BENCHIp, cellIp, myDistribution)
200 main.ONOSbench.createNullDevProviderFile( BENCHIp, cellIp, myDistribution)
201 main.ONOSbench.createNullLinkProviderFile( BENCHIp )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800202
jenkins3af0cd82015-03-24 10:27:16 -0700203 #neighbors = max(1, clusterCount-1)
204 neighbors = 0
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800205
jenkins3af0cd82015-03-24 10:27:16 -0700206 main.log.step("Writing IntentPerf config file")
207 intentPerfConfig = open( homeDir + "/onos/tools/package/etc/org.onosproject.intentperf.IntentPerfInstaller.cfg", "w+")
208 intentPerfConfig.write("numKeys = 40000\n")
209 intentPerfConfig.write("cyclePeriod = 1000\n")
210 intentPerfConfig.write("numNeighors = " + str(neighbors) + "\n")
211 intentPerfConfig.close()
andrew@onlab.us10332202015-03-11 15:04:43 -0700212
213 main.step( "Creating ONOS package, preparing to reinstall" )
214 packageResult = main.ONOSbench.onosPackage()
215
216 main.log.report( "Reinstalling on all nodes and increasing cluster size to " + str( clusterCount ) )
217 for node in range(1, clusterCount + 1):
218 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
219 main.ONOSbench.onosInstall( ONOSIp[node])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800220
andrew@onlab.us10332202015-03-11 15:04:43 -0700221 for i in range( 2 ):
222 isup = main.ONOSbench.isup( ONOSIp[node] )
223 if isup:
224 main.log.info("ONOS " + str(node) + " is up\n")
225 break
226 if not isup:
227 main.log.report( "ONOS " + str(node) + " didn't start!" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800228
andrew@onlab.us10332202015-03-11 15:04:43 -0700229 lastOutput = "--"
230 origin = time.time()
231 clockStarted = False
232 while True:
233 main.ONOSbench.handle.sendline("onos $OC1 summary")
234 main.ONOSbench.handle.expect(":~")
235 clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3]
236 print("\nBefore: " + str(clusterCheck))
jenkins3af0cd82015-03-24 10:27:16 -0700237 if ("SCC(s)=1,") in clusterCheck:
andrew@onlab.us10332202015-03-11 15:04:43 -0700238 break
239 if clusterCheck != lastOutput:
240 sameOutput = False
241 elif clusterCheck == lastOutput:
242 if clockStarted == False:
243 start = time.time()
244 clockStarted = True
245 if time.time() > (start + 60):
246 main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...")
247 break
248 lastOutput = clusterCheck
249 time.sleep(5)
250
251
252 def CASE3( self, main ):
253 import time
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800254 import json
andrew@onlab.us10332202015-03-11 15:04:43 -0700255 import string
256 import csv
jenkins3af0cd82015-03-24 10:27:16 -0700257 import numpy
andrew@onlab.us10332202015-03-11 15:04:43 -0700258
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800259 main.log.info("Cluster Count = " + str(clusterCount))
260
andrew@onlab.us10332202015-03-11 15:04:43 -0700261 intentsRate = main.params['METRICS']['intents_rate']
262 intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ]
263 intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ]
264 testDuration = main.params[ 'TEST' ][ 'duration' ]
265 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
266 debug = main.params[ 'debugMode' ]
267
268 metricList = [intentsRate, intentsWithdrawn, intentsFailed]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800269
jenkins3af0cd82015-03-24 10:27:16 -0700270 tempsleep =20
andrew@onlab.us10332202015-03-11 15:04:43 -0700271 main.log.info("sleeping " + str(tempsleep))
272 time.sleep(tempsleep)
273
274 loadFrom = ['0']
275 loadFrom.extend((main.params[ 'TEST' ][ 'loadFrom' ]).split(","))
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800276
277 for node in range(1, clusterCount+1):
andrew@onlab.us10332202015-03-11 15:04:43 -0700278 if loadFrom[node] == "1":
279 cmd = "onos $OC" + str(node) + " feature:install onos-app-intent-perf"
280 main.ONOSbench.handle.sendline(cmd)
281 main.ONOSbench.handle.expect(":~")
282 main.log.info("Load initiated on node " + str(node))
jenkins3af0cd82015-03-24 10:27:16 -0700283
284 time.sleep(5)
285 actcmd = "onos $OC" + str(node) + " intent-perf-start"
286 main.ONOSbench.handle.sendline(actcmd)
287 main.ONOSbench.handle.expect(":~")
288 main.log.info("Starting ONOS " + str(node) + " intent-perf...")
289
andrew@onlab.us10332202015-03-11 15:04:43 -0700290 main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800291 stop = time.time() + float( testDuration )
andrew@onlab.us10332202015-03-11 15:04:43 -0700292
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800293 while time.time() < stop:
294 time.sleep( float( logInterval ) )
jenkins3af0cd82015-03-24 10:27:16 -0700295 groupResult = []
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800296 for node in range (1, clusterCount + 1):
jenkins3af0cd82015-03-24 10:27:16 -0700297 if loadFrom[node] == "0": continue
298 groupResult.append(0)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800299
jenkins3af0cd82015-03-24 10:27:16 -0700300 cmd = " onos-ssh $OC" + str(node) + """ cat /opt/onos/log/karaf.log | grep "SNAPSHOT | Throughput" | tail -1 """
301 main.log.info("COMMAND: " + str(cmd))
302
303 x = 0
304 while True:
305 main.ONOSbench.handle.sendline(cmd)
306 main.ONOSbench.handle.expect(":~")
307 raw = main.ONOSbench.handle.before
308 if "OVERALL=" in raw:
309 break
310 x += 1
311 if x > 10:
312 main.log.error("Expected output not being recieved... continuing")
313 break
314 time.sleep(2)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800315
jenkins3af0cd82015-03-24 10:27:16 -0700316 raw = raw.splitlines()
317 splitResults = []
318 for line in raw:
319 splitResults.extend(line.split(" "))
320
321 myResult = "--"
322 for field in splitResults:
323 if "OVERALL" in field:
324 myResult = field
325
326 if myResult == "--":
327 main.log.error("Parsing/Pexpect error\n" + str(splitResults))
328
329 myResult = myResult.replace(";", "")
330 myResult = myResult.replace("OVERALL=","")
331 myResult = float(myResult)
332 groupResult[len(groupResult) -1] = myResult
333
334 main.log.info("Node " + str(node) + " overall rate: " + str(myResult))
335
336 main.log.report("Results from this round of polling: " + str(groupResult))
337 main.log.report("Cluster Total: " + str(numpy.sum(groupResult)) + "\n")
338