blob: 7807daf9621e4b16ec57f97a1ba7abeb5f89425a [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(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700147 sw="s" + str( i ),
148 ip=ONOSIpList[ 0 ],
149 port=defaultSwPort
andrewonlab79244cc2015-01-26 01:11:49 -0500150 )
151 elif clusterCount == 3:
andrewonlaba57a3042015-01-23 13:53:05 -0500152 if i < 3:
153 index = 0
154 elif i < 6 and i >= 3:
155 index = 1
156 else:
157 index = 2
andrewonlab79244cc2015-01-26 01:11:49 -0500158 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700159 sw="s" + str( i ),
160 ip=ONOSIpList[ index ],
161 port=defaultSwPort
andrewonlab79244cc2015-01-26 01:11:49 -0500162 )
163 elif clusterCount == 5:
andrewonlaba57a3042015-01-23 13:53:05 -0500164 if i < 3:
165 index = 0
166 elif i < 5 and i >= 3:
167 index = 1
168 elif i < 7 and i >= 5:
169 index = 2
170 elif i == 7:
171 index = 3
172 else:
173 index = 4
andrewonlab79244cc2015-01-26 01:11:49 -0500174 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700175 sw="s" + str( i ),
176 ip=ONOSIpList[ index ],
177 port=defaultSwPort
andrewonlab79244cc2015-01-26 01:11:49 -0500178 )
179 elif clusterCount == 7:
andrewonlaba57a3042015-01-23 13:53:05 -0500180 if i < 6:
181 index = i
182 else:
183 index = 6
andrewonlab79244cc2015-01-26 01:11:49 -0500184 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700185 sw="s" + str( i ),
186 ip=ONOSIpList[ index ],
187 port=defaultSwPort
andrewonlab79244cc2015-01-26 01:11:49 -0500188 )
andrewonlab70decc02014-11-19 18:50:23 -0500189
andrewonlab79244cc2015-01-26 01:11:49 -0500190 time.sleep( 10 )
andrewonlab70decc02014-11-19 18:50:23 -0500191
andrewonlab79244cc2015-01-26 01:11:49 -0500192 main.log.report( "Single intent add latency test" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500193
andrewonlab79244cc2015-01-26 01:11:49 -0500194 devicesJsonStr = main.ONOS1cli.devices()
195 devicesJsonObj = json.loads( devicesJsonStr )
196
197 if not devicesJsonObj:
198 main.log.report( "Devices not discovered" )
199 main.log.report( "Aborting test" )
andrewonlaba57a3042015-01-23 13:53:05 -0500200 main.exit()
201 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500202 main.log.info( "Devices discovered successfully" )
andrewonlaba57a3042015-01-23 13:53:05 -0500203
andrewonlab79244cc2015-01-26 01:11:49 -0500204 deviceIdList = []
andrewonlab92ea3672014-11-04 20:22:14 -0500205
andrewonlab79244cc2015-01-26 01:11:49 -0500206 # Obtain device id list in ONOS format.
207 # They should already be in order ( 1,2,3,10,11,12,13, etc )
208 for device in devicesJsonObj:
209 deviceIdList.append( device[ 'id' ] )
andrewonlab92ea3672014-11-04 20:22:14 -0500210
andrewonlab79244cc2015-01-26 01:11:49 -0500211 for i in range( 0, int( numIter ) ):
212 # addPointIntent( ingrDevice, egrDevice,
213 # ingrPort, egrPort )
214 main.ONOS1cli.addPointIntent(
215 deviceIdList[ 0 ] + "/2", deviceIdList[ 7 ] + "/2" )
216
217 # Allow some time for intents to propagate
218 time.sleep( 5 )
219
220 intentsStr = main.ONOS1cli.intents( jsonFormat=True )
221 intentsObj = json.loads( intentsStr )
222 for intent in intentsObj:
223 if intent[ 'state' ] == "INSTALLED":
224 main.log.info( "Intent installed successfully" )
225 intentId = intent[ 'id' ]
226 main.log.info( "Intent id: " + str( intentId ) )
andrewonlaba57a3042015-01-23 13:53:05 -0500227 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500228 # TODO: Add error handling
229 main.log.info( "Intent installation failed" )
230 intentId = ""
andrewonlab92ea3672014-11-04 20:22:14 -0500231
andrewonlab79244cc2015-01-26 01:11:49 -0500232 # Obtain metrics from ONOS 1, 2, 3
233 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
234 intentsJsonObj1 = json.loads( intentsJsonStr1 )
235 # Parse values from the json object
236 intentSubmit1 = \
237 intentsJsonObj1[ submitTime ][ 'value' ]
238 intentInstall1 = \
239 intentsJsonObj1[ installTime ][ 'value' ]
240 intentInstallLat1 = \
241 int( intentInstall1 ) - int( intentSubmit1 )
242
243 if clusterCount == 3:
244 intentsJsonStr2 = main.ONOS2cli.intentsEventsMetrics()
245 intentsJsonStr3 = main.ONOS3cli.intentsEventsMetrics()
246 intentsJsonObj2 = json.loads( intentsJsonStr2 )
247 intentsJsonObj3 = json.loads( intentsJsonStr3 )
248 intentSubmit2 = \
249 intentsJsonObj2[ submitTime ][ 'value' ]
250 intentSubmit3 = \
251 intentsJsonObj3[ submitTime ][ 'value' ]
252 intentInstall2 = \
253 intentsJsonObj2[ installTime ][ 'value' ]
254 intentInstall3 = \
255 intentsJsonObj3[ installTime ][ 'value' ]
256 intentInstallLat2 = \
257 int( intentInstall2 ) - int( intentSubmit2 )
258 intentInstallLat3 = \
259 int( intentInstall3 ) - int( intentSubmit3 )
andrewonlaba57a3042015-01-23 13:53:05 -0500260 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500261 intentInstallLat2 = 0
262 intentInstallLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500263
andrewonlab79244cc2015-01-26 01:11:49 -0500264 if clusterCount == 5:
265 intentsJsonStr4 = main.ONOS4cli.intentsEventsMetrics()
266 intentsJsonStr5 = main.ONOS5cli.intentsEventsMetrics()
267 intentsJsonObj4 = json.loads( intentsJsonStr4 )
268 intentsJsonObj5 = json.loads( intentsJsonStr5 )
269 intentSubmit4 = \
270 intentsJsonObj4[ submitTime ][ 'value' ]
271 intentSubmit5 = \
272 intentsJsonObj5[ submitTime ][ 'value' ]
273 intentInstall4 = \
274 intentsJsonObj5[ installTime ][ 'value' ]
275 intentInstall5 = \
276 intentsJsonObj5[ installTime ][ 'value' ]
277 intentInstallLat4 = \
278 int( intentInstall4 ) - int( intentSubmit4 )
279 intentInstallLat5 = \
280 int( intentInstall5 ) - int( intentSubmit5 )
andrewonlaba57a3042015-01-23 13:53:05 -0500281 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500282 intentInstallLat4 = 0
283 intentInstallLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500284
andrewonlab79244cc2015-01-26 01:11:49 -0500285 if clusterCount == 7:
286 intentsJsonStr6 = main.ONOS6cli.intentsEventsMetrics()
287 intentsJsonStr7 = main.ONOS7cli.intentsEventsMetrics()
288 intentsJsonObj6 = json.loads( intentsJsonStr6 )
289 intentsJsonObj7 = json.loads( intentsJsonStr7 )
290 intentSubmit6 = \
291 intentsJsonObj6[ submitTime ][ 'value' ]
292 intentSubmit7 = \
293 intentsJsonObj6[ submitTime ][ 'value' ]
294 intentInstall6 = \
295 intentsJsonObj6[ installTime ][ 'value' ]
296 intentInstall7 = \
297 intentsJsonObj7[ installTime ][ 'value' ]
298 intentInstallLat6 = \
299 int( intentInstall6 ) - int( intentSubmit6 )
300 intentInstallLat7 = \
301 int( intentInstall7 ) - int( intentSubmit7 )
andrewonlaba57a3042015-01-23 13:53:05 -0500302 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500303 intentInstallLat6 = 0
304 intentInstallLat7 = 0
andrewonlab8790abb2014-11-06 13:51:54 -0500305
andrewonlab79244cc2015-01-26 01:11:49 -0500306 intentInstallLatAvg = \
307 ( intentInstallLat1 +
308 intentInstallLat2 +
309 intentInstallLat3 +
310 intentInstallLat4 +
311 intentInstallLat5 +
312 intentInstallLat6 +
313 intentInstallLat7 ) / clusterCount
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800314
andrewonlab79244cc2015-01-26 01:11:49 -0500315 main.log.info( "Intent add latency avg for iteration " + str( i ) +
316 ": " + str( intentInstallLatAvg ) + " ms" )
andrewonlab8790abb2014-11-06 13:51:54 -0500317
andrewonlab79244cc2015-01-26 01:11:49 -0500318 if intentInstallLatAvg > 0.0 and \
319 intentInstallLatAvg < 1000 and i > numIgnore:
320 intentAddLatList.append( intentInstallLatAvg )
andrewonlab8790abb2014-11-06 13:51:54 -0500321 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500322 main.log.info( "Intent add latency exceeded " +
323 "threshold. Skipping iteration " + str( i ) )
andrewonlab8790abb2014-11-06 13:51:54 -0500324
andrewonlab79244cc2015-01-26 01:11:49 -0500325 time.sleep( 3 )
326
327 # TODO: Only remove intents that were installed
andrewonlaba57a3042015-01-23 13:53:05 -0500328 # in this case... Otherwise many other intents
329 # may show up distorting the results
andrewonlab79244cc2015-01-26 01:11:49 -0500330 main.log.info( "Removing intents for next iteration" )
331 jsonTemp = \
332 main.ONOS1cli.intents( jsonFormat=True )
333 jsonObjIntents = json.loads( jsonTemp )
334 if jsonObjIntents:
335 for intents in jsonObjIntents:
336 tempId = intents[ 'id' ]
337 # main.ONOS1cli.removeIntent( tempId )
338 main.log.info( "Removing intent id: " +
339 str( tempId ) )
340 main.ONOS1cli.removeIntent( tempId )
andrewonlab8790abb2014-11-06 13:51:54 -0500341 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500342 main.log.info( "Intents were not installed correctly" )
andrewonlab8790abb2014-11-06 13:51:54 -0500343
andrewonlab79244cc2015-01-26 01:11:49 -0500344 time.sleep( 5 )
andrewonlab8790abb2014-11-06 13:51:54 -0500345
andrewonlab79244cc2015-01-26 01:11:49 -0500346 if intentAddLatList:
347 intentAddLatAvg = sum( intentAddLatList ) /\
348 len( intentAddLatList )
andrewonlaba57a3042015-01-23 13:53:05 -0500349 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500350 main.log.report( "Intent installation latency test failed" )
351 intentAddLatAvg = "NA"
andrewonlaba57a3042015-01-23 13:53:05 -0500352 assertion = main.FALSE
353
andrewonlab79244cc2015-01-26 01:11:49 -0500354 intentAddLatStd = \
355 round( numpy.std( intentAddLatList ), 1 )
356 # END ITERATION FOR LOOP
357 main.log.report( "Single intent add latency - " )
358 main.log.report( "Avg: " + str( intentAddLatAvg ) + " ms" )
359 main.log.report( "Std Deviation: " + str( intentAddLatStd ) + " ms" )
360
361 utilities.assert_equals(
362 expect=main.TRUE,
363 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500364 onpass="Single intent install latency test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500365 onfail="Single intent install latency test failed" )
andrewonlab92ea3672014-11-04 20:22:14 -0500366
andrewonlab79244cc2015-01-26 01:11:49 -0500367 def CASE3( self, main ):
368 """
andrewonlab4cf9dd22014-11-18 21:28:38 -0500369 Intent Reroute latency
andrewonlab79244cc2015-01-26 01:11:49 -0500370 """
andrewonlab4cf9dd22014-11-18 21:28:38 -0500371 import time
372 import json
373 import requests
374 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500375 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500376 global clusterCount
andrewonlab4cf9dd22014-11-18 21:28:38 -0500377
andrewonlab79244cc2015-01-26 01:11:49 -0500378 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
379 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
380 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
381 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlabc3336d52015-02-26 18:54:56 -0500382
383 ONOSIpList = []
384 for i in range( 1, 8 ):
385 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500386
andrewonlab79244cc2015-01-26 01:11:49 -0500387 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab4cf9dd22014-11-18 21:28:38 -0500388
andrewonlab79244cc2015-01-26 01:11:49 -0500389 # number of iterations of case
390 numIter = main.params[ 'TEST' ][ 'numIter' ]
391 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
andrewonlaba57a3042015-01-23 13:53:05 -0500392 assertion = main.TRUE
andrewonlab4cf9dd22014-11-18 21:28:38 -0500393
andrewonlab79244cc2015-01-26 01:11:49 -0500394 # Timestamp keys for json metrics output
395 submitTime = main.params[ 'JSON' ][ 'submittedTime' ]
396 installTime = main.params[ 'JSON' ][ 'installedTime' ]
397 wdRequestTime = main.params[ 'JSON' ][ 'wdRequestTime' ]
398 withdrawnTime = main.params[ 'JSON' ][ 'withdrawnTime' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500399
andrewonlab79244cc2015-01-26 01:11:49 -0500400 # NOTE: May need to configure interface depending on topology
401 intfs = main.params[ 'TEST' ][ 'intfs' ]
andrewonlabc3336d52015-02-26 18:54:56 -0500402
403 # Distribute switches according to cluster count
404 for i in range( 1, 9 ):
405 if clusterCount == 1:
406 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700407 sw="s" + str( i ),
408 ip=ONOSIpList[ 0 ],
409 port=defaultSwPort
andrewonlabc3336d52015-02-26 18:54:56 -0500410 )
411 elif clusterCount == 3:
412 if i < 3:
413 index = 0
414 elif i < 6 and i >= 3:
415 index = 1
416 else:
417 index = 2
418 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700419 sw="s" + str( i ),
420 ip=ONOSIpList[ index ],
421 port=defaultSwPort
andrewonlabc3336d52015-02-26 18:54:56 -0500422 )
423 elif clusterCount == 5:
424 if i < 3:
425 index = 0
426 elif i < 5 and i >= 3:
427 index = 1
428 elif i < 7 and i >= 5:
429 index = 2
430 elif i == 7:
431 index = 3
432 else:
433 index = 4
434 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700435 sw="s" + str( i ),
436 ip=ONOSIpList[ index ],
437 port=defaultSwPort
andrewonlabc3336d52015-02-26 18:54:56 -0500438 )
439 elif clusterCount == 7:
440 if i < 6:
441 index = i
442 else:
443 index = 6
444 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700445 sw="s" + str( i ),
446 ip=ONOSIpList[ index ],
447 port=defaultSwPort
andrewonlabc3336d52015-02-26 18:54:56 -0500448 )
449
450 time.sleep(10)
andrewonlab70decc02014-11-19 18:50:23 -0500451
andrewonlab79244cc2015-01-26 01:11:49 -0500452 devicesJsonStr = main.ONOS1cli.devices()
453 devicesJsonObj = json.loads( devicesJsonStr )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500454
andrewonlab79244cc2015-01-26 01:11:49 -0500455 deviceIdList = []
andrewonlab4cf9dd22014-11-18 21:28:38 -0500456
andrewonlab79244cc2015-01-26 01:11:49 -0500457 # Obtain device id list in ONOS format.
458 # They should already be in order ( 1,2,3,10,11,12,13, etc )
459 for device in devicesJsonObj:
460 deviceIdList.append( device[ 'id' ] )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500461
andrewonlab79244cc2015-01-26 01:11:49 -0500462 intentRerouteLatList = []
andrewonlab4cf9dd22014-11-18 21:28:38 -0500463
andrewonlab79244cc2015-01-26 01:11:49 -0500464 for i in range( 0, int( numIter ) ):
465 # addPointIntent( ingrDevice, ingrPort,
466 # egrDevice, egrPort )
467 if len( deviceIdList ) > 0:
468 main.ONOS1cli.addPointIntent(
469 deviceIdList[ 0 ] + "/2", deviceIdList[ 7 ] + "/2" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500470 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500471 main.log.info( "Failed to fetch devices from ONOS" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500472
andrewonlab79244cc2015-01-26 01:11:49 -0500473 time.sleep( 5 )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500474
andrewonlab79244cc2015-01-26 01:11:49 -0500475 intentsStr = main.ONOS1cli.intents( jsonFormat=True )
476 intentsObj = json.loads( intentsStr )
477 for intent in intentsObj:
andrewonlabc3336d52015-02-26 18:54:56 -0500478 main.log.info(intent)
andrewonlab79244cc2015-01-26 01:11:49 -0500479 if intent[ 'state' ] == "INSTALLED":
480 main.log.info( "Intent installed successfully" )
481 intentId = intent[ 'id' ]
482 main.log.info( "Intent id: " + str( intentId ) )
andrewonlabc3336d52015-02-26 18:54:56 -0500483 #else:
484 #TODO: Add error handling
485 #main.log.info( "Intent installation failed" )
486 #intentId = ""
andrewonlab79244cc2015-01-26 01:11:49 -0500487
488 main.log.info( "Disabling interface " + intfs )
489 t0System = time.time() * 1000
andrewonlab4cf9dd22014-11-18 21:28:38 -0500490 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500491 "sh ifconfig " + intfs + " down" )
492 main.Mininet1.handle.expect( "mininet>" )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500493
andrewonlab79244cc2015-01-26 01:11:49 -0500494 # TODO: Check for correct intent reroute
495 time.sleep( 1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800496
andrewonlab79244cc2015-01-26 01:11:49 -0500497 # Obtain metrics from ONOS 1, 2, 3
498 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
499 intentsJsonObj1 = json.loads( intentsJsonStr1 )
500 # Parse values from the json object
501 intentInstall1 = \
502 intentsJsonObj1[ installTime ][ 'value' ]
503 intentRerouteLat1 = \
504 int( intentInstall1 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500505
andrewonlab79244cc2015-01-26 01:11:49 -0500506 if clusterCount == 3:
507 intentsJsonStr2 = main.ONOS2cli.intentsEventsMetrics()
508 intentsJsonStr3 = main.ONOS3cli.intentsEventsMetrics()
509
510 intentsJsonObj2 = json.loads( intentsJsonStr2 )
511 intentsJsonObj3 = json.loads( intentsJsonStr3 )
512 intentInstall2 = \
513 intentsJsonObj2[ installTime ][ 'value' ]
514 intentInstall3 = \
515 intentsJsonObj3[ installTime ][ 'value' ]
516 intentRerouteLat2 = \
517 int( intentInstall2 ) - int( t0System )
518 intentRerouteLat3 = \
519 int( intentInstall3 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500520 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500521 intentRerouteLat2 = 0
522 intentRerouteLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500523
andrewonlab79244cc2015-01-26 01:11:49 -0500524 if clusterCount == 5:
525 intentsJsonStr4 = main.ONOS4cli.intentsEventsMetrics()
526 intentsJsonStr5 = main.ONOS5cli.intentsEventsMetrics()
andrewonlaba57a3042015-01-23 13:53:05 -0500527
andrewonlab79244cc2015-01-26 01:11:49 -0500528 intentsJsonObj4 = json.loads( intentsJsonStr4 )
529 intentsJsonObj5 = json.loads( intentsJsonStr5 )
530 intentInstall4 = \
531 intentsJsonObj4[ installTime ][ 'value' ]
532 intentInstall5 = \
533 intentsJsonObj5[ installTime ][ 'value' ]
534 intentRerouteLat4 = \
535 int( intentInstall4 ) - int( t0System )
536 intentRerouteLat5 = \
537 int( intentInstall5 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500538 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500539 intentRerouteLat4 = 0
540 intentRerouteLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500541
andrewonlab79244cc2015-01-26 01:11:49 -0500542 if clusterCount == 7:
543 intentsJsonStr6 = main.ONOS6cli.intentsEventsMetrics()
544 intentsJsonStr7 = main.ONOS7cli.intentsEventsMetrics()
andrewonlaba57a3042015-01-23 13:53:05 -0500545
andrewonlab79244cc2015-01-26 01:11:49 -0500546 intentsJsonObj6 = json.loads( intentsJsonStr6 )
547 intentsJsonObj7 = json.loads( intentsJsonStr7 )
548 intentInstall6 = \
549 intentsJsonObj6[ installTime ][ 'value' ]
550 intentInstall7 = \
551 intentsJsonObj7[ installTime ][ 'value' ]
552 intentRerouteLat6 = \
553 int( intentInstall6 ) - int( t0System )
554 intentRerouteLat7 = \
555 int( intentInstall7 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500556 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500557 intentRerouteLat6 = 0
558 intentRerouteLat7 = 0
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800559
andrewonlab79244cc2015-01-26 01:11:49 -0500560 intentRerouteLatAvg = \
561 ( intentRerouteLat1 +
562 intentRerouteLat2 +
563 intentRerouteLat3 +
564 intentRerouteLat4 +
565 intentRerouteLat5 +
566 intentRerouteLat6 +
567 intentRerouteLat7 ) / clusterCount
andrewonlab4cf9dd22014-11-18 21:28:38 -0500568
andrewonlab79244cc2015-01-26 01:11:49 -0500569 main.log.info( "Intent reroute latency avg for iteration " +
andrewonlabc3336d52015-02-26 18:54:56 -0500570 str( i ) + ": " + str( intentRerouteLatAvg )+ " ms")
andrewonlab79244cc2015-01-26 01:11:49 -0500571
572 if intentRerouteLatAvg > 0.0 and \
573 intentRerouteLatAvg < 1000 and i > numIgnore:
574 intentRerouteLatList.append( intentRerouteLatAvg )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500575 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500576 main.log.info( "Intent reroute latency exceeded " +
577 "threshold. Skipping iteration " + str( i ) )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500578
andrewonlab79244cc2015-01-26 01:11:49 -0500579 main.log.info( "Removing intents for next iteration" )
580 main.ONOS1cli.removeIntent( intentId )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800581
andrewonlab79244cc2015-01-26 01:11:49 -0500582 main.log.info( "Bringing Mininet interface up for next " +
583 "iteration" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500584 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500585 "sh ifconfig " + intfs + " up" )
586 main.Mininet1.handle.expect( "mininet>" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800587
andrewonlab79244cc2015-01-26 01:11:49 -0500588 if intentRerouteLatList:
589 intentRerouteLatAvg = sum( intentRerouteLatList ) /\
590 len( intentRerouteLatList )
andrewonlaba57a3042015-01-23 13:53:05 -0500591 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500592 main.log.report( "Intent reroute test failed. Results NA" )
593 intentRerouteLatAvg = "NA"
594 # NOTE: fails test when list is empty
andrewonlaba57a3042015-01-23 13:53:05 -0500595 assertion = main.FALSE
andrewonlab79244cc2015-01-26 01:11:49 -0500596
597 intentRerouteLatStd = \
598 round( numpy.std( intentRerouteLatList ), 1 )
599 # END ITERATION FOR LOOP
600 main.log.report( "Single intent reroute latency - " )
601 main.log.report( "Avg: " + str( intentRerouteLatAvg ) + " ms" )
602 main.log.report(
603 "Std Deviation: " +
604 str( intentRerouteLatStd ) +
605 " ms" )
606
607 utilities.assert_equals(
608 expect=main.TRUE,
609 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500610 onpass="Single intent reroute latency test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500611 onfail="Single intent reroute latency test failed" )
612
613 def CASE4( self, main ):
614 """
andrewonlab042b3912014-12-10 16:40:50 -0500615 Batch intent install
andrewonlab082dfc32015-02-06 13:59:51 -0500616
617 Supports scale-out scenarios and increasing
618 number of intents within each iteration
andrewonlab79244cc2015-01-26 01:11:49 -0500619 """
andrewonlab70decc02014-11-19 18:50:23 -0500620 import time
621 import json
622 import requests
623 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500624 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500625 global clusterCount
andrewonlab302cd532015-02-20 13:59:50 -0500626 global timeToPost
andrewonlab70decc02014-11-19 18:50:23 -0500627
andrewonlab79244cc2015-01-26 01:11:49 -0500628 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
629 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
630 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
631 ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
632 ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
633 ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
634 ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500635
636 assertion = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800637
andrewonlab79244cc2015-01-26 01:11:49 -0500638 ONOSIpList = []
639 for i in range( 1, 8 ):
640 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlab4293dcb2014-12-02 15:48:05 -0500641
andrewonlab79244cc2015-01-26 01:11:49 -0500642 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab70decc02014-11-19 18:50:23 -0500643
andrewonlab79244cc2015-01-26 01:11:49 -0500644 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab70decc02014-11-19 18:50:23 -0500645
andrewonlab79244cc2015-01-26 01:11:49 -0500646 batchIntentSize = int( main.params[ 'TEST' ][ 'batchIntentSize' ] )
647 batchThreshMin = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
648 batchThreshMax = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
andrewonlab4293dcb2014-12-02 15:48:05 -0500649
andrewonlab79244cc2015-01-26 01:11:49 -0500650 # number of iterations of case
651 numIter = main.params[ 'TEST' ][ 'numIter' ]
652 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
653 numSwitch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
654 nThread = main.params[ 'TEST' ][ 'numMult' ]
655 #nThread = 105
656
andrewonlabe07f8562015-02-20 12:23:07 -0500657 # DB operation variables
andrewonlab302cd532015-02-20 13:59:50 -0500658 intentFilePath = main.params[ 'DB' ][ 'intentFilePath' ]
andrewonlabe07f8562015-02-20 12:23:07 -0500659
andrewonlab79244cc2015-01-26 01:11:49 -0500660 # Switch assignment NOTE: hardcoded
661 if clusterCount == 1:
662 for i in range( 1, numSwitch + 1 ):
663 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700664 sw="s" + str( i ),
665 ip=ONOS1Ip,
666 port=defaultSwPort )
andrewonlab79244cc2015-01-26 01:11:49 -0500667 if clusterCount == 3:
668 for i in range( 1, 3 ):
669 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700670 sw="s" + str( i ),
671 ip=ONOS1Ip,
672 port=defaultSwPort )
andrewonlab79244cc2015-01-26 01:11:49 -0500673 for i in range( 3, 6 ):
674 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700675 sw="s" + str( i ),
676 ip=ONOS2Ip,
677 port=defaultSwPort )
andrewonlab79244cc2015-01-26 01:11:49 -0500678 for i in range( 6, 9 ):
679 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700680 sw="s" + str( i ),
681 ip=ONOS3Ip,
682 port=defaultSwPort )
andrewonlab79244cc2015-01-26 01:11:49 -0500683 if clusterCount == 5:
684 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700685 sw="s1",
686 ip=ONOS1Ip,
687 port=defaultSwPort )
andrewonlab79244cc2015-01-26 01:11:49 -0500688 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700689 sw="s2",
690 ip=ONOS1Ip,
691 port=defaultSwPort )
andrewonlab79244cc2015-01-26 01:11:49 -0500692 for i in range( 3, 6 ):
693 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700694 sw="s" + str( i ),
695 ip=ONOS3Ip,
696 port=defaultSwPort )
andrewonlab79244cc2015-01-26 01:11:49 -0500697 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700698 sw="s6",
699 ip=ONOS4Ip,
700 port=defaultSwPort )
andrewonlab79244cc2015-01-26 01:11:49 -0500701 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700702 sw="s7",
703 ip=ONOS5Ip,
704 port=defaultSwPort )
andrewonlab79244cc2015-01-26 01:11:49 -0500705 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700706 sw="s8",
707 ip=ONOS5Ip,
708 port=defaultSwPort )
andrewonlab79244cc2015-01-26 01:11:49 -0500709
710 if clusterCount == 7:
711 for i in range( 1, 9 ):
andrewonlabeb1d0542014-12-03 20:12:01 -0500712 if i < 8:
andrewonlab79244cc2015-01-26 01:11:49 -0500713 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700714 sw="s" + str( i ),
715 ip=ONOSIpList[ i - 1 ],
716 port=defaultSwPort )
andrewonlab79244cc2015-01-26 01:11:49 -0500717 elif i >= 8:
718 main.Mininet1.assignSwController(
kelvin-onlab9d8bf3d2015-07-06 10:49:38 -0700719 sw="s" + str( i ),
720 ip=ONOSIpList[ 6 ],
721 port=defaultSwPort )
andrewonlab70decc02014-11-19 18:50:23 -0500722
andrewonlab79244cc2015-01-26 01:11:49 -0500723 time.sleep( 20 )
andrewonlabeb1d0542014-12-03 20:12:01 -0500724
andrewonlab79244cc2015-01-26 01:11:49 -0500725 main.log.report( "Batch intent installation test of " +
726 str( batchIntentSize ) + " intent(s)" )
andrewonlab4293dcb2014-12-02 15:48:05 -0500727
andrewonlab79244cc2015-01-26 01:11:49 -0500728 batchResultList = []
andrewonlab70decc02014-11-19 18:50:23 -0500729
andrewonlab79244cc2015-01-26 01:11:49 -0500730 main.log.info( "Getting list of available devices" )
731 deviceIdList = []
732 jsonStr = main.ONOS1cli.devices()
733 jsonObj = json.loads( jsonStr )
734 for device in jsonObj:
735 deviceIdList.append( device[ 'id' ] )
andrewonlab70decc02014-11-19 18:50:23 -0500736
andrewonlab302cd532015-02-20 13:59:50 -0500737 # List of install / witdhraw latencies for each batch
andrewonlab79244cc2015-01-26 01:11:49 -0500738 batchInstallLat = []
739 batchWithdrawLat = []
andrewonlab70decc02014-11-19 18:50:23 -0500740
andrewonlab79244cc2015-01-26 01:11:49 -0500741 sleepTime = 10
742
743 baseDir = "/tmp/"
744
andrewonlabe07f8562015-02-20 12:23:07 -0500745 # Batch size increase loop
andrewonlab79244cc2015-01-26 01:11:49 -0500746 for batch in range( 0, 5 ):
andrewonlabe07f8562015-02-20 12:23:07 -0500747 # Max intent install measurement of all nodes
748 # Resets after each batch calculation
749 maxInstallLat = []
750 maxWithdrawLat = []
andrewonlabc3336d52015-02-26 18:54:56 -0500751 # Max single intent install measurement of all nodes
752 # For example, if batch size is 1000, result latency
753 # will be divided by 1000
754 maxSingleInstallLat = []
755 maxSingleWithdrawLat = []
andrewonlabe07f8562015-02-20 12:23:07 -0500756 # Statistical gathering loop over number of iterations
andrewonlab79244cc2015-01-26 01:11:49 -0500757 for i in range( 0, int( numIter ) ):
758 main.log.info( "Pushing " +
759 str( int( batchIntentSize ) * int( nThread ) ) +
760 " intents. Iteration " + str( i ) )
761
762 for node in range( 1, clusterCount + 1 ):
763 saveDir = baseDir + "batch_intent_" + str( node ) + ".txt"
764 main.ONOSbench.pushTestIntentsShell(
765 deviceIdList[ 0 ] + "/2",
766 deviceIdList[ 7 ] + "/2",
767 batchIntentSize,
768 saveDir, ONOSIpList[ node - 1 ],
andrewonlabc3336d52015-02-26 18:54:56 -0500769 numMult=nThread )
andrewonlab79244cc2015-01-26 01:11:49 -0500770
771 # Wait sufficient time for intents to start
772 # installing
773 time.sleep( sleepTime )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800774
andrewonlaba57a3042015-01-23 13:53:05 -0500775 intent = ""
776 counter = 300
andrewonlab79244cc2015-01-26 01:11:49 -0500777 while len( intent ) > 0 and counter > 0:
andrewonlaba57a3042015-01-23 13:53:05 -0500778 main.ONOS1cli.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500779 "intents | wc -l" )
andrewonlaba57a3042015-01-23 13:53:05 -0500780 main.ONOS1cli.handle.expect(
andrewonlab79244cc2015-01-26 01:11:49 -0500781 "intents | wc -l" )
andrewonlaba57a3042015-01-23 13:53:05 -0500782 main.ONOS1cli.handle.expect(
andrewonlab79244cc2015-01-26 01:11:49 -0500783 "onos>" )
784 intentTemp = main.ONOS1cli.handle.before()
andrewonlaba57a3042015-01-23 13:53:05 -0500785 intent = main.ONOS1cli.intents()
andrewonlab79244cc2015-01-26 01:11:49 -0500786 intent = json.loads( intent )
787 counter = counter - 1
788 time.sleep( 1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800789
andrewonlab79244cc2015-01-26 01:11:49 -0500790 time.sleep( 5 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800791
andrewonlab79244cc2015-01-26 01:11:49 -0500792 for node in range( 1, clusterCount + 1 ):
793 saveDir = baseDir + "batch_intent_" + str( node ) + ".txt"
794 with open( saveDir ) as fOnos:
795 lineCount = 0
796 for line in fOnos:
andrewonlabc3336d52015-02-26 18:54:56 -0500797 line_temp = ""
andrewonlab79244cc2015-01-26 01:11:49 -0500798 main.log.info( "Line read: " + str( line ) )
andrewonlabc3336d52015-02-26 18:54:56 -0500799 line_temp = line[ 1: ]
800 line_temp = line_temp.split( ": " )
andrewonlabd019a6b2015-02-05 00:05:22 -0500801 #Prevent split method if line doesn't have
802 #space
andrewonlabc3336d52015-02-26 18:54:56 -0500803 if " " in str(line_temp):
804 result = line_temp[ 1 ].split( " " )[ 0 ]
andrewonlabd019a6b2015-02-05 00:05:22 -0500805 else:
806 main.log.warn( "Empty line read" )
807 result = 0
andrewonlab79244cc2015-01-26 01:11:49 -0500808 # TODO: add parameters before appending latency
809 if lineCount == 0:
andrewonlabc3336d52015-02-26 18:54:56 -0500810 if "Failure" in str(line):
811 main.log.warn("Intent installation failed")
812 result = 'NA'
813 else:
814 main.log.info("Install result: "+result)
815 batchInstallLat.append( int( result ) )
andrewonlab79244cc2015-01-26 01:11:49 -0500816 installResult = result
817 elif lineCount == 1:
andrewonlabc3336d52015-02-26 18:54:56 -0500818 if "Failure" in str(line):
819 main.log.warn("Intent withdraw failed")
820 result = 'NA'
821 else:
822 main.log.info("Withdraw result: "+result)
823 batchWithdrawLat.append( int( result ) )
andrewonlab79244cc2015-01-26 01:11:49 -0500824 withdrawResult = result
andrewonlabd019a6b2015-02-05 00:05:22 -0500825 else:
andrewonlabc3336d52015-02-26 18:54:56 -0500826 main.log.warn("Invalid results: excess lines")
andrewonlabd019a6b2015-02-05 00:05:22 -0500827 installResult = 'NA'
828 withdrawResult = 'NA'
andrewonlab79244cc2015-01-26 01:11:49 -0500829 lineCount += 1
830 main.log.info( "Batch install latency for ONOS" +
831 str( node ) + " with " +
832 str( batchIntentSize ) + "intents: " +
833 str( installResult ) + " ms" )
834 main.log.info( "Batch withdraw latency for ONOS" +
835 str( node ) + " with " +
836 str( batchIntentSize ) + "intents: " +
837 str( withdrawResult ) + " ms" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500838
andrewonlabc3336d52015-02-26 18:54:56 -0500839 main.log.info( "Single intent install latency ONOS" +
840 str( node ) + " with " +
841 str( batchIntentSize ) + "intents: " +
842 str( float(installResult) /\
843 int(batchIntentSize) ) + " ms" )
844 main.log.info( "Single intent withdraw latency ONOS" +
845 str( node ) + " with " +
846 str( batchIntentSize ) + "intents: " +
847 str( float(withdrawResult) /\
848 int(batchIntentSize) ) + " ms" )
849
andrewonlab302cd532015-02-20 13:59:50 -0500850 #NOTE: END node loop
851
andrewonlab79244cc2015-01-26 01:11:49 -0500852 if len( batchInstallLat ) > 0 and int( i ) > numIgnore:
853 maxInstallLat.append( max( batchInstallLat ) )
andrewonlabc3336d52015-02-26 18:54:56 -0500854 maxSingleInstallLat.append(
855 max( batchInstallLat ) / int( batchIntentSize )
856 )
andrewonlab79244cc2015-01-26 01:11:49 -0500857 elif len( batchInstallLat ) == 0:
858 # If I failed to read anything from the file,
859 # increase the wait time before checking intents
860 sleepTime += 30
861 if len( batchWithdrawLat ) > 0 and int( i ) > numIgnore:
862 maxWithdrawLat.append( max( batchWithdrawLat ) )
andrewonlabc3336d52015-02-26 18:54:56 -0500863 maxSingleWithdrawLat.append(
864 max( batchWithdrawLat ) / int( batchIntentSize )
865 )
andrewonlab79244cc2015-01-26 01:11:49 -0500866 batchInstallLat = []
867 batchWithdrawLat = []
868
869 # Sleep in between iterations
870 time.sleep( 5 )
871
andrewonlab302cd532015-02-20 13:59:50 -0500872 #NOTE: END iteration loop
873
andrewonlab79244cc2015-01-26 01:11:49 -0500874 if maxInstallLat:
andrewonlabc3336d52015-02-26 18:54:56 -0500875 avgInstallLat = str( round( numpy.average(maxInstallLat)
andrewonlabd019a6b2015-02-05 00:05:22 -0500876 , 2 ))
andrewonlab302cd532015-02-20 13:59:50 -0500877 stdInstallLat = str( round(
878 numpy.std(maxInstallLat), 2))
andrewonlabc3336d52015-02-26 18:54:56 -0500879 avgSingleInstallLat = str( round(
880 numpy.average(maxSingleInstallLat)
881 , 3 ))
882 stdSingleInstallLat = str( round(
883 numpy.std(maxSingleInstallLat),
884 3 ))
andrewonlaba57a3042015-01-23 13:53:05 -0500885 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500886 avgInstallLat = "NA"
andrewonlab302cd532015-02-20 13:59:50 -0500887 stdInstallLat = "NA"
andrewonlab79244cc2015-01-26 01:11:49 -0500888 main.log.report( "Batch installation failed" )
andrewonlaba57a3042015-01-23 13:53:05 -0500889 assertion = main.FALSE
andrewonlabeb1d0542014-12-03 20:12:01 -0500890
andrewonlab79244cc2015-01-26 01:11:49 -0500891 if maxWithdrawLat:
andrewonlabc3336d52015-02-26 18:54:56 -0500892 avgWithdrawLat = str( round( numpy.average(maxWithdrawLat)
andrewonlabd019a6b2015-02-05 00:05:22 -0500893 , 2 ))
andrewonlab302cd532015-02-20 13:59:50 -0500894 stdWithdrawLat = str( round(
895 numpy.std(maxWithdrawLat), 2))
andrewonlabc3336d52015-02-26 18:54:56 -0500896 avgSingleWithdrawLat = str( round(
897 numpy.average(maxSingleWithdrawLat)
898 , 3 ))
899 stdSingleWithdrawLat = str( round(
900 numpy.std(maxSingleWithdrawLat),
901 3 ))
andrewonlaba57a3042015-01-23 13:53:05 -0500902 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500903 avgWithdrawLat = "NA"
andrewonlab302cd532015-02-20 13:59:50 -0500904 stdWithdrawLat = "NA"
andrewonlab79244cc2015-01-26 01:11:49 -0500905 main.log.report( "Batch withdraw failed" )
andrewonlaba57a3042015-01-23 13:53:05 -0500906 assertion = main.FALSE
andrewonlabeb1d0542014-12-03 20:12:01 -0500907
andrewonlab79244cc2015-01-26 01:11:49 -0500908 main.log.report( "Avg of batch installation latency " +
909 "of size " + str( batchIntentSize ) + ": " +
910 str( avgInstallLat ) + " ms" )
911 main.log.report( "Std Deviation of batch installation latency " +
andrewonlabd019a6b2015-02-05 00:05:22 -0500912 ": " +
andrewonlab302cd532015-02-20 13:59:50 -0500913 str( stdInstallLat ) + " ms" )
andrewonlabc3336d52015-02-26 18:54:56 -0500914 main.log.report( "Avg of single installation latency " +
915 "of size " + str( batchIntentSize ) + ": " +
916 str( avgSingleInstallLat ) + " ms" )
917 main.log.report( "Std Deviation of single installation latency " +
918 ": " +
919 str( stdSingleInstallLat ) + " ms" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500920
andrewonlab79244cc2015-01-26 01:11:49 -0500921 main.log.report( "Avg of batch withdraw latency " +
922 "of size " + str( batchIntentSize ) + ": " +
923 str( avgWithdrawLat ) + " ms" )
924 main.log.report( "Std Deviation of batch withdraw latency " +
925 ": " +
andrewonlab302cd532015-02-20 13:59:50 -0500926 str( stdWithdrawLat ) + " ms" )
andrewonlabc3336d52015-02-26 18:54:56 -0500927 main.log.report( "Avg of single withdraw latency " +
928 "of size " + str( batchIntentSize ) + ": " +
929 str( avgSingleWithdrawLat ) + " ms" )
930 main.log.report( "Std Deviation of single withdraw latency " +
931 ": " +
932 str( stdSingleWithdrawLat ) + " ms" )
andrewonlab302cd532015-02-20 13:59:50 -0500933
934 dbCmd = (
andrewonlabc3336d52015-02-26 18:54:56 -0500935 "INSERT INTO intents_latency_tests VALUES("
936 "'"+timeToPost+"','intents_latency_results',"
andrewonlab302cd532015-02-20 13:59:50 -0500937 ""+runNum+","+str(clusterCount)+","+str(batchIntentSize)+","
938 ""+str(avgInstallLat)+","+str(stdInstallLat)+","
939 ""+str(avgWithdrawLat)+","+str(stdWithdrawLat)+");"
940 )
941
942 # Write result to file (which is posted to DB by jenkins)
943 fResult = open(intentFilePath, 'a')
944 if dbCmd:
945 fResult.write(dbCmd+"\n")
946 fResult.close()
andrewonlab79244cc2015-01-26 01:11:49 -0500947
andrewonlabd019a6b2015-02-05 00:05:22 -0500948 if batch == 0:
949 batchIntentSize = 10
950 elif batch == 1:
951 batchIntentSize = 100
952 elif batch == 2:
953 batchIntentSize = 1000
954 elif batch == 3:
955 batchIntentSize = 2000
956 if batch < 4:
957 main.log.report( "Increasing batch intent size to " +
andrewonlab79244cc2015-01-26 01:11:49 -0500958 str(batchIntentSize) )
959
andrewonlab302cd532015-02-20 13:59:50 -0500960 #NOTE: END batch loop
961
andrewonlab79244cc2015-01-26 01:11:49 -0500962 #main.log.info( "Removing all intents for next test case" )
963 #jsonTemp = main.ONOS1cli.intents( jsonFormat=True )
964 #jsonObjIntents = json.loads( jsonTemp )
965 # if jsonObjIntents:
966 # for intents in jsonObjIntents:
967 # tempId = intents[ 'id' ]
968 # main.ONOS1cli.removeIntent( tempId )
969 # main.ONOS1cli.removeIntent( tempId )
970
971 utilities.assert_equals(
972 expect=main.TRUE,
973 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500974 onpass="Batch intent install/withdraw test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500975 onfail="Batch intent install/withdraw test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800976
andrewonlab79244cc2015-01-26 01:11:49 -0500977 def CASE5( self, main ):
978 """
andrewonlab4293dcb2014-12-02 15:48:05 -0500979 Increase number of nodes and initiate CLI
andrewonlab79244cc2015-01-26 01:11:49 -0500980 """
andrewonlab4293dcb2014-12-02 15:48:05 -0500981 import time
982 import json
983
andrewonlab79244cc2015-01-26 01:11:49 -0500984 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
985 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
986 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
987 ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
988 ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
989 ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
990 ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
andrewonlab4293dcb2014-12-02 15:48:05 -0500991
andrewonlab79244cc2015-01-26 01:11:49 -0500992 global clusterCount
993 clusterCount += 2
994 main.log.report( "Increasing cluster size to " +
995 str( clusterCount ) )
andrewonlab4293dcb2014-12-02 15:48:05 -0500996
andrewonlab79244cc2015-01-26 01:11:49 -0500997 installResult = main.FALSE
andrewonlab4293dcb2014-12-02 15:48:05 -0500998
andrewonlab79244cc2015-01-26 01:11:49 -0500999 if clusterCount == 3:
1000 installResult1 = \
1001 main.ONOSbench.onosInstall( node=ONOS2Ip )
1002 installResult2 = \
1003 main.ONOSbench.onosInstall( node=ONOS3Ip )
1004 time.sleep( 5 )
andrewonlab4293dcb2014-12-02 15:48:05 -05001005
andrewonlab79244cc2015-01-26 01:11:49 -05001006 main.log.info( "Starting ONOS CLI" )
1007 main.ONOS2cli.startOnosCli( ONOS2Ip )
1008 main.ONOS3cli.startOnosCli( ONOS3Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -05001009
andrewonlab79244cc2015-01-26 01:11:49 -05001010 installResult = installResult1 and installResult2
andrewonlab4293dcb2014-12-02 15:48:05 -05001011
andrewonlab79244cc2015-01-26 01:11:49 -05001012 if clusterCount == 5:
1013 main.log.info( "Installing ONOS on node 4 and 5" )
1014 installResult1 = \
1015 main.ONOSbench.onosInstall( node=ONOS4Ip )
1016 installResult2 = \
1017 main.ONOSbench.onosInstall( node=ONOS5Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -05001018
andrewonlab79244cc2015-01-26 01:11:49 -05001019 main.log.info( "Starting ONOS CLI" )
1020 main.ONOS4cli.startOnosCli( ONOS4Ip )
1021 main.ONOS5cli.startOnosCli( ONOS5Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -05001022
andrewonlab79244cc2015-01-26 01:11:49 -05001023 installResult = installResult1 and installResult2
andrewonlab4293dcb2014-12-02 15:48:05 -05001024
andrewonlab79244cc2015-01-26 01:11:49 -05001025 if clusterCount == 7:
1026 main.log.info( "Installing ONOS on node 6 and 7" )
1027 installResult1 = \
1028 main.ONOSbench.onosInstall( node=ONOS6Ip )
1029 installResult2 = \
1030 main.ONOSbench.onosInstall( node=ONOS7Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -05001031
andrewonlab79244cc2015-01-26 01:11:49 -05001032 main.log.info( "Starting ONOS CLI" )
1033 main.ONOS6cli.startOnosCli( ONOS6Ip )
1034 main.ONOS7cli.startOnosCli( ONOS7Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -05001035
andrewonlab79244cc2015-01-26 01:11:49 -05001036 installResult = installResult1 and installResult2
andrewonlab4293dcb2014-12-02 15:48:05 -05001037
andrewonlab79244cc2015-01-26 01:11:49 -05001038 time.sleep( 5 )
andrewonlab4293dcb2014-12-02 15:48:05 -05001039
andrewonlab79244cc2015-01-26 01:11:49 -05001040 if installResult == main.TRUE:
andrewonlab4293dcb2014-12-02 15:48:05 -05001041 assertion = main.TRUE
1042 else:
1043 assertion = main.FALSE
1044
andrewonlab79244cc2015-01-26 01:11:49 -05001045 utilities.assert_equals( expect=main.TRUE, actual=assertion,
1046 onpass="Scale out to " + str( clusterCount ) +
1047 " nodes successful",
1048 onfail="Scale out to " + str( clusterCount ) +
1049 " nodes failed" )
andrewonlab4293dcb2014-12-02 15:48:05 -05001050
andrewonlab79244cc2015-01-26 01:11:49 -05001051 def CASE7( self, main ):
1052 # TODO: Fix for scale-out scenario
1053 """
andrewonlaba57a3042015-01-23 13:53:05 -05001054 Batch intent reroute latency
andrewonlab79244cc2015-01-26 01:11:49 -05001055 """
andrewonlaba57a3042015-01-23 13:53:05 -05001056 import time
1057 import json
1058 import requests
1059 import os
1060 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -05001061 global clusterCount
andrewonlaba57a3042015-01-23 13:53:05 -05001062
andrewonlab79244cc2015-01-26 01:11:49 -05001063 ONOSIpList = []
1064 for i in range( 1, 8 ):
1065 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlaba57a3042015-01-23 13:53:05 -05001066
andrewonlab79244cc2015-01-26 01:11:49 -05001067 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
1068 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlaba57a3042015-01-23 13:53:05 -05001069
andrewonlab79244cc2015-01-26 01:11:49 -05001070 batchIntentSize = main.params[ 'TEST' ][ 'batchIntentSize' ]
1071 batchThreshMin = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
1072 batchThreshMax = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
1073 intfs = main.params[ 'TEST' ][ 'intfs' ]
1074 installTime = main.params[ 'JSON' ][ 'installedTime' ]
andrewonlaba57a3042015-01-23 13:53:05 -05001075
andrewonlab79244cc2015-01-26 01:11:49 -05001076 # number of iterations of case
1077 numIter = main.params[ 'TEST' ][ 'numIter' ]
1078 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
1079 numSwitch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
1080 nThread = main.params[ 'TEST' ][ 'numMult' ]
andrewonlaba57a3042015-01-23 13:53:05 -05001081
andrewonlab79244cc2015-01-26 01:11:49 -05001082 main.log.report( "Batch intent installation test of " +
1083 batchIntentSize + " intents" )
andrewonlaba57a3042015-01-23 13:53:05 -05001084
andrewonlab79244cc2015-01-26 01:11:49 -05001085 batchResultList = []
andrewonlaba57a3042015-01-23 13:53:05 -05001086
andrewonlab79244cc2015-01-26 01:11:49 -05001087 time.sleep( 10 )
andrewonlaba57a3042015-01-23 13:53:05 -05001088
andrewonlab79244cc2015-01-26 01:11:49 -05001089 main.log.info( "Getting list of available devices" )
1090 deviceIdList = []
1091 jsonStr = main.ONOS1cli.devices()
1092 jsonObj = json.loads( jsonStr )
1093 for device in jsonObj:
1094 deviceIdList.append( device[ 'id' ] )
andrewonlaba57a3042015-01-23 13:53:05 -05001095
andrewonlab79244cc2015-01-26 01:11:49 -05001096 batchInstallLat = []
1097 batchWithdrawLat = []
1098 sleepTime = 10
andrewonlaba57a3042015-01-23 13:53:05 -05001099
andrewonlab79244cc2015-01-26 01:11:49 -05001100 baseDir = "/tmp/"
1101 maxInstallLat = []
1102
1103 for i in range( 0, int( numIter ) ):
1104 main.log.info( "Pushing " +
1105 str( int( batchIntentSize ) * int( nThread ) ) +
1106 " intents. Iteration " + str( i ) )
1107
1108 main.ONOSbench.pushTestIntentsShell(
1109 deviceIdList[ 0 ] + "/2",
1110 deviceIdList[ 7 ] + "/2",
1111 batchIntentSize, "/tmp/batch_install.txt",
1112 ONOSIpList[ 0 ], numMult="1", appId="1",
1113 report=False, options="--install" )
1114 # main.ONOSbench.pushTestIntentsShell(
andrewonlaba57a3042015-01-23 13:53:05 -05001115 # "of:0000000000001002/1",
1116 # "of:0000000000002002/1",
1117 # 133, "/tmp/temp2.txt", "10.128.174.2",
andrewonlab79244cc2015-01-26 01:11:49 -05001118 # numMult="6", appId="2",report=False )
1119
1120 # TODO: Check for installation success then proceed
1121 time.sleep( 30 )
1122
1123 # NOTE: this interface is specific to
andrewonlaba57a3042015-01-23 13:53:05 -05001124 # topo-intentFlower.py topology
1125 # reroute case.
andrewonlab79244cc2015-01-26 01:11:49 -05001126 main.log.info( "Disabling interface " + intfs )
andrewonlaba57a3042015-01-23 13:53:05 -05001127 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001128 "sh ifconfig " + intfs + " down" )
1129 t0System = time.time() * 1000
andrewonlaba57a3042015-01-23 13:53:05 -05001130
andrewonlab79244cc2015-01-26 01:11:49 -05001131 # TODO: Wait sufficient time for intents to install
1132 time.sleep( 10 )
andrewonlaba57a3042015-01-23 13:53:05 -05001133
andrewonlab79244cc2015-01-26 01:11:49 -05001134 # TODO: get intent installation time
1135
1136 # Obtain metrics from ONOS 1, 2, 3
1137 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
1138 intentsJsonObj1 = json.loads( intentsJsonStr1 )
1139 # Parse values from the json object
1140 intentInstall1 = \
1141 intentsJsonObj1[ installTime ][ 'value' ]
1142 intentRerouteLat1 = \
1143 int( intentInstall1 ) - int( t0System )
1144
1145 if clusterCount == 3:
1146 intentsJsonStr2 =\
1147 main.ONOS2cli.intentsEventsMetrics()
1148 intentsJsonStr3 =\
1149 main.ONOS3cli.intentsEventsMetrics()
1150 intentsJsonObj2 = json.loads( intentsJsonStr2 )
1151 intentsJsonObj3 = json.loads( intentsJsonStr3 )
1152 intentInstall2 = \
1153 intentsJsonObj2[ installTime ][ 'value' ]
1154 intentInstall3 = \
1155 intentsJsonObj3[ installTime ][ 'value' ]
1156 intentRerouteLat2 = \
1157 int( intentInstall2 ) - int( t0System )
1158 intentRerouteLat3 = \
1159 int( intentInstall3 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -05001160 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001161 intentRerouteLat2 = 0
1162 intentRerouteLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001163
andrewonlab79244cc2015-01-26 01:11:49 -05001164 if clusterCount == 5:
1165 intentsJsonStr4 =\
1166 main.ONOS4cli.intentsEventsMetrics()
1167 intentsJsonStr5 =\
1168 main.ONOS5cli.intentsEventsMetrics()
1169 intentsJsonObj4 = json.loads( intentsJsonStr4 )
1170 intentsJsonObj5 = json.loads( intentsJsonStr5 )
1171 intentInstall4 = \
1172 intentsJsonObj4[ installTime ][ 'value' ]
1173 intentInstall5 = \
1174 intentsJsonObj5[ installTime ][ 'value' ]
1175 intentRerouteLat4 = \
1176 int( intentInstall4 ) - int( t0System )
1177 intentRerouteLat5 = \
1178 int( intentInstall5 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -05001179 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001180 intentRerouteLat4 = 0
1181 intentRerouteLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001182
andrewonlab79244cc2015-01-26 01:11:49 -05001183 if clusterCount == 7:
1184 intentsJsonStr6 =\
1185 main.ONOS6cli.intentsEventsMetrics()
1186 intentsJsonStr7 =\
1187 main.ONOS7cli.intentsEventsMetrics()
1188 intentsJsonObj6 = json.loads( intentsJsonStr6 )
1189 intentsJsonObj7 = json.loads( intentsJsonStr7 )
1190 intentInstall6 = \
1191 intentsJsonObj6[ installTime ][ 'value' ]
1192 intentInstall7 = \
1193 intentsJsonObj7[ installTime ][ 'value' ]
1194 intentRerouteLat6 = \
1195 int( intentInstall6 ) - int( t0System )
1196 intentRerouteLat7 = \
1197 int( intentInstall7 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -05001198 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001199 intentRerouteLat6 = 0
1200 intentRerouteLat7 = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001201
andrewonlab79244cc2015-01-26 01:11:49 -05001202 intentRerouteLatAvg = \
1203 ( intentRerouteLat1 +
1204 intentRerouteLat2 +
1205 intentRerouteLat3 +
1206 intentRerouteLat4 +
1207 intentRerouteLat5 +
1208 intentRerouteLat6 +
1209 intentRerouteLat7 ) / clusterCount
andrewonlaba57a3042015-01-23 13:53:05 -05001210
andrewonlab79244cc2015-01-26 01:11:49 -05001211 main.log.info( "Intent reroute latency avg for iteration " +
1212 str( i ) + ": " + str( intentRerouteLatAvg ) )
1213 # TODO: Remove intents for next iteration
1214
1215 time.sleep( 5 )
1216
1217 intentsStr = main.ONOS1cli.intents()
1218 intentsJson = json.loads( intentsStr )
1219 for intents in intentsJson:
1220 intentId = intents[ 'id' ]
1221 # TODO: make sure this removes all intents
1222 # print intentId
1223 if intentId:
1224 main.ONOS1cli.removeIntent( intentId )
andrewonlaba57a3042015-01-23 13:53:05 -05001225
1226 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001227 "sh ifconfig " + intfs + " up" )
andrewonlaba57a3042015-01-23 13:53:05 -05001228
andrewonlab79244cc2015-01-26 01:11:49 -05001229 main.log.info( "Intents removed and port back up" )
1230
1231 def CASE9( self, main ):
andrewonlabeb1d0542014-12-03 20:12:01 -05001232 count = 0
andrewonlab79244cc2015-01-26 01:11:49 -05001233 swNum1 = 1
1234 swNum2 = 1
andrewonlabeb1d0542014-12-03 20:12:01 -05001235 appid = 0
andrewonlab79244cc2015-01-26 01:11:49 -05001236 portNum1 = 1
1237 portNum2 = 1
1238
1239 time.sleep( 30 )
andrewonlab4cf9dd22014-11-18 21:28:38 -05001240
andrewonlabeb1d0542014-12-03 20:12:01 -05001241 while True:
andrewonlab79244cc2015-01-26 01:11:49 -05001242 # main.ONOS1cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001243 #"of:0000000000001001/1",
1244 #"of:0000000000002001/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001245 # 100, numMult="10", appId="1" )
1246 # main.ONOS2cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001247 # "of:0000000000001002/1",
1248 # "of:0000000000002002/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001249 # 100, numMult="10", appId="2" )
1250 # main.ONOS2cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001251 # "of:0000000000001003/1",
1252 # "of:0000000000002003/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001253 # 100, numMult="10", appId="3" )
andrewonlabeb1d0542014-12-03 20:12:01 -05001254 count += 1
andrewonlab79244cc2015-01-26 01:11:49 -05001255
andrewonlabeb1d0542014-12-03 20:12:01 -05001256 if count >= 100:
1257 main.ONOSbench.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001258 "onos 10.128.174.1 intents-events-metrics >>" +
1259 " /tmp/metrics_intents_temp.txt &" )
andrewonlabeb1d0542014-12-03 20:12:01 -05001260 count = 0
1261
andrewonlab79244cc2015-01-26 01:11:49 -05001262 arg1 = "of:000000000000100" + str( swNum1 ) + "/" + str( portNum1 )
1263 arg2 = "of:000000000000200" + str( swNum2 ) + "/" + str( portNum2 )
andrewonlabeb1d0542014-12-03 20:12:01 -05001264
andrewonlab79244cc2015-01-26 01:11:49 -05001265 swNum1 += 1
1266
1267 if swNum1 > 7:
1268 swNum1 = 1
1269 swNum2 += 1
1270 if swNum2 > 7:
andrewonlabeb1d0542014-12-03 20:12:01 -05001271 appid += 1
1272
andrewonlab79244cc2015-01-26 01:11:49 -05001273 if swNum2 > 7:
1274 swNum2 = 1
1275
1276 main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001277 arg1,
andrewonlab79244cc2015-01-26 01:11:49 -05001278 arg2,
andrewonlab042b3912014-12-10 16:40:50 -05001279 100, "/tmp/temp.txt", "10.128.174.1",
andrewonlab79244cc2015-01-26 01:11:49 -05001280 numMult="10", appId=appid, report=False )
1281 # main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001282 # "of:0000000000001002/1",
1283 # "of:0000000000002002/1",
1284 # 133, "/tmp/temp2.txt", "10.128.174.2",
andrewonlab79244cc2015-01-26 01:11:49 -05001285 # numMult="6", appId="2",report=False )
1286 # main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001287 # "of:0000000000001003/1",
1288 # "of:0000000000002003/1",
1289 # 133, "/tmp/temp3.txt", "10.128.174.3",
andrewonlab79244cc2015-01-26 01:11:49 -05001290 # numMult="6", appId="3",report=False )
andrewonlab92ea3672014-11-04 20:22:14 -05001291
andrewonlab79244cc2015-01-26 01:11:49 -05001292 time.sleep( 0.2 )