blob: 0e8af7d01a57d3ab13e1a7294d4e4ba996dbf1b5 [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
136 #main.ONOSbench.handle.sendline("""onos $OC1 "cfg setorg.onosproject.provider.nil.NullProviders enabled true" """)
137 #main.ONOSbench.handle.expect(":~")
138 #print main.ONOSbench.handle.before
139
140 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount """ + str(clusterCount*10) + """ " """)
141 main.ONOSbench.handle.expect(":~")
142 print main.ONOSbench.handle.before
143 time.sleep(10)
144 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
145 main.ONOSbench.handle.expect(":~")
146 print main.ONOSbench.handle.before
147 time.sleep(10)
148 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
149 main.ONOSbench.handle.expect(":~")
150 print main.ONOSbench.handle.before
151 time.sleep(10)
152 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
153 main.ONOSbench.handle.expect(":~")
154 print main.ONOSbench.handle.before
155
andrew@onlab.us10332202015-03-11 15:04:43 -0700156 lastOutput = "--"
157 origin = time.time()
158 clockStarted = False
159 while True:
160 main.ONOSbench.handle.sendline("onos $OC1 summary")
161 main.ONOSbench.handle.expect(":~")
162 clusterCheck = ((main.ONOSbench.handle.before).splitlines())[3]
163 print("\nBefore: " + str(clusterCheck))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700164 if ("SCC(s)=1,") in clusterCheck:
andrew@onlab.us10332202015-03-11 15:04:43 -0700165 break
166 if clusterCheck != lastOutput:
167 sameOutput = False
168 elif clusterCheck == lastOutput:
169 if clockStarted == False:
170 start = time.time()
171 clockStarted = True
cameron@onlab.us059c2562015-04-02 14:12:51 -0700172 if time.time() > (start + 10):
andrew@onlab.us10332202015-03-11 15:04:43 -0700173 main.log.error("TIMEOUT EXCEEDED: Clusters have not converged, continuing anyway...")
174 break
175 lastOutput = clusterCheck
176 time.sleep(5)
cameron@onlab.us059c2562015-04-02 14:12:51 -0700177
cameron@onlab.us059c2562015-04-02 14:12:51 -0700178
179 def CASE2( self, main ):
andrew@onlab.us10332202015-03-11 15:04:43 -0700180 import time
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800181 import json
cameron@onlab.us059c2562015-04-02 14:12:51 -0700182 import string
andrew@onlab.us10332202015-03-11 15:04:43 -0700183 import csv
jenkins3af0cd82015-03-24 10:27:16 -0700184 import numpy
andrew@onlab.us10332202015-03-11 15:04:43 -0700185
andrew@onlab.us2ae3a112015-02-02 11:24:32 -0800186 main.log.info("Cluster Count = " + str(clusterCount))
187
andrew@onlab.us10332202015-03-11 15:04:43 -0700188 intentsRate = main.params['METRICS']['intents_rate']
189 intentsWithdrawn = main.params[ 'METRICS' ][ 'intents_withdrawn' ]
190 intentsFailed = main.params[ 'METRICS' ][ 'intents_failed' ]
191 testDuration = main.params[ 'TEST' ][ 'duration' ]
192 logInterval = main.params[ 'TEST' ][ 'log_interval' ]
193 debug = main.params[ 'debugMode' ]
cameron@onlab.us059c2562015-04-02 14:12:51 -0700194 numKeys = main.params[ 'TEST' ][ 'numKeys' ]
195 cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
196 neighbors = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
andrew@onlab.us10332202015-03-11 15:04:43 -0700197 metricList = [intentsRate, intentsWithdrawn, intentsFailed]
jenkins3af0cd82015-03-24 10:27:16 -0700198
cameron@onlab.us059c2562015-04-02 14:12:51 -0700199 for n in range(0, len(neighbors)):
200 if neighbors[n] == 'a':
201 neighbors[n] = str(clusterCount -1)
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700202 if int(clusterCount) == 1:
203 neighbors = neighbors.pop()
204
cameron@onlab.us059c2562015-04-02 14:12:51 -0700205 for n in neighbors:
206 main.log.info("Run with " + n + " neighbors")
207 time.sleep(5)
208 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numKeys " + numKeys )
209 main.ONOSbench.handle.expect(":~")
210 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller numNeighbors " + n )
211 main.ONOSbench.handle.expect(":~")
212 main.ONOSbench.handle.sendline("onos $OC1 cfg set org.onosproject.intentperf.IntentPerfInstaller cyclePeriod " + cyclePeriod )
213 main.ONOSbench.handle.expect(":~")
jenkins3af0cd82015-03-24 10:27:16 -0700214
cameron@onlab.us059c2562015-04-02 14:12:51 -0700215 cmd = "onos $OC1 intent-perf-start"
216 main.ONOSbench.handle.sendline(cmd)
217 main.ONOSbench.handle.expect(":~")
218 main.log.info("Starting ONOS (all nodes) intent-perf from $OC1" )
jenkins3af0cd82015-03-24 10:27:16 -0700219
cameron@onlab.us059c2562015-04-02 14:12:51 -0700220 main.log.info( "Starting test loop for " + str(testDuration) + " seconds...\n" )
221 stop = time.time() + float( testDuration )
jenkins3af0cd82015-03-24 10:27:16 -0700222
cameron@onlab.us059c2562015-04-02 14:12:51 -0700223 while time.time() < stop:
224 time.sleep( float( logInterval ) )
225 groupResult = []
226 for node in range (1, clusterCount + 1):
227 groupResult.append(0)
jenkins3af0cd82015-03-24 10:27:16 -0700228
cameron@onlab.us059c2562015-04-02 14:12:51 -0700229 cmd = " onos-ssh $OC" + str(node) + """ cat /opt/onos/log/karaf.log | grep "SNAPSHOT | Throughput" | tail -1 """
230 main.log.info("COMMAND: " + str(cmd))
231
232 x = 0
233 while True:
234 main.ONOSbench.handle.sendline(cmd)
235 main.ONOSbench.handle.expect(":~")
236 raw = main.ONOSbench.handle.before
237 if "OVERALL=" in raw:
238 break
239 x += 1
240 if x > 10:
241 main.log.error("Expected output not being recieved... continuing")
242 break
243 time.sleep(2)
244
245 raw = raw.splitlines()
246 splitResults = []
247 for line in raw:
248 splitResults.extend(line.split(" "))
249
250 myResult = "--"
251 for field in splitResults:
252 if "OVERALL" in field:
253 myResult = field
254
255 if myResult == "--":
256 main.log.error("Parsing/Pexpect error\n" + str(splitResults))
257
258 myResult = myResult.replace(";", "")
259 myResult = myResult.replace("OVERALL=","")
260 myResult = float(myResult)
261 groupResult[len(groupResult) -1] = myResult
262
263 main.log.info("Node " + str(node) + " overall rate: " + str(myResult))
264
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700265 clusterTotal = str(numpy.sum(groupResult))
cameron@onlab.us059c2562015-04-02 14:12:51 -0700266 main.log.report("Results from this round of polling: " + str(groupResult))
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700267 main.log.report("Cluster Total: " + clusterTotal + "\n")
cameron@onlab.us059c2562015-04-02 14:12:51 -0700268
269 cmd = "onos $OC1 intent-perf-stop"
270 main.ONOSbench.handle.sendline(cmd)
271 main.ONOSbench.handle.expect(":~")
272 main.log.info("Stopping intentperf" )
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700273
274 resultsDB = open("IntentEventTPDB", "a")
275 for node in groupResult:
276
277 resultString = "'" + commit + "',"
278 resultString += "'1gig',"
279 resultString += str(clusterCount) + ","
280 resultString += "'baremetal" + str(int(groupResult.index(node)) + 1) + "',"
281 resultString += n + ","
282 resultString += str(node) + ","
283 resultString += str(0) + "\n" #no stddev
284 resultsDB.write(resultString)
285
286 resultsDB.close()
287
288
289