blob: 762b61731d0f593355d63bd46da5652263cfb26b [file] [log] [blame]
cameron@onlab.us1201bc42015-04-01 16:30:05 -07001# ScaleOutTemplate
2#
3# CASE1 starts number of nodes specified in param file
4#
5# cameron@onlab.us
6
7import sys
8import os.path
9
10
11class IntentInstallWithdrawLat:
12
13 def __init__( self ):
14 self.default = ''
15
cameron@onlab.us61e06032015-04-02 10:54:26 -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
cameron@onlab.us1201bc42015-04-01 16:30:05 -070026 #Load values from params file
27 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
28 gitPull = main.params[ 'GIT' ][ 'autopull' ]
29 cellName = main.params[ 'ENV' ][ 'cellName' ]
cameron@onlab.us61e06032015-04-02 10:54:26 -070030 Apps = main.params[ 'ENV' ][ 'cellApps' ]
cameron@onlab.us1201bc42015-04-01 16:30:05 -070031 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
32 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
33 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
34 maxNodes = int(main.params[ 'availableNodes' ])
cameron@onlab.us1201bc42015-04-01 16:30:05 -070035 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
cameron@onlab.us61e06032015-04-02 10:54:26 -070036 cellName = main.params[ 'ENV' ][ 'cellName' ]
cameron@onlab.us1201bc42015-04-01 16:30:05 -070037 switchCount = main.params[ 'TEST' ][ 'switchCount' ]
38
cameron@onlab.us61e06032015-04-02 10:54:26 -070039 # -- INIT SECTION, ONLY RUNS ONCE -- #
40 if init == False:
41 init = True
42 global clusterCount #number of nodes running
43 global ONOSIp #list of ONOS IP addresses
44 global scale
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070045 global commit
46
cameron@onlab.us61e06032015-04-02 10:54:26 -070047 clusterCount = 0
48 ONOSIp = [ 0 ]
49 scale = (main.params[ 'SCALE' ]).split(",")
50 clusterCount = int(scale[0])
cameron@onlab.us1201bc42015-04-01 16:30:05 -070051
cameron@onlab.us61e06032015-04-02 10:54:26 -070052 #Populate ONOSIp with ips from params
53 for i in range(1, maxNodes + 1):
54 ipString = 'ip' + str(i)
55 ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
56
57 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
58 if skipMvn != "yes":
59 mvnResult = main.ONOSbench.cleanInstall()
cameron@onlab.us1201bc42015-04-01 16:30:05 -070060
cameron@onlab.us1201bc42015-04-01 16:30:05 -070061 #git
62 main.step( "Git checkout and pull " + checkoutBranch )
63 if gitPull == 'on':
64 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
65 pullResult = main.ONOSbench.gitPull()
66
67 else:
68 checkoutResult = main.TRUE
69 pullResult = main.TRUE
70 main.log.info( "Skipped git checkout and pull" )
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070071
72 commit = main.ONOSbench.getVersion()
73 commit = (commit.split(" "))[1]
74
75 resultsDB = open("IntentInstallWithdrawLatDB", "w+")
76 resultsDB.close()
77
cameron@onlab.us61e06032015-04-02 10:54:26 -070078 # -- END OF INIT SECTION --#
79
80 clusterCount = int(scale[0])
81 scale.remove(scale[0])
cameron@onlab.us1201bc42015-04-01 16:30:05 -070082
cameron@onlab.us61e06032015-04-02 10:54:26 -070083 #kill off all onos processes
84 main.log.step("Safety check, killing all ONOS processes")
85 main.log.step("before initiating enviornment setup")
86 for node in range(1, maxNodes + 1):
87 main.ONOSbench.onosDie(ONOSIp[node])
88
89 #Uninstall everywhere
90 main.log.step( "Cleaning Enviornment..." )
91 for i in range(1, maxNodes + 1):
92 main.log.info(" Uninstalling ONOS " + str(i) )
93 main.ONOSbench.onosUninstall( ONOSIp[i] )
94
95 #construct the cell file
cameron@onlab.us1201bc42015-04-01 16:30:05 -070096 main.log.info("Creating cell file")
cameron@onlab.us1201bc42015-04-01 16:30:05 -070097 cellIp = []
98 for node in range (1, clusterCount + 1):
99 cellIp.append(ONOSIp[node])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700100
cameron@onlab.us61e06032015-04-02 10:54:26 -0700101 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700102
cameron@onlab.us61e06032015-04-02 10:54:26 -0700103 main.step( "Set Cell" )
104 main.ONOSbench.setCell(cellName)
105
cameron@onlab.us61e06032015-04-02 10:54:26 -0700106 main.step( "Creating ONOS package" )
107 packageResult = main.ONOSbench.onosPackage()
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700108
cameron@onlab.us61e06032015-04-02 10:54:26 -0700109 main.step( "verify cells" )
110 verifyCellResult = main.ONOSbench.verifyCell()
111
112 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700113 for node in range(1, clusterCount + 1):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700114 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
115 main.ONOSbench.onosInstall( ONOSIp[node])
116
117 for node in range(1, clusterCount + 1):
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700118 for i in range( 2 ):
119 isup = main.ONOSbench.isup( ONOSIp[node] )
120 if isup:
121 main.log.info("ONOS " + str(node) + " is up\n")
122 break
123 if not isup:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700124 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700125
cameron@onlab.us61e06032015-04-02 10:54:26 -0700126 main.ONOS1cli.startOnosCli( ONOSIp[1] )
127 main.log.info("Startup sequence complete")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700128
129 time.sleep(30)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700130
jenkins0a0d6762015-06-19 13:37:09 -0700131 for i in range(5):
132 main.ONOSbench.handle.sendline("""onos $OC1 "cfg setorg.onosproject.provider.nil.NullProviders enabled true" """)
133 main.ONOSbench.handle.expect(":~")
134 print main.ONOSbench.handle.before
135 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount """ + str(switchCount) + """ " """)
136 main.ONOSbench.handle.expect(":~")
137 print main.ONOSbench.handle.before
138 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
139 main.ONOSbench.handle.expect(":~")
140 print main.ONOSbench.handle.before
141 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
142 main.ONOSbench.handle.expect(":~")
143 print main.ONOSbench.handle.before
144 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
145 main.ONOSbench.handle.expect(":~")
146 print main.ONOSbench.handle.before
147
148 main.ONOSbench.handle.sendline("onos $OC1 summary")
149 main.ONOSbench.handle.expect(":~")
150 check = main.ONOSbench.handle.before
151 main.log.info(check)
152 if "SSC(s)=1," in check:
153 break
154
155
156
157 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
cameron@onlab.us61e06032015-04-02 10:54:26 -0700158
159 def CASE2( self, main ):
160
161 import time
162 import numpy
163
jenkins0a0d6762015-06-19 13:37:09 -0700164 testStatus = "pass"
cameron@onlab.us61e06032015-04-02 10:54:26 -0700165 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700166 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
167 intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",")
168 switchCount = int(main.params[ 'TEST' ][ 'switchCount' ])
169 debug = main.params[ 'TEST' ][ 'switchCount' ]
170 for i in range(0,len(intentsList)):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700171 intentsList[i] = int(intentsList[i])
172
jenkins73f5aac2015-06-22 14:34:46 -0700173 ######################
jenkins0a0d6762015-06-19 13:37:09 -0700174 debug = True
jenkins73f5aac2015-06-22 14:34:46 -0700175 ######################
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700176
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700177 linkCount = 0
178 for i in range(0,10):
179 main.ONOSbench.handle.sendline("onos $OC1 links|wc -l")
180 main.ONOSbench.handle.expect(":~")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700181 linkCount = main.ONOSbench.handle.before
182 if debug: main.log.info("Link Count check: " + linkCount)
183 if str((switchCount*2)-2) in linkCount:
184 break
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700185 time.sleep(2)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700186
cameron@onlab.us61e06032015-04-02 10:54:26 -0700187 links = "--"
jenkins73f5aac2015-06-22 14:34:46 -0700188 for i in range(8):
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700189 if debug: main.log.info("top of loop")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700190 main.ONOSbench.handle.sendline("onos $OC1 links")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700191 main.ONOSbench.handle.expect(":~")
192 links = main.ONOSbench.handle.before
jenkins73f5aac2015-06-22 14:34:46 -0700193 if "=null:" in links:
194 break
cameron@onlab.us61e06032015-04-02 10:54:26 -0700195 if debug: main.log.info(str(links))
jenkins73f5aac2015-06-22 14:34:46 -0700196 if i > 3:
197 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], "d")
198 if i == 7:
199 main.log.error("link data missing")
200 time.sleep(3)
201
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700202 links = links.splitlines()
cameron@onlab.us61e06032015-04-02 10:54:26 -0700203 templinks = links
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700204
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700205 tempDevices = []
cameron@onlab.us61e06032015-04-02 10:54:26 -0700206 for line in links:
207 temp = line.split(" ")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700208 temp[0].replace("src=","")
209 temp[0] = (temp[0].split("/"))[0]
cameron@onlab.us61e06032015-04-02 10:54:26 -0700210 tempDevices.append(temp[0])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700211
212 tempDevices.sort()
213 devices = []
cameron@onlab.us61e06032015-04-02 10:54:26 -0700214 for i in tempDevices:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700215 if "src=null" in i:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700216 devices.append(i.replace("src=", ""))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700217 if debug: main.log.info(str(devices))
218
219 ingress = devices[0]
cameron@onlab.us61e06032015-04-02 10:54:26 -0700220 egress = devices.pop()
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700221 if debug: main.log.info(ingress)
222 if debug: main.log.info(egress)
223
224 for intentSize in intentsList:
225 cmd = "onos $OC1 push-test-intents "
226 cmd += ingress + "/6 "
227 cmd += egress + "/5 "
228 cmd += str(intentSize) + " 1"
229 installed = []
230 withdrawn = []
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700231
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700232 for run in range(0, (warmUp + sampleSize)):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700233 if run > warmUp:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700234 time.sleep(5)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700235
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700236 myRawResult = "--"
237 while "ms" not in myRawResult:
238 main.ONOSbench.handle.sendline(cmd)
239 main.ONOSbench.handle.expect(":~")
240 myRawResult = main.ONOSbench.handle.before
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700241 if debug: main.log.info(myRawResult)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700242
cameron@onlab.us61e06032015-04-02 10:54:26 -0700243 if debug: main.log.info(myRawResult)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700244
cameron@onlab.us61e06032015-04-02 10:54:26 -0700245 if run >= warmUp:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700246 myRawResult = myRawResult.splitlines()
247 for line in myRawResult:
248 if "install" in line:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700249 installed.append(int(line.split(" ")[5]))
250
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700251 for line in myRawResult:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700252 if "withdraw" in line:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700253 withdrawn.append(int(line.split(" ")[5]))
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700254
jenkins0a0d6762015-06-19 13:37:09 -0700255 for line in myRawResult:
256 if "Failure:" in line:
257 main.log.error("INTENT TEST FAILURE, ABORTING TESTCASE")
258 testStatus = "fail"
259 if testStatus == "fail":
260 break
261
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700262 print("installed: " + str(installed))
263 print("withraw: " + str(withdrawn) + "\n")
jenkins0a0d6762015-06-19 13:37:09 -0700264 if withdrawn[len(withdrawn) -1] > 1000 or installed[len(installed) -1] > 1000:
265 main.log.info("ABNORMAL VALUE, CHECKING LOG")
266 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700267
jenkins0a0d6762015-06-19 13:37:09 -0700268 if testStatus == "fail":
269 break
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700270 main.log.report("----------------------------------------------------")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700271 main.log.report("Scale: " + str(clusterCount) + "\tIntent batch size: " + str(intentSize))
272 main.log.report("Data samples: " + str(sampleSize) + "\tWarm up tests: " + str(warmUp))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700273 main.log.report("Installed average: " + str(numpy.mean(installed)))
274 main.log.report("Installed standard deviation: " + str(numpy.std(installed)))
275 main.log.report("Withdraw average: " + str(numpy.mean(withdrawn)))
276 main.log.report("Withdraw standard deviation: " + str(numpy.std(withdrawn)))
277 main.log.report(" ")
278
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700279 resultString = "'" + commit + "',"
280 resultString += str(clusterCount) + ","
281 resultString += str(intentSize) + ","
282 resultString += str(numpy.mean(installed)) + ","
283 resultString += str(numpy.std(installed)) + ","
284 resultString += str(numpy.mean(withdrawn)) + ","
285 resultString += str(numpy.std(withdrawn)) + "\n"
cameron@onlab.us768363a2015-05-06 13:55:17 -0700286 resultsDB = open("IntentInstallWithdrawLatDB", "a")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700287 resultsDB.write(resultString)
288 resultsDB.close()
jenkins0a0d6762015-06-19 13:37:09 -0700289
290 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
jenkins73f5aac2015-06-22 14:34:46 -0700291 time.sleep(20)