blob: ec47721ef2ad7057fc99a14faa18110c6fd669a6 [file] [log] [blame]
YPZhang737d0012016-03-24 13:56:24 -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 SCPFintentInstallWithdrawLatWithFlowObj:
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 main.maxNodes = int(main.params[ 'max' ])
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("/tmp/IntentInstallWithdrawLatDBWFO", "w+")
75 resultsDB.close()
76
77 # -- END OF INIT SECTION --#
78
79 clusterCount = int(scale[0])
80 scale.remove(scale[0])
81
82 #kill off all onos processes
83 main.log.step("Safety check, killing all ONOS processes")
84 main.log.step("before initiating environment setup")
85 for node in range(1, main.maxNodes + 1):
86 main.ONOSbench.onosDie(ONOSIp[node])
87
88 #Uninstall everywhere
89 main.log.step( "Cleaning Enviornment..." )
90 for i in range(1, main.maxNodes + 1):
91 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
100 main.ONOSbench.createCellFile(BENCHIp,cellName,MN1Ip,str(Apps), cellIp)
101
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 main.ONOS1cli.setCfg( "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator"," useFlowObjectives","true" )
135 if main.ONOSbench.verifySummary(ONOSIp[1], switchCount):
136 break
137 else:
138 print "Failed- looping"
139
140 main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
141 main.ONOSbench.handle.expect(":~")
142 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
143
144 def CASE2( self, main ):
145
146 import time
147 import numpy
148
149 testStatus = "pass"
150 sampleSize = int(main.params[ 'TEST' ][ 'sampleSize' ])
151 warmUp = int(main.params[ 'TEST' ][ 'warmUp' ])
152 intentsList = (main.params[ 'TEST' ][ 'intents' ]).split(",")
153 switchCount = int(main.params[ 'TEST' ][ 'switchCount' ])
154 debug = main.params[ 'TEST' ][ 'switchCount' ]
155 for i in range(0,len(intentsList)):
156 intentsList[i] = int(intentsList[i])
157
158 ######################
159 debug = True
160 ######################
161
162 linkCount = 0
163 for i in range(0,10):
164 main.ONOSbench.handle.sendline("onos $OC1 links|wc -l")
165 main.ONOSbench.handle.expect(":~")
166 linkCount = main.ONOSbench.handle.before
167 if debug: main.log.info("Link Count check: " + linkCount)
168 if str((switchCount*2)-2) in linkCount:
169 break
170 time.sleep(2)
171
172 links = "--"
173 for i in range(8):
174 if debug: main.log.info("top of loop")
175 main.ONOSbench.handle.sendline("onos $OC1 links")
176 main.ONOSbench.handle.expect(":~")
177 links = main.ONOSbench.handle.before
178 if "=null:" in links:
179 break
180 if debug: main.log.info(str(links))
181 if i > 3:
182 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], "d")
183 if i == 7:
184 main.log.error("link data missing")
185 time.sleep(3)
186
187 links = links.splitlines()
188 templinks = links
189
190 tempDevices = []
191 for line in links:
192 temp = line.split(" ")
193 temp[0].replace("src=","")
194 temp[0] = (temp[0].split("/"))[0]
195 tempDevices.append(temp[0])
196
197 tempDevices.sort()
198 devices = []
199 for i in tempDevices:
200 if "src=null" in i:
201 devices.append(i.replace("src=", ""))
202 if debug: main.log.info(str(devices))
203
204 ingress = devices[0]
205 egress = devices.pop()
206 if debug: main.log.info(ingress)
207 if debug: main.log.info(egress)
208
209 for intentSize in intentsList:
210 cmd = "onos $OC1 push-test-intents "
211 cmd += ingress + "/6 "
212 cmd += egress + "/5 "
213 cmd += str(intentSize) + " 1"
214 installed = []
215 withdrawn = []
216 testStatus = ""
217
218 for run in range(0, (warmUp + sampleSize)):
219 if run > warmUp:
220 time.sleep(5)
221
222 myRawResult = "--"
223
224 main.ONOSbench.handle.sendline(cmd)
225 main.ONOSbench.handle.expect(":~")
226 myRawResult = main.ONOSbench.handle.before
227
228 if debug: main.log.info(myRawResult)
229
230 if run >= warmUp:
231 myRawResult = myRawResult.splitlines()
232 for line in myRawResult:
233 if "Failure:" in line:
234 main.log.error("INTENT TEST FAILURE, ABORTING TESTCASE")
235 testStatus = "fail"
236 break
237
238 if "install" in line:
239 installed.append(int(line.split(" ")[5]))
240
241 if "withdraw" in line:
242 withdrawn.append(int(line.split(" ")[5]))
243
244 if testStatus == "fail":
245 main.log.info("Installed: " + str(installed))
246 main.log.info("Withdrawn: " + str(withdrawn))
247 main.log.info("Scale: " + str(clusterCount))
248 main.log.info("Warmup: " + str(warmUp) + " SampleSize: " + str(sampleSize))
249 main.log.info("Run: " + str(run))
250 main.log.error("Skipping test case")
251 main.skipCase()
252
253 main.log.report("----------------------------------------------------")
254 main.log.report("Scale: " + str(clusterCount) + "\tIntent batch size: " + str(intentSize))
255 main.log.report("Data samples: " + str(sampleSize) + "\tWarm up tests: " + str(warmUp))
256 main.log.report("Installed average: " + str(numpy.mean(installed)))
257 main.log.report("Installed standard deviation: " + str(numpy.std(installed)))
258 main.log.report("Withdraw average: " + str(numpy.mean(withdrawn)))
259 main.log.report("Withdraw standard deviation: " + str(numpy.std(withdrawn)))
260 main.log.report(" ")
261
262 resultString = "'" + commit + "',"
263 resultString += str(clusterCount) + ","
264 resultString += str(intentSize) + ","
265 resultString += str(numpy.mean(installed)) + ","
266 resultString += str(numpy.std(installed)) + ","
267 resultString += str(numpy.mean(withdrawn)) + ","
268 resultString += str(numpy.std(withdrawn)) + "\n"
269 resultsDB = open("/tmp/IntentInstallWithdrawLatDBWFO", "a")
270 resultsDB.write(resultString)
271 resultsDB.close()
272
273 main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"])
274 time.sleep(20)