blob: 325cdbfc5f67565476abd28dd3d0a981eb2f4519 [file] [log] [blame]
cameron@onlab.us41c16f52015-07-08 15:40:28 -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 SCPFintentInstallWithdrawLat:
12
13 def __init__( self ):
14 self.default = ''
15
Jon Hall4ba53f02015-07-29 13:07:41 -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.us41c16f52015-07-08 15:40:28 -070026 #Load values from params file
27 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
28 gitPull = main.params[ 'GIT' ][ 'autopull' ]
29 cellName = main.params[ 'ENV' ][ 'cellName' ]
30 Apps = main.params[ 'ENV' ][ 'cellApps' ]
31 BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
32 BENCHUser = main.params[ 'BENCH' ][ 'user' ]
33 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
cameron@onlab.usceff56f2015-07-13 16:42:08 -070034 main.maxNodes = int(main.params[ 'max' ])
cameron@onlab.us41c16f52015-07-08 15:40:28 -070035 skipMvn = main.params[ 'TEST' ][ 'skipCleanInstall' ]
Jon Hall4ba53f02015-07-29 13:07:41 -070036 cellName = main.params[ 'ENV' ][ 'cellName' ]
cameron@onlab.us41c16f52015-07-08 15:40:28 -070037 switchCount = main.params[ 'TEST' ][ 'switchCount' ]
38
Jon Hall4ba53f02015-07-29 13:07:41 -070039 # -- INIT SECTION, ONLY RUNS ONCE -- #
40 if init == False:
cameron@onlab.us41c16f52015-07-08 15:40:28 -070041 init = True
42 global clusterCount #number of nodes running
43 global ONOSIp #list of ONOS IP addresses
Jon Hall4ba53f02015-07-29 13:07:41 -070044 global scale
45 global commit
46
cameron@onlab.us41c16f52015-07-08 15:40:28 -070047 clusterCount = 0
48 ONOSIp = [ 0 ]
Jon Hall4ba53f02015-07-29 13:07:41 -070049 scale = (main.params[ 'SCALE' ]).split(",")
cameron@onlab.us41c16f52015-07-08 15:40:28 -070050 clusterCount = int(scale[0])
51
Jon Hall4ba53f02015-07-29 13:07:41 -070052 #Populate ONOSIp with ips from params
cameron@onlab.us41c16f52015-07-08 15:40:28 -070053 ONOSIp = [0]
54 ONOSIp.extend(main.ONOSbench.getOnosIps())
55
56 #mvn clean install, for debugging set param 'skipCleanInstall' to yes to speed up test
57 if skipMvn != "yes":
58 mvnResult = main.ONOSbench.cleanInstall()
59
60 #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" )
Jon Hall4ba53f02015-07-29 13:07:41 -070070
cameron@onlab.us41c16f52015-07-08 15:40:28 -070071 commit = main.ONOSbench.getVersion()
72 commit = (commit.split(" "))[1]
73
suibin584c0702015-07-14 15:57:27 -070074 resultsDB = open("/tmp/IntentInstallWithdrawLatDB", "w+")
cameron@onlab.us41c16f52015-07-08 15:40:28 -070075 resultsDB.close()
76
77 # -- END OF INIT SECTION --#
cameron@onlab.us41c16f52015-07-08 15:40:28 -070078
Jon Hall4ba53f02015-07-29 13:07:41 -070079 clusterCount = int(scale[0])
80 scale.remove(scale[0])
81
82 #kill off all onos processes
cameron@onlab.us41c16f52015-07-08 15:40:28 -070083 main.log.step("Safety check, killing all ONOS processes")
Jon Hall70b2ff42015-11-17 15:49:44 -080084 main.log.step("before initiating environment setup")
cameron@onlab.usceff56f2015-07-13 16:42:08 -070085 for node in range(1, main.maxNodes + 1):
cameron@onlab.us41c16f52015-07-08 15:40:28 -070086 main.ONOSbench.onosDie(ONOSIp[node])
Jon Hall4ba53f02015-07-29 13:07:41 -070087
cameron@onlab.us41c16f52015-07-08 15:40:28 -070088 #Uninstall everywhere
89 main.log.step( "Cleaning Enviornment..." )
cameron@onlab.usceff56f2015-07-13 16:42:08 -070090 for i in range(1, main.maxNodes + 1):
cameron@onlab.us41c16f52015-07-08 15:40:28 -070091 main.log.info(" Uninstalling ONOS " + str(i) )
92 main.ONOSbench.onosUninstall( ONOSIp[i] )
Jon Hall4ba53f02015-07-29 13:07:41 -070093
cameron@onlab.us41c16f52015-07-08 15:40:28 -070094 #construct the cell file
95 main.log.info("Creating cell file")
96 cellIp = []
97 for node in range (1, clusterCount + 1):
98 cellIp.append(ONOSIp[node])
99
cameron@onlab.usceff56f2015-07-13 16:42:08 -0700100 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), cellIp)
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700101
102 main.step( "Set Cell" )
103 main.ONOSbench.setCell(cellName)
Jon Hall4ba53f02015-07-29 13:07:41 -0700104
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700105 main.step( "Creating ONOS package" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700106 packageResult = main.ONOSbench.onosPackage()
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700107
108 main.step( "verify cells" )
109 verifyCellResult = main.ONOSbench.verifyCell()
Jon Hall4ba53f02015-07-29 13:07:41 -0700110
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700111 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
112 for node in range(1, clusterCount + 1):
113 main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
114 main.ONOSbench.onosInstall( ONOSIp[node])
115
116 for node in range(1, clusterCount + 1):
117 for i in range( 2 ):
118 isup = main.ONOSbench.isup( ONOSIp[node] )
119 if isup:
120 main.log.info("ONOS " + str(node) + " is up\n")
121 break
122 if not isup:
123 main.log.report( "ONOS " + str(node) + " didn't start!" )
124
125 main.ONOS1cli.startOnosCli( ONOSIp[1] )
126 main.log.info("Startup sequence complete")
Jon Hall4ba53f02015-07-29 13:07:41 -0700127
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700128 time.sleep(30)
Jon Hall4ba53f02015-07-29 13:07:41 -0700129
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700130 for i in range(3):
Jon Hall4ba53f02015-07-29 13:07:41 -0700131 main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.provider.nil.NullProviders", ("deviceCount " + str(switchCount)) )
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700132 main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "topoShape linear")
133 main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "enabled true")
134 if main.ONOSbench.verifySummary(ONOSIp[1], switchCount):
135 break
Jon Hall4ba53f02015-07-29 13:07:41 -0700136 else:
137 print "Failed- looping"
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700138
139 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
140 main.ONOSbench.handle.expect(":~")
141 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
142
143 def CASE2( self, main ):
Jon Hall4ba53f02015-07-29 13:07:41 -0700144
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700145 import time
146 import numpy
147
148 testStatus = "pass"
149 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
150 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
151 intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",")
152 switchCount = int(main.params[ 'TEST' ][ 'switchCount' ])
153 debug = main.params[ 'TEST' ][ 'switchCount' ]
154 for i in range(0,len(intentsList)):
155 intentsList[i] = int(intentsList[i])
156
157 ######################
158 debug = True
159 ######################
160
161 linkCount = 0
162 for i in range(0,10):
163 main.ONOSbench.handle.sendline("onos $OC1 links|wc -l")
164 main.ONOSbench.handle.expect(":~")
165 linkCount = main.ONOSbench.handle.before
166 if debug: main.log.info("Link Count check: " + linkCount)
167 if str((switchCount*2)-2) in linkCount:
168 break
169 time.sleep(2)
170
171 links = "--"
Jon Hall4ba53f02015-07-29 13:07:41 -0700172 for i in range(8):
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700173 if debug: main.log.info("top of loop")
174 main.ONOSbench.handle.sendline("onos $OC1 links")
175 main.ONOSbench.handle.expect(":~")
176 links = main.ONOSbench.handle.before
177 if "=null:" in links:
Jon Hall4ba53f02015-07-29 13:07:41 -0700178 break
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700179 if debug: main.log.info(str(links))
Jon Hall4ba53f02015-07-29 13:07:41 -0700180 if i > 3:
181 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], "d")
182 if i == 7:
183 main.log.error("link data missing")
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700184 time.sleep(3)
185
186 links = links.splitlines()
187 templinks = links
188
189 tempDevices = []
190 for line in links:
191 temp = line.split(" ")
192 temp[0].replace("src=","")
193 temp[0] = (temp[0].split("/"))[0]
194 tempDevices.append(temp[0])
195
196 tempDevices.sort()
197 devices = []
198 for i in tempDevices:
199 if "src=null" in i:
200 devices.append(i.replace("src=", ""))
201 if debug: main.log.info(str(devices))
202
203 ingress = devices[0]
204 egress = devices.pop()
205 if debug: main.log.info(ingress)
206 if debug: main.log.info(egress)
207
208 for intentSize in intentsList:
209 cmd = "onos $OC1 push-test-intents "
210 cmd += ingress + "/6 "
211 cmd += egress + "/5 "
212 cmd += str(intentSize) + " 1"
213 installed = []
214 withdrawn = []
GlennRC6018f842015-09-10 15:24:21 -0700215 testStatus = ""
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700216
217 for run in range(0, (warmUp + sampleSize)):
218 if run > warmUp:
219 time.sleep(5)
220
221 myRawResult = "--"
GlennRCd942a9f2015-08-25 13:00:49 -0700222
223 main.ONOSbench.handle.sendline(cmd)
224 main.ONOSbench.handle.expect(":~")
225 myRawResult = main.ONOSbench.handle.before
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700226
227 if debug: main.log.info(myRawResult)
228
229 if run >= warmUp:
230 myRawResult = myRawResult.splitlines()
231 for line in myRawResult:
GlennRC95f2bfb2015-09-11 09:53:33 -0700232 if "Failure:" in line:
233 main.log.error("INTENT TEST FAILURE, ABORTING TESTCASE")
234 testStatus = "fail"
235 break
236
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700237 if "install" in line:
238 installed.append(int(line.split(" ")[5]))
239
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700240 if "withdraw" in line:
241 withdrawn.append(int(line.split(" ")[5]))
242
GlennRC6018f842015-09-10 15:24:21 -0700243 if testStatus == "fail":
244 main.log.info("Installed: " + str(installed))
245 main.log.info("Withdrawn: " + str(withdrawn))
246 main.log.info("Scale: " + str(clusterCount))
247 main.log.info("Warmup: " + str(warmUp) + " SampleSize: " + str(sampleSize))
248 main.log.info("Run: " + str(run))
249 main.log.error("Skipping test case")
250 main.skipCase()
251
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700252 main.log.report("----------------------------------------------------")
253 main.log.report("Scale: " + str(clusterCount) + "\tIntent batch size: " + str(intentSize))
254 main.log.report("Data samples: " + str(sampleSize) + "\tWarm up tests: " + str(warmUp))
255 main.log.report("Installed average: " + str(numpy.mean(installed)))
256 main.log.report("Installed standard deviation: " + str(numpy.std(installed)))
257 main.log.report("Withdraw average: " + str(numpy.mean(withdrawn)))
258 main.log.report("Withdraw standard deviation: " + str(numpy.std(withdrawn)))
259 main.log.report(" ")
260
261 resultString = "'" + commit + "',"
262 resultString += str(clusterCount) + ","
263 resultString += str(intentSize) + ","
264 resultString += str(numpy.mean(installed)) + ","
265 resultString += str(numpy.std(installed)) + ","
266 resultString += str(numpy.mean(withdrawn)) + ","
267 resultString += str(numpy.std(withdrawn)) + "\n"
suibine1e58772015-07-15 09:52:59 -0700268 resultsDB = open("/tmp/IntentInstallWithdrawLatDB", "a")
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700269 resultsDB.write(resultString)
270 resultsDB.close()
271
272 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
273 time.sleep(20)