blob: 789f5184934411ed8ac210427c481ff7f40523e5 [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
jenkins0a0d6762015-06-19 13:37:09 -0700173 #if debug == "True":
174 # debug = True
175 #else:
176 # debug = False
177 debug = True
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700178
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700179 linkCount = 0
180 for i in range(0,10):
181 main.ONOSbench.handle.sendline("onos $OC1 links|wc -l")
182 main.ONOSbench.handle.expect(":~")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700183 linkCount = main.ONOSbench.handle.before
184 if debug: main.log.info("Link Count check: " + linkCount)
185 if str((switchCount*2)-2) in linkCount:
186 break
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700187 time.sleep(2)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700188
cameron@onlab.us61e06032015-04-02 10:54:26 -0700189 links = "--"
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700190 while "=null:" not in links:
191 if debug: main.log.info("top of loop")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700192 main.ONOSbench.handle.sendline("onos $OC1 links")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700193 main.ONOSbench.handle.expect(":~")
194 links = main.ONOSbench.handle.before
cameron@onlab.us61e06032015-04-02 10:54:26 -0700195 if debug: main.log.info(str(links))
196 time.sleep(1)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700197 links = links.splitlines()
cameron@onlab.us61e06032015-04-02 10:54:26 -0700198 templinks = links
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700199
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700200 tempDevices = []
cameron@onlab.us61e06032015-04-02 10:54:26 -0700201 for line in links:
202 temp = line.split(" ")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700203 temp[0].replace("src=","")
204 temp[0] = (temp[0].split("/"))[0]
cameron@onlab.us61e06032015-04-02 10:54:26 -0700205 tempDevices.append(temp[0])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700206
207 tempDevices.sort()
208 devices = []
cameron@onlab.us61e06032015-04-02 10:54:26 -0700209 for i in tempDevices:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700210 if "src=null" in i:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700211 devices.append(i.replace("src=", ""))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700212 if debug: main.log.info(str(devices))
213
214 ingress = devices[0]
cameron@onlab.us61e06032015-04-02 10:54:26 -0700215 egress = devices.pop()
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700216 if debug: main.log.info(ingress)
217 if debug: main.log.info(egress)
218
219 for intentSize in intentsList:
220 cmd = "onos $OC1 push-test-intents "
221 cmd += ingress + "/6 "
222 cmd += egress + "/5 "
223 cmd += str(intentSize) + " 1"
224 installed = []
225 withdrawn = []
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700226
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700227 for run in range(0, (warmUp + sampleSize)):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700228 if run > warmUp:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700229 time.sleep(5)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700230
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700231 myRawResult = "--"
232 while "ms" not in myRawResult:
233 main.ONOSbench.handle.sendline(cmd)
234 main.ONOSbench.handle.expect(":~")
235 myRawResult = main.ONOSbench.handle.before
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700236 if debug: main.log.info(myRawResult)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700237
cameron@onlab.us61e06032015-04-02 10:54:26 -0700238 if debug: main.log.info(myRawResult)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700239
cameron@onlab.us61e06032015-04-02 10:54:26 -0700240 if run >= warmUp:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700241 myRawResult = myRawResult.splitlines()
242 for line in myRawResult:
243 if "install" in line:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700244 installed.append(int(line.split(" ")[5]))
245
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700246 for line in myRawResult:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700247 if "withdraw" in line:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700248 withdrawn.append(int(line.split(" ")[5]))
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700249
jenkins0a0d6762015-06-19 13:37:09 -0700250 for line in myRawResult:
251 if "Failure:" in line:
252 main.log.error("INTENT TEST FAILURE, ABORTING TESTCASE")
253 testStatus = "fail"
254 if testStatus == "fail":
255 break
256
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700257 print("installed: " + str(installed))
258 print("withraw: " + str(withdrawn) + "\n")
jenkins0a0d6762015-06-19 13:37:09 -0700259 if withdrawn[len(withdrawn) -1] > 1000 or installed[len(installed) -1] > 1000:
260 main.log.info("ABNORMAL VALUE, CHECKING LOG")
261 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700262
jenkins0a0d6762015-06-19 13:37:09 -0700263 if testStatus == "fail":
264 break
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700265 main.log.report("----------------------------------------------------")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700266 main.log.report("Scale: " + str(clusterCount) + "\tIntent batch size: " + str(intentSize))
267 main.log.report("Data samples: " + str(sampleSize) + "\tWarm up tests: " + str(warmUp))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700268 main.log.report("Installed average: " + str(numpy.mean(installed)))
269 main.log.report("Installed standard deviation: " + str(numpy.std(installed)))
270 main.log.report("Withdraw average: " + str(numpy.mean(withdrawn)))
271 main.log.report("Withdraw standard deviation: " + str(numpy.std(withdrawn)))
272 main.log.report(" ")
273
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700274 resultString = "'" + commit + "',"
275 resultString += str(clusterCount) + ","
276 resultString += str(intentSize) + ","
277 resultString += str(numpy.mean(installed)) + ","
278 resultString += str(numpy.std(installed)) + ","
279 resultString += str(numpy.mean(withdrawn)) + ","
280 resultString += str(numpy.std(withdrawn)) + "\n"
cameron@onlab.us768363a2015-05-06 13:55:17 -0700281 resultsDB = open("IntentInstallWithdrawLatDB", "a")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700282 resultsDB.write(resultString)
283 resultsDB.close()
jenkins0a0d6762015-06-19 13:37:09 -0700284
285 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])