blob: 6fe4f73e481bd382685ec931628142935b93cd96 [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' ]
andrew@onlab.us10332202015-03-11 15:04:43 -070037 maxNodes = int(main.params[ 'availableNodes' ])
andrew@onlab.us10332202015-03-11 15:04:43 -070038 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
cameron@onlab.usaaecfd72015-07-08 12:27:26 -070039 cellName = main.params[ 'ENV' ][ 'cellName' ]
jenkins3af0cd82015-03-24 10:27:16 -070040 numSwitches = (main.params[ 'TEST' ][ 'numSwitches' ]).split(",")
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -070041 flowRuleBU = main.params[ 'TEST' ][ 'flowRuleBUEnabled' ]
cameron@onlab.usc10e22c2015-05-13 13:07:28 -070042 onBaremetal = main.params['isOnBaremetal']
43 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.usaaecfd72015-07-08 12:27:26 -070058 ONOSIp = []
cameron@onlab.us059c2562015-04-02 14:12:51 -070059 scale = (main.params[ 'SCALE' ]).split(",")
60 clusterCount = int(scale[0])
61
62 #Populate ONOSIp with ips from params
jenkins15b2b132015-06-23 14:04:09 -070063 ONOSIp.extend(main.ONOSbench.getOnosIps())
jenkins15b2b132015-06-23 14:04:09 -070064
cameron@onlab.us059c2562015-04-02 14:12:51 -070065 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
66 if skipMvn != "yes":
67 mvnResult = main.ONOSbench.cleanInstall()
68
69 #git
70 main.step( "Git checkout and pull " + checkoutBranch )
71 if gitPull == 'on':
72 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
73 pullResult = main.ONOSbench.gitPull()
74
75 else:
76 checkoutResult = main.TRUE
77 pullResult = main.TRUE
78 main.log.info( "Skipped git checkout and pull" )
andrew@onlab.us10332202015-03-11 15:04:43 -070079
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070080 commit = main.ONOSbench.getVersion()
81 commit = (commit.split(" "))[1]
82
83 resultsDB = open("IntentEventTPDB", "w+")
84 resultsDB.close()
85
cameron@onlab.us059c2562015-04-02 14:12:51 -070086 # -- END OF INIT SECTION --#
87
88 clusterCount = int(scale[0])
89 scale.remove(scale[0])
jenkins5a771992015-06-24 13:53:27 -070090
91 MN1Ip = ONOSIp[len(ONOSIp) -1]
92 BENCHIp = ONOSIp[len(ONOSIp) -2]
93
cameron@onlab.us059c2562015-04-02 14:12:51 -070094 #kill off all onos processes
andrew@onlab.us10332202015-03-11 15:04:43 -070095 main.log.step("Safety check, killing all ONOS processes")
96 main.log.step("before initiating enviornment setup")
cameron@onlab.usaaecfd72015-07-08 12:27:26 -070097 for node in range(maxNodes):
andrew@onlab.us10332202015-03-11 15:04:43 -070098 main.ONOSbench.onosDie(ONOSIp[node])
jenkins8f8f4f32015-06-24 14:05:04 -070099
100 MN1Ip = ONOSIp[len(ONOSIp) -1]
101 BENCHIp = ONOSIp[len(ONOSIp) -2]
102
andrew@onlab.us10332202015-03-11 15:04:43 -0700103 #Uninstall everywhere
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800104 main.log.step( "Cleaning Enviornment..." )
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700105 for i in range(maxNodes):
andrew@onlab.us10332202015-03-11 15:04:43 -0700106 main.log.info(" Uninstalling ONOS " + str(i) )
107 main.ONOSbench.onosUninstall( ONOSIp[i] )
suibine1a104d2015-07-08 15:58:29 -0700108 main.log.info("Sleep 10 second for uninstall to settle...")
109 time.sleep(10)
110 main.ONOSbench.handle.sendline(" ")
111 main.ONOSbench.handle.expect(":~")
112
cameron@onlab.us059c2562015-04-02 14:12:51 -0700113 #construct the cell file
114 main.log.info("Creating cell file")
115 cellIp = []
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700116 for node in range (clusterCount):
cameron@onlab.us059c2562015-04-02 14:12:51 -0700117 cellIp.append(ONOSIp[node])
jenkins5a771992015-06-24 13:53:27 -0700118
cameron@onlab.us059c2562015-04-02 14:12:51 -0700119 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
120
121 main.step( "Set Cell" )
122 main.ONOSbench.setCell(cellName)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800123
jenkins3af0cd82015-03-24 10:27:16 -0700124 myDistribution = []
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700125 for node in range (clusterCount):
126 myDistribution.append(numSwitches[node])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800127
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700128 #main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700129
130 if onBaremetal == "True":
131 filename = "/onos/tools/package/bin/onos-service"
132 serviceConfig = open(homeDir + filename, 'w+')
133 serviceConfig.write("#!/bin/bash\n ")
134 serviceConfig.write("#------------------------------------- \n ")
135 serviceConfig.write("# Starts ONOS Apache Karaf container\n ")
136 serviceConfig.write("#------------------------------------- \n ")
137 serviceConfig.write("#export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-openjdk-amd64/}\n ")
138 serviceConfig.write("""export JAVA_OPTS="${JAVA_OPTS:--Xms8G -Xmx8G}" \n """)
139 serviceConfig.write("")
140 serviceConfig.write("ONOS_HOME=/opt/onos \n ")
141 serviceConfig.write("")
142 serviceConfig.write("[ -d $ONOS_HOME ] && cd $ONOS_HOME || ONOS_HOME=$(dirname $0)/..\n")
143 serviceConfig.write("""${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf "$@" \n """)
144 serviceConfig.close()
145 main.log.info("Set /onos/tools/package/bin/onos-service with 8G Xms/Xmx Options.")
146
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800147 main.step( "Creating ONOS package" )
148 packageResult = main.ONOSbench.onosPackage()
149
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800150 main.step( "verify cells" )
151 verifyCellResult = main.ONOSbench.verifyCell()
cameron@onlab.us059c2562015-04-02 14:12:51 -0700152
153 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700154 for node in range(clusterCount):
cameron@onlab.us059c2562015-04-02 14:12:51 -0700155 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
andrew@onlab.us10332202015-03-11 15:04:43 -0700156 main.ONOSbench.onosInstall( ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700157
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700158 for node in range(clusterCount):
andrew@onlab.us10332202015-03-11 15:04:43 -0700159 for i in range( 2 ):
160 isup = main.ONOSbench.isup( ONOSIp[node] )
161 if isup:
162 main.log.info("ONOS " + str(node) + " is up\n")
163 break
164 if not isup:
165 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700166 main.log.info("Startup sequence complete")
167
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700168 time.sleep(20)
169
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700170 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.store.flow.impl.NewDistributedFlowRuleStore", "backupEnabled false")
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700171
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700172 main.log.step("Setting up null provider")
173 for i in range(3):
174 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.provider.nil.NullProviders", "deviceCount 8")
175 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.provider.nil.NullProviders", "topoShape linear")
176 main.ONOSbench.onosCfgSet( ONOSIp[0], "org.onosproject.provider.nil.NullProviders", "enabled true")
177 time.sleep(5)
178
179 main.ONOSbench.handle.sendline("onos $OC1 summary")
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700180 main.ONOSbench.handle.expect(":~")
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700181
182 before = main.ONOSbench.handle.before
183 if "devices=8" in before and "links=14" in before:
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700184 break
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700185
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700186 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
187 main.ONOSbench.handle.expect(":~")
188 print main.ONOSbench.handle.before
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700189
andrew@onlab.us10332202015-03-11 15:04:43 -0700190 lastOutput = "--"
191 origin = time.time()
192 clockStarted = False
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700193 while True:
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700194
195 main.ONOSbench.handle.sendline("")
196 main.ONOSbench.handle.expect(":~")
197
andrew@onlab.us10332202015-03-11 15:04:43 -0700198 main.ONOSbench.handle.sendline("onos $OC1 summary")
199 main.ONOSbench.handle.expect(":~")
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700200
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700201 main.log.info("before" + main.ONOSbench.handle.before)
Jon Hallf57a5ef2015-07-07 17:56:16 -0700202 clusterCheck = main.ONOSbench.handle.before
andrew@onlab.us10332202015-03-11 15:04:43 -0700203 print("\nBefore: " + str(clusterCheck))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700204 if ("SCC(s)=1,") in clusterCheck:
andrew@onlab.us10332202015-03-11 15:04:43 -0700205 break
206 if clusterCheck != lastOutput:
207 sameOutput = False
208 elif clusterCheck == lastOutput:
209 if clockStarted == False:
210 start = time.time()
211 clockStarted = True
cameron@onlab.usaaecfd72015-07-08 12:27:26 -0700212 if time.time() > (start + 30):
andrew@onlab.us10332202015-03-11 15:04:43 -0700213 main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...")
214 break
215 lastOutput = clusterCheck
216 time.sleep(5)
jenkins50379942015-06-19 13:36:43 -0700217 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700218 def CASE2( self, main ):
andrew@onlab.us10332202015-03-11 15:04:43 -0700219 import time
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800220 import json
cameron@onlab.us059c2562015-04-02 14:12:51 -0700221 import string
andrew@onlab.us10332202015-03-11 15:04:43 -0700222 import csv
jenkins3af0cd82015-03-24 10:27:16 -0700223 import numpy
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700224 import os.path
225
226 global currentNeighbors
227 neighbors = []
228
229 try:
230 currentNeighbors
231 except:
232 currentNeighbors = "0"
233 neighbors = ['0']
234 else:
235 if currentNeighbors == "r": #reset
236 currentNeighbors = "a"
237 neighbors = ['0']
238 else:
239 currentNeighbors = "r"
240 neighbors = ['a']
241
242 if clusterCount == 1:
243 currentNeighbors = "r"
andrew@onlab.us10332202015-03-11 15:04:43 -0700244
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800245 main.log.info("Cluster Count = " + str(clusterCount))
246
andrew@onlab.us10332202015-03-11 15:04:43 -0700247 intentsRate = main.params['METRICS']['intents_rate']
248 intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ]
249 intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ]
250 testDuration = main.params[ 'TEST' ][ 'duration' ]
251 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
252 debug = main.params[ 'debugMode' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -0700253 numKeys = main.params[ 'TEST' ][ 'numKeys' ]
254 cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700255 #neighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
andrew@onlab.us10332202015-03-11 15:04:43 -0700256 metricList = [intentsRate, intentsWithdrawn, intentsFailed]
jenkins3af0cd82015-03-24 10:27:16 -0700257
cameron@onlab.us059c2562015-04-02 14:12:51 -0700258 for n in range(0, len(neighbors)):
259 if neighbors[n] == 'a':
260 neighbors[n] = str(clusterCount -1)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700261 if int(clusterCount) == 1:
262 neighbors = neighbors.pop()
263
cameron@onlab.us059c2562015-04-02 14:12:51 -0700264 for n in neighbors:
265 main.log.info("Run with " + n + " neighbors")
266 time.sleep(5)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700267 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numKeys " + numKeys )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700268 main.ONOSbench.handle.expect(":~")
269 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numNeighbors " + n )
270 main.ONOSbench.handle.expect(":~")
271 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller cyclePeriod " + cyclePeriod )
272 main.ONOSbench.handle.expect(":~")
jenkins3af0cd82015-03-24 10:27:16 -0700273
cameron@onlab.us059c2562015-04-02 14:12:51 -0700274 cmd = "onos $OC1 intent-perf-start"
275 main.ONOSbench.handle.sendline(cmd)
276 main.ONOSbench.handle.expect(":~")
277 main.log.info("Starting ONOS (all nodes) intent-perf from $OC1" )
jenkins3af0cd82015-03-24 10:27:16 -0700278
cameron@onlab.us059c2562015-04-02 14:12:51 -0700279 main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" )
280 stop = time.time() + float( testDuration )
jenkins3af0cd82015-03-24 10:27:16 -0700281
cameron@onlab.us059c2562015-04-02 14:12:51 -0700282 while time.time() < stop:
283 time.sleep( float( logInterval ) )
284 groupResult = []
285 for node in range (1, clusterCount + 1):
286 groupResult.append(0)
jenkins3af0cd82015-03-24 10:27:16 -0700287
cameron@onlab.us059c2562015-04-02 14:12:51 -0700288 cmd = " onos-ssh $OC" + str(node) + """ cat /opt/onos/log/karaf.log | grep "SNAPSHOT | Throughput" | tail -1 """
289 main.log.info("COMMAND: " + str(cmd))
290
291 x = 0
292 while True:
293 main.ONOSbench.handle.sendline(cmd)
jenkins50379942015-06-19 13:36:43 -0700294 time.sleep(6)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700295 main.ONOSbench.handle.expect(":~")
296 raw = main.ONOSbench.handle.before
297 if "OVERALL=" in raw:
298 break
299 x += 1
300 if x > 10:
301 main.log.error("Expected output not being recieved... continuing")
302 break
303 time.sleep(2)
304
305 raw = raw.splitlines()
306 splitResults = []
307 for line in raw:
308 splitResults.extend(line.split(" "))
309
310 myResult = "--"
311 for field in splitResults:
312 if "OVERALL" in field:
313 myResult = field
314
315 if myResult == "--":
316 main.log.error("Parsing/Pexpect error\n" + str(splitResults))
317
318 myResult = myResult.replace(";", "")
319 myResult = myResult.replace("OVERALL=","")
320 myResult = float(myResult)
321 groupResult[len(groupResult) -1] = myResult
322
323 main.log.info("Node " + str(node) + " overall rate: " + str(myResult))
324
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700325 clusterTotal = str(numpy.sum(groupResult))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700326 main.log.report("Results from this round of polling: " + str(groupResult))
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700327 main.log.report("Cluster Total: " + clusterTotal + "\n")
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700328
cameron@onlab.us059c2562015-04-02 14:12:51 -0700329 cmd = "onos $OC1 intent-perf-stop"
330 main.ONOSbench.handle.sendline(cmd)
331 main.ONOSbench.handle.expect(":~")
332 main.log.info("Stopping intentperf" )
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700333
334 resultsDB = open("IntentEventTPDB", "a")
335 for node in groupResult:
336
337 resultString = "'" + commit + "',"
338 resultString += "'1gig',"
339 resultString += str(clusterCount) + ","
340 resultString += "'baremetal" + str(int(groupResult.index(node)) + 1) + "',"
341 resultString += n + ","
342 resultString += str(node) + ","
343 resultString += str(0) + "\n" #no stddev
344 resultsDB.write(resultString)
345
346 resultsDB.close()
cameron@onlab.usc10e22c2015-05-13 13:07:28 -0700347
jenkins50379942015-06-19 13:36:43 -0700348 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700349