blob: ba63f4ce400a22da0817736048395e1681cb5e19 [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
andrew@onlab.us10332202015-03-11 15:04:43 -07009
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080010
11class IntentEventTP:
12
13 def __init__( self ):
14 self.default = ''
15
cameron@onlab.us059c2562015-04-02 14:12:51 -070016 def CASE1( self, main ):
17
18 import time
19 global init
20 try:
21 if type(init) is not bool:
22 init = False
23 except NameError:
24 init = False
25
andrew@onlab.us10332202015-03-11 15:04:43 -070026 #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' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -070030 Apps = main.params[ 'ENV' ][ 'cellApps' ]
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080031 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
32 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -070033 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
andrew@onlab.us10332202015-03-11 15:04:43 -070034 maxNodes = int(main.params[ 'availableNodes' ])
andrew@onlab.us10332202015-03-11 15:04:43 -070035 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -070036 cellName = main.params[ 'ENV' ][ 'cellName' ]
jenkins3af0cd82015-03-24 10:27:16 -070037 numSwitches = (main.params[ 'TEST' ][ 'numSwitches' ]).split(",")
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -070038 flowRuleBU = main.params[ 'TEST' ][ 'flowRuleBUEnabled' ]
andrew@onlab.us10332202015-03-11 15:04:43 -070039
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080040
cameron@onlab.us059c2562015-04-02 14:12:51 -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
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070047 global commit
cameron@onlab.us059c2562015-04-02 14:12:51 -070048
49 clusterCount = 0
50 ONOSIp = [ 0 ]
51 scale = (main.params[ 'SCALE' ]).split(",")
52 clusterCount = int(scale[0])
53
54 #Populate ONOSIp with ips from params
55 for i in range(1, maxNodes + 1):
56 ipString = 'ip' + str(i)
57 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
58
59 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
60 if skipMvn != "yes":
61 mvnResult = main.ONOSbench.cleanInstall()
62
63 #git
64 main.step( "Git checkout and pull " + checkoutBranch )
65 if gitPull == 'on':
66 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
67 pullResult = main.ONOSbench.gitPull()
68
69 else:
70 checkoutResult = main.TRUE
71 pullResult = main.TRUE
72 main.log.info( "Skipped git checkout and pull" )
andrew@onlab.us10332202015-03-11 15:04:43 -070073
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070074 commit = main.ONOSbench.getVersion()
75 commit = (commit.split(" "))[1]
76
77 resultsDB = open("IntentEventTPDB", "w+")
78 resultsDB.close()
79
cameron@onlab.us059c2562015-04-02 14:12:51 -070080 # -- END OF INIT SECTION --#
81
82 clusterCount = int(scale[0])
83 scale.remove(scale[0])
84
85 #kill off all onos processes
andrew@onlab.us10332202015-03-11 15:04:43 -070086 main.log.step("Safety check, killing all ONOS processes")
87 main.log.step("before initiating enviornment setup")
88 for node in range(1, maxNodes + 1):
andrew@onlab.us10332202015-03-11 15:04:43 -070089 main.ONOSbench.onosDie(ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -070090
andrew@onlab.us10332202015-03-11 15:04:43 -070091 #Uninstall everywhere
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080092 main.log.step( "Cleaning Enviornment..." )
andrew@onlab.us10332202015-03-11 15:04:43 -070093 for i in range(1, maxNodes + 1):
94 main.log.info(" Uninstalling ONOS " + str(i) )
95 main.ONOSbench.onosUninstall( ONOSIp[i] )
cameron@onlab.us059c2562015-04-02 14:12:51 -070096
97 #construct the cell file
98 main.log.info("Creating cell file")
99 cellIp = []
100 for node in range (1, clusterCount + 1):
101 cellIp.append(ONOSIp[node])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800102
cameron@onlab.us059c2562015-04-02 14:12:51 -0700103 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
104
105 main.step( "Set Cell" )
106 main.ONOSbench.setCell(cellName)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800107
jenkins3af0cd82015-03-24 10:27:16 -0700108 myDistribution = []
109 for node in range (1, clusterCount + 1):
110 myDistribution.append(numSwitches[node-1])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800111
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700112 #main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700113
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800114 main.step( "Creating ONOS package" )
115 packageResult = main.ONOSbench.onosPackage()
116
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800117 main.step( "verify cells" )
118 verifyCellResult = main.ONOSbench.verifyCell()
cameron@onlab.us059c2562015-04-02 14:12:51 -0700119
120 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
andrew@onlab.us10332202015-03-11 15:04:43 -0700121 for node in range(1, clusterCount + 1):
cameron@onlab.us059c2562015-04-02 14:12:51 -0700122 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
andrew@onlab.us10332202015-03-11 15:04:43 -0700123 main.ONOSbench.onosInstall( ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700124
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700125 for node in range(1, clusterCount + 1):
andrew@onlab.us10332202015-03-11 15:04:43 -0700126 for i in range( 2 ):
127 isup = main.ONOSbench.isup( ONOSIp[node] )
128 if isup:
129 main.log.info("ONOS " + str(node) + " is up\n")
130 break
131 if not isup:
132 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700133 main.log.info("Startup sequence complete")
134
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700135 time.sleep(20)
136
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700137
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700138 while True:
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700139 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount """ + str(clusterCount*10) + """ " """)
140 main.ONOSbench.handle.expect(":~")
141 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get org.onosproject.provider.nil.NullProviders" """)
142 main.ONOSbench.handle.expect(":~")
143 if ("value=" + str(clusterCount*10)) in main.ONOSbench.handle.before:
144 main.log.info("Device count set")
145 main.log.info("before" + main.ONOSbench.handle.before)
146 break
147 time.sleep(10)
148 main.log.info("cfg set failure, retrying")
149 main.log.info("before" + main.ONOSbench.handle.before)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700150
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700151 while True:
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700152 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
153 main.ONOSbench.handle.expect(":~")
154 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get org.onosproject.provider.nil.NullProviders" """)
155 main.ONOSbench.handle.expect(":~")
156 if ("value=linear") in main.ONOSbench.handle.before:
157 main.log.info("Device count set")
158 main.log.info("before" + main.ONOSbench.handle.before)
159 break
160 time.sleep(10)
161 main.log.info("cfg set failure, retrying")
162 main.log.info("before" + main.ONOSbench.handle.before)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700163
164 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.store.flow.impl.NewDistributedFlowRuleStore backupEnabled """ + flowRuleBU + """" """)
165 main.ONOSbench.handle.expect(":~")
166 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get" """)
167 main.ONOSbench.handle.expect(":~")
168 main.log.info(main.ONOSbench.handle.before)
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700169
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700170 time.sleep(10)
171 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
172 main.ONOSbench.handle.expect(":~")
173 print main.ONOSbench.handle.before
174 time.sleep(10)
175 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
176 main.ONOSbench.handle.expect(":~")
177 print main.ONOSbench.handle.before
178
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:
andrew@onlab.us10332202015-03-11 15:04:43 -0700183 main.ONOSbench.handle.sendline("onos $OC1 summary")
184 main.ONOSbench.handle.expect(":~")
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700185 main.log.info("before" + main.ONOSbench.handle.before)
andrew@onlab.us10332202015-03-11 15:04:43 -0700186 clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3]
187 print("\nBefore: " + str(clusterCheck))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700188 if ("SCC(s)=1,") in clusterCheck:
andrew@onlab.us10332202015-03-11 15:04:43 -0700189 break
190 if clusterCheck != lastOutput:
191 sameOutput = False
192 elif clusterCheck == lastOutput:
193 if clockStarted == False:
194 start = time.time()
195 clockStarted = True
cameron@onlab.us059c2562015-04-02 14:12:51 -0700196 if time.time() > (start + 10):
andrew@onlab.us10332202015-03-11 15:04:43 -0700197 main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...")
198 break
199 lastOutput = clusterCheck
200 time.sleep(5)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700201
cameron@onlab.us059c2562015-04-02 14:12:51 -0700202
203 def CASE2( self, main ):
andrew@onlab.us10332202015-03-11 15:04:43 -0700204 import time
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800205 import json
cameron@onlab.us059c2562015-04-02 14:12:51 -0700206 import string
andrew@onlab.us10332202015-03-11 15:04:43 -0700207 import csv
jenkins3af0cd82015-03-24 10:27:16 -0700208 import numpy
andrew@onlab.us10332202015-03-11 15:04:43 -0700209
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800210 main.log.info("Cluster Count = " + str(clusterCount))
211
andrew@onlab.us10332202015-03-11 15:04:43 -0700212 intentsRate = main.params['METRICS']['intents_rate']
213 intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ]
214 intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ]
215 testDuration = main.params[ 'TEST' ][ 'duration' ]
216 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
217 debug = main.params[ 'debugMode' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -0700218 numKeys = main.params[ 'TEST' ][ 'numKeys' ]
219 cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
220 neighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
andrew@onlab.us10332202015-03-11 15:04:43 -0700221 metricList = [intentsRate, intentsWithdrawn, intentsFailed]
jenkins3af0cd82015-03-24 10:27:16 -0700222
cameron@onlab.us059c2562015-04-02 14:12:51 -0700223 for n in range(0, len(neighbors)):
224 if neighbors[n] == 'a':
225 neighbors[n] = str(clusterCount -1)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700226 if int(clusterCount) == 1:
227 neighbors = neighbors.pop()
228
cameron@onlab.us059c2562015-04-02 14:12:51 -0700229 for n in neighbors:
230 main.log.info("Run with " + n + " neighbors")
231 time.sleep(5)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700232 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numKeys " + numKeys )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700233 main.ONOSbench.handle.expect(":~")
234 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numNeighbors " + n )
235 main.ONOSbench.handle.expect(":~")
236 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller cyclePeriod " + cyclePeriod )
237 main.ONOSbench.handle.expect(":~")
jenkins3af0cd82015-03-24 10:27:16 -0700238
cameron@onlab.us059c2562015-04-02 14:12:51 -0700239 cmd = "onos $OC1 intent-perf-start"
240 main.ONOSbench.handle.sendline(cmd)
241 main.ONOSbench.handle.expect(":~")
242 main.log.info("Starting ONOS (all nodes) intent-perf from $OC1" )
jenkins3af0cd82015-03-24 10:27:16 -0700243
cameron@onlab.us059c2562015-04-02 14:12:51 -0700244 main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" )
245 stop = time.time() + float( testDuration )
jenkins3af0cd82015-03-24 10:27:16 -0700246
cameron@onlab.us059c2562015-04-02 14:12:51 -0700247 while time.time() < stop:
248 time.sleep( float( logInterval ) )
249 groupResult = []
250 for node in range (1, clusterCount + 1):
251 groupResult.append(0)
jenkins3af0cd82015-03-24 10:27:16 -0700252
cameron@onlab.us059c2562015-04-02 14:12:51 -0700253 cmd = " onos-ssh $OC" + str(node) + """ cat /opt/onos/log/karaf.log | grep "SNAPSHOT | Throughput" | tail -1 """
254 main.log.info("COMMAND: " + str(cmd))
255
256 x = 0
257 while True:
258 main.ONOSbench.handle.sendline(cmd)
259 main.ONOSbench.handle.expect(":~")
260 raw = main.ONOSbench.handle.before
261 if "OVERALL=" in raw:
262 break
263 x += 1
264 if x > 10:
265 main.log.error("Expected output not being recieved... continuing")
266 break
267 time.sleep(2)
268
269 raw = raw.splitlines()
270 splitResults = []
271 for line in raw:
272 splitResults.extend(line.split(" "))
273
274 myResult = "--"
275 for field in splitResults:
276 if "OVERALL" in field:
277 myResult = field
278
279 if myResult == "--":
280 main.log.error("Parsing/Pexpect error\n" + str(splitResults))
281
282 myResult = myResult.replace(";", "")
283 myResult = myResult.replace("OVERALL=","")
284 myResult = float(myResult)
285 groupResult[len(groupResult) -1] = myResult
286
287 main.log.info("Node " + str(node) + " overall rate: " + str(myResult))
288
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700289 clusterTotal = str(numpy.sum(groupResult))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700290 main.log.report("Results from this round of polling: " + str(groupResult))
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700291 main.log.report("Cluster Total: " + clusterTotal + "\n")
cameron@onlab.us059c2562015-04-02 14:12:51 -0700292
293 cmd = "onos $OC1 intent-perf-stop"
294 main.ONOSbench.handle.sendline(cmd)
295 main.ONOSbench.handle.expect(":~")
296 main.log.info("Stopping intentperf" )
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700297
298 resultsDB = open("IntentEventTPDB", "a")
299 for node in groupResult:
300
301 resultString = "'" + commit + "',"
302 resultString += "'1gig',"
303 resultString += str(clusterCount) + ","
304 resultString += "'baremetal" + str(int(groupResult.index(node)) + 1) + "',"
305 resultString += n + ","
306 resultString += str(node) + ","
307 resultString += str(0) + "\n" #no stddev
308 resultsDB.write(resultString)
309
310 resultsDB.close()
311
312
313