blob: 34e9a8df10819f4251b7f9de4146484edc7d2c69 [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' ]
34 maxNodes = int(main.params[ 'availableNodes' ])
35 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
74 resultsDB = open("IntentInstallWithdrawLatDB", "w+")
75 resultsDB.close()
76
77 # -- END OF INIT SECTION --#
78
79 clusterCount = int(scale[0])
80 scale.remove(scale[0])
81
82 MN1Ip = ONOSIp[len(ONOSIp)-1]
83 BENCHIp = ONOSIp[len(ONOSIp)-2]
84
85 #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
98 main.log.info("Creating cell file")
99 cellIp = []
100 for node in range (1, clusterCount + 1):
101 cellIp.append(ONOSIp[node])
102
103 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), *cellIp)
104
105 main.step( "Set Cell" )
106 main.ONOSbench.setCell(cellName)
107
108 main.step( "Creating ONOS package" )
109 packageResult = main.ONOSbench.onosPackage()
110
111 main.step( "verify cells" )
112 verifyCellResult = main.ONOSbench.verifyCell()
113
114 main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
115 for node in range(1, clusterCount + 1):
116 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):
120 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:
126 main.log.report( "ONOS " + str(node) + " didn't start!" )
127
128 main.ONOS1cli.startOnosCli( ONOSIp[1] )
129 main.log.info("Startup sequence complete")
130
131 time.sleep(30)
132
133 for i in range(3):
134 main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.provider.nil.NullProviders", ("deviceCount " + str(switchCount)) )
135 main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "topoShape linear")
136 main.ONOSbench.onosCfgSet( ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "enabled true")
137 if main.ONOSbench.verifySummary(ONOSIp[1], switchCount):
138 break
139 else:
140 print "Failed- looping"
141
142 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
143 main.ONOSbench.handle.expect(":~")
144 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
145
146 def CASE2( self, main ):
147
148 import time
149 import numpy
150
151 testStatus = "pass"
152 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
153 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
154 intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",")
155 switchCount = int(main.params[ 'TEST' ][ 'switchCount' ])
156 debug = main.params[ 'TEST' ][ 'switchCount' ]
157 for i in range(0,len(intentsList)):
158 intentsList[i] = int(intentsList[i])
159
160 ######################
161 debug = True
162 ######################
163
164 linkCount = 0
165 for i in range(0,10):
166 main.ONOSbench.handle.sendline("onos $OC1 links|wc -l")
167 main.ONOSbench.handle.expect(":~")
168 linkCount = main.ONOSbench.handle.before
169 if debug: main.log.info("Link Count check: " + linkCount)
170 if str((switchCount*2)-2) in linkCount:
171 break
172 time.sleep(2)
173
174 links = "--"
175 for i in range(8):
176 if debug: main.log.info("top of loop")
177 main.ONOSbench.handle.sendline("onos $OC1 links")
178 main.ONOSbench.handle.expect(":~")
179 links = main.ONOSbench.handle.before
180 if "=null:" in links:
181 break
182 if debug: main.log.info(str(links))
183 if i > 3:
184 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], "d")
185 if i == 7:
186 main.log.error("link data missing")
187 time.sleep(3)
188
189 links = links.splitlines()
190 templinks = links
191
192 tempDevices = []
193 for line in links:
194 temp = line.split(" ")
195 temp[0].replace("src=","")
196 temp[0] = (temp[0].split("/"))[0]
197 tempDevices.append(temp[0])
198
199 tempDevices.sort()
200 devices = []
201 for i in tempDevices:
202 if "src=null" in i:
203 devices.append(i.replace("src=", ""))
204 if debug: main.log.info(str(devices))
205
206 ingress = devices[0]
207 egress = devices.pop()
208 if debug: main.log.info(ingress)
209 if debug: main.log.info(egress)
210
211 for intentSize in intentsList:
212 cmd = "onos $OC1 push-test-intents "
213 cmd += ingress + "/6 "
214 cmd += egress + "/5 "
215 cmd += str(intentSize) + " 1"
216 installed = []
217 withdrawn = []
218
219 for run in range(0, (warmUp + sampleSize)):
220 if run > warmUp:
221 time.sleep(5)
222
223 myRawResult = "--"
224 while "ms" not in myRawResult:
225 main.ONOSbench.handle.sendline(cmd)
226 main.ONOSbench.handle.expect(":~")
227 myRawResult = main.ONOSbench.handle.before
228 if debug: main.log.info(myRawResult)
229
230 if debug: main.log.info(myRawResult)
231
232 if run >= warmUp:
233 myRawResult = myRawResult.splitlines()
234 for line in myRawResult:
235 if "install" in line:
236 installed.append(int(line.split(" ")[5]))
237
238 for line in myRawResult:
239 if "withdraw" in line:
240 withdrawn.append(int(line.split(" ")[5]))
241
242 for line in myRawResult:
243 if "Failure:" in line:
244 main.log.error("INTENT TEST FAILURE, ABORTING TESTCASE")
245 testStatus = "fail"
246 if testStatus == "fail":
247 break
248
249 print("installed: " + str(installed))
250 print("withraw: " + str(withdrawn) + "\n")
251 if withdrawn[len(withdrawn) -1] > 1000 or installed[len(installed) -1] > 1000:
252 main.log.info("ABNORMAL VALUE, CHECKING LOG")
253 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
254
255 if testStatus == "fail":
256 break
257 main.log.report("----------------------------------------------------")
258 main.log.report("Scale: " + str(clusterCount) + "\tIntent batch size: " + str(intentSize))
259 main.log.report("Data samples: " + str(sampleSize) + "\tWarm up tests: " + str(warmUp))
260 main.log.report("Installed average: " + str(numpy.mean(installed)))
261 main.log.report("Installed standard deviation: " + str(numpy.std(installed)))
262 main.log.report("Withdraw average: " + str(numpy.mean(withdrawn)))
263 main.log.report("Withdraw standard deviation: " + str(numpy.std(withdrawn)))
264 main.log.report(" ")
265
266 resultString = "'" + commit + "',"
267 resultString += str(clusterCount) + ","
268 resultString += str(intentSize) + ","
269 resultString += str(numpy.mean(installed)) + ","
270 resultString += str(numpy.std(installed)) + ","
271 resultString += str(numpy.mean(withdrawn)) + ","
272 resultString += str(numpy.std(withdrawn)) + "\n"
273 resultsDB = open("IntentInstallWithdrawLatDB", "a")
274 resultsDB.write(resultString)
275 resultsDB.close()
276
277 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
278 time.sleep(20)