blob: 4dbd38be09e2fb10ea113d7a7c5a2a17f4940544 [file] [log] [blame]
cameron@onlab.us059c2562015-04-02 14:12:51 -07001# ScaleOutTemplate
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
cameron@onlab.us059c2562015-04-02 14:12:51 -07008import os.path
cameron@onlab.usaaecfd72015-07-08 12:27:26 -07009import time
andrew@onlab.us10332202015-03-11 15:04:43 -070010
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080011
suibin7f2c9cd2015-07-08 17:34:59 -070012class SCPFintentEventTp:
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080013
14 def __init__( self ):
15 self.default = ''
16
cameron@onlab.usaaecfd72015-07-08 12:27:26 -070017 def CASE1( self, main ):
18 import sys
cameron@onlab.usc10e22c2015-05-13 13:07:28 -070019 import os.path
cameron@onlab.usaaecfd72015-07-08 12:27:26 -070020 import time
cameron@onlab.usc10e22c2015-05-13 13:07:28 -070021
cameron@onlab.usaaecfd72015-07-08 12:27:26 -070022 global init
23 try:
24 if type(init) is not bool:
25 init = Fals
26 except NameError:
27 init = False
28
andrew@onlab.us10332202015-03-11 15:04:43 -070029 #Load values from params file
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080030 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
31 gitPull = main.params[ 'GIT' ][ 'autopull' ]
32 cellName = main.params[ 'ENV' ][ 'cellName' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -070033 Apps = main.params[ 'ENV' ][ 'cellApps' ]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080034 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
35 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -070036 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
cameron@onlab.usc5bf8192015-07-13 13:36:05 -070037 maxNodes = int(main.params[ 'max' ])
38 main.maxNodes = maxNodes
andrew@onlab.us10332202015-03-11 15:04:43 -070039 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
cameron@onlab.usaaecfd72015-07-08 12:27:26 -070040 cellName = main.params[ 'ENV' ][ 'cellName' ]
jenkins3af0cd82015-03-24 10:27:16 -070041 numSwitches = (main.params[ 'TEST' ][ 'numSwitches' ]).split(",")
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -070042 flowRuleBU = main.params[ 'TEST' ][ 'flowRuleBUEnabled' ]
cameron@onlab.usc10e22c2015-05-13 13:07:28 -070043 homeDir = os.path.expanduser('~')
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080044
cameron@onlab.us412e9562015-05-13 16:04:34 -070045 main.exceptions = [0]*11
46 main.warnings = [0]*11
47 main.errors = [0]*11
48
cameron@onlab.us059c2562015-04-02 14:12:51 -070049 # -- INIT SECTION, ONLY RUNS ONCE -- #
50 if init == False:
51 init = True
52 global clusterCount #number of nodes running
53 global ONOSIp #list of ONOS IP addresses
54 global scale
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070055 global commit
cameron@onlab.usc10e22c2015-05-13 13:07:28 -070056
cameron@onlab.us059c2562015-04-02 14:12:51 -070057 clusterCount = 0
cameron@onlab.usc5bf8192015-07-13 13:36:05 -070058 ONOSIp = main.ONOSbench.getOnosIps()
59 print ONOSIp
60 print main.ONOSbench.onosIps.values()
61
cameron@onlab.us059c2562015-04-02 14:12:51 -070062 scale = (main.params[ 'SCALE' ]).split(",")
63 clusterCount = int(scale[0])
64
65 #Populate ONOSIp with ips from params
jenkins15b2b132015-06-23 14:04:09 -070066 ONOSIp.extend(main.ONOSbench.getOnosIps())
jenkins15b2b132015-06-23 14:04:09 -070067
cameron@onlab.us059c2562015-04-02 14:12:51 -070068 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
69 if skipMvn != "yes":
70 mvnResult = main.ONOSbench.cleanInstall()
71
72 #git
73 main.step( "Git checkout and pull " + checkoutBranch )
74 if gitPull == 'on':
75 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
76 pullResult = main.ONOSbench.gitPull()
77
78 else:
79 checkoutResult = main.TRUE
80 pullResult = main.TRUE
81 main.log.info( "Skipped git checkout and pull" )
cameron@onlab.usc5bf8192015-07-13 13:36:05 -070082
83 main.log.step("Grabbing commit number")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070084 commit = main.ONOSbench.getVersion()
85 commit = (commit.split(" "))[1]
86
cameron@onlab.usc5bf8192015-07-13 13:36:05 -070087 main.log.step("Creating results file")
suibin584c0702015-07-14 15:57:27 -070088 resultsDB = open("/tmp/IntentEventTPDB", "w+")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070089 resultsDB.close()
90
cameron@onlab.us059c2562015-04-02 14:12:51 -070091 # -- END OF INIT SECTION --#
cameron@onlab.usc5bf8192015-07-13 13:36:05 -070092
93 main.log.step("Adjusting scale")
94 print str(scale)
95 print str(ONOSIp)
cameron@onlab.us059c2562015-04-02 14:12:51 -070096 clusterCount = int(scale[0])
97 scale.remove(scale[0])
jenkins5a771992015-06-24 13:53:27 -070098
99 MN1Ip = ONOSIp[len(ONOSIp) -1]
100 BENCHIp = ONOSIp[len(ONOSIp) -2]
101
cameron@onlab.us059c2562015-04-02 14:12:51 -0700102 #kill off all onos processes
andrew@onlab.us10332202015-03-11 15:04:43 -0700103 main.log.step("Safety check, killing all ONOS processes")
104 main.log.step("before initiating enviornment setup")
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700105 for node in range(maxNodes):
andrew@onlab.us10332202015-03-11 15:04:43 -0700106 main.ONOSbench.onosDie(ONOSIp[node])
jenkins8f8f4f32015-06-24 14:05:04 -0700107
108 MN1Ip = ONOSIp[len(ONOSIp) -1]
109 BENCHIp = ONOSIp[len(ONOSIp) -2]
110
andrew@onlab.us10332202015-03-11 15:04:43 -0700111 #Uninstall everywhere
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800112 main.log.step( "Cleaning Enviornment..." )
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700113 for i in range(maxNodes):
andrew@onlab.us10332202015-03-11 15:04:43 -0700114 main.log.info(" Uninstalling ONOS " + str(i) )
115 main.ONOSbench.onosUninstall( ONOSIp[i] )
suibine1a104d2015-07-08 15:58:29 -0700116 main.log.info("Sleep 10 second for uninstall to settle...")
117 time.sleep(10)
118 main.ONOSbench.handle.sendline(" ")
119 main.ONOSbench.handle.expect(":~")
120
cameron@onlab.us059c2562015-04-02 14:12:51 -0700121 #construct the cell file
122 main.log.info("Creating cell file")
123 cellIp = []
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700124 for node in range (clusterCount):
cameron@onlab.us059c2562015-04-02 14:12:51 -0700125 cellIp.append(ONOSIp[node])
jenkins5a771992015-06-24 13:53:27 -0700126
cameron@onlab.usc5bf8192015-07-13 13:36:05 -0700127 main.ONOSbench.createCellFile("localhost",cellName,MN1Ip,str(Apps), cellIp)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700128
129 main.step( "Set Cell" )
130 main.ONOSbench.setCell(cellName)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800131
jenkins3af0cd82015-03-24 10:27:16 -0700132 myDistribution = []
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700133 for node in range (clusterCount):
134 myDistribution.append(numSwitches[node])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800135
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800136 main.step( "Creating ONOS package" )
137 packageResult = main.ONOSbench.onosPackage()
138
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800139 main.step( "verify cells" )
140 verifyCellResult = main.ONOSbench.verifyCell()
cameron@onlab.us059c2562015-04-02 14:12:51 -0700141
142 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700143 for node in range(clusterCount):
cameron@onlab.us059c2562015-04-02 14:12:51 -0700144 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
andrew@onlab.us10332202015-03-11 15:04:43 -0700145 main.ONOSbench.onosInstall( ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700146
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700147 for node in range(clusterCount):
andrew@onlab.us10332202015-03-11 15:04:43 -0700148 for i in range( 2 ):
149 isup = main.ONOSbench.isup( ONOSIp[node] )
150 if isup:
151 main.log.info("ONOS " + str(node) + " is up\n")
152 break
153 if not isup:
154 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700155 main.log.info("Startup sequence complete")
156
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700157 time.sleep(20)
158
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700159 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.store.flow.impl.NewDistributedFlowRuleStore", "backupEnabled false")
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700160
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700161 main.log.step("Setting up null provider")
162 for i in range(3):
163 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.provider.nil.NullProviders", "deviceCount 8")
164 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.provider.nil.NullProviders", "topoShape linear")
165 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.provider.nil.NullProviders", "enabled true")
166 time.sleep(5)
167
168 main.ONOSbench.handle.sendline("onos $OC1 summary")
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700169 main.ONOSbench.handle.expect(":~")
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700170
171 before = main.ONOSbench.handle.before
172 if "devices=8" in before and "links=14" in before:
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700173 break
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700174
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700175 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
176 main.ONOSbench.handle.expect(":~")
177 print main.ONOSbench.handle.before
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700178
andrew@onlab.us10332202015-03-11 15:04:43 -0700179 lastOutput = "--"
180 origin = time.time()
181 clockStarted = False
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700182 while True:
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700183
184 main.ONOSbench.handle.sendline("")
185 main.ONOSbench.handle.expect(":~")
186
andrew@onlab.us10332202015-03-11 15:04:43 -0700187 main.ONOSbench.handle.sendline("onos $OC1 summary")
188 main.ONOSbench.handle.expect(":~")
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700189
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700190 main.log.info("before" + main.ONOSbench.handle.before)
Jon Hallf57a5ef2015-07-07 17:56:16 -0700191 clusterCheck = main.ONOSbench.handle.before
andrew@onlab.us10332202015-03-11 15:04:43 -0700192 print("\nBefore: " + str(clusterCheck))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700193 if ("SCC(s)=1,") in clusterCheck:
andrew@onlab.us10332202015-03-11 15:04:43 -0700194 break
195 if clusterCheck != lastOutput:
196 sameOutput = False
197 elif clusterCheck == lastOutput:
198 if clockStarted == False:
199 start = time.time()
200 clockStarted = True
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700201 if time.time() > (start + 30):
andrew@onlab.us10332202015-03-11 15:04:43 -0700202 main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...")
203 break
204 lastOutput = clusterCheck
205 time.sleep(5)
jenkins50379942015-06-19 13:36:43 -0700206 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700207 def CASE2( self, main ):
andrew@onlab.us10332202015-03-11 15:04:43 -0700208 import time
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800209 import json
cameron@onlab.us059c2562015-04-02 14:12:51 -0700210 import string
andrew@onlab.us10332202015-03-11 15:04:43 -0700211 import csv
jenkins3af0cd82015-03-24 10:27:16 -0700212 import numpy
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700213 import os.path
214
215 global currentNeighbors
216 neighbors = []
217
218 try:
219 currentNeighbors
220 except:
221 currentNeighbors = "0"
222 neighbors = ['0']
223 else:
224 if currentNeighbors == "r": #reset
225 currentNeighbors = "a"
226 neighbors = ['0']
227 else:
228 currentNeighbors = "r"
229 neighbors = ['a']
230
231 if clusterCount == 1:
232 currentNeighbors = "r"
andrew@onlab.us10332202015-03-11 15:04:43 -0700233
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800234 main.log.info("Cluster Count = " + str(clusterCount))
235
andrew@onlab.us10332202015-03-11 15:04:43 -0700236 intentsRate = main.params['METRICS']['intents_rate']
237 intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ]
238 intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ]
239 testDuration = main.params[ 'TEST' ][ 'duration' ]
240 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
241 debug = main.params[ 'debugMode' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -0700242 numKeys = main.params[ 'TEST' ][ 'numKeys' ]
243 cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700244 #neighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
andrew@onlab.us10332202015-03-11 15:04:43 -0700245 metricList = [intentsRate, intentsWithdrawn, intentsFailed]
jenkins3af0cd82015-03-24 10:27:16 -0700246
cameron@onlab.us059c2562015-04-02 14:12:51 -0700247 for n in range(0, len(neighbors)):
248 if neighbors[n] == 'a':
249 neighbors[n] = str(clusterCount -1)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700250 if int(clusterCount) == 1:
251 neighbors = neighbors.pop()
252
cameron@onlab.us059c2562015-04-02 14:12:51 -0700253 for n in neighbors:
254 main.log.info("Run with " + n + " neighbors")
255 time.sleep(5)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700256 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numKeys " + numKeys )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700257 main.ONOSbench.handle.expect(":~")
258 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numNeighbors " + n )
259 main.ONOSbench.handle.expect(":~")
260 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller cyclePeriod " + cyclePeriod )
261 main.ONOSbench.handle.expect(":~")
jenkins3af0cd82015-03-24 10:27:16 -0700262
cameron@onlab.us059c2562015-04-02 14:12:51 -0700263 cmd = "onos $OC1 intent-perf-start"
264 main.ONOSbench.handle.sendline(cmd)
265 main.ONOSbench.handle.expect(":~")
266 main.log.info("Starting ONOS (all nodes) intent-perf from $OC1" )
jenkins3af0cd82015-03-24 10:27:16 -0700267
cameron@onlab.us059c2562015-04-02 14:12:51 -0700268 main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" )
269 stop = time.time() + float( testDuration )
jenkins3af0cd82015-03-24 10:27:16 -0700270
cameron@onlab.us059c2562015-04-02 14:12:51 -0700271 while time.time() < stop:
272 time.sleep( float( logInterval ) )
273 groupResult = []
274 for node in range (1, clusterCount + 1):
275 groupResult.append(0)
jenkins3af0cd82015-03-24 10:27:16 -0700276
cameron@onlab.us059c2562015-04-02 14:12:51 -0700277 cmd = " onos-ssh $OC" + str(node) + """ cat /opt/onos/log/karaf.log | grep "SNAPSHOT | Throughput" | tail -1 """
278 main.log.info("COMMAND: " + str(cmd))
279
280 x = 0
281 while True:
282 main.ONOSbench.handle.sendline(cmd)
jenkins50379942015-06-19 13:36:43 -0700283 time.sleep(6)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700284 main.ONOSbench.handle.expect(":~")
285 raw = main.ONOSbench.handle.before
286 if "OVERALL=" in raw:
287 break
288 x += 1
289 if x > 10:
290 main.log.error("Expected output not being recieved... continuing")
291 break
292 time.sleep(2)
293
294 raw = raw.splitlines()
295 splitResults = []
296 for line in raw:
297 splitResults.extend(line.split(" "))
298
299 myResult = "--"
300 for field in splitResults:
301 if "OVERALL" in field:
302 myResult = field
303
304 if myResult == "--":
305 main.log.error("Parsing/Pexpect error\n" + str(splitResults))
306
307 myResult = myResult.replace(";", "")
308 myResult = myResult.replace("OVERALL=","")
309 myResult = float(myResult)
310 groupResult[len(groupResult) -1] = myResult
311
312 main.log.info("Node " + str(node) + " overall rate: " + str(myResult))
313
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700314 clusterTotal = str(numpy.sum(groupResult))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700315 main.log.report("Results from this round of polling: " + str(groupResult))
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700316 main.log.report("Cluster Total: " + clusterTotal + "\n")
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700317
cameron@onlab.us059c2562015-04-02 14:12:51 -0700318 cmd = "onos $OC1 intent-perf-stop"
319 main.ONOSbench.handle.sendline(cmd)
320 main.ONOSbench.handle.expect(":~")
321 main.log.info("Stopping intentperf" )
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700322
suibine1e58772015-07-15 09:52:59 -0700323 resultsDB = open("/tmp/IntentEventTPDB", "a")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700324 for node in groupResult:
325
326 resultString = "'" + commit + "',"
327 resultString += "'1gig',"
328 resultString += str(clusterCount) + ","
329 resultString += "'baremetal" + str(int(groupResult.index(node)) + 1) + "',"
330 resultString += n + ","
331 resultString += str(node) + ","
332 resultString += str(0) + "\n" #no stddev
333 resultsDB.write(resultString)
334
335 resultsDB.close()
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700336
jenkins50379942015-06-19 13:36:43 -0700337 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700338