blob: a3833d401fb3c760799659d3706066bc521bb487 [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
jenkins15b2b132015-06-23 14:04:09 -070053 ONOSIp = [0]
54 ONOSIp.extend(main.ONOSbench.getOnosIps())
55 MN1Ip = ONOSIps[len(ONOSIp)-1]
56 BENCHIp = ONOSIps[len(ONOSIp)-2]
57
cameron@onlab.us61e06032015-04-02 10:54:26 -070058 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
59 if skipMvn != "yes":
60 mvnResult = main.ONOSbench.cleanInstall()
cameron@onlab.us1201bc42015-04-01 16:30:05 -070061
cameron@onlab.us1201bc42015-04-01 16:30:05 -070062 #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" )
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070072
73 commit = main.ONOSbench.getVersion()
74 commit = (commit.split(" "))[1]
75
76 resultsDB = open("IntentInstallWithdrawLatDB", "w+")
77 resultsDB.close()
78
cameron@onlab.us61e06032015-04-02 10:54:26 -070079 # -- END OF INIT SECTION --#
80
81 clusterCount = int(scale[0])
82 scale.remove(scale[0])
cameron@onlab.us1201bc42015-04-01 16:30:05 -070083
cameron@onlab.us61e06032015-04-02 10:54:26 -070084 #kill off all onos processes
85 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):
88 main.ONOSbench.onosDie(ONOSIp[node])
89
90 #Uninstall everywhere
91 main.log.step( "Cleaning Enviornment..." )
92 for i in range(1, maxNodes + 1):
93 main.log.info(" Uninstalling ONOS " + str(i) )
94 main.ONOSbench.onosUninstall( ONOSIp[i] )
95
96 #construct the cell file
cameron@onlab.us1201bc42015-04-01 16:30:05 -070097 main.log.info("Creating cell file")
cameron@onlab.us1201bc42015-04-01 16:30:05 -070098 cellIp = []
99 for node in range (1, clusterCount + 1):
100 cellIp.append(ONOSIp[node])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700101
cameron@onlab.us61e06032015-04-02 10:54:26 -0700102 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700103
cameron@onlab.us61e06032015-04-02 10:54:26 -0700104 main.step( "Set Cell" )
105 main.ONOSbench.setCell(cellName)
106
cameron@onlab.us61e06032015-04-02 10:54:26 -0700107 main.step( "Creating ONOS package" )
108 packageResult = main.ONOSbench.onosPackage()
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700109
cameron@onlab.us61e06032015-04-02 10:54:26 -0700110 main.step( "verify cells" )
111 verifyCellResult = main.ONOSbench.verifyCell()
112
113 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700114 for node in range(1, clusterCount + 1):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700115 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
116 main.ONOSbench.onosInstall( ONOSIp[node])
117
118 for node in range(1, clusterCount + 1):
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700119 for i in range( 2 ):
120 isup = main.ONOSbench.isup( ONOSIp[node] )
121 if isup:
122 main.log.info("ONOS " + str(node) + " is up\n")
123 break
124 if not isup:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700125 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700126
cameron@onlab.us61e06032015-04-02 10:54:26 -0700127 main.ONOS1cli.startOnosCli( ONOSIp[1] )
128 main.log.info("Startup sequence complete")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700129
130 time.sleep(30)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700131
jenkins0a0d6762015-06-19 13:37:09 -0700132 for i in range(5):
133 main.ONOSbench.handle.sendline("""onos $OC1 "cfg setorg.onosproject.provider.nil.NullProviders enabled true" """)
134 main.ONOSbench.handle.expect(":~")
135 print main.ONOSbench.handle.before
136 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount """ + str(switchCount) + """ " """)
137 main.ONOSbench.handle.expect(":~")
138 print main.ONOSbench.handle.before
139 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
140 main.ONOSbench.handle.expect(":~")
141 print main.ONOSbench.handle.before
142 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
143 main.ONOSbench.handle.expect(":~")
144 print main.ONOSbench.handle.before
145 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
146 main.ONOSbench.handle.expect(":~")
147 print main.ONOSbench.handle.before
148
149 main.ONOSbench.handle.sendline("onos $OC1 summary")
150 main.ONOSbench.handle.expect(":~")
151 check = main.ONOSbench.handle.before
152 main.log.info(check)
153 if "SSC(s)=1," in check:
154 break
155
156
157
158 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
cameron@onlab.us61e06032015-04-02 10:54:26 -0700159
160 def CASE2( self, main ):
161
162 import time
163 import numpy
164
jenkins0a0d6762015-06-19 13:37:09 -0700165 testStatus = "pass"
cameron@onlab.us61e06032015-04-02 10:54:26 -0700166 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700167 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
168 intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",")
169 switchCount = int(main.params[ 'TEST' ][ 'switchCount' ])
170 debug = main.params[ 'TEST' ][ 'switchCount' ]
171 for i in range(0,len(intentsList)):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700172 intentsList[i] = int(intentsList[i])
173
jenkins73f5aac2015-06-22 14:34:46 -0700174 ######################
jenkins0a0d6762015-06-19 13:37:09 -0700175 debug = True
jenkins73f5aac2015-06-22 14:34:46 -0700176 ######################
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700177
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700178 linkCount = 0
179 for i in range(0,10):
180 main.ONOSbench.handle.sendline("onos $OC1 links|wc -l")
181 main.ONOSbench.handle.expect(":~")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700182 linkCount = main.ONOSbench.handle.before
183 if debug: main.log.info("Link Count check: " + linkCount)
184 if str((switchCount*2)-2) in linkCount:
185 break
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700186 time.sleep(2)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700187
cameron@onlab.us61e06032015-04-02 10:54:26 -0700188 links = "--"
jenkins73f5aac2015-06-22 14:34:46 -0700189 for i in range(8):
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700190 if debug: main.log.info("top of loop")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700191 main.ONOSbench.handle.sendline("onos $OC1 links")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700192 main.ONOSbench.handle.expect(":~")
193 links = main.ONOSbench.handle.before
jenkins73f5aac2015-06-22 14:34:46 -0700194 if "=null:" in links:
195 break
cameron@onlab.us61e06032015-04-02 10:54:26 -0700196 if debug: main.log.info(str(links))
jenkins73f5aac2015-06-22 14:34:46 -0700197 if i > 3:
198 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], "d")
199 if i == 7:
200 main.log.error("link data missing")
201 time.sleep(3)
202
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700203 links = links.splitlines()
cameron@onlab.us61e06032015-04-02 10:54:26 -0700204 templinks = links
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700205
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700206 tempDevices = []
cameron@onlab.us61e06032015-04-02 10:54:26 -0700207 for line in links:
208 temp = line.split(" ")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700209 temp[0].replace("src=","")
210 temp[0] = (temp[0].split("/"))[0]
cameron@onlab.us61e06032015-04-02 10:54:26 -0700211 tempDevices.append(temp[0])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700212
213 tempDevices.sort()
214 devices = []
cameron@onlab.us61e06032015-04-02 10:54:26 -0700215 for i in tempDevices:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700216 if "src=null" in i:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700217 devices.append(i.replace("src=", ""))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700218 if debug: main.log.info(str(devices))
219
220 ingress = devices[0]
cameron@onlab.us61e06032015-04-02 10:54:26 -0700221 egress = devices.pop()
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700222 if debug: main.log.info(ingress)
223 if debug: main.log.info(egress)
224
225 for intentSize in intentsList:
226 cmd = "onos $OC1 push-test-intents "
227 cmd += ingress + "/6 "
228 cmd += egress + "/5 "
229 cmd += str(intentSize) + " 1"
230 installed = []
231 withdrawn = []
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700232
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700233 for run in range(0, (warmUp + sampleSize)):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700234 if run > warmUp:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700235 time.sleep(5)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700236
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700237 myRawResult = "--"
238 while "ms" not in myRawResult:
239 main.ONOSbench.handle.sendline(cmd)
240 main.ONOSbench.handle.expect(":~")
241 myRawResult = main.ONOSbench.handle.before
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700242 if debug: main.log.info(myRawResult)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700243
cameron@onlab.us61e06032015-04-02 10:54:26 -0700244 if debug: main.log.info(myRawResult)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700245
cameron@onlab.us61e06032015-04-02 10:54:26 -0700246 if run >= warmUp:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700247 myRawResult = myRawResult.splitlines()
248 for line in myRawResult:
249 if "install" in line:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700250 installed.append(int(line.split(" ")[5]))
251
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700252 for line in myRawResult:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700253 if "withdraw" in line:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700254 withdrawn.append(int(line.split(" ")[5]))
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700255
jenkins0a0d6762015-06-19 13:37:09 -0700256 for line in myRawResult:
257 if "Failure:" in line:
258 main.log.error("INTENT TEST FAILURE, ABORTING TESTCASE")
259 testStatus = "fail"
260 if testStatus == "fail":
261 break
262
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700263 print("installed: " + str(installed))
264 print("withraw: " + str(withdrawn) + "\n")
jenkins0a0d6762015-06-19 13:37:09 -0700265 if withdrawn[len(withdrawn) -1] > 1000 or installed[len(installed) -1] > 1000:
266 main.log.info("ABNORMAL VALUE, CHECKING LOG")
267 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700268
jenkins0a0d6762015-06-19 13:37:09 -0700269 if testStatus == "fail":
270 break
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700271 main.log.report("----------------------------------------------------")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700272 main.log.report("Scale: " + str(clusterCount) + "\tIntent batch size: " + str(intentSize))
273 main.log.report("Data samples: " + str(sampleSize) + "\tWarm up tests: " + str(warmUp))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700274 main.log.report("Installed average: " + str(numpy.mean(installed)))
275 main.log.report("Installed standard deviation: " + str(numpy.std(installed)))
276 main.log.report("Withdraw average: " + str(numpy.mean(withdrawn)))
277 main.log.report("Withdraw standard deviation: " + str(numpy.std(withdrawn)))
278 main.log.report(" ")
279
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700280 resultString = "'" + commit + "',"
281 resultString += str(clusterCount) + ","
282 resultString += str(intentSize) + ","
283 resultString += str(numpy.mean(installed)) + ","
284 resultString += str(numpy.std(installed)) + ","
285 resultString += str(numpy.mean(withdrawn)) + ","
286 resultString += str(numpy.std(withdrawn)) + "\n"
cameron@onlab.us768363a2015-05-06 13:55:17 -0700287 resultsDB = open("IntentInstallWithdrawLatDB", "a")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700288 resultsDB.write(resultString)
289 resultsDB.close()
jenkins0a0d6762015-06-19 13:37:09 -0700290
291 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
jenkins73f5aac2015-06-22 14:34:46 -0700292 time.sleep(20)