blob: 30c44f6b1a9aa9449feb8e3cd4eeb44f5abdd9a0 [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
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700221 for node in range(1, clusterCount + 1):
andrew@onlab.us10332202015-03-11 15:04:43 -0700222 for i in range( 2 ):
223 isup = main.ONOSbench.isup( ONOSIp[node] )
224 if isup:
225 main.log.info("ONOS " + str(node) + " is up\n")
226 break
227 if not isup:
228 main.log.report( "ONOS " + str(node) + " didn't start!" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800229
andrew@onlab.us10332202015-03-11 15:04:43 -0700230 lastOutput = "--"
231 origin = time.time()
232 clockStarted = False
233 while True:
234 main.ONOSbench.handle.sendline("onos $OC1 summary")
235 main.ONOSbench.handle.expect(":~")
236 clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3]
237 print("\nBefore: " + str(clusterCheck))
jenkins3af0cd82015-03-24 10:27:16 -0700238 if ("SCC(s)=1,") in clusterCheck:
andrew@onlab.us10332202015-03-11 15:04:43 -0700239 break
240 if clusterCheck != lastOutput:
241 sameOutput = False
242 elif clusterCheck == lastOutput:
243 if clockStarted == False:
244 start = time.time()
245 clockStarted = True
246 if time.time() > (start + 60):
247 main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...")
248 break
249 lastOutput = clusterCheck
250 time.sleep(5)
251
252
253 def CASE3( self, main ):
254 import time
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800255 import json
andrew@onlab.us10332202015-03-11 15:04:43 -0700256 import string
257 import csv
jenkins3af0cd82015-03-24 10:27:16 -0700258 import numpy
andrew@onlab.us10332202015-03-11 15:04:43 -0700259
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800260 main.log.info("Cluster Count = " + str(clusterCount))
261
andrew@onlab.us10332202015-03-11 15:04:43 -0700262 intentsRate = main.params['METRICS']['intents_rate']
263 intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ]
264 intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ]
265 testDuration = main.params[ 'TEST' ][ 'duration' ]
266 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
267 debug = main.params[ 'debugMode' ]
268
269 metricList = [intentsRate, intentsWithdrawn, intentsFailed]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800270
jenkins3af0cd82015-03-24 10:27:16 -0700271 tempsleep =20
andrew@onlab.us10332202015-03-11 15:04:43 -0700272 main.log.info("sleeping " + str(tempsleep))
273 time.sleep(tempsleep)
274
275 loadFrom = ['0']
276 loadFrom.extend((main.params[ 'TEST' ][ 'loadFrom' ]).split(","))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700277
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800278 for node in range(1, clusterCount+1):
andrew@onlab.us10332202015-03-11 15:04:43 -0700279 if loadFrom[node] == "1":
280 cmd = "onos $OC" + str(node) + " feature:install onos-app-intent-perf"
281 main.ONOSbench.handle.sendline(cmd)
282 main.ONOSbench.handle.expect(":~")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700283 main.log.info( "intent-perf feature installed on: ONOS" + str(node) )
jenkins3af0cd82015-03-24 10:27:16 -0700284
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700285 time.sleep(5)
286 actcmd = "onos $OC1" + " intent-perf-start"
287 main.ONOSbench.handle.sendline(actcmd)
288 main.ONOSbench.handle.expect(":~")
289 main.log.info("Starting ONOS (all nodes) intent-perf from $OC1" )
jenkins3af0cd82015-03-24 10:27:16 -0700290
andrew@onlab.us10332202015-03-11 15:04:43 -0700291 main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" )
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800292 stop = time.time() + float( testDuration )
andrew@onlab.us10332202015-03-11 15:04:43 -0700293
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800294 while time.time() < stop:
295 time.sleep( float( logInterval ) )
jenkins3af0cd82015-03-24 10:27:16 -0700296 groupResult = []
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800297 for node in range (1, clusterCount + 1):
jenkins3af0cd82015-03-24 10:27:16 -0700298 if loadFrom[node] == "0": continue
299 groupResult.append(0)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800300
jenkins3af0cd82015-03-24 10:27:16 -0700301 cmd = " onos-ssh $OC" + str(node) + """ cat /opt/onos/log/karaf.log | grep "SNAPSHOT | Throughput" | tail -1 """
302 main.log.info("COMMAND: " + str(cmd))
303
304 x = 0
305 while True:
306 main.ONOSbench.handle.sendline(cmd)
307 main.ONOSbench.handle.expect(":~")
308 raw = main.ONOSbench.handle.before
309 if "OVERALL=" in raw:
310 break
311 x += 1
312 if x > 10:
313 main.log.error("Expected output not being recieved... continuing")
314 break
315 time.sleep(2)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800316
jenkins3af0cd82015-03-24 10:27:16 -0700317 raw = raw.splitlines()
318 splitResults = []
319 for line in raw:
320 splitResults.extend(line.split(" "))
321
322 myResult = "--"
323 for field in splitResults:
324 if "OVERALL" in field:
325 myResult = field
326
327 if myResult == "--":
328 main.log.error("Parsing/Pexpect error\n" + str(splitResults))
329
330 myResult = myResult.replace(";", "")
331 myResult = myResult.replace("OVERALL=","")
332 myResult = float(myResult)
333 groupResult[len(groupResult) -1] = myResult
334
335 main.log.info("Node " + str(node) + " overall rate: " + str(myResult))
336
337 main.log.report("Results from this round of polling: " + str(groupResult))
338 main.log.report("Cluster Total: " + str(numpy.sum(groupResult)) + "\n")
339