blob: e96307d24455d751e72a89991ec79a56ab04206c [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())
jenkins15b2b132015-06-23 14:04:09 -070055
cameron@onlab.us61e06032015-04-02 10:54:26 -070056 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
57 if skipMvn != "yes":
58 mvnResult = main.ONOSbench.cleanInstall()
cameron@onlab.us1201bc42015-04-01 16:30:05 -070059
cameron@onlab.us1201bc42015-04-01 16:30:05 -070060 #git
61 main.step( "Git checkout and pull " + checkoutBranch )
62 if gitPull == 'on':
63 checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
64 pullResult = main.ONOSbench.gitPull()
65
66 else:
67 checkoutResult = main.TRUE
68 pullResult = main.TRUE
69 main.log.info( "Skipped git checkout and pull" )
cameron@onlab.usc80a8c82015-04-15 14:57:37 -070070
71 commit = main.ONOSbench.getVersion()
72 commit = (commit.split(" "))[1]
73
74 resultsDB = open("IntentInstallWithdrawLatDB", "w+")
75 resultsDB.close()
76
cameron@onlab.us61e06032015-04-02 10:54:26 -070077 # -- END OF INIT SECTION --#
78
79 clusterCount = int(scale[0])
80 scale.remove(scale[0])
jenkins8f8f4f32015-06-24 14:05:04 -070081
82 MN1Ip = ONOSIps[len(ONOSIp)-1]
83 BENCHIp = ONOSIps[len(ONOSIp)-2]
84
cameron@onlab.us61e06032015-04-02 10:54:26 -070085 #kill off all onos processes
86 main.log.step("Safety check, killing all ONOS processes")
87 main.log.step("before initiating enviornment setup")
88 for node in range(1, maxNodes + 1):
89 main.ONOSbench.onosDie(ONOSIp[node])
90
91 #Uninstall everywhere
92 main.log.step( "Cleaning Enviornment..." )
93 for i in range(1, maxNodes + 1):
94 main.log.info(" Uninstalling ONOS " + str(i) )
95 main.ONOSbench.onosUninstall( ONOSIp[i] )
96
97 #construct the cell file
cameron@onlab.us1201bc42015-04-01 16:30:05 -070098 main.log.info("Creating cell file")
cameron@onlab.us1201bc42015-04-01 16:30:05 -070099 cellIp = []
100 for node in range (1, clusterCount + 1):
101 cellIp.append(ONOSIp[node])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700102
cameron@onlab.us61e06032015-04-02 10:54:26 -0700103 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700104
cameron@onlab.us61e06032015-04-02 10:54:26 -0700105 main.step( "Set Cell" )
106 main.ONOSbench.setCell(cellName)
107
cameron@onlab.us61e06032015-04-02 10:54:26 -0700108 main.step( "Creating ONOS package" )
109 packageResult = main.ONOSbench.onosPackage()
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700110
cameron@onlab.us61e06032015-04-02 10:54:26 -0700111 main.step( "verify cells" )
112 verifyCellResult = main.ONOSbench.verifyCell()
113
114 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700115 for node in range(1, clusterCount + 1):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700116 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
117 main.ONOSbench.onosInstall( ONOSIp[node])
118
119 for node in range(1, clusterCount + 1):
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700120 for i in range( 2 ):
121 isup = main.ONOSbench.isup( ONOSIp[node] )
122 if isup:
123 main.log.info("ONOS " + str(node) + " is up\n")
124 break
125 if not isup:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700126 main.log.report( "ONOS " + str(node) + " didn't start!" )
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700127
cameron@onlab.us61e06032015-04-02 10:54:26 -0700128 main.ONOS1cli.startOnosCli( ONOSIp[1] )
129 main.log.info("Startup sequence complete")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700130
131 time.sleep(30)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700132
jenkins0a0d6762015-06-19 13:37:09 -0700133 for i in range(5):
134 main.ONOSbench.handle.sendline("""onos $OC1 "cfg setorg.onosproject.provider.nil.NullProviders enabled true" """)
135 main.ONOSbench.handle.expect(":~")
136 print main.ONOSbench.handle.before
137 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount """ + str(switchCount) + """ " """)
138 main.ONOSbench.handle.expect(":~")
139 print main.ONOSbench.handle.before
140 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders topoShape linear" """)
141 main.ONOSbench.handle.expect(":~")
142 print main.ONOSbench.handle.before
143 main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
144 main.ONOSbench.handle.expect(":~")
145 print main.ONOSbench.handle.before
146 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
147 main.ONOSbench.handle.expect(":~")
148 print main.ONOSbench.handle.before
149
150 main.ONOSbench.handle.sendline("onos $OC1 summary")
151 main.ONOSbench.handle.expect(":~")
152 check = main.ONOSbench.handle.before
153 main.log.info(check)
154 if "SSC(s)=1," in check:
155 break
156
157
158
159 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
cameron@onlab.us61e06032015-04-02 10:54:26 -0700160
161 def CASE2( self, main ):
162
163 import time
164 import numpy
165
jenkins0a0d6762015-06-19 13:37:09 -0700166 testStatus = "pass"
cameron@onlab.us61e06032015-04-02 10:54:26 -0700167 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700168 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
169 intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",")
170 switchCount = int(main.params[ 'TEST' ][ 'switchCount' ])
171 debug = main.params[ 'TEST' ][ 'switchCount' ]
172 for i in range(0,len(intentsList)):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700173 intentsList[i] = int(intentsList[i])
174
jenkins73f5aac2015-06-22 14:34:46 -0700175 ######################
jenkins0a0d6762015-06-19 13:37:09 -0700176 debug = True
jenkins73f5aac2015-06-22 14:34:46 -0700177 ######################
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 = "--"
jenkins73f5aac2015-06-22 14:34:46 -0700190 for i in range(8):
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700191 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
jenkins73f5aac2015-06-22 14:34:46 -0700195 if "=null:" in links:
196 break
cameron@onlab.us61e06032015-04-02 10:54:26 -0700197 if debug: main.log.info(str(links))
jenkins73f5aac2015-06-22 14:34:46 -0700198 if i > 3:
199 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], "d")
200 if i == 7:
201 main.log.error("link data missing")
202 time.sleep(3)
203
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700204 links = links.splitlines()
cameron@onlab.us61e06032015-04-02 10:54:26 -0700205 templinks = links
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700206
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700207 tempDevices = []
cameron@onlab.us61e06032015-04-02 10:54:26 -0700208 for line in links:
209 temp = line.split(" ")
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700210 temp[0].replace("src=","")
211 temp[0] = (temp[0].split("/"))[0]
cameron@onlab.us61e06032015-04-02 10:54:26 -0700212 tempDevices.append(temp[0])
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700213
214 tempDevices.sort()
215 devices = []
cameron@onlab.us61e06032015-04-02 10:54:26 -0700216 for i in tempDevices:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700217 if "src=null" in i:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700218 devices.append(i.replace("src=", ""))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700219 if debug: main.log.info(str(devices))
220
221 ingress = devices[0]
cameron@onlab.us61e06032015-04-02 10:54:26 -0700222 egress = devices.pop()
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700223 if debug: main.log.info(ingress)
224 if debug: main.log.info(egress)
225
226 for intentSize in intentsList:
227 cmd = "onos $OC1 push-test-intents "
228 cmd += ingress + "/6 "
229 cmd += egress + "/5 "
230 cmd += str(intentSize) + " 1"
231 installed = []
232 withdrawn = []
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700233
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700234 for run in range(0, (warmUp + sampleSize)):
cameron@onlab.us61e06032015-04-02 10:54:26 -0700235 if run > warmUp:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700236 time.sleep(5)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700237
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700238 myRawResult = "--"
239 while "ms" not in myRawResult:
240 main.ONOSbench.handle.sendline(cmd)
241 main.ONOSbench.handle.expect(":~")
242 myRawResult = main.ONOSbench.handle.before
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700243 if debug: main.log.info(myRawResult)
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700244
cameron@onlab.us61e06032015-04-02 10:54:26 -0700245 if debug: main.log.info(myRawResult)
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700246
cameron@onlab.us61e06032015-04-02 10:54:26 -0700247 if run >= warmUp:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700248 myRawResult = myRawResult.splitlines()
249 for line in myRawResult:
250 if "install" in line:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700251 installed.append(int(line.split(" ")[5]))
252
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700253 for line in myRawResult:
cameron@onlab.us61e06032015-04-02 10:54:26 -0700254 if "withdraw" in line:
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700255 withdrawn.append(int(line.split(" ")[5]))
cameron@onlab.uscd4e8a22015-05-11 10:58:43 -0700256
jenkins0a0d6762015-06-19 13:37:09 -0700257 for line in myRawResult:
258 if "Failure:" in line:
259 main.log.error("INTENT TEST FAILURE, ABORTING TESTCASE")
260 testStatus = "fail"
261 if testStatus == "fail":
262 break
263
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700264 print("installed: " + str(installed))
265 print("withraw: " + str(withdrawn) + "\n")
jenkins0a0d6762015-06-19 13:37:09 -0700266 if withdrawn[len(withdrawn) -1] > 1000 or installed[len(installed) -1] > 1000:
267 main.log.info("ABNORMAL VALUE, CHECKING LOG")
268 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700269
jenkins0a0d6762015-06-19 13:37:09 -0700270 if testStatus == "fail":
271 break
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700272 main.log.report("----------------------------------------------------")
cameron@onlab.us61e06032015-04-02 10:54:26 -0700273 main.log.report("Scale: " + str(clusterCount) + "\tIntent batch size: " + str(intentSize))
274 main.log.report("Data samples: " + str(sampleSize) + "\tWarm up tests: " + str(warmUp))
cameron@onlab.us1201bc42015-04-01 16:30:05 -0700275 main.log.report("Installed average: " + str(numpy.mean(installed)))
276 main.log.report("Installed standard deviation: " + str(numpy.std(installed)))
277 main.log.report("Withdraw average: " + str(numpy.mean(withdrawn)))
278 main.log.report("Withdraw standard deviation: " + str(numpy.std(withdrawn)))
279 main.log.report(" ")
280
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700281 resultString = "'" + commit + "',"
282 resultString += str(clusterCount) + ","
283 resultString += str(intentSize) + ","
284 resultString += str(numpy.mean(installed)) + ","
285 resultString += str(numpy.std(installed)) + ","
286 resultString += str(numpy.mean(withdrawn)) + ","
287 resultString += str(numpy.std(withdrawn)) + "\n"
cameron@onlab.us768363a2015-05-06 13:55:17 -0700288 resultsDB = open("IntentInstallWithdrawLatDB", "a")
cameron@onlab.usc80a8c82015-04-15 14:57:37 -0700289 resultsDB.write(resultString)
290 resultsDB.close()
jenkins0a0d6762015-06-19 13:37:09 -0700291
292 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
jenkins73f5aac2015-06-22 14:34:46 -0700293 time.sleep(20)