blob: ef92e582a0df627957ed774f829171abe27fcc75 [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
16 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
26 #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' ]
36 cellName = main.params[ 'ENV' ][ 'cellName' ]
37 switchCount = main.params[ 'TEST' ][ 'switchCount' ]
38
39 # -- 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
45 global commit
46
47 clusterCount = 0
48 ONOSIp = [ 0 ]
49 scale = (main.params[ 'SCALE' ]).split(",")
50 clusterCount = int(scale[0])
51
52 #Populate ONOSIp with ips from params
53 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" )
70
71 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 --#
78
79 clusterCount = int(scale[0])
80 scale.remove(scale[0])
81
cameron@onlab.us41c16f52015-07-08 15:40:28 -070082 #kill off all onos processes
83 main.log.step("Safety check, killing all ONOS processes")
84 main.log.step("before initiating enviornment 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])
87
88 #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] )
93
94 #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)
104
105 main.step( "Creating ONOS package" )
106 packageResult = main.ONOSbench.onosPackage()
107
108 main.step( "verify cells" )
109 verifyCellResult = main.ONOSbench.verifyCell()
110
111 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")
127
128 time.sleep(30)
129
130 for i in range(3):
131 main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.provider.nil.NullProviders", ("deviceCount " + str(switchCount)) )
132 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
136 else:
137 print "Failed- looping"
138
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 ):
144
145 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 = "--"
172 for i in range(8):
173 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:
178 break
179 if debug: main.log.info(str(links))
180 if i > 3:
181 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], "d")
182 if i == 7:
183 main.log.error("link data missing")
184 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 = []
215
216 for run in range(0, (warmUp + sampleSize)):
217 if run > warmUp:
218 time.sleep(5)
219
220 myRawResult = "--"
221 while "ms" not in myRawResult:
222 main.ONOSbench.handle.sendline(cmd)
223 main.ONOSbench.handle.expect(":~")
224 myRawResult = main.ONOSbench.handle.before
225 if debug: main.log.info(myRawResult)
226
227 if debug: main.log.info(myRawResult)
228
229 if run >= warmUp:
230 myRawResult = myRawResult.splitlines()
231 for line in myRawResult:
232 if "install" in line:
233 installed.append(int(line.split(" ")[5]))
234
235 for line in myRawResult:
236 if "withdraw" in line:
237 withdrawn.append(int(line.split(" ")[5]))
238
239 for line in myRawResult:
240 if "Failure:" in line:
241 main.log.error("INTENT TEST FAILURE, ABORTING TESTCASE")
242 testStatus = "fail"
243 if testStatus == "fail":
244 break
245
246 print("installed: " + str(installed))
247 print("withraw: " + str(withdrawn) + "\n")
248 if withdrawn[len(withdrawn) -1] > 1000 or installed[len(installed) -1] > 1000:
249 main.log.info("ABNORMAL VALUE, CHECKING LOG")
250 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
251
252 if testStatus == "fail":
253 break
254 main.log.report("----------------------------------------------------")
255 main.log.report("Scale: " + str(clusterCount) + "\tIntent batch size: " + str(intentSize))
256 main.log.report("Data samples: " + str(sampleSize) + "\tWarm up tests: " + str(warmUp))
257 main.log.report("Installed average: " + str(numpy.mean(installed)))
258 main.log.report("Installed standard deviation: " + str(numpy.std(installed)))
259 main.log.report("Withdraw average: " + str(numpy.mean(withdrawn)))
260 main.log.report("Withdraw standard deviation: " + str(numpy.std(withdrawn)))
261 main.log.report(" ")
262
263 resultString = "'" + commit + "',"
264 resultString += str(clusterCount) + ","
265 resultString += str(intentSize) + ","
266 resultString += str(numpy.mean(installed)) + ","
267 resultString += str(numpy.std(installed)) + ","
268 resultString += str(numpy.mean(withdrawn)) + ","
269 resultString += str(numpy.std(withdrawn)) + "\n"
suibine1e58772015-07-15 09:52:59 -0700270 resultsDB = open("/tmp/IntentInstallWithdrawLatDB", "a")
cameron@onlab.us41c16f52015-07-08 15:40:28 -0700271 resultsDB.write(resultString)
272 resultsDB.close()
273
274 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
275 time.sleep(20)