blob: 422f1c9eaccdc2e8742a050839f6ed6d54530f69 [file] [log] [blame]
andrewonlab79244cc2015-01-26 01:11:49 -05001# Intent Performance Test for ONOS-next
andrewonlab92ea3672014-11-04 20:22:14 -05002#
andrewonlab79244cc2015-01-26 01:11:49 -05003# andrew@onlab.us
andrewonlab8790abb2014-11-06 13:51:54 -05004#
andrewonlab79244cc2015-01-26 01:11:49 -05005# November 5, 2014
6
andrewonlab92ea3672014-11-04 20:22:14 -05007
8class IntentPerfNext:
andrewonlab79244cc2015-01-26 01:11:49 -05009
10 def __init__( self ):
andrewonlab92ea3672014-11-04 20:22:14 -050011 self.default = ""
12
andrewonlab79244cc2015-01-26 01:11:49 -050013 def CASE1( self, main ):
14 """
andrewonlab92ea3672014-11-04 20:22:14 -050015 ONOS startup sequence
andrewonlab79244cc2015-01-26 01:11:49 -050016 """
andrewonlab92ea3672014-11-04 20:22:14 -050017 import time
andrewonlab79244cc2015-01-26 01:11:49 -050018 global clusterCount
andrewonlab302cd532015-02-20 13:59:50 -050019 global timeToPost
20 global runNum
21
andrewonlab79244cc2015-01-26 01:11:49 -050022 clusterCount = 1
andrewonlab302cd532015-02-20 13:59:50 -050023 timeToPost = time.strftime("%Y-%m-%d %H:%M:%S")
24 runNum = time.strftime("%d%H%M%S")
andrewonlab92ea3672014-11-04 20:22:14 -050025
andrewonlab79244cc2015-01-26 01:11:49 -050026 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrewonlab92ea3672014-11-04 20:22:14 -050027
andrewonlab79244cc2015-01-26 01:11:49 -050028 gitPull = main.params[ 'GIT' ][ 'autoPull' ]
29 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
andrewonlab302cd532015-02-20 13:59:50 -050030 intentFilePath = main.params[ 'DB' ][ 'intentFilePath' ]
andrewonlab92ea3672014-11-04 20:22:14 -050031
andrewonlab082dfc32015-02-06 13:59:51 -050032 ONOSIp = []
33 for i in range(1, 8):
34 ONOSIp.append(main.params[ 'CTRL' ][ 'ip'+str(i) ])
35 main.ONOSbench.onosUninstall( nodeIp = ONOSIp[i-1] )
andrewonlab4293dcb2014-12-02 15:48:05 -050036
andrewonlab79244cc2015-01-26 01:11:49 -050037 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
38 BENCHIp = main.params[ 'BENCH' ][ 'ip' ]
andrewonlab92ea3672014-11-04 20:22:14 -050039
andrewonlab79244cc2015-01-26 01:11:49 -050040 main.case( "Setting up test environment" )
andrewonlab92ea3672014-11-04 20:22:14 -050041
andrewonlab302cd532015-02-20 13:59:50 -050042 main.step( "Clearing previous DB log file" )
43 fIntentLog = open(intentFilePath, 'w')
44 # Overwrite with empty line and close
45 fIntentLog.write('')
46 fIntentLog.close()
47
andrewonlab5b954b02015-02-05 13:03:46 -050048 main.step( "Starting mininet topology" )
49 main.Mininet1.startNet()
50
andrewonlab79244cc2015-01-26 01:11:49 -050051 main.step( "Creating cell file" )
52 cellFileResult = main.ONOSbench.createCellFile(
53 BENCHIp, cellName, MN1Ip,
andrewonlabe07f8562015-02-20 12:23:07 -050054 ("onos-core,webconsole,onos-api,onos-app-metrics,onos-gui,"
55 "onos-cli,onos-openflow"),
andrewonlab082dfc32015-02-06 13:59:51 -050056 ONOSIp[0] )
andrewonlab92ea3672014-11-04 20:22:14 -050057
andrewonlab79244cc2015-01-26 01:11:49 -050058 main.step( "Applying cell file to environment" )
59 cellApplyResult = main.ONOSbench.setCell( cellName )
60 verifyCellResult = main.ONOSbench.verifyCell()
andrewonlab4293dcb2014-12-02 15:48:05 -050061
andrewonlab79244cc2015-01-26 01:11:49 -050062 main.step( "Removing raft logs" )
63 main.ONOSbench.onosRemoveRaftLogs()
64
65 main.step( "Git checkout and pull " + checkoutBranch )
66 if gitPull == 'on':
67 checkoutResult = \
68 main.ONOSbench.gitCheckout( checkoutBranch )
69 pullResult = main.ONOSbench.gitPull()
70
71 # If you used git pull, auto compile
72 main.step( "Using onos-build to compile ONOS" )
73 buildResult = main.ONOSbench.onosBuild()
andrewonlab92ea3672014-11-04 20:22:14 -050074 else:
andrewonlab79244cc2015-01-26 01:11:49 -050075 checkoutResult = main.TRUE
76 pullResult = main.TRUE
77 buildResult = main.TRUE
78 main.log.info( "Git pull skipped by configuration" )
andrewonlab92ea3672014-11-04 20:22:14 -050079
andrewonlab79244cc2015-01-26 01:11:49 -050080 main.log.report( "Commit information - " )
81 main.ONOSbench.getVersion( report=True )
andrewonlab4cf9dd22014-11-18 21:28:38 -050082
andrewonlab79244cc2015-01-26 01:11:49 -050083 main.step( "Creating ONOS package" )
84 packageResult = main.ONOSbench.onosPackage()
andrewonlab92ea3672014-11-04 20:22:14 -050085
andrewonlab79244cc2015-01-26 01:11:49 -050086 main.step( "Installing ONOS package" )
andrewonlab082dfc32015-02-06 13:59:51 -050087 install1Result = main.ONOSbench.onosInstall( node=ONOSIp[0] )
andrewonlab92ea3672014-11-04 20:22:14 -050088
andrewonlab79244cc2015-01-26 01:11:49 -050089 main.step( "Set cell for ONOScli env" )
90 main.ONOS1cli.setCell( cellName )
andrewonlab92ea3672014-11-04 20:22:14 -050091
andrewonlab79244cc2015-01-26 01:11:49 -050092 time.sleep( 5 )
andrewonlab92ea3672014-11-04 20:22:14 -050093
andrewonlab79244cc2015-01-26 01:11:49 -050094 main.step( "Start onos cli" )
andrewonlab082dfc32015-02-06 13:59:51 -050095 cli1 = main.ONOS1cli.startOnosCli( ONOSIp[0] )
andrewonlab92ea3672014-11-04 20:22:14 -050096
andrewonlab79244cc2015-01-26 01:11:49 -050097 utilities.assert_equals( expect=main.TRUE,
98 actual=cellFileResult and cellApplyResult and
99 verifyCellResult and checkoutResult and
100 pullResult and buildResult and
101 install1Result, # and install2Result and
102 # install3Result,
103 onpass="ONOS started successfully",
104 onfail="Failed to start ONOS" )
andrewonlab92ea3672014-11-04 20:22:14 -0500105
andrewonlab79244cc2015-01-26 01:11:49 -0500106 def CASE2( self, main ):
107 """
andrewonlab92ea3672014-11-04 20:22:14 -0500108 Single intent add latency
109
andrewonlab79244cc2015-01-26 01:11:49 -0500110 """
andrewonlab92ea3672014-11-04 20:22:14 -0500111 import time
112 import json
113 import requests
114 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500115 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500116 global clusterCount
andrewonlab92ea3672014-11-04 20:22:14 -0500117
andrewonlab79244cc2015-01-26 01:11:49 -0500118 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
119 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
120 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
121 ONOSIpList = []
122 for i in range( 1, 8 ):
123 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlab92ea3672014-11-04 20:22:14 -0500124
andrewonlab79244cc2015-01-26 01:11:49 -0500125 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab92ea3672014-11-04 20:22:14 -0500126
andrewonlab79244cc2015-01-26 01:11:49 -0500127 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab92ea3672014-11-04 20:22:14 -0500128
andrewonlab79244cc2015-01-26 01:11:49 -0500129 # number of iterations of case
130 numIter = main.params[ 'TEST' ][ 'numIter' ]
131 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
132
133 # Timestamp keys for json metrics output
134 submitTime = main.params[ 'JSON' ][ 'submittedTime' ]
135 installTime = main.params[ 'JSON' ][ 'installedTime' ]
136 wdRequestTime = main.params[ 'JSON' ][ 'wdRequestTime' ]
137 withdrawnTime = main.params[ 'JSON' ][ 'withdrawnTime' ]
138
andrewonlaba57a3042015-01-23 13:53:05 -0500139 assertion = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800140
andrewonlab79244cc2015-01-26 01:11:49 -0500141 intentAddLatList = []
142
143 # Distribute switches according to cluster count
144 for i in range( 1, 9 ):
145 if clusterCount == 1:
146 main.Mininet1.assignSwController(
147 sw=str( i ), ip1=ONOSIpList[ 0 ],
148 port1=defaultSwPort
149 )
150 elif clusterCount == 3:
andrewonlaba57a3042015-01-23 13:53:05 -0500151 if i < 3:
152 index = 0
153 elif i < 6 and i >= 3:
154 index = 1
155 else:
156 index = 2
andrewonlab79244cc2015-01-26 01:11:49 -0500157 main.Mininet1.assignSwController(
158 sw=str( i ), ip1=ONOSIpList[ index ],
159 port1=defaultSwPort
160 )
161 elif clusterCount == 5:
andrewonlaba57a3042015-01-23 13:53:05 -0500162 if i < 3:
163 index = 0
164 elif i < 5 and i >= 3:
165 index = 1
166 elif i < 7 and i >= 5:
167 index = 2
168 elif i == 7:
169 index = 3
170 else:
171 index = 4
andrewonlab79244cc2015-01-26 01:11:49 -0500172 main.Mininet1.assignSwController(
173 sw=str( i ), ip1=ONOSIpList[ index ],
174 port1=defaultSwPort
175 )
176 elif clusterCount == 7:
andrewonlaba57a3042015-01-23 13:53:05 -0500177 if i < 6:
178 index = i
179 else:
180 index = 6
andrewonlab79244cc2015-01-26 01:11:49 -0500181 main.Mininet1.assignSwController(
182 sw=str( i ), ip1=ONOSIpList[ index ],
183 port1=defaultSwPort
184 )
andrewonlab70decc02014-11-19 18:50:23 -0500185
andrewonlab79244cc2015-01-26 01:11:49 -0500186 time.sleep( 10 )
andrewonlab70decc02014-11-19 18:50:23 -0500187
andrewonlab79244cc2015-01-26 01:11:49 -0500188 main.log.report( "Single intent add latency test" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500189
andrewonlab79244cc2015-01-26 01:11:49 -0500190 devicesJsonStr = main.ONOS1cli.devices()
191 devicesJsonObj = json.loads( devicesJsonStr )
192
193 if not devicesJsonObj:
194 main.log.report( "Devices not discovered" )
195 main.log.report( "Aborting test" )
andrewonlaba57a3042015-01-23 13:53:05 -0500196 main.exit()
197 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500198 main.log.info( "Devices discovered successfully" )
andrewonlaba57a3042015-01-23 13:53:05 -0500199
andrewonlab79244cc2015-01-26 01:11:49 -0500200 deviceIdList = []
andrewonlab92ea3672014-11-04 20:22:14 -0500201
andrewonlab79244cc2015-01-26 01:11:49 -0500202 # Obtain device id list in ONOS format.
203 # They should already be in order ( 1,2,3,10,11,12,13, etc )
204 for device in devicesJsonObj:
205 deviceIdList.append( device[ 'id' ] )
andrewonlab92ea3672014-11-04 20:22:14 -0500206
andrewonlab79244cc2015-01-26 01:11:49 -0500207 for i in range( 0, int( numIter ) ):
208 # addPointIntent( ingrDevice, egrDevice,
209 # ingrPort, egrPort )
210 main.ONOS1cli.addPointIntent(
211 deviceIdList[ 0 ] + "/2", deviceIdList[ 7 ] + "/2" )
212
213 # Allow some time for intents to propagate
214 time.sleep( 5 )
215
216 intentsStr = main.ONOS1cli.intents( jsonFormat=True )
217 intentsObj = json.loads( intentsStr )
218 for intent in intentsObj:
219 if intent[ 'state' ] == "INSTALLED":
220 main.log.info( "Intent installed successfully" )
221 intentId = intent[ 'id' ]
222 main.log.info( "Intent id: " + str( intentId ) )
andrewonlaba57a3042015-01-23 13:53:05 -0500223 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500224 # TODO: Add error handling
225 main.log.info( "Intent installation failed" )
226 intentId = ""
andrewonlab92ea3672014-11-04 20:22:14 -0500227
andrewonlab79244cc2015-01-26 01:11:49 -0500228 # Obtain metrics from ONOS 1, 2, 3
229 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
230 intentsJsonObj1 = json.loads( intentsJsonStr1 )
231 # Parse values from the json object
232 intentSubmit1 = \
233 intentsJsonObj1[ submitTime ][ 'value' ]
234 intentInstall1 = \
235 intentsJsonObj1[ installTime ][ 'value' ]
236 intentInstallLat1 = \
237 int( intentInstall1 ) - int( intentSubmit1 )
238
239 if clusterCount == 3:
240 intentsJsonStr2 = main.ONOS2cli.intentsEventsMetrics()
241 intentsJsonStr3 = main.ONOS3cli.intentsEventsMetrics()
242 intentsJsonObj2 = json.loads( intentsJsonStr2 )
243 intentsJsonObj3 = json.loads( intentsJsonStr3 )
244 intentSubmit2 = \
245 intentsJsonObj2[ submitTime ][ 'value' ]
246 intentSubmit3 = \
247 intentsJsonObj3[ submitTime ][ 'value' ]
248 intentInstall2 = \
249 intentsJsonObj2[ installTime ][ 'value' ]
250 intentInstall3 = \
251 intentsJsonObj3[ installTime ][ 'value' ]
252 intentInstallLat2 = \
253 int( intentInstall2 ) - int( intentSubmit2 )
254 intentInstallLat3 = \
255 int( intentInstall3 ) - int( intentSubmit3 )
andrewonlaba57a3042015-01-23 13:53:05 -0500256 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500257 intentInstallLat2 = 0
258 intentInstallLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500259
andrewonlab79244cc2015-01-26 01:11:49 -0500260 if clusterCount == 5:
261 intentsJsonStr4 = main.ONOS4cli.intentsEventsMetrics()
262 intentsJsonStr5 = main.ONOS5cli.intentsEventsMetrics()
263 intentsJsonObj4 = json.loads( intentsJsonStr4 )
264 intentsJsonObj5 = json.loads( intentsJsonStr5 )
265 intentSubmit4 = \
266 intentsJsonObj4[ submitTime ][ 'value' ]
267 intentSubmit5 = \
268 intentsJsonObj5[ submitTime ][ 'value' ]
269 intentInstall4 = \
270 intentsJsonObj5[ installTime ][ 'value' ]
271 intentInstall5 = \
272 intentsJsonObj5[ installTime ][ 'value' ]
273 intentInstallLat4 = \
274 int( intentInstall4 ) - int( intentSubmit4 )
275 intentInstallLat5 = \
276 int( intentInstall5 ) - int( intentSubmit5 )
andrewonlaba57a3042015-01-23 13:53:05 -0500277 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500278 intentInstallLat4 = 0
279 intentInstallLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500280
andrewonlab79244cc2015-01-26 01:11:49 -0500281 if clusterCount == 7:
282 intentsJsonStr6 = main.ONOS6cli.intentsEventsMetrics()
283 intentsJsonStr7 = main.ONOS7cli.intentsEventsMetrics()
284 intentsJsonObj6 = json.loads( intentsJsonStr6 )
285 intentsJsonObj7 = json.loads( intentsJsonStr7 )
286 intentSubmit6 = \
287 intentsJsonObj6[ submitTime ][ 'value' ]
288 intentSubmit7 = \
289 intentsJsonObj6[ submitTime ][ 'value' ]
290 intentInstall6 = \
291 intentsJsonObj6[ installTime ][ 'value' ]
292 intentInstall7 = \
293 intentsJsonObj7[ installTime ][ 'value' ]
294 intentInstallLat6 = \
295 int( intentInstall6 ) - int( intentSubmit6 )
296 intentInstallLat7 = \
297 int( intentInstall7 ) - int( intentSubmit7 )
andrewonlaba57a3042015-01-23 13:53:05 -0500298 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500299 intentInstallLat6 = 0
300 intentInstallLat7 = 0
andrewonlab8790abb2014-11-06 13:51:54 -0500301
andrewonlab79244cc2015-01-26 01:11:49 -0500302 intentInstallLatAvg = \
303 ( intentInstallLat1 +
304 intentInstallLat2 +
305 intentInstallLat3 +
306 intentInstallLat4 +
307 intentInstallLat5 +
308 intentInstallLat6 +
309 intentInstallLat7 ) / clusterCount
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800310
andrewonlab79244cc2015-01-26 01:11:49 -0500311 main.log.info( "Intent add latency avg for iteration " + str( i ) +
312 ": " + str( intentInstallLatAvg ) + " ms" )
andrewonlab8790abb2014-11-06 13:51:54 -0500313
andrewonlab79244cc2015-01-26 01:11:49 -0500314 if intentInstallLatAvg > 0.0 and \
315 intentInstallLatAvg < 1000 and i > numIgnore:
316 intentAddLatList.append( intentInstallLatAvg )
andrewonlab8790abb2014-11-06 13:51:54 -0500317 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500318 main.log.info( "Intent add latency exceeded " +
319 "threshold. Skipping iteration " + str( i ) )
andrewonlab8790abb2014-11-06 13:51:54 -0500320
andrewonlab79244cc2015-01-26 01:11:49 -0500321 time.sleep( 3 )
322
323 # TODO: Only remove intents that were installed
andrewonlaba57a3042015-01-23 13:53:05 -0500324 # in this case... Otherwise many other intents
325 # may show up distorting the results
andrewonlab79244cc2015-01-26 01:11:49 -0500326 main.log.info( "Removing intents for next iteration" )
327 jsonTemp = \
328 main.ONOS1cli.intents( jsonFormat=True )
329 jsonObjIntents = json.loads( jsonTemp )
330 if jsonObjIntents:
331 for intents in jsonObjIntents:
332 tempId = intents[ 'id' ]
333 # main.ONOS1cli.removeIntent( tempId )
334 main.log.info( "Removing intent id: " +
335 str( tempId ) )
336 main.ONOS1cli.removeIntent( tempId )
andrewonlab8790abb2014-11-06 13:51:54 -0500337 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500338 main.log.info( "Intents were not installed correctly" )
andrewonlab8790abb2014-11-06 13:51:54 -0500339
andrewonlab79244cc2015-01-26 01:11:49 -0500340 time.sleep( 5 )
andrewonlab8790abb2014-11-06 13:51:54 -0500341
andrewonlab79244cc2015-01-26 01:11:49 -0500342 if intentAddLatList:
343 intentAddLatAvg = sum( intentAddLatList ) /\
344 len( intentAddLatList )
andrewonlaba57a3042015-01-23 13:53:05 -0500345 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500346 main.log.report( "Intent installation latency test failed" )
347 intentAddLatAvg = "NA"
andrewonlaba57a3042015-01-23 13:53:05 -0500348 assertion = main.FALSE
349
andrewonlab79244cc2015-01-26 01:11:49 -0500350 intentAddLatStd = \
351 round( numpy.std( intentAddLatList ), 1 )
352 # END ITERATION FOR LOOP
353 main.log.report( "Single intent add latency - " )
354 main.log.report( "Avg: " + str( intentAddLatAvg ) + " ms" )
355 main.log.report( "Std Deviation: " + str( intentAddLatStd ) + " ms" )
356
357 utilities.assert_equals(
358 expect=main.TRUE,
359 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500360 onpass="Single intent install latency test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500361 onfail="Single intent install latency test failed" )
andrewonlab92ea3672014-11-04 20:22:14 -0500362
andrewonlab79244cc2015-01-26 01:11:49 -0500363 def CASE3( self, main ):
364 """
andrewonlab4cf9dd22014-11-18 21:28:38 -0500365 Intent Reroute latency
andrewonlab79244cc2015-01-26 01:11:49 -0500366 """
andrewonlab4cf9dd22014-11-18 21:28:38 -0500367 import time
368 import json
369 import requests
370 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500371 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500372 global clusterCount
andrewonlab4cf9dd22014-11-18 21:28:38 -0500373
andrewonlab79244cc2015-01-26 01:11:49 -0500374 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
375 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
376 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
377 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab4cf9dd22014-11-18 21:28:38 -0500378
andrewonlab79244cc2015-01-26 01:11:49 -0500379 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab4cf9dd22014-11-18 21:28:38 -0500380
andrewonlab79244cc2015-01-26 01:11:49 -0500381 # number of iterations of case
382 numIter = main.params[ 'TEST' ][ 'numIter' ]
383 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
andrewonlaba57a3042015-01-23 13:53:05 -0500384 assertion = main.TRUE
andrewonlab4cf9dd22014-11-18 21:28:38 -0500385
andrewonlab79244cc2015-01-26 01:11:49 -0500386 # Timestamp keys for json metrics output
387 submitTime = main.params[ 'JSON' ][ 'submittedTime' ]
388 installTime = main.params[ 'JSON' ][ 'installedTime' ]
389 wdRequestTime = main.params[ 'JSON' ][ 'wdRequestTime' ]
390 withdrawnTime = main.params[ 'JSON' ][ 'withdrawnTime' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500391
andrewonlab79244cc2015-01-26 01:11:49 -0500392 # NOTE: May need to configure interface depending on topology
393 intfs = main.params[ 'TEST' ][ 'intfs' ]
andrewonlab70decc02014-11-19 18:50:23 -0500394
andrewonlab79244cc2015-01-26 01:11:49 -0500395 devicesJsonStr = main.ONOS1cli.devices()
396 devicesJsonObj = json.loads( devicesJsonStr )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500397
andrewonlab79244cc2015-01-26 01:11:49 -0500398 deviceIdList = []
andrewonlab4cf9dd22014-11-18 21:28:38 -0500399
andrewonlab79244cc2015-01-26 01:11:49 -0500400 # Obtain device id list in ONOS format.
401 # They should already be in order ( 1,2,3,10,11,12,13, etc )
402 for device in devicesJsonObj:
403 deviceIdList.append( device[ 'id' ] )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500404
andrewonlab79244cc2015-01-26 01:11:49 -0500405 intentRerouteLatList = []
andrewonlab4cf9dd22014-11-18 21:28:38 -0500406
andrewonlab79244cc2015-01-26 01:11:49 -0500407 for i in range( 0, int( numIter ) ):
408 # addPointIntent( ingrDevice, ingrPort,
409 # egrDevice, egrPort )
410 if len( deviceIdList ) > 0:
411 main.ONOS1cli.addPointIntent(
412 deviceIdList[ 0 ] + "/2", deviceIdList[ 7 ] + "/2" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500413 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500414 main.log.info( "Failed to fetch devices from ONOS" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500415
andrewonlab79244cc2015-01-26 01:11:49 -0500416 time.sleep( 5 )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500417
andrewonlab79244cc2015-01-26 01:11:49 -0500418 intentsStr = main.ONOS1cli.intents( jsonFormat=True )
419 intentsObj = json.loads( intentsStr )
420 for intent in intentsObj:
421 if intent[ 'state' ] == "INSTALLED":
422 main.log.info( "Intent installed successfully" )
423 intentId = intent[ 'id' ]
424 main.log.info( "Intent id: " + str( intentId ) )
andrewonlab70decc02014-11-19 18:50:23 -0500425 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500426 # TODO: Add error handling
427 main.log.info( "Intent installation failed" )
428 intentId = ""
429
430 main.log.info( "Disabling interface " + intfs )
431 t0System = time.time() * 1000
andrewonlab4cf9dd22014-11-18 21:28:38 -0500432 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500433 "sh ifconfig " + intfs + " down" )
434 main.Mininet1.handle.expect( "mininet>" )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500435
andrewonlab79244cc2015-01-26 01:11:49 -0500436 # TODO: Check for correct intent reroute
437 time.sleep( 1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800438
andrewonlab79244cc2015-01-26 01:11:49 -0500439 # Obtain metrics from ONOS 1, 2, 3
440 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
441 intentsJsonObj1 = json.loads( intentsJsonStr1 )
442 # Parse values from the json object
443 intentInstall1 = \
444 intentsJsonObj1[ installTime ][ 'value' ]
445 intentRerouteLat1 = \
446 int( intentInstall1 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500447
andrewonlab79244cc2015-01-26 01:11:49 -0500448 if clusterCount == 3:
449 intentsJsonStr2 = main.ONOS2cli.intentsEventsMetrics()
450 intentsJsonStr3 = main.ONOS3cli.intentsEventsMetrics()
451
452 intentsJsonObj2 = json.loads( intentsJsonStr2 )
453 intentsJsonObj3 = json.loads( intentsJsonStr3 )
454 intentInstall2 = \
455 intentsJsonObj2[ installTime ][ 'value' ]
456 intentInstall3 = \
457 intentsJsonObj3[ installTime ][ 'value' ]
458 intentRerouteLat2 = \
459 int( intentInstall2 ) - int( t0System )
460 intentRerouteLat3 = \
461 int( intentInstall3 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500462 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500463 intentRerouteLat2 = 0
464 intentRerouteLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500465
andrewonlab79244cc2015-01-26 01:11:49 -0500466 if clusterCount == 5:
467 intentsJsonStr4 = main.ONOS4cli.intentsEventsMetrics()
468 intentsJsonStr5 = main.ONOS5cli.intentsEventsMetrics()
andrewonlaba57a3042015-01-23 13:53:05 -0500469
andrewonlab79244cc2015-01-26 01:11:49 -0500470 intentsJsonObj4 = json.loads( intentsJsonStr4 )
471 intentsJsonObj5 = json.loads( intentsJsonStr5 )
472 intentInstall4 = \
473 intentsJsonObj4[ installTime ][ 'value' ]
474 intentInstall5 = \
475 intentsJsonObj5[ installTime ][ 'value' ]
476 intentRerouteLat4 = \
477 int( intentInstall4 ) - int( t0System )
478 intentRerouteLat5 = \
479 int( intentInstall5 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500480 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500481 intentRerouteLat4 = 0
482 intentRerouteLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500483
andrewonlab79244cc2015-01-26 01:11:49 -0500484 if clusterCount == 7:
485 intentsJsonStr6 = main.ONOS6cli.intentsEventsMetrics()
486 intentsJsonStr7 = main.ONOS7cli.intentsEventsMetrics()
andrewonlaba57a3042015-01-23 13:53:05 -0500487
andrewonlab79244cc2015-01-26 01:11:49 -0500488 intentsJsonObj6 = json.loads( intentsJsonStr6 )
489 intentsJsonObj7 = json.loads( intentsJsonStr7 )
490 intentInstall6 = \
491 intentsJsonObj6[ installTime ][ 'value' ]
492 intentInstall7 = \
493 intentsJsonObj7[ installTime ][ 'value' ]
494 intentRerouteLat6 = \
495 int( intentInstall6 ) - int( t0System )
496 intentRerouteLat7 = \
497 int( intentInstall7 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500498 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500499 intentRerouteLat6 = 0
500 intentRerouteLat7 = 0
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800501
andrewonlab79244cc2015-01-26 01:11:49 -0500502 intentRerouteLatAvg = \
503 ( intentRerouteLat1 +
504 intentRerouteLat2 +
505 intentRerouteLat3 +
506 intentRerouteLat4 +
507 intentRerouteLat5 +
508 intentRerouteLat6 +
509 intentRerouteLat7 ) / clusterCount
andrewonlab4cf9dd22014-11-18 21:28:38 -0500510
andrewonlab79244cc2015-01-26 01:11:49 -0500511 main.log.info( "Intent reroute latency avg for iteration " +
512 str( i ) + ": " + str( intentRerouteLatAvg ) )
513
514 if intentRerouteLatAvg > 0.0 and \
515 intentRerouteLatAvg < 1000 and i > numIgnore:
516 intentRerouteLatList.append( intentRerouteLatAvg )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500517 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500518 main.log.info( "Intent reroute latency exceeded " +
519 "threshold. Skipping iteration " + str( i ) )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500520
andrewonlab79244cc2015-01-26 01:11:49 -0500521 main.log.info( "Removing intents for next iteration" )
522 main.ONOS1cli.removeIntent( intentId )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800523
andrewonlab79244cc2015-01-26 01:11:49 -0500524 main.log.info( "Bringing Mininet interface up for next " +
525 "iteration" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500526 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500527 "sh ifconfig " + intfs + " up" )
528 main.Mininet1.handle.expect( "mininet>" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800529
andrewonlab79244cc2015-01-26 01:11:49 -0500530 if intentRerouteLatList:
531 intentRerouteLatAvg = sum( intentRerouteLatList ) /\
532 len( intentRerouteLatList )
andrewonlaba57a3042015-01-23 13:53:05 -0500533 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500534 main.log.report( "Intent reroute test failed. Results NA" )
535 intentRerouteLatAvg = "NA"
536 # NOTE: fails test when list is empty
andrewonlaba57a3042015-01-23 13:53:05 -0500537 assertion = main.FALSE
andrewonlab79244cc2015-01-26 01:11:49 -0500538
539 intentRerouteLatStd = \
540 round( numpy.std( intentRerouteLatList ), 1 )
541 # END ITERATION FOR LOOP
542 main.log.report( "Single intent reroute latency - " )
543 main.log.report( "Avg: " + str( intentRerouteLatAvg ) + " ms" )
544 main.log.report(
545 "Std Deviation: " +
546 str( intentRerouteLatStd ) +
547 " ms" )
548
549 utilities.assert_equals(
550 expect=main.TRUE,
551 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500552 onpass="Single intent reroute latency test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500553 onfail="Single intent reroute latency test failed" )
554
555 def CASE4( self, main ):
556 """
andrewonlab042b3912014-12-10 16:40:50 -0500557 Batch intent install
andrewonlab082dfc32015-02-06 13:59:51 -0500558
559 Supports scale-out scenarios and increasing
560 number of intents within each iteration
andrewonlab79244cc2015-01-26 01:11:49 -0500561 """
andrewonlab70decc02014-11-19 18:50:23 -0500562 import time
563 import json
564 import requests
565 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500566 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500567 global clusterCount
andrewonlab302cd532015-02-20 13:59:50 -0500568 global timeToPost
andrewonlab70decc02014-11-19 18:50:23 -0500569
andrewonlab79244cc2015-01-26 01:11:49 -0500570 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
571 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
572 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
573 ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
574 ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
575 ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
576 ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500577
578 assertion = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800579
andrewonlab79244cc2015-01-26 01:11:49 -0500580 ONOSIpList = []
581 for i in range( 1, 8 ):
582 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlab4293dcb2014-12-02 15:48:05 -0500583
andrewonlab79244cc2015-01-26 01:11:49 -0500584 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab70decc02014-11-19 18:50:23 -0500585
andrewonlab79244cc2015-01-26 01:11:49 -0500586 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab70decc02014-11-19 18:50:23 -0500587
andrewonlab79244cc2015-01-26 01:11:49 -0500588 batchIntentSize = int( main.params[ 'TEST' ][ 'batchIntentSize' ] )
589 batchThreshMin = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
590 batchThreshMax = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
andrewonlab4293dcb2014-12-02 15:48:05 -0500591
andrewonlab79244cc2015-01-26 01:11:49 -0500592 # number of iterations of case
593 numIter = main.params[ 'TEST' ][ 'numIter' ]
594 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
595 numSwitch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
596 nThread = main.params[ 'TEST' ][ 'numMult' ]
597 #nThread = 105
598
andrewonlabe07f8562015-02-20 12:23:07 -0500599 # DB operation variables
andrewonlab302cd532015-02-20 13:59:50 -0500600 intentFilePath = main.params[ 'DB' ][ 'intentFilePath' ]
andrewonlabe07f8562015-02-20 12:23:07 -0500601
andrewonlab79244cc2015-01-26 01:11:49 -0500602 # Switch assignment NOTE: hardcoded
603 if clusterCount == 1:
604 for i in range( 1, numSwitch + 1 ):
605 main.Mininet1.assignSwController(
606 sw=str( i ),
607 ip1=ONOS1Ip,
608 port1=defaultSwPort )
609 if clusterCount == 3:
610 for i in range( 1, 3 ):
611 main.Mininet1.assignSwController(
612 sw=str( i ),
613 ip1=ONOS1Ip,
614 port1=defaultSwPort )
615 for i in range( 3, 6 ):
616 main.Mininet1.assignSwController(
617 sw=str( i ),
618 ip1=ONOS2Ip,
619 port1=defaultSwPort )
620 for i in range( 6, 9 ):
621 main.Mininet1.assignSwController(
622 sw=str( i ),
623 ip1=ONOS3Ip,
624 port1=defaultSwPort )
625 if clusterCount == 5:
626 main.Mininet1.assignSwController(
627 sw="1",
628 ip1=ONOS1Ip,
629 port1=defaultSwPort )
630 main.Mininet1.assignSwController(
631 sw="2",
632 ip1=ONOS2Ip,
633 port1=defaultSwPort )
634 for i in range( 3, 6 ):
635 main.Mininet1.assignSwController(
636 sw=str( i ),
637 ip1=ONOS3Ip,
638 port1=defaultSwPort )
639 main.Mininet1.assignSwController(
640 sw="6",
641 ip1=ONOS4Ip,
642 port1=defaultSwPort )
643 main.Mininet1.assignSwController(
644 sw="7",
645 ip1=ONOS5Ip,
646 port1=defaultSwPort )
647 main.Mininet1.assignSwController(
648 sw="8",
649 ip1=ONOS5Ip,
650 port1=defaultSwPort )
651
652 if clusterCount == 7:
653 for i in range( 1, 9 ):
andrewonlabeb1d0542014-12-03 20:12:01 -0500654 if i < 8:
andrewonlab79244cc2015-01-26 01:11:49 -0500655 main.Mininet1.assignSwController(
656 sw=str( i ),
657 ip1=ONOSIpList[ i - 1 ],
658 port1=defaultSwPort )
659 elif i >= 8:
660 main.Mininet1.assignSwController(
661 sw=str( i ),
662 ip1=ONOSIpList[ 6 ],
663 port1=defaultSwPort )
andrewonlab70decc02014-11-19 18:50:23 -0500664
andrewonlab79244cc2015-01-26 01:11:49 -0500665 time.sleep( 20 )
andrewonlabeb1d0542014-12-03 20:12:01 -0500666
andrewonlab79244cc2015-01-26 01:11:49 -0500667 main.log.report( "Batch intent installation test of " +
668 str( batchIntentSize ) + " intent(s)" )
andrewonlab4293dcb2014-12-02 15:48:05 -0500669
andrewonlab79244cc2015-01-26 01:11:49 -0500670 batchResultList = []
andrewonlab70decc02014-11-19 18:50:23 -0500671
andrewonlab79244cc2015-01-26 01:11:49 -0500672 main.log.info( "Getting list of available devices" )
673 deviceIdList = []
674 jsonStr = main.ONOS1cli.devices()
675 jsonObj = json.loads( jsonStr )
676 for device in jsonObj:
677 deviceIdList.append( device[ 'id' ] )
andrewonlab70decc02014-11-19 18:50:23 -0500678
andrewonlab302cd532015-02-20 13:59:50 -0500679 # List of install / witdhraw latencies for each batch
andrewonlab79244cc2015-01-26 01:11:49 -0500680 batchInstallLat = []
681 batchWithdrawLat = []
andrewonlab70decc02014-11-19 18:50:23 -0500682
andrewonlab79244cc2015-01-26 01:11:49 -0500683 sleepTime = 10
684
685 baseDir = "/tmp/"
686
andrewonlabe07f8562015-02-20 12:23:07 -0500687 # Batch size increase loop
andrewonlab79244cc2015-01-26 01:11:49 -0500688 for batch in range( 0, 5 ):
andrewonlabe07f8562015-02-20 12:23:07 -0500689 # Max intent install measurement of all nodes
690 # Resets after each batch calculation
691 maxInstallLat = []
692 maxWithdrawLat = []
693 # Statistical gathering loop over number of iterations
andrewonlab79244cc2015-01-26 01:11:49 -0500694 for i in range( 0, int( numIter ) ):
695 main.log.info( "Pushing " +
696 str( int( batchIntentSize ) * int( nThread ) ) +
697 " intents. Iteration " + str( i ) )
698
699 for node in range( 1, clusterCount + 1 ):
700 saveDir = baseDir + "batch_intent_" + str( node ) + ".txt"
701 main.ONOSbench.pushTestIntentsShell(
702 deviceIdList[ 0 ] + "/2",
703 deviceIdList[ 7 ] + "/2",
704 batchIntentSize,
705 saveDir, ONOSIpList[ node - 1 ],
706 numMult=nThread, appId=node )
707
708 # Wait sufficient time for intents to start
709 # installing
710 time.sleep( sleepTime )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800711
andrewonlaba57a3042015-01-23 13:53:05 -0500712 intent = ""
713 counter = 300
andrewonlab79244cc2015-01-26 01:11:49 -0500714 while len( intent ) > 0 and counter > 0:
andrewonlaba57a3042015-01-23 13:53:05 -0500715 main.ONOS1cli.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500716 "intents | wc -l" )
andrewonlaba57a3042015-01-23 13:53:05 -0500717 main.ONOS1cli.handle.expect(
andrewonlab79244cc2015-01-26 01:11:49 -0500718 "intents | wc -l" )
andrewonlaba57a3042015-01-23 13:53:05 -0500719 main.ONOS1cli.handle.expect(
andrewonlab79244cc2015-01-26 01:11:49 -0500720 "onos>" )
721 intentTemp = main.ONOS1cli.handle.before()
andrewonlaba57a3042015-01-23 13:53:05 -0500722 intent = main.ONOS1cli.intents()
andrewonlab79244cc2015-01-26 01:11:49 -0500723 intent = json.loads( intent )
724 counter = counter - 1
725 time.sleep( 1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800726
andrewonlab79244cc2015-01-26 01:11:49 -0500727 time.sleep( 5 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800728
andrewonlab79244cc2015-01-26 01:11:49 -0500729 for node in range( 1, clusterCount + 1 ):
730 saveDir = baseDir + "batch_intent_" + str( node ) + ".txt"
731 with open( saveDir ) as fOnos:
732 lineCount = 0
733 for line in fOnos:
734 line = line[ 1: ]
735 line = line.split( ": " )
736 main.log.info( "Line read: " + str( line ) )
andrewonlabd019a6b2015-02-05 00:05:22 -0500737 #Prevent split method if line doesn't have
738 #space
739 if " " in str(line):
740 result = line[ 1 ].split( " " )[ 0 ]
741 else:
742 main.log.warn( "Empty line read" )
743 result = 0
andrewonlab79244cc2015-01-26 01:11:49 -0500744 # TODO: add parameters before appending latency
745 if lineCount == 0:
746 batchInstallLat.append( int( result ) )
747 installResult = result
748 elif lineCount == 1:
749 batchWithdrawLat.append( int( result ) )
750 withdrawResult = result
andrewonlabd019a6b2015-02-05 00:05:22 -0500751 else:
752 main.log.warn("Invalid results")
753 installResult = 'NA'
754 withdrawResult = 'NA'
andrewonlab79244cc2015-01-26 01:11:49 -0500755 lineCount += 1
756 main.log.info( "Batch install latency for ONOS" +
757 str( node ) + " with " +
758 str( batchIntentSize ) + "intents: " +
759 str( installResult ) + " ms" )
760 main.log.info( "Batch withdraw latency for ONOS" +
761 str( node ) + " with " +
762 str( batchIntentSize ) + "intents: " +
763 str( withdrawResult ) + " ms" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500764
andrewonlab302cd532015-02-20 13:59:50 -0500765 #NOTE: END node loop
766
andrewonlab79244cc2015-01-26 01:11:49 -0500767 if len( batchInstallLat ) > 0 and int( i ) > numIgnore:
768 maxInstallLat.append( max( batchInstallLat ) )
769 elif len( batchInstallLat ) == 0:
770 # If I failed to read anything from the file,
771 # increase the wait time before checking intents
772 sleepTime += 30
773 if len( batchWithdrawLat ) > 0 and int( i ) > numIgnore:
774 maxWithdrawLat.append( max( batchWithdrawLat ) )
775 batchInstallLat = []
776 batchWithdrawLat = []
777
778 # Sleep in between iterations
779 time.sleep( 5 )
780
andrewonlab302cd532015-02-20 13:59:50 -0500781 #NOTE: END iteration loop
782
andrewonlab79244cc2015-01-26 01:11:49 -0500783 if maxInstallLat:
andrewonlabd019a6b2015-02-05 00:05:22 -0500784 avgInstallLat = str( round(
785 sum( maxInstallLat ) /
786 len( maxInstallLat )
787 , 2 ))
andrewonlab302cd532015-02-20 13:59:50 -0500788 stdInstallLat = str( round(
789 numpy.std(maxInstallLat), 2))
andrewonlaba57a3042015-01-23 13:53:05 -0500790 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500791 avgInstallLat = "NA"
andrewonlab302cd532015-02-20 13:59:50 -0500792 stdInstallLat = "NA"
andrewonlab79244cc2015-01-26 01:11:49 -0500793 main.log.report( "Batch installation failed" )
andrewonlaba57a3042015-01-23 13:53:05 -0500794 assertion = main.FALSE
andrewonlabeb1d0542014-12-03 20:12:01 -0500795
andrewonlab79244cc2015-01-26 01:11:49 -0500796 if maxWithdrawLat:
andrewonlabd019a6b2015-02-05 00:05:22 -0500797 avgWithdrawLat = str( round(
798 sum( maxWithdrawLat ) /
799 len( maxWithdrawLat )
800 , 2 ))
andrewonlab302cd532015-02-20 13:59:50 -0500801 stdWithdrawLat = str( round(
802 numpy.std(maxWithdrawLat), 2))
andrewonlaba57a3042015-01-23 13:53:05 -0500803 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500804 avgWithdrawLat = "NA"
andrewonlab302cd532015-02-20 13:59:50 -0500805 stdWithdrawLat = "NA"
andrewonlab79244cc2015-01-26 01:11:49 -0500806 main.log.report( "Batch withdraw failed" )
andrewonlaba57a3042015-01-23 13:53:05 -0500807 assertion = main.FALSE
andrewonlabeb1d0542014-12-03 20:12:01 -0500808
andrewonlab79244cc2015-01-26 01:11:49 -0500809 main.log.report( "Avg of batch installation latency " +
810 "of size " + str( batchIntentSize ) + ": " +
811 str( avgInstallLat ) + " ms" )
812 main.log.report( "Std Deviation of batch installation latency " +
andrewonlabd019a6b2015-02-05 00:05:22 -0500813 ": " +
andrewonlab302cd532015-02-20 13:59:50 -0500814 str( stdInstallLat ) + " ms" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500815
andrewonlab79244cc2015-01-26 01:11:49 -0500816 main.log.report( "Avg of batch withdraw latency " +
817 "of size " + str( batchIntentSize ) + ": " +
818 str( avgWithdrawLat ) + " ms" )
819 main.log.report( "Std Deviation of batch withdraw latency " +
820 ": " +
andrewonlab302cd532015-02-20 13:59:50 -0500821 str( stdWithdrawLat ) + " ms" )
822
823 dbCmd = (
824 "INSERT INTO intent_latency_tests VALUES("
825 "'"+timeToPost+"','intent_latency_results',"
826 ""+runNum+","+str(clusterCount)+","+str(batchIntentSize)+","
827 ""+str(avgInstallLat)+","+str(stdInstallLat)+","
828 ""+str(avgWithdrawLat)+","+str(stdWithdrawLat)+");"
829 )
830
831 # Write result to file (which is posted to DB by jenkins)
832 fResult = open(intentFilePath, 'a')
833 if dbCmd:
834 fResult.write(dbCmd+"\n")
835 fResult.close()
andrewonlab79244cc2015-01-26 01:11:49 -0500836
andrewonlabd019a6b2015-02-05 00:05:22 -0500837 if batch == 0:
838 batchIntentSize = 10
839 elif batch == 1:
840 batchIntentSize = 100
841 elif batch == 2:
842 batchIntentSize = 1000
843 elif batch == 3:
844 batchIntentSize = 2000
845 if batch < 4:
846 main.log.report( "Increasing batch intent size to " +
andrewonlab79244cc2015-01-26 01:11:49 -0500847 str(batchIntentSize) )
848
andrewonlab302cd532015-02-20 13:59:50 -0500849 #NOTE: END batch loop
850
andrewonlab79244cc2015-01-26 01:11:49 -0500851 #main.log.info( "Removing all intents for next test case" )
852 #jsonTemp = main.ONOS1cli.intents( jsonFormat=True )
853 #jsonObjIntents = json.loads( jsonTemp )
854 # if jsonObjIntents:
855 # for intents in jsonObjIntents:
856 # tempId = intents[ 'id' ]
857 # main.ONOS1cli.removeIntent( tempId )
858 # main.ONOS1cli.removeIntent( tempId )
859
860 utilities.assert_equals(
861 expect=main.TRUE,
862 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500863 onpass="Batch intent install/withdraw test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500864 onfail="Batch intent install/withdraw test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800865
andrewonlab79244cc2015-01-26 01:11:49 -0500866 def CASE5( self, main ):
867 """
andrewonlab4293dcb2014-12-02 15:48:05 -0500868 Increase number of nodes and initiate CLI
andrewonlab79244cc2015-01-26 01:11:49 -0500869 """
andrewonlab4293dcb2014-12-02 15:48:05 -0500870 import time
871 import json
872
andrewonlab79244cc2015-01-26 01:11:49 -0500873 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
874 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
875 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
876 ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
877 ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
878 ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
879 ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
andrewonlab4293dcb2014-12-02 15:48:05 -0500880
andrewonlab79244cc2015-01-26 01:11:49 -0500881 global clusterCount
882 clusterCount += 2
883 main.log.report( "Increasing cluster size to " +
884 str( clusterCount ) )
andrewonlab4293dcb2014-12-02 15:48:05 -0500885
andrewonlab79244cc2015-01-26 01:11:49 -0500886 installResult = main.FALSE
andrewonlab4293dcb2014-12-02 15:48:05 -0500887
andrewonlab79244cc2015-01-26 01:11:49 -0500888 if clusterCount == 3:
889 installResult1 = \
890 main.ONOSbench.onosInstall( node=ONOS2Ip )
891 installResult2 = \
892 main.ONOSbench.onosInstall( node=ONOS3Ip )
893 time.sleep( 5 )
andrewonlab4293dcb2014-12-02 15:48:05 -0500894
andrewonlab79244cc2015-01-26 01:11:49 -0500895 main.log.info( "Starting ONOS CLI" )
896 main.ONOS2cli.startOnosCli( ONOS2Ip )
897 main.ONOS3cli.startOnosCli( ONOS3Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500898
andrewonlab79244cc2015-01-26 01:11:49 -0500899 installResult = installResult1 and installResult2
andrewonlab4293dcb2014-12-02 15:48:05 -0500900
andrewonlab79244cc2015-01-26 01:11:49 -0500901 if clusterCount == 5:
902 main.log.info( "Installing ONOS on node 4 and 5" )
903 installResult1 = \
904 main.ONOSbench.onosInstall( node=ONOS4Ip )
905 installResult2 = \
906 main.ONOSbench.onosInstall( node=ONOS5Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500907
andrewonlab79244cc2015-01-26 01:11:49 -0500908 main.log.info( "Starting ONOS CLI" )
909 main.ONOS4cli.startOnosCli( ONOS4Ip )
910 main.ONOS5cli.startOnosCli( ONOS5Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500911
andrewonlab79244cc2015-01-26 01:11:49 -0500912 installResult = installResult1 and installResult2
andrewonlab4293dcb2014-12-02 15:48:05 -0500913
andrewonlab79244cc2015-01-26 01:11:49 -0500914 if clusterCount == 7:
915 main.log.info( "Installing ONOS on node 6 and 7" )
916 installResult1 = \
917 main.ONOSbench.onosInstall( node=ONOS6Ip )
918 installResult2 = \
919 main.ONOSbench.onosInstall( node=ONOS7Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500920
andrewonlab79244cc2015-01-26 01:11:49 -0500921 main.log.info( "Starting ONOS CLI" )
922 main.ONOS6cli.startOnosCli( ONOS6Ip )
923 main.ONOS7cli.startOnosCli( ONOS7Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500924
andrewonlab79244cc2015-01-26 01:11:49 -0500925 installResult = installResult1 and installResult2
andrewonlab4293dcb2014-12-02 15:48:05 -0500926
andrewonlab79244cc2015-01-26 01:11:49 -0500927 time.sleep( 5 )
andrewonlab4293dcb2014-12-02 15:48:05 -0500928
andrewonlab79244cc2015-01-26 01:11:49 -0500929 if installResult == main.TRUE:
andrewonlab4293dcb2014-12-02 15:48:05 -0500930 assertion = main.TRUE
931 else:
932 assertion = main.FALSE
933
andrewonlab79244cc2015-01-26 01:11:49 -0500934 utilities.assert_equals( expect=main.TRUE, actual=assertion,
935 onpass="Scale out to " + str( clusterCount ) +
936 " nodes successful",
937 onfail="Scale out to " + str( clusterCount ) +
938 " nodes failed" )
andrewonlab4293dcb2014-12-02 15:48:05 -0500939
andrewonlab79244cc2015-01-26 01:11:49 -0500940 def CASE7( self, main ):
941 # TODO: Fix for scale-out scenario
942 """
andrewonlaba57a3042015-01-23 13:53:05 -0500943 Batch intent reroute latency
andrewonlab79244cc2015-01-26 01:11:49 -0500944 """
andrewonlaba57a3042015-01-23 13:53:05 -0500945 import time
946 import json
947 import requests
948 import os
949 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500950 global clusterCount
andrewonlaba57a3042015-01-23 13:53:05 -0500951
andrewonlab79244cc2015-01-26 01:11:49 -0500952 ONOSIpList = []
953 for i in range( 1, 8 ):
954 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlaba57a3042015-01-23 13:53:05 -0500955
andrewonlab79244cc2015-01-26 01:11:49 -0500956 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
957 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500958
andrewonlab79244cc2015-01-26 01:11:49 -0500959 batchIntentSize = main.params[ 'TEST' ][ 'batchIntentSize' ]
960 batchThreshMin = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
961 batchThreshMax = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
962 intfs = main.params[ 'TEST' ][ 'intfs' ]
963 installTime = main.params[ 'JSON' ][ 'installedTime' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500964
andrewonlab79244cc2015-01-26 01:11:49 -0500965 # number of iterations of case
966 numIter = main.params[ 'TEST' ][ 'numIter' ]
967 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
968 numSwitch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
969 nThread = main.params[ 'TEST' ][ 'numMult' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500970
andrewonlab79244cc2015-01-26 01:11:49 -0500971 main.log.report( "Batch intent installation test of " +
972 batchIntentSize + " intents" )
andrewonlaba57a3042015-01-23 13:53:05 -0500973
andrewonlab79244cc2015-01-26 01:11:49 -0500974 batchResultList = []
andrewonlaba57a3042015-01-23 13:53:05 -0500975
andrewonlab79244cc2015-01-26 01:11:49 -0500976 time.sleep( 10 )
andrewonlaba57a3042015-01-23 13:53:05 -0500977
andrewonlab79244cc2015-01-26 01:11:49 -0500978 main.log.info( "Getting list of available devices" )
979 deviceIdList = []
980 jsonStr = main.ONOS1cli.devices()
981 jsonObj = json.loads( jsonStr )
982 for device in jsonObj:
983 deviceIdList.append( device[ 'id' ] )
andrewonlaba57a3042015-01-23 13:53:05 -0500984
andrewonlab79244cc2015-01-26 01:11:49 -0500985 batchInstallLat = []
986 batchWithdrawLat = []
987 sleepTime = 10
andrewonlaba57a3042015-01-23 13:53:05 -0500988
andrewonlab79244cc2015-01-26 01:11:49 -0500989 baseDir = "/tmp/"
990 maxInstallLat = []
991
992 for i in range( 0, int( numIter ) ):
993 main.log.info( "Pushing " +
994 str( int( batchIntentSize ) * int( nThread ) ) +
995 " intents. Iteration " + str( i ) )
996
997 main.ONOSbench.pushTestIntentsShell(
998 deviceIdList[ 0 ] + "/2",
999 deviceIdList[ 7 ] + "/2",
1000 batchIntentSize, "/tmp/batch_install.txt",
1001 ONOSIpList[ 0 ], numMult="1", appId="1",
1002 report=False, options="--install" )
1003 # main.ONOSbench.pushTestIntentsShell(
andrewonlaba57a3042015-01-23 13:53:05 -05001004 # "of:0000000000001002/1",
1005 # "of:0000000000002002/1",
1006 # 133, "/tmp/temp2.txt", "10.128.174.2",
andrewonlab79244cc2015-01-26 01:11:49 -05001007 # numMult="6", appId="2",report=False )
1008
1009 # TODO: Check for installation success then proceed
1010 time.sleep( 30 )
1011
1012 # NOTE: this interface is specific to
andrewonlaba57a3042015-01-23 13:53:05 -05001013 # topo-intentFlower.py topology
1014 # reroute case.
andrewonlab79244cc2015-01-26 01:11:49 -05001015 main.log.info( "Disabling interface " + intfs )
andrewonlaba57a3042015-01-23 13:53:05 -05001016 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001017 "sh ifconfig " + intfs + " down" )
1018 t0System = time.time() * 1000
andrewonlaba57a3042015-01-23 13:53:05 -05001019
andrewonlab79244cc2015-01-26 01:11:49 -05001020 # TODO: Wait sufficient time for intents to install
1021 time.sleep( 10 )
andrewonlaba57a3042015-01-23 13:53:05 -05001022
andrewonlab79244cc2015-01-26 01:11:49 -05001023 # TODO: get intent installation time
1024
1025 # Obtain metrics from ONOS 1, 2, 3
1026 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
1027 intentsJsonObj1 = json.loads( intentsJsonStr1 )
1028 # Parse values from the json object
1029 intentInstall1 = \
1030 intentsJsonObj1[ installTime ][ 'value' ]
1031 intentRerouteLat1 = \
1032 int( intentInstall1 ) - int( t0System )
1033
1034 if clusterCount == 3:
1035 intentsJsonStr2 =\
1036 main.ONOS2cli.intentsEventsMetrics()
1037 intentsJsonStr3 =\
1038 main.ONOS3cli.intentsEventsMetrics()
1039 intentsJsonObj2 = json.loads( intentsJsonStr2 )
1040 intentsJsonObj3 = json.loads( intentsJsonStr3 )
1041 intentInstall2 = \
1042 intentsJsonObj2[ installTime ][ 'value' ]
1043 intentInstall3 = \
1044 intentsJsonObj3[ installTime ][ 'value' ]
1045 intentRerouteLat2 = \
1046 int( intentInstall2 ) - int( t0System )
1047 intentRerouteLat3 = \
1048 int( intentInstall3 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -05001049 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001050 intentRerouteLat2 = 0
1051 intentRerouteLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001052
andrewonlab79244cc2015-01-26 01:11:49 -05001053 if clusterCount == 5:
1054 intentsJsonStr4 =\
1055 main.ONOS4cli.intentsEventsMetrics()
1056 intentsJsonStr5 =\
1057 main.ONOS5cli.intentsEventsMetrics()
1058 intentsJsonObj4 = json.loads( intentsJsonStr4 )
1059 intentsJsonObj5 = json.loads( intentsJsonStr5 )
1060 intentInstall4 = \
1061 intentsJsonObj4[ installTime ][ 'value' ]
1062 intentInstall5 = \
1063 intentsJsonObj5[ installTime ][ 'value' ]
1064 intentRerouteLat4 = \
1065 int( intentInstall4 ) - int( t0System )
1066 intentRerouteLat5 = \
1067 int( intentInstall5 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -05001068 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001069 intentRerouteLat4 = 0
1070 intentRerouteLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001071
andrewonlab79244cc2015-01-26 01:11:49 -05001072 if clusterCount == 7:
1073 intentsJsonStr6 =\
1074 main.ONOS6cli.intentsEventsMetrics()
1075 intentsJsonStr7 =\
1076 main.ONOS7cli.intentsEventsMetrics()
1077 intentsJsonObj6 = json.loads( intentsJsonStr6 )
1078 intentsJsonObj7 = json.loads( intentsJsonStr7 )
1079 intentInstall6 = \
1080 intentsJsonObj6[ installTime ][ 'value' ]
1081 intentInstall7 = \
1082 intentsJsonObj7[ installTime ][ 'value' ]
1083 intentRerouteLat6 = \
1084 int( intentInstall6 ) - int( t0System )
1085 intentRerouteLat7 = \
1086 int( intentInstall7 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -05001087 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001088 intentRerouteLat6 = 0
1089 intentRerouteLat7 = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001090
andrewonlab79244cc2015-01-26 01:11:49 -05001091 intentRerouteLatAvg = \
1092 ( intentRerouteLat1 +
1093 intentRerouteLat2 +
1094 intentRerouteLat3 +
1095 intentRerouteLat4 +
1096 intentRerouteLat5 +
1097 intentRerouteLat6 +
1098 intentRerouteLat7 ) / clusterCount
andrewonlaba57a3042015-01-23 13:53:05 -05001099
andrewonlab79244cc2015-01-26 01:11:49 -05001100 main.log.info( "Intent reroute latency avg for iteration " +
1101 str( i ) + ": " + str( intentRerouteLatAvg ) )
1102 # TODO: Remove intents for next iteration
1103
1104 time.sleep( 5 )
1105
1106 intentsStr = main.ONOS1cli.intents()
1107 intentsJson = json.loads( intentsStr )
1108 for intents in intentsJson:
1109 intentId = intents[ 'id' ]
1110 # TODO: make sure this removes all intents
1111 # print intentId
1112 if intentId:
1113 main.ONOS1cli.removeIntent( intentId )
andrewonlaba57a3042015-01-23 13:53:05 -05001114
1115 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001116 "sh ifconfig " + intfs + " up" )
andrewonlaba57a3042015-01-23 13:53:05 -05001117
andrewonlab79244cc2015-01-26 01:11:49 -05001118 main.log.info( "Intents removed and port back up" )
1119
1120 def CASE9( self, main ):
andrewonlabeb1d0542014-12-03 20:12:01 -05001121 count = 0
andrewonlab79244cc2015-01-26 01:11:49 -05001122 swNum1 = 1
1123 swNum2 = 1
andrewonlabeb1d0542014-12-03 20:12:01 -05001124 appid = 0
andrewonlab79244cc2015-01-26 01:11:49 -05001125 portNum1 = 1
1126 portNum2 = 1
1127
1128 time.sleep( 30 )
andrewonlab4cf9dd22014-11-18 21:28:38 -05001129
andrewonlabeb1d0542014-12-03 20:12:01 -05001130 while True:
andrewonlab79244cc2015-01-26 01:11:49 -05001131 # main.ONOS1cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001132 #"of:0000000000001001/1",
1133 #"of:0000000000002001/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001134 # 100, numMult="10", appId="1" )
1135 # main.ONOS2cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001136 # "of:0000000000001002/1",
1137 # "of:0000000000002002/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001138 # 100, numMult="10", appId="2" )
1139 # main.ONOS2cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001140 # "of:0000000000001003/1",
1141 # "of:0000000000002003/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001142 # 100, numMult="10", appId="3" )
andrewonlabeb1d0542014-12-03 20:12:01 -05001143 count += 1
andrewonlab79244cc2015-01-26 01:11:49 -05001144
andrewonlabeb1d0542014-12-03 20:12:01 -05001145 if count >= 100:
1146 main.ONOSbench.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001147 "onos 10.128.174.1 intents-events-metrics >>" +
1148 " /tmp/metrics_intents_temp.txt &" )
andrewonlabeb1d0542014-12-03 20:12:01 -05001149 count = 0
1150
andrewonlab79244cc2015-01-26 01:11:49 -05001151 arg1 = "of:000000000000100" + str( swNum1 ) + "/" + str( portNum1 )
1152 arg2 = "of:000000000000200" + str( swNum2 ) + "/" + str( portNum2 )
andrewonlabeb1d0542014-12-03 20:12:01 -05001153
andrewonlab79244cc2015-01-26 01:11:49 -05001154 swNum1 += 1
1155
1156 if swNum1 > 7:
1157 swNum1 = 1
1158 swNum2 += 1
1159 if swNum2 > 7:
andrewonlabeb1d0542014-12-03 20:12:01 -05001160 appid += 1
1161
andrewonlab79244cc2015-01-26 01:11:49 -05001162 if swNum2 > 7:
1163 swNum2 = 1
1164
1165 main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001166 arg1,
andrewonlab79244cc2015-01-26 01:11:49 -05001167 arg2,
andrewonlab042b3912014-12-10 16:40:50 -05001168 100, "/tmp/temp.txt", "10.128.174.1",
andrewonlab79244cc2015-01-26 01:11:49 -05001169 numMult="10", appId=appid, report=False )
1170 # main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001171 # "of:0000000000001002/1",
1172 # "of:0000000000002002/1",
1173 # 133, "/tmp/temp2.txt", "10.128.174.2",
andrewonlab79244cc2015-01-26 01:11:49 -05001174 # numMult="6", appId="2",report=False )
1175 # main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001176 # "of:0000000000001003/1",
1177 # "of:0000000000002003/1",
1178 # 133, "/tmp/temp3.txt", "10.128.174.3",
andrewonlab79244cc2015-01-26 01:11:49 -05001179 # numMult="6", appId="3",report=False )
andrewonlab92ea3672014-11-04 20:22:14 -05001180
andrewonlab79244cc2015-01-26 01:11:49 -05001181 time.sleep( 0.2 )