blob: 37da13839b03d338c7540906b7f16d0fb4ca0054 [file] [log] [blame]
YPZhangb34b7e12016-06-14 14:28:19 -07001"""
2SCPFintentInstallWithdrawLatWithFlowObj:
3 - Test the latency of intent installed and withdrawn
4 - Use Push-test-intents command to push intents
5 - Use Null provider with 7 devices and linear topology
6 - Always push intents between 1/6 and 7/5
7 - The batch size is defined in parm file. (default 1,100)
8 - org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator useFlowObjectives set
9 to true
10 yunpeng@onlab.us
11"""
YPZhang737d0012016-03-24 13:56:24 -070012
13import sys
14import os.path
15
16
17class SCPFintentInstallWithdrawLatWithFlowObj:
YPZhang737d0012016-03-24 13:56:24 -070018 def __init__( self ):
19 self.default = ''
YPZhangb34b7e12016-06-14 14:28:19 -070020
21 def CASE0( self, main ):
22 '''
23 - GIT
24 - BUILDING ONOS
25 Pull specific ONOS branch, then Build ONOS ono ONOS Bench.
26 This step is usually skipped. Because in a Jenkins driven automated
27 test env. We want Jenkins jobs to pull&build for flexibility to handle
28 different versions of ONOS.
29 - Construct tests variables
30 '''
31 gitPull = main.params['GIT']['gitPull']
32 gitBranch = main.params['GIT']['gitBranch']
33
34 main.case("Pull onos branch and build onos on Teststation.")
35
36 if gitPull == 'True':
37 main.step("Git Checkout ONOS branch: " + gitBranch)
38 stepResult = main.ONOSbench.gitCheckout(branch=gitBranch)
39 utilities.assert_equals(expect=main.TRUE,
40 actual=stepResult,
41 onpass="Successfully checkout onos branch.",
42 onfail="Failed to checkout onos branch. Exiting test...")
43 if not stepResult: main.exit()
44
45 main.step("Git Pull on ONOS branch:" + gitBranch)
46 stepResult = main.ONOSbench.gitPull()
47 utilities.assert_equals(expect=main.TRUE,
48 actual=stepResult,
49 onpass="Successfully pull onos. ",
50 onfail="Failed to pull onos. Exiting test ...")
51 if not stepResult: main.exit()
52
53 main.step("Building ONOS branch: " + gitBranch)
54 stepResult = main.ONOSbench.cleanInstall(skipTest=True)
55 utilities.assert_equals(expect=main.TRUE,
56 actual=stepResult,
57 onpass="Successfully build onos.",
58 onfail="Failed to build onos. Exiting test...")
59 if not stepResult: main.exit()
60
61 else:
62 main.log.warn("Skipped pulling onos and Skipped building ONOS")
63
64 main.apps = main.params['ENV']['cellApps']
65 main.BENCHUser = main.params['BENCH']['user']
66 main.BENCHIp = main.params['BENCH']['ip1']
67 main.MN1Ip = main.params['MN']['ip1']
68 main.maxNodes = int(main.params['max'])
69 main.cellName = main.params['ENV']['cellName']
70 main.scale = (main.params['SCALE']).split(",")
71 main.dbFileName = main.params['DATABASE']['file']
72 main.timeout = int(main.params['SLEEP']['timeout'])
73 main.startUpSleep = int(main.params['SLEEP']['startup'])
74 main.installSleep = int(main.params['SLEEP']['install'])
75 main.verifySleep = int(main.params['SLEEP']['verify'])
76 main.verifyAttempts = int(main.params['ATTEMPTS']['verify'])
77 main.sampleSize = int(main.params['TEST']['sampleSize'])
78 main.warmUp = int(main.params['TEST']['warmUp'])
79 main.intentsList = (main.params['TEST']['intents']).split(",")
80 main.ingress = main.params['TEST']['ingress']
81 main.egress = main.params['TEST']['egress']
82 main.debug = main.params['TEST']['debug']
83 for i in range(0, len(main.intentsList)):
84 main.intentsList[i] = int(main.intentsList[i])
85 # Create DataBase file
86 main.log.info("Create Database file " + main.dbFileName)
87 resultsDB = open(main.dbFileName, "w+")
88 resultsDB.close()
89
YPZhang737d0012016-03-24 13:56:24 -070090 def CASE1( self, main ):
YPZhangb34b7e12016-06-14 14:28:19 -070091 # Clean up test environment and set up
YPZhang737d0012016-03-24 13:56:24 -070092 import time
YPZhangb34b7e12016-06-14 14:28:19 -070093 main.log.info("Get ONOS cluster IP")
94 print(main.scale)
95 main.numCtrls = int(main.scale[0])
96 main.ONOSip = []
97 main.maxNumBatch = 0
98 main.AllONOSip = main.ONOSbench.getOnosIps()
99 for i in range(main.numCtrls):
100 main.ONOSip.append(main.AllONOSip[i])
101 main.log.info(main.ONOSip)
102 main.CLIs = []
103 main.log.info("Creating list of ONOS cli handles")
104 for i in range(main.numCtrls):
105 main.CLIs.append(getattr(main, 'ONOS%scli' % (i + 1)))
YPZhang737d0012016-03-24 13:56:24 -0700106
YPZhangb34b7e12016-06-14 14:28:19 -0700107 if not main.CLIs:
108 main.log.error("Failed to create the list of ONOS cli handles")
109 main.cleanup()
110 main.exit()
YPZhang737d0012016-03-24 13:56:24 -0700111
YPZhangb34b7e12016-06-14 14:28:19 -0700112 main.commit = main.ONOSbench.getVersion(report=True)
113 main.commit = main.commit.split(" ")[1]
114 main.log.info("Starting up %s node(s) ONOS cluster" % main.numCtrls)
115 main.log.info("Safety check, killing all ONOS processes" +
116 " before initiating environment setup")
YPZhang737d0012016-03-24 13:56:24 -0700117
YPZhangb34b7e12016-06-14 14:28:19 -0700118 for i in range(main.numCtrls):
119 main.ONOSbench.onosDie(main.ONOSip[i])
YPZhang737d0012016-03-24 13:56:24 -0700120
YPZhangb34b7e12016-06-14 14:28:19 -0700121 main.log.info("NODE COUNT = %s" % main.numCtrls)
122 main.ONOSbench.createCellFile(main.ONOSbench.ip_address,
123 main.cellName,
124 main.MN1Ip,
125 main.apps,
126 main.ONOSip)
127 main.step("Apply cell to environment")
128 cellResult = main.ONOSbench.setCell(main.cellName)
129 verifyResult = main.ONOSbench.verifyCell()
130 stepResult = cellResult and verifyResult
131 utilities.assert_equals(expect=main.TRUE,
132 actual=stepResult,
133 onpass="Successfully applied cell to " + \
134 "environment",
135 onfail="Failed to apply cell to environment ")
YPZhang737d0012016-03-24 13:56:24 -0700136
YPZhangb34b7e12016-06-14 14:28:19 -0700137 main.step("Creating ONOS package")
YPZhang737d0012016-03-24 13:56:24 -0700138 packageResult = main.ONOSbench.onosPackage()
YPZhangb34b7e12016-06-14 14:28:19 -0700139 stepResult = packageResult
140 utilities.assert_equals(expect=main.TRUE,
141 actual=stepResult,
142 onpass="Successfully created ONOS package",
143 onfail="Failed to create ONOS package")
YPZhang737d0012016-03-24 13:56:24 -0700144
YPZhangb34b7e12016-06-14 14:28:19 -0700145 main.step("Uninstall ONOS package on all Nodes")
146 uninstallResult = main.TRUE
147 for i in range(int(main.numCtrls)):
148 main.log.info("Uninstalling package on ONOS Node IP: " + main.ONOSip[i])
149 u_result = main.ONOSbench.onosUninstall(main.ONOSip[i])
150 utilities.assert_equals(expect=main.TRUE, actual=u_result,
151 onpass="Test step PASS",
152 onfail="Test step FAIL")
153 uninstallResult = (uninstallResult and u_result)
YPZhang737d0012016-03-24 13:56:24 -0700154
YPZhangb34b7e12016-06-14 14:28:19 -0700155 main.step("Install ONOS package on all Nodes")
156 installResult = main.TRUE
157 for i in range(int(main.numCtrls)):
158 main.log.info("Installing package on ONOS Node IP: " + main.ONOSip[i])
159 i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i])
160 utilities.assert_equals(expect=main.TRUE, actual=i_result,
161 onpass="Test step PASS",
162 onfail="Test step FAIL")
163 installResult = installResult and i_result
YPZhang737d0012016-03-24 13:56:24 -0700164
YPZhangb34b7e12016-06-14 14:28:19 -0700165 main.step("Verify ONOS nodes UP status")
166 statusResult = main.TRUE
167 for i in range(int(main.numCtrls)):
168 main.log.info("ONOS Node " + main.ONOSip[i] + " status:")
169 onos_status = main.ONOSbench.onosStatus(node=main.ONOSip[i])
170 utilities.assert_equals(expect=main.TRUE, actual=onos_status,
171 onpass="Test step PASS",
172 onfail="Test step FAIL")
173 statusResult = (statusResult and onos_status)
174 time.sleep(2)
175 main.step("Start ONOS CLI on all nodes")
176 cliResult = main.TRUE
Jon Hall6509dbf2016-06-21 17:01:17 -0700177 main.step(" Start ONOS cli using thread ")
YPZhangb34b7e12016-06-14 14:28:19 -0700178 startCliResult = main.TRUE
179 pool = []
180 main.threadID = 0
181 for i in range(int(main.numCtrls)):
182 t = main.Thread(target=main.CLIs[i].startOnosCli,
183 threadID=main.threadID,
184 name="startOnosCli",
185 args=[main.ONOSip[i]],
186 kwargs={"onosStartTimeout": main.timeout})
187 pool.append(t)
188 t.start()
189 main.threadID = main.threadID + 1
190 for t in pool:
191 t.join()
192 startCliResult = startCliResult and t.result
193 time.sleep(main.startUpSleep)
YPZhang737d0012016-03-24 13:56:24 -0700194
YPZhangb34b7e12016-06-14 14:28:19 -0700195 # configure apps
196 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=7)
197 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="linear")
198 main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
YPZhang98c609f2016-06-21 12:34:05 -0700199 main.CLIs[0].setCfg("org.onosproject.net.intent.impl.IntentManager",
200 "skipReleaseResourcesOnWithdrawal", value="true")
YPZhangb34b7e12016-06-14 14:28:19 -0700201 main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
202 "useFlowObjectives", value="true")
203 time.sleep(main.startUpSleep)
YPZhang737d0012016-03-24 13:56:24 -0700204
YPZhangb34b7e12016-06-14 14:28:19 -0700205 # balanceMasters
206 main.CLIs[0].balanceMasters()
You Wang3b148ea2016-06-20 20:33:42 -0700207 time.sleep(main.startUpSleep)
YPZhang737d0012016-03-24 13:56:24 -0700208
209 def CASE2( self, main ):
YPZhang737d0012016-03-24 13:56:24 -0700210 import time
211 import numpy
YPZhangb34b7e12016-06-14 14:28:19 -0700212 import json
213 print(main.intentsList)
214 for batchSize in main.intentsList:
215 main.log.report("Intent Batch size: {}".format(batchSize))
216 main.installLatList = []
217 main.withdrawLatList = []
218 validrun = 0
219 invalidrun = 0
220 # we use two variables to control the iteration
221 while validrun <= main.warmUp + main.sampleSize and invalidrun < 20:
222 if validrun >= main.warmUp:
223 main.log.info("================================================")
224 main.log.info("Starting test iteration " + str(validrun - main.warmUp))
225 main.log.info("Total test iteration: " + str(invalidrun + validrun))
226 main.log.info("================================================")
227 else:
228 main.log.info("====================Warm Up=====================")
YPZhang737d0012016-03-24 13:56:24 -0700229
YPZhangb34b7e12016-06-14 14:28:19 -0700230 # push intents
231 installResult = main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize,
232 offset=1, options="-i", timeout=main.timeout,
233 getResponse=True)
234 if type(installResult) is str:
235 if "Failure" in installResult:
236 main.log.error("Install Intents failure, ignore this iteration.")
237 if validrun < main.warmUp:
238 validrun += 1
239 continue
240 else:
241 invalidrun += 1
242 continue
YPZhang737d0012016-03-24 13:56:24 -0700243
YPZhangb34b7e12016-06-14 14:28:19 -0700244 try:
245 latency = int(installResult.split()[5])
246 main.log.info(installResult)
247 except:
248 main.log.error("Failed to get latency, ignore this iteration.")
249 main.log.error("Response from ONOS:")
250 print(installResult)
251 if validrun < main.warmUp:
252 validrun += 1
253 continue
254 else:
255 invalidrun += 1
256 continue
YPZhang737d0012016-03-24 13:56:24 -0700257
YPZhangb34b7e12016-06-14 14:28:19 -0700258 if validrun >= main.warmUp:
259 main.installLatList.append(latency)
260 else:
261 invalidrun += 1
262 continue
263 time.sleep(2)
264 # Withdraw Intents
265 withdrawResult = main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize,
266 offset=1, options="-w", timeout=main.timeout,
267 getResponse=True)
YPZhang737d0012016-03-24 13:56:24 -0700268
YPZhangb34b7e12016-06-14 14:28:19 -0700269 if type(withdrawResult) is str:
270 if "Failure" in withdrawResult:
271 main.log.error("withdraw Intents failure, ignore this iteration.")
272 if validrun < main.warmUp:
273 validrun += 1
274 continue
275 else:
276 invalidrun += 1
277 continue
YPZhang737d0012016-03-24 13:56:24 -0700278
YPZhangb34b7e12016-06-14 14:28:19 -0700279 try:
280 latency = int(withdrawResult.split()[5])
281 main.log.info(withdrawResult)
282 except:
283 main.log.error("Failed to get latency, ignore this iteration.")
284 main.log.error("Response from ONOS:")
285 print(withdrawResult)
286 if validrun < main.warmUp:
287 validrun += 1
288 continue
289 else:
290 invalidrun += 1
291 continue
YPZhang737d0012016-03-24 13:56:24 -0700292
YPZhangb34b7e12016-06-14 14:28:19 -0700293 if validrun >= main.warmUp:
294 main.withdrawLatList.append(latency)
295 else:
296 invalidrun += 1
297 continue
298 time.sleep(2)
299 main.CLIs[0].purgeWithdrawnIntents()
300 validrun += 1
301 installave = numpy.average(main.installLatList)
302 installstd = numpy.std(main.installLatList)
303 withdrawave = numpy.average(main.withdrawLatList)
304 withdrawstd = numpy.std(main.withdrawLatList)
305 # log report
YPZhang737d0012016-03-24 13:56:24 -0700306 main.log.report("----------------------------------------------------")
YPZhangb34b7e12016-06-14 14:28:19 -0700307 main.log.report("Scale: " + str(main.numCtrls))
308 main.log.report("Intent batch: " + str(batchSize))
309 main.log.report("Install average: {} std: {}".format(installave, installstd))
310 main.log.report("Withdraw average: {} std: {}".format(withdrawave, withdrawstd))
311 # write result to database file
312 if not (numpy.isnan(installave) or numpy.isnan(installstd) or \
313 numpy.isnan(withdrawstd) or numpy.isnan(withdrawave)):
314 databaseString = "'" + main.commit + "',"
315 databaseString += str(main.numCtrls) + ","
316 databaseString += str(batchSize) + ","
317 databaseString += str(installave) + ","
318 databaseString += str(installstd) + ","
319 databaseString += str(withdrawave) + ","
320 databaseString += str(withdrawstd) + "\n"
321 resultsDB = open(main.dbFileName, "a")
322 resultsDB.write(databaseString)
323 resultsDB.close()
324 del main.scale[0]