blob: 6aea7b0d719a0f466f620469b8985b1c85bb2409 [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(",")
andrew@onlab.us10332202015-03-11 15:04:43 -070038
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080039
cameron@onlab.us059c2562015-04-02 14:12:51 -070040 # -- INIT SECTION, ONLY RUNS ONCE -- #
41 if init == False:
42 init = True
43 global clusterCount #number of nodes running
44 global ONOSIp #list of ONOS IP addresses
45 global scale
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070046 global commit
cameron@onlab.us059c2562015-04-02 14:12:51 -070047
48 clusterCount = 0
49 ONOSIp = [ 0 ]
50 scale = (main.params[ 'SCALE' ]).split(",")
51 clusterCount = int(scale[0])
52
53 #Populate ONOSIp with ips from params
54 for i in range(1, maxNodes + 1):
55 ipString = 'ip' + str(i)
56 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
57
58 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
59 if skipMvn != "yes":
60 mvnResult = main.ONOSbench.cleanInstall()
61
62 #git
63 main.step( "Git checkout and pull " + checkoutBranch )
64 if gitPull == 'on':
65 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
66 pullResult = main.ONOSbench.gitPull()
67
68 else:
69 checkoutResult = main.TRUE
70 pullResult = main.TRUE
71 main.log.info( "Skipped git checkout and pull" )
andrew@onlab.us10332202015-03-11 15:04:43 -070072
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070073 commit = main.ONOSbench.getVersion()
74 commit = (commit.split(" "))[1]
75
76 resultsDB = open("IntentEventTPDB", "w+")
77 resultsDB.close()
78
cameron@onlab.us059c2562015-04-02 14:12:51 -070079 # -- END OF INIT SECTION --#
80
81 clusterCount = int(scale[0])
82 scale.remove(scale[0])
83
84 #kill off all onos processes
andrew@onlab.us10332202015-03-11 15:04:43 -070085 main.log.step("Safety check, killing all ONOS processes")
86 main.log.step("before initiating enviornment setup")
87 for node in range(1, maxNodes + 1):
andrew@onlab.us10332202015-03-11 15:04:43 -070088 main.ONOSbench.onosDie(ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -070089
andrew@onlab.us10332202015-03-11 15:04:43 -070090 #Uninstall everywhere
andrew@onlab.us2ae3a112015-02-02 11:24:32 -080091 main.log.step( "Cleaning Enviornment..." )
andrew@onlab.us10332202015-03-11 15:04:43 -070092 for i in range(1, maxNodes + 1):
93 main.log.info(" Uninstalling ONOS " + str(i) )
94 main.ONOSbench.onosUninstall( ONOSIp[i] )
cameron@onlab.us059c2562015-04-02 14:12:51 -070095
96 #construct the cell file
97 main.log.info("Creating cell file")
98 cellIp = []
99 for node in range (1, clusterCount + 1):
100 cellIp.append(ONOSIp[node])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800101
cameron@onlab.us059c2562015-04-02 14:12:51 -0700102 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
103
104 main.step( "Set Cell" )
105 main.ONOSbench.setCell(cellName)
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800106
jenkins3af0cd82015-03-24 10:27:16 -0700107 myDistribution = []
108 for node in range (1, clusterCount + 1):
109 myDistribution.append(numSwitches[node-1])
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800110
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700111 #main.ONOSbench.createLinkGraphFile( BENCHIp,cellIp,myDistribution)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700112
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800113 main.step( "Creating ONOS package" )
114 packageResult = main.ONOSbench.onosPackage()
115
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800116 main.step( "verify cells" )
117 verifyCellResult = main.ONOSbench.verifyCell()
cameron@onlab.us059c2562015-04-02 14:12:51 -0700118
119 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
andrew@onlab.us10332202015-03-11 15:04:43 -0700120 for node in range(1, clusterCount + 1):
cameron@onlab.us059c2562015-04-02 14:12:51 -0700121 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
andrew@onlab.us10332202015-03-11 15:04:43 -0700122 main.ONOSbench.onosInstall( ONOSIp[node])
cameron@onlab.us059c2562015-04-02 14:12:51 -0700123
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700124 for node in range(1, clusterCount + 1):
andrew@onlab.us10332202015-03-11 15:04:43 -0700125 for i in range( 2 ):
126 isup = main.ONOSbench.isup( ONOSIp[node] )
127 if isup:
128 main.log.info("ONOS " + str(node) + " is up\n")
129 break
130 if not isup:
131 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us059c2562015-04-02 14:12:51 -0700132 main.log.info("Startup sequence complete")
133
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700134 time.sleep(20)
135
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700136
137 for i in range (0,5):
138 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount """ + str(clusterCount*10) + """ " """)
139 main.ONOSbench.handle.expect(":~")
140 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get org.onosproject.provider.nil.NullProviders" """)
141 main.ONOSbench.handle.expect(":~")
142 if ("value=" + str(clusterCount*10)) in main.ONOSbench.handle.before:
143 main.log.info("Device count set")
144 main.log.info("before" + main.ONOSbench.handle.before)
145 break
146 time.sleep(10)
147 main.log.info("cfg set failure, retrying")
148 main.log.info("before" + main.ONOSbench.handle.before)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700149
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700150 x = 1
151 while True:
152 if x >= 6:
153 main.log.error("Null provider start failure, TEST INVALID")
154 break
155 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
156 main.ONOSbench.handle.expect(":~")
157 main.ONOSbench.handle.sendline("""onos $OC1 "cfg get org.onosproject.provider.nil.NullProviders" """)
158 main.ONOSbench.handle.expect(":~")
159 if ("value=linear") in main.ONOSbench.handle.before:
160 main.log.info("Device count set")
161 main.log.info("before" + main.ONOSbench.handle.before)
162 break
163 time.sleep(10)
164 main.log.info("cfg set failure, retrying")
165 main.log.info("before" + main.ONOSbench.handle.before)
166 x += 1
167
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700168 time.sleep(10)
169 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
170 main.ONOSbench.handle.expect(":~")
171 print main.ONOSbench.handle.before
172 time.sleep(10)
173 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
174 main.ONOSbench.handle.expect(":~")
175 print main.ONOSbench.handle.before
176
andrew@onlab.us10332202015-03-11 15:04:43 -0700177 lastOutput = "--"
178 origin = time.time()
179 clockStarted = False
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700180 for i in range (0,8):
andrew@onlab.us10332202015-03-11 15:04:43 -0700181 main.ONOSbench.handle.sendline("onos $OC1 summary")
182 main.ONOSbench.handle.expect(":~")
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700183 main.log.info("before" + main.ONOSbench.handle.before)
andrew@onlab.us10332202015-03-11 15:04:43 -0700184 clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3]
185 print("\nBefore: " + str(clusterCheck))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700186 if ("SCC(s)=1,") in clusterCheck:
andrew@onlab.us10332202015-03-11 15:04:43 -0700187 break
188 if clusterCheck != lastOutput:
189 sameOutput = False
190 elif clusterCheck == lastOutput:
191 if clockStarted == False:
192 start = time.time()
193 clockStarted = True
cameron@onlab.us059c2562015-04-02 14:12:51 -0700194 if time.time() > (start + 10):
andrew@onlab.us10332202015-03-11 15:04:43 -0700195 main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...")
196 break
197 lastOutput = clusterCheck
198 time.sleep(5)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700199
cameron@onlab.us059c2562015-04-02 14:12:51 -0700200
201 def CASE2( self, main ):
andrew@onlab.us10332202015-03-11 15:04:43 -0700202 import time
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800203 import json
cameron@onlab.us059c2562015-04-02 14:12:51 -0700204 import string
andrew@onlab.us10332202015-03-11 15:04:43 -0700205 import csv
jenkins3af0cd82015-03-24 10:27:16 -0700206 import numpy
andrew@onlab.us10332202015-03-11 15:04:43 -0700207
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800208 main.log.info("Cluster Count = " + str(clusterCount))
209
andrew@onlab.us10332202015-03-11 15:04:43 -0700210 intentsRate = main.params['METRICS']['intents_rate']
211 intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ]
212 intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ]
213 testDuration = main.params[ 'TEST' ][ 'duration' ]
214 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
215 debug = main.params[ 'debugMode' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -0700216 numKeys = main.params[ 'TEST' ][ 'numKeys' ]
217 cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
218 neighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
andrew@onlab.us10332202015-03-11 15:04:43 -0700219 metricList = [intentsRate, intentsWithdrawn, intentsFailed]
jenkins3af0cd82015-03-24 10:27:16 -0700220
cameron@onlab.us059c2562015-04-02 14:12:51 -0700221 for n in range(0, len(neighbors)):
222 if neighbors[n] == 'a':
223 neighbors[n] = str(clusterCount -1)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700224 if int(clusterCount) == 1:
225 neighbors = neighbors.pop()
226
cameron@onlab.us059c2562015-04-02 14:12:51 -0700227 for n in neighbors:
228 main.log.info("Run with " + n + " neighbors")
229 time.sleep(5)
cameron@onlab.usf33b45c2015-05-06 13:54:46 -0700230 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numKeys " + numKeysn)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700231 main.ONOSbench.handle.expect(":~")
232 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numNeighbors " + n )
233 main.ONOSbench.handle.expect(":~")
234 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller cyclePeriod " + cyclePeriod )
235 main.ONOSbench.handle.expect(":~")
jenkins3af0cd82015-03-24 10:27:16 -0700236
cameron@onlab.us059c2562015-04-02 14:12:51 -0700237 cmd = "onos $OC1 intent-perf-start"
238 main.ONOSbench.handle.sendline(cmd)
239 main.ONOSbench.handle.expect(":~")
240 main.log.info("Starting ONOS (all nodes) intent-perf from $OC1" )
jenkins3af0cd82015-03-24 10:27:16 -0700241
cameron@onlab.us059c2562015-04-02 14:12:51 -0700242 main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" )
243 stop = time.time() + float( testDuration )
jenkins3af0cd82015-03-24 10:27:16 -0700244
cameron@onlab.us059c2562015-04-02 14:12:51 -0700245 while time.time() < stop:
246 time.sleep( float( logInterval ) )
247 groupResult = []
248 for node in range (1, clusterCount + 1):
249 groupResult.append(0)
jenkins3af0cd82015-03-24 10:27:16 -0700250
cameron@onlab.us059c2562015-04-02 14:12:51 -0700251 cmd = " onos-ssh $OC" + str(node) + """ cat /opt/onos/log/karaf.log | grep "SNAPSHOT | Throughput" | tail -1 """
252 main.log.info("COMMAND: " + str(cmd))
253
254 x = 0
255 while True:
256 main.ONOSbench.handle.sendline(cmd)
257 main.ONOSbench.handle.expect(":~")
258 raw = main.ONOSbench.handle.before
259 if "OVERALL=" in raw:
260 break
261 x += 1
262 if x > 10:
263 main.log.error("Expected output not being recieved... continuing")
264 break
265 time.sleep(2)
266
267 raw = raw.splitlines()
268 splitResults = []
269 for line in raw:
270 splitResults.extend(line.split(" "))
271
272 myResult = "--"
273 for field in splitResults:
274 if "OVERALL" in field:
275 myResult = field
276
277 if myResult == "--":
278 main.log.error("Parsing/Pexpect error\n" + str(splitResults))
279
280 myResult = myResult.replace(";", "")
281 myResult = myResult.replace("OVERALL=","")
282 myResult = float(myResult)
283 groupResult[len(groupResult) -1] = myResult
284
285 main.log.info("Node " + str(node) + " overall rate: " + str(myResult))
286
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700287 clusterTotal = str(numpy.sum(groupResult))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700288 main.log.report("Results from this round of polling: " + str(groupResult))
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700289 main.log.report("Cluster Total: " + clusterTotal + "\n")
cameron@onlab.us059c2562015-04-02 14:12:51 -0700290
291 cmd = "onos $OC1 intent-perf-stop"
292 main.ONOSbench.handle.sendline(cmd)
293 main.ONOSbench.handle.expect(":~")
294 main.log.info("Stopping intentperf" )
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700295
296 resultsDB = open("IntentEventTPDB", "a")
297 for node in groupResult:
298
299 resultString = "'" + commit + "',"
300 resultString += "'1gig',"
301 resultString += str(clusterCount) + ","
302 resultString += "'baremetal" + str(int(groupResult.index(node)) + 1) + "',"
303 resultString += n + ","
304 resultString += str(node) + ","
305 resultString += str(0) + "\n" #no stddev
306 resultsDB.write(resultString)
307
308 resultsDB.close()
309
310
311