blob: 06610730c7de4e8c48b488cb6571b2502c832889 [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
19 clusterCount = 1
andrewonlab92ea3672014-11-04 20:22:14 -050020
andrewonlab79244cc2015-01-26 01:11:49 -050021 cellName = main.params[ 'ENV' ][ 'cellName' ]
andrewonlab92ea3672014-11-04 20:22:14 -050022
andrewonlab79244cc2015-01-26 01:11:49 -050023 gitPull = main.params[ 'GIT' ][ 'autoPull' ]
24 checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
andrewonlab92ea3672014-11-04 20:22:14 -050025
andrewonlab79244cc2015-01-26 01:11:49 -050026 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
27 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
28 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
29 ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
30 ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
31 ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
32 ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
andrewonlab4293dcb2014-12-02 15:48:05 -050033
andrewonlab79244cc2015-01-26 01:11:49 -050034 main.ONOSbench.onosUninstall( nodeIp=ONOS1Ip )
35 main.ONOSbench.onosUninstall( nodeIp=ONOS2Ip )
36 main.ONOSbench.onosUninstall( nodeIp=ONOS3Ip )
37 main.ONOSbench.onosUninstall( nodeIp=ONOS4Ip )
38 main.ONOSbench.onosUninstall( nodeIp=ONOS5Ip )
39 main.ONOSbench.onosUninstall( nodeIp=ONOS6Ip )
andrewonlabd019a6b2015-02-05 00:05:22 -050040 #TODO: Investigate why node 7 uninstall fails
41 #main.ONOSbench.onosUninstall( nodeIp=ONOS7Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -050042
andrewonlab79244cc2015-01-26 01:11:49 -050043 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
44 BENCHIp = main.params[ 'BENCH' ][ 'ip' ]
andrewonlab92ea3672014-11-04 20:22:14 -050045
andrewonlab79244cc2015-01-26 01:11:49 -050046 main.case( "Setting up test environment" )
andrewonlab92ea3672014-11-04 20:22:14 -050047
andrewonlab79244cc2015-01-26 01:11:49 -050048 main.step( "Creating cell file" )
49 cellFileResult = main.ONOSbench.createCellFile(
50 BENCHIp, cellName, MN1Ip,
51 "onos-core,onos-app-metrics,onos-gui",
52 ONOS1Ip )
andrewonlab92ea3672014-11-04 20:22:14 -050053
andrewonlab79244cc2015-01-26 01:11:49 -050054 main.step( "Applying cell file to environment" )
55 cellApplyResult = main.ONOSbench.setCell( cellName )
56 verifyCellResult = main.ONOSbench.verifyCell()
andrewonlab4293dcb2014-12-02 15:48:05 -050057
andrewonlab79244cc2015-01-26 01:11:49 -050058 main.step( "Removing raft logs" )
59 main.ONOSbench.onosRemoveRaftLogs()
60
61 main.step( "Git checkout and pull " + checkoutBranch )
62 if gitPull == 'on':
63 checkoutResult = \
64 main.ONOSbench.gitCheckout( checkoutBranch )
65 pullResult = main.ONOSbench.gitPull()
66
67 # If you used git pull, auto compile
68 main.step( "Using onos-build to compile ONOS" )
69 buildResult = main.ONOSbench.onosBuild()
andrewonlab92ea3672014-11-04 20:22:14 -050070 else:
andrewonlab79244cc2015-01-26 01:11:49 -050071 checkoutResult = main.TRUE
72 pullResult = main.TRUE
73 buildResult = main.TRUE
74 main.log.info( "Git pull skipped by configuration" )
andrewonlab92ea3672014-11-04 20:22:14 -050075
andrewonlab79244cc2015-01-26 01:11:49 -050076 main.log.report( "Commit information - " )
77 main.ONOSbench.getVersion( report=True )
andrewonlab4cf9dd22014-11-18 21:28:38 -050078
andrewonlab79244cc2015-01-26 01:11:49 -050079 main.step( "Creating ONOS package" )
80 packageResult = main.ONOSbench.onosPackage()
andrewonlab92ea3672014-11-04 20:22:14 -050081
andrewonlab79244cc2015-01-26 01:11:49 -050082 main.step( "Installing ONOS package" )
83 install1Result = main.ONOSbench.onosInstall( node=ONOS1Ip )
84 #install2Result = main.ONOSbench.onosInstall( node=ONOS2Ip )
85 #install3Result = main.ONOSbench.onosInstall( node=ONOS3Ip )
andrewonlab92ea3672014-11-04 20:22:14 -050086
andrewonlab79244cc2015-01-26 01:11:49 -050087 main.step( "Set cell for ONOScli env" )
88 main.ONOS1cli.setCell( cellName )
89 # main.ONOS2cli.setCell( cellName )
90 # main.ONOS3cli.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" )
95 cli1 = main.ONOS1cli.startOnosCli( ONOS1Ip )
96 #cli2 = main.ONOS2cli.startOnosCli( ONOS2Ip )
97 #cli3 = main.ONOS3cli.startOnosCli( ONOS3Ip )
andrewonlab92ea3672014-11-04 20:22:14 -050098
andrewonlab79244cc2015-01-26 01:11:49 -050099 utilities.assert_equals( expect=main.TRUE,
100 actual=cellFileResult and cellApplyResult and
101 verifyCellResult and checkoutResult and
102 pullResult and buildResult and
103 install1Result, # and install2Result and
104 # install3Result,
105 onpass="ONOS started successfully",
106 onfail="Failed to start ONOS" )
andrewonlab92ea3672014-11-04 20:22:14 -0500107
andrewonlab79244cc2015-01-26 01:11:49 -0500108 def CASE2( self, main ):
109 """
andrewonlab92ea3672014-11-04 20:22:14 -0500110 Single intent add latency
111
andrewonlab79244cc2015-01-26 01:11:49 -0500112 """
andrewonlab92ea3672014-11-04 20:22:14 -0500113 import time
114 import json
115 import requests
116 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500117 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500118 global clusterCount
andrewonlab92ea3672014-11-04 20:22:14 -0500119
andrewonlab79244cc2015-01-26 01:11:49 -0500120 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
121 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
122 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
123 ONOSIpList = []
124 for i in range( 1, 8 ):
125 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlab92ea3672014-11-04 20:22:14 -0500126
andrewonlab79244cc2015-01-26 01:11:49 -0500127 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab92ea3672014-11-04 20:22:14 -0500128
andrewonlab79244cc2015-01-26 01:11:49 -0500129 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab92ea3672014-11-04 20:22:14 -0500130
andrewonlab79244cc2015-01-26 01:11:49 -0500131 # number of iterations of case
132 numIter = main.params[ 'TEST' ][ 'numIter' ]
133 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
134
135 # Timestamp keys for json metrics output
136 submitTime = main.params[ 'JSON' ][ 'submittedTime' ]
137 installTime = main.params[ 'JSON' ][ 'installedTime' ]
138 wdRequestTime = main.params[ 'JSON' ][ 'wdRequestTime' ]
139 withdrawnTime = main.params[ 'JSON' ][ 'withdrawnTime' ]
140
andrewonlaba57a3042015-01-23 13:53:05 -0500141 assertion = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800142
andrewonlab79244cc2015-01-26 01:11:49 -0500143 intentAddLatList = []
144
145 # Distribute switches according to cluster count
146 for i in range( 1, 9 ):
147 if clusterCount == 1:
148 main.Mininet1.assignSwController(
149 sw=str( i ), ip1=ONOSIpList[ 0 ],
150 port1=defaultSwPort
151 )
152 elif clusterCount == 3:
andrewonlaba57a3042015-01-23 13:53:05 -0500153 if i < 3:
154 index = 0
155 elif i < 6 and i >= 3:
156 index = 1
157 else:
158 index = 2
andrewonlab79244cc2015-01-26 01:11:49 -0500159 main.Mininet1.assignSwController(
160 sw=str( i ), ip1=ONOSIpList[ index ],
161 port1=defaultSwPort
162 )
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(
175 sw=str( i ), ip1=ONOSIpList[ index ],
176 port1=defaultSwPort
177 )
178 elif clusterCount == 7:
andrewonlaba57a3042015-01-23 13:53:05 -0500179 if i < 6:
180 index = i
181 else:
182 index = 6
andrewonlab79244cc2015-01-26 01:11:49 -0500183 main.Mininet1.assignSwController(
184 sw=str( i ), ip1=ONOSIpList[ index ],
185 port1=defaultSwPort
186 )
andrewonlab70decc02014-11-19 18:50:23 -0500187
andrewonlab79244cc2015-01-26 01:11:49 -0500188 time.sleep( 10 )
andrewonlab70decc02014-11-19 18:50:23 -0500189
andrewonlab79244cc2015-01-26 01:11:49 -0500190 main.log.report( "Single intent add latency test" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500191
andrewonlab79244cc2015-01-26 01:11:49 -0500192 devicesJsonStr = main.ONOS1cli.devices()
193 devicesJsonObj = json.loads( devicesJsonStr )
194
195 if not devicesJsonObj:
196 main.log.report( "Devices not discovered" )
197 main.log.report( "Aborting test" )
andrewonlaba57a3042015-01-23 13:53:05 -0500198 main.exit()
199 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500200 main.log.info( "Devices discovered successfully" )
andrewonlaba57a3042015-01-23 13:53:05 -0500201
andrewonlab79244cc2015-01-26 01:11:49 -0500202 deviceIdList = []
andrewonlab92ea3672014-11-04 20:22:14 -0500203
andrewonlab79244cc2015-01-26 01:11:49 -0500204 # Obtain device id list in ONOS format.
205 # They should already be in order ( 1,2,3,10,11,12,13, etc )
206 for device in devicesJsonObj:
207 deviceIdList.append( device[ 'id' ] )
andrewonlab92ea3672014-11-04 20:22:14 -0500208
andrewonlab79244cc2015-01-26 01:11:49 -0500209 for i in range( 0, int( numIter ) ):
210 # addPointIntent( ingrDevice, egrDevice,
211 # ingrPort, egrPort )
212 main.ONOS1cli.addPointIntent(
213 deviceIdList[ 0 ] + "/2", deviceIdList[ 7 ] + "/2" )
214
215 # Allow some time for intents to propagate
216 time.sleep( 5 )
217
218 intentsStr = main.ONOS1cli.intents( jsonFormat=True )
219 intentsObj = json.loads( intentsStr )
220 for intent in intentsObj:
221 if intent[ 'state' ] == "INSTALLED":
222 main.log.info( "Intent installed successfully" )
223 intentId = intent[ 'id' ]
224 main.log.info( "Intent id: " + str( intentId ) )
andrewonlaba57a3042015-01-23 13:53:05 -0500225 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500226 # TODO: Add error handling
227 main.log.info( "Intent installation failed" )
228 intentId = ""
andrewonlab92ea3672014-11-04 20:22:14 -0500229
andrewonlab79244cc2015-01-26 01:11:49 -0500230 # Obtain metrics from ONOS 1, 2, 3
231 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
232 intentsJsonObj1 = json.loads( intentsJsonStr1 )
233 # Parse values from the json object
234 intentSubmit1 = \
235 intentsJsonObj1[ submitTime ][ 'value' ]
236 intentInstall1 = \
237 intentsJsonObj1[ installTime ][ 'value' ]
238 intentInstallLat1 = \
239 int( intentInstall1 ) - int( intentSubmit1 )
240
241 if clusterCount == 3:
242 intentsJsonStr2 = main.ONOS2cli.intentsEventsMetrics()
243 intentsJsonStr3 = main.ONOS3cli.intentsEventsMetrics()
244 intentsJsonObj2 = json.loads( intentsJsonStr2 )
245 intentsJsonObj3 = json.loads( intentsJsonStr3 )
246 intentSubmit2 = \
247 intentsJsonObj2[ submitTime ][ 'value' ]
248 intentSubmit3 = \
249 intentsJsonObj3[ submitTime ][ 'value' ]
250 intentInstall2 = \
251 intentsJsonObj2[ installTime ][ 'value' ]
252 intentInstall3 = \
253 intentsJsonObj3[ installTime ][ 'value' ]
254 intentInstallLat2 = \
255 int( intentInstall2 ) - int( intentSubmit2 )
256 intentInstallLat3 = \
257 int( intentInstall3 ) - int( intentSubmit3 )
andrewonlaba57a3042015-01-23 13:53:05 -0500258 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500259 intentInstallLat2 = 0
260 intentInstallLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500261
andrewonlab79244cc2015-01-26 01:11:49 -0500262 if clusterCount == 5:
263 intentsJsonStr4 = main.ONOS4cli.intentsEventsMetrics()
264 intentsJsonStr5 = main.ONOS5cli.intentsEventsMetrics()
265 intentsJsonObj4 = json.loads( intentsJsonStr4 )
266 intentsJsonObj5 = json.loads( intentsJsonStr5 )
267 intentSubmit4 = \
268 intentsJsonObj4[ submitTime ][ 'value' ]
269 intentSubmit5 = \
270 intentsJsonObj5[ submitTime ][ 'value' ]
271 intentInstall4 = \
272 intentsJsonObj5[ installTime ][ 'value' ]
273 intentInstall5 = \
274 intentsJsonObj5[ installTime ][ 'value' ]
275 intentInstallLat4 = \
276 int( intentInstall4 ) - int( intentSubmit4 )
277 intentInstallLat5 = \
278 int( intentInstall5 ) - int( intentSubmit5 )
andrewonlaba57a3042015-01-23 13:53:05 -0500279 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500280 intentInstallLat4 = 0
281 intentInstallLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500282
andrewonlab79244cc2015-01-26 01:11:49 -0500283 if clusterCount == 7:
284 intentsJsonStr6 = main.ONOS6cli.intentsEventsMetrics()
285 intentsJsonStr7 = main.ONOS7cli.intentsEventsMetrics()
286 intentsJsonObj6 = json.loads( intentsJsonStr6 )
287 intentsJsonObj7 = json.loads( intentsJsonStr7 )
288 intentSubmit6 = \
289 intentsJsonObj6[ submitTime ][ 'value' ]
290 intentSubmit7 = \
291 intentsJsonObj6[ submitTime ][ 'value' ]
292 intentInstall6 = \
293 intentsJsonObj6[ installTime ][ 'value' ]
294 intentInstall7 = \
295 intentsJsonObj7[ installTime ][ 'value' ]
296 intentInstallLat6 = \
297 int( intentInstall6 ) - int( intentSubmit6 )
298 intentInstallLat7 = \
299 int( intentInstall7 ) - int( intentSubmit7 )
andrewonlaba57a3042015-01-23 13:53:05 -0500300 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500301 intentInstallLat6 = 0
302 intentInstallLat7 = 0
andrewonlab8790abb2014-11-06 13:51:54 -0500303
andrewonlab79244cc2015-01-26 01:11:49 -0500304 intentInstallLatAvg = \
305 ( intentInstallLat1 +
306 intentInstallLat2 +
307 intentInstallLat3 +
308 intentInstallLat4 +
309 intentInstallLat5 +
310 intentInstallLat6 +
311 intentInstallLat7 ) / clusterCount
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800312
andrewonlab79244cc2015-01-26 01:11:49 -0500313 main.log.info( "Intent add latency avg for iteration " + str( i ) +
314 ": " + str( intentInstallLatAvg ) + " ms" )
andrewonlab8790abb2014-11-06 13:51:54 -0500315
andrewonlab79244cc2015-01-26 01:11:49 -0500316 if intentInstallLatAvg > 0.0 and \
317 intentInstallLatAvg < 1000 and i > numIgnore:
318 intentAddLatList.append( intentInstallLatAvg )
andrewonlab8790abb2014-11-06 13:51:54 -0500319 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500320 main.log.info( "Intent add latency exceeded " +
321 "threshold. Skipping iteration " + str( i ) )
andrewonlab8790abb2014-11-06 13:51:54 -0500322
andrewonlab79244cc2015-01-26 01:11:49 -0500323 time.sleep( 3 )
324
325 # TODO: Only remove intents that were installed
andrewonlaba57a3042015-01-23 13:53:05 -0500326 # in this case... Otherwise many other intents
327 # may show up distorting the results
andrewonlab79244cc2015-01-26 01:11:49 -0500328 main.log.info( "Removing intents for next iteration" )
329 jsonTemp = \
330 main.ONOS1cli.intents( jsonFormat=True )
331 jsonObjIntents = json.loads( jsonTemp )
332 if jsonObjIntents:
333 for intents in jsonObjIntents:
334 tempId = intents[ 'id' ]
335 # main.ONOS1cli.removeIntent( tempId )
336 main.log.info( "Removing intent id: " +
337 str( tempId ) )
338 main.ONOS1cli.removeIntent( tempId )
andrewonlab8790abb2014-11-06 13:51:54 -0500339 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500340 main.log.info( "Intents were not installed correctly" )
andrewonlab8790abb2014-11-06 13:51:54 -0500341
andrewonlab79244cc2015-01-26 01:11:49 -0500342 time.sleep( 5 )
andrewonlab8790abb2014-11-06 13:51:54 -0500343
andrewonlab79244cc2015-01-26 01:11:49 -0500344 if intentAddLatList:
345 intentAddLatAvg = sum( intentAddLatList ) /\
346 len( intentAddLatList )
andrewonlaba57a3042015-01-23 13:53:05 -0500347 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500348 main.log.report( "Intent installation latency test failed" )
349 intentAddLatAvg = "NA"
andrewonlaba57a3042015-01-23 13:53:05 -0500350 assertion = main.FALSE
351
andrewonlab79244cc2015-01-26 01:11:49 -0500352 intentAddLatStd = \
353 round( numpy.std( intentAddLatList ), 1 )
354 # END ITERATION FOR LOOP
355 main.log.report( "Single intent add latency - " )
356 main.log.report( "Avg: " + str( intentAddLatAvg ) + " ms" )
357 main.log.report( "Std Deviation: " + str( intentAddLatStd ) + " ms" )
358
359 utilities.assert_equals(
360 expect=main.TRUE,
361 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500362 onpass="Single intent install latency test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500363 onfail="Single intent install latency test failed" )
andrewonlab92ea3672014-11-04 20:22:14 -0500364
andrewonlab79244cc2015-01-26 01:11:49 -0500365 def CASE3( self, main ):
366 """
andrewonlab4cf9dd22014-11-18 21:28:38 -0500367 Intent Reroute latency
andrewonlab79244cc2015-01-26 01:11:49 -0500368 """
andrewonlab4cf9dd22014-11-18 21:28:38 -0500369 import time
370 import json
371 import requests
372 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500373 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500374 global clusterCount
andrewonlab4cf9dd22014-11-18 21:28:38 -0500375
andrewonlab79244cc2015-01-26 01:11:49 -0500376 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
377 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
378 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
379 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab4cf9dd22014-11-18 21:28:38 -0500380
andrewonlab79244cc2015-01-26 01:11:49 -0500381 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab4cf9dd22014-11-18 21:28:38 -0500382
andrewonlab79244cc2015-01-26 01:11:49 -0500383 # number of iterations of case
384 numIter = main.params[ 'TEST' ][ 'numIter' ]
385 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
andrewonlaba57a3042015-01-23 13:53:05 -0500386 assertion = main.TRUE
andrewonlab4cf9dd22014-11-18 21:28:38 -0500387
andrewonlab79244cc2015-01-26 01:11:49 -0500388 # Timestamp keys for json metrics output
389 submitTime = main.params[ 'JSON' ][ 'submittedTime' ]
390 installTime = main.params[ 'JSON' ][ 'installedTime' ]
391 wdRequestTime = main.params[ 'JSON' ][ 'wdRequestTime' ]
392 withdrawnTime = main.params[ 'JSON' ][ 'withdrawnTime' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500393
andrewonlab79244cc2015-01-26 01:11:49 -0500394 # NOTE: May need to configure interface depending on topology
395 intfs = main.params[ 'TEST' ][ 'intfs' ]
andrewonlab70decc02014-11-19 18:50:23 -0500396
andrewonlab79244cc2015-01-26 01:11:49 -0500397 devicesJsonStr = main.ONOS1cli.devices()
398 devicesJsonObj = json.loads( devicesJsonStr )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500399
andrewonlab79244cc2015-01-26 01:11:49 -0500400 deviceIdList = []
andrewonlab4cf9dd22014-11-18 21:28:38 -0500401
andrewonlab79244cc2015-01-26 01:11:49 -0500402 # Obtain device id list in ONOS format.
403 # They should already be in order ( 1,2,3,10,11,12,13, etc )
404 for device in devicesJsonObj:
405 deviceIdList.append( device[ 'id' ] )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500406
andrewonlab79244cc2015-01-26 01:11:49 -0500407 intentRerouteLatList = []
andrewonlab4cf9dd22014-11-18 21:28:38 -0500408
andrewonlab79244cc2015-01-26 01:11:49 -0500409 for i in range( 0, int( numIter ) ):
410 # addPointIntent( ingrDevice, ingrPort,
411 # egrDevice, egrPort )
412 if len( deviceIdList ) > 0:
413 main.ONOS1cli.addPointIntent(
414 deviceIdList[ 0 ] + "/2", deviceIdList[ 7 ] + "/2" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500415 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500416 main.log.info( "Failed to fetch devices from ONOS" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500417
andrewonlab79244cc2015-01-26 01:11:49 -0500418 time.sleep( 5 )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500419
andrewonlab79244cc2015-01-26 01:11:49 -0500420 intentsStr = main.ONOS1cli.intents( jsonFormat=True )
421 intentsObj = json.loads( intentsStr )
422 for intent in intentsObj:
423 if intent[ 'state' ] == "INSTALLED":
424 main.log.info( "Intent installed successfully" )
425 intentId = intent[ 'id' ]
426 main.log.info( "Intent id: " + str( intentId ) )
andrewonlab70decc02014-11-19 18:50:23 -0500427 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500428 # TODO: Add error handling
429 main.log.info( "Intent installation failed" )
430 intentId = ""
431
432 main.log.info( "Disabling interface " + intfs )
433 t0System = time.time() * 1000
andrewonlab4cf9dd22014-11-18 21:28:38 -0500434 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500435 "sh ifconfig " + intfs + " down" )
436 main.Mininet1.handle.expect( "mininet>" )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500437
andrewonlab79244cc2015-01-26 01:11:49 -0500438 # TODO: Check for correct intent reroute
439 time.sleep( 1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800440
andrewonlab79244cc2015-01-26 01:11:49 -0500441 # Obtain metrics from ONOS 1, 2, 3
442 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
443 intentsJsonObj1 = json.loads( intentsJsonStr1 )
444 # Parse values from the json object
445 intentInstall1 = \
446 intentsJsonObj1[ installTime ][ 'value' ]
447 intentRerouteLat1 = \
448 int( intentInstall1 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500449
andrewonlab79244cc2015-01-26 01:11:49 -0500450 if clusterCount == 3:
451 intentsJsonStr2 = main.ONOS2cli.intentsEventsMetrics()
452 intentsJsonStr3 = main.ONOS3cli.intentsEventsMetrics()
453
454 intentsJsonObj2 = json.loads( intentsJsonStr2 )
455 intentsJsonObj3 = json.loads( intentsJsonStr3 )
456 intentInstall2 = \
457 intentsJsonObj2[ installTime ][ 'value' ]
458 intentInstall3 = \
459 intentsJsonObj3[ installTime ][ 'value' ]
460 intentRerouteLat2 = \
461 int( intentInstall2 ) - int( t0System )
462 intentRerouteLat3 = \
463 int( intentInstall3 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500464 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500465 intentRerouteLat2 = 0
466 intentRerouteLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500467
andrewonlab79244cc2015-01-26 01:11:49 -0500468 if clusterCount == 5:
469 intentsJsonStr4 = main.ONOS4cli.intentsEventsMetrics()
470 intentsJsonStr5 = main.ONOS5cli.intentsEventsMetrics()
andrewonlaba57a3042015-01-23 13:53:05 -0500471
andrewonlab79244cc2015-01-26 01:11:49 -0500472 intentsJsonObj4 = json.loads( intentsJsonStr4 )
473 intentsJsonObj5 = json.loads( intentsJsonStr5 )
474 intentInstall4 = \
475 intentsJsonObj4[ installTime ][ 'value' ]
476 intentInstall5 = \
477 intentsJsonObj5[ installTime ][ 'value' ]
478 intentRerouteLat4 = \
479 int( intentInstall4 ) - int( t0System )
480 intentRerouteLat5 = \
481 int( intentInstall5 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500482 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500483 intentRerouteLat4 = 0
484 intentRerouteLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500485
andrewonlab79244cc2015-01-26 01:11:49 -0500486 if clusterCount == 7:
487 intentsJsonStr6 = main.ONOS6cli.intentsEventsMetrics()
488 intentsJsonStr7 = main.ONOS7cli.intentsEventsMetrics()
andrewonlaba57a3042015-01-23 13:53:05 -0500489
andrewonlab79244cc2015-01-26 01:11:49 -0500490 intentsJsonObj6 = json.loads( intentsJsonStr6 )
491 intentsJsonObj7 = json.loads( intentsJsonStr7 )
492 intentInstall6 = \
493 intentsJsonObj6[ installTime ][ 'value' ]
494 intentInstall7 = \
495 intentsJsonObj7[ installTime ][ 'value' ]
496 intentRerouteLat6 = \
497 int( intentInstall6 ) - int( t0System )
498 intentRerouteLat7 = \
499 int( intentInstall7 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500500 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500501 intentRerouteLat6 = 0
502 intentRerouteLat7 = 0
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800503
andrewonlab79244cc2015-01-26 01:11:49 -0500504 intentRerouteLatAvg = \
505 ( intentRerouteLat1 +
506 intentRerouteLat2 +
507 intentRerouteLat3 +
508 intentRerouteLat4 +
509 intentRerouteLat5 +
510 intentRerouteLat6 +
511 intentRerouteLat7 ) / clusterCount
andrewonlab4cf9dd22014-11-18 21:28:38 -0500512
andrewonlab79244cc2015-01-26 01:11:49 -0500513 main.log.info( "Intent reroute latency avg for iteration " +
514 str( i ) + ": " + str( intentRerouteLatAvg ) )
515
516 if intentRerouteLatAvg > 0.0 and \
517 intentRerouteLatAvg < 1000 and i > numIgnore:
518 intentRerouteLatList.append( intentRerouteLatAvg )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500519 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500520 main.log.info( "Intent reroute latency exceeded " +
521 "threshold. Skipping iteration " + str( i ) )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500522
andrewonlab79244cc2015-01-26 01:11:49 -0500523 main.log.info( "Removing intents for next iteration" )
524 main.ONOS1cli.removeIntent( intentId )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800525
andrewonlab79244cc2015-01-26 01:11:49 -0500526 main.log.info( "Bringing Mininet interface up for next " +
527 "iteration" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500528 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500529 "sh ifconfig " + intfs + " up" )
530 main.Mininet1.handle.expect( "mininet>" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800531
andrewonlab79244cc2015-01-26 01:11:49 -0500532 if intentRerouteLatList:
533 intentRerouteLatAvg = sum( intentRerouteLatList ) /\
534 len( intentRerouteLatList )
andrewonlaba57a3042015-01-23 13:53:05 -0500535 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500536 main.log.report( "Intent reroute test failed. Results NA" )
537 intentRerouteLatAvg = "NA"
538 # NOTE: fails test when list is empty
andrewonlaba57a3042015-01-23 13:53:05 -0500539 assertion = main.FALSE
andrewonlab79244cc2015-01-26 01:11:49 -0500540
541 intentRerouteLatStd = \
542 round( numpy.std( intentRerouteLatList ), 1 )
543 # END ITERATION FOR LOOP
544 main.log.report( "Single intent reroute latency - " )
545 main.log.report( "Avg: " + str( intentRerouteLatAvg ) + " ms" )
546 main.log.report(
547 "Std Deviation: " +
548 str( intentRerouteLatStd ) +
549 " ms" )
550
551 utilities.assert_equals(
552 expect=main.TRUE,
553 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500554 onpass="Single intent reroute latency test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500555 onfail="Single intent reroute latency test failed" )
556
557 def CASE4( self, main ):
558 """
andrewonlab042b3912014-12-10 16:40:50 -0500559 Batch intent install
andrewonlab79244cc2015-01-26 01:11:49 -0500560 """
andrewonlab70decc02014-11-19 18:50:23 -0500561 import time
562 import json
563 import requests
564 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500565 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500566 global clusterCount
andrewonlab70decc02014-11-19 18:50:23 -0500567
andrewonlab79244cc2015-01-26 01:11:49 -0500568 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
569 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
570 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
571 ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
572 ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
573 ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
574 ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500575
576 assertion = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800577
andrewonlab79244cc2015-01-26 01:11:49 -0500578 ONOSIpList = []
579 for i in range( 1, 8 ):
580 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlab4293dcb2014-12-02 15:48:05 -0500581
andrewonlab79244cc2015-01-26 01:11:49 -0500582 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab70decc02014-11-19 18:50:23 -0500583
andrewonlab79244cc2015-01-26 01:11:49 -0500584 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab70decc02014-11-19 18:50:23 -0500585
andrewonlab79244cc2015-01-26 01:11:49 -0500586 batchIntentSize = int( main.params[ 'TEST' ][ 'batchIntentSize' ] )
587 batchThreshMin = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
588 batchThreshMax = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
andrewonlab4293dcb2014-12-02 15:48:05 -0500589
andrewonlab79244cc2015-01-26 01:11:49 -0500590 # number of iterations of case
591 numIter = main.params[ 'TEST' ][ 'numIter' ]
592 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
593 numSwitch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
594 nThread = main.params[ 'TEST' ][ 'numMult' ]
595 #nThread = 105
596
597 # Switch assignment NOTE: hardcoded
598 if clusterCount == 1:
599 for i in range( 1, numSwitch + 1 ):
600 main.Mininet1.assignSwController(
601 sw=str( i ),
602 ip1=ONOS1Ip,
603 port1=defaultSwPort )
604 if clusterCount == 3:
605 for i in range( 1, 3 ):
606 main.Mininet1.assignSwController(
607 sw=str( i ),
608 ip1=ONOS1Ip,
609 port1=defaultSwPort )
610 for i in range( 3, 6 ):
611 main.Mininet1.assignSwController(
612 sw=str( i ),
613 ip1=ONOS2Ip,
614 port1=defaultSwPort )
615 for i in range( 6, 9 ):
616 main.Mininet1.assignSwController(
617 sw=str( i ),
618 ip1=ONOS3Ip,
619 port1=defaultSwPort )
620 if clusterCount == 5:
621 main.Mininet1.assignSwController(
622 sw="1",
623 ip1=ONOS1Ip,
624 port1=defaultSwPort )
625 main.Mininet1.assignSwController(
626 sw="2",
627 ip1=ONOS2Ip,
628 port1=defaultSwPort )
629 for i in range( 3, 6 ):
630 main.Mininet1.assignSwController(
631 sw=str( i ),
632 ip1=ONOS3Ip,
633 port1=defaultSwPort )
634 main.Mininet1.assignSwController(
635 sw="6",
636 ip1=ONOS4Ip,
637 port1=defaultSwPort )
638 main.Mininet1.assignSwController(
639 sw="7",
640 ip1=ONOS5Ip,
641 port1=defaultSwPort )
642 main.Mininet1.assignSwController(
643 sw="8",
644 ip1=ONOS5Ip,
645 port1=defaultSwPort )
646
647 if clusterCount == 7:
648 for i in range( 1, 9 ):
andrewonlabeb1d0542014-12-03 20:12:01 -0500649 if i < 8:
andrewonlab79244cc2015-01-26 01:11:49 -0500650 main.Mininet1.assignSwController(
651 sw=str( i ),
652 ip1=ONOSIpList[ i - 1 ],
653 port1=defaultSwPort )
654 elif i >= 8:
655 main.Mininet1.assignSwController(
656 sw=str( i ),
657 ip1=ONOSIpList[ 6 ],
658 port1=defaultSwPort )
andrewonlab70decc02014-11-19 18:50:23 -0500659
andrewonlab79244cc2015-01-26 01:11:49 -0500660 time.sleep( 20 )
andrewonlabeb1d0542014-12-03 20:12:01 -0500661
andrewonlab79244cc2015-01-26 01:11:49 -0500662 main.log.report( "Batch intent installation test of " +
663 str( batchIntentSize ) + " intent(s)" )
andrewonlab4293dcb2014-12-02 15:48:05 -0500664
andrewonlab79244cc2015-01-26 01:11:49 -0500665 batchResultList = []
andrewonlab70decc02014-11-19 18:50:23 -0500666
andrewonlab79244cc2015-01-26 01:11:49 -0500667 main.log.info( "Getting list of available devices" )
668 deviceIdList = []
669 jsonStr = main.ONOS1cli.devices()
670 jsonObj = json.loads( jsonStr )
671 for device in jsonObj:
672 deviceIdList.append( device[ 'id' ] )
andrewonlab70decc02014-11-19 18:50:23 -0500673
andrewonlab79244cc2015-01-26 01:11:49 -0500674 batchInstallLat = []
675 batchWithdrawLat = []
andrewonlab70decc02014-11-19 18:50:23 -0500676
andrewonlab79244cc2015-01-26 01:11:49 -0500677 # Max intent install measurement of all nodes
678 maxInstallLat = []
679 maxWithdrawLat = []
680 sleepTime = 10
681
682 baseDir = "/tmp/"
683
684 for batch in range( 0, 5 ):
685 for i in range( 0, int( numIter ) ):
686 main.log.info( "Pushing " +
687 str( int( batchIntentSize ) * int( nThread ) ) +
688 " intents. Iteration " + str( i ) )
689
690 for node in range( 1, clusterCount + 1 ):
691 saveDir = baseDir + "batch_intent_" + str( node ) + ".txt"
692 main.ONOSbench.pushTestIntentsShell(
693 deviceIdList[ 0 ] + "/2",
694 deviceIdList[ 7 ] + "/2",
695 batchIntentSize,
696 saveDir, ONOSIpList[ node - 1 ],
697 numMult=nThread, appId=node )
698
699 # Wait sufficient time for intents to start
700 # installing
701 time.sleep( sleepTime )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800702
andrewonlaba57a3042015-01-23 13:53:05 -0500703 intent = ""
704 counter = 300
andrewonlab79244cc2015-01-26 01:11:49 -0500705 while len( intent ) > 0 and counter > 0:
andrewonlaba57a3042015-01-23 13:53:05 -0500706 main.ONOS1cli.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500707 "intents | wc -l" )
andrewonlaba57a3042015-01-23 13:53:05 -0500708 main.ONOS1cli.handle.expect(
andrewonlab79244cc2015-01-26 01:11:49 -0500709 "intents | wc -l" )
andrewonlaba57a3042015-01-23 13:53:05 -0500710 main.ONOS1cli.handle.expect(
andrewonlab79244cc2015-01-26 01:11:49 -0500711 "onos>" )
712 intentTemp = main.ONOS1cli.handle.before()
andrewonlaba57a3042015-01-23 13:53:05 -0500713 intent = main.ONOS1cli.intents()
andrewonlab79244cc2015-01-26 01:11:49 -0500714 intent = json.loads( intent )
715 counter = counter - 1
716 time.sleep( 1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800717
andrewonlab79244cc2015-01-26 01:11:49 -0500718 time.sleep( 5 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800719
andrewonlab79244cc2015-01-26 01:11:49 -0500720 for node in range( 1, clusterCount + 1 ):
721 saveDir = baseDir + "batch_intent_" + str( node ) + ".txt"
722 with open( saveDir ) as fOnos:
723 lineCount = 0
724 for line in fOnos:
725 line = line[ 1: ]
726 line = line.split( ": " )
727 main.log.info( "Line read: " + str( line ) )
andrewonlabd019a6b2015-02-05 00:05:22 -0500728 #Prevent split method if line doesn't have
729 #space
730 if " " in str(line):
731 result = line[ 1 ].split( " " )[ 0 ]
732 else:
733 main.log.warn( "Empty line read" )
734 result = 0
andrewonlab79244cc2015-01-26 01:11:49 -0500735 # TODO: add parameters before appending latency
736 if lineCount == 0:
737 batchInstallLat.append( int( result ) )
738 installResult = result
739 elif lineCount == 1:
740 batchWithdrawLat.append( int( result ) )
741 withdrawResult = result
andrewonlabd019a6b2015-02-05 00:05:22 -0500742 else:
743 main.log.warn("Invalid results")
744 installResult = 'NA'
745 withdrawResult = 'NA'
andrewonlab79244cc2015-01-26 01:11:49 -0500746 lineCount += 1
747 main.log.info( "Batch install latency for ONOS" +
748 str( node ) + " with " +
749 str( batchIntentSize ) + "intents: " +
750 str( installResult ) + " ms" )
751 main.log.info( "Batch withdraw latency for ONOS" +
752 str( node ) + " with " +
753 str( batchIntentSize ) + "intents: " +
754 str( withdrawResult ) + " ms" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500755
andrewonlab79244cc2015-01-26 01:11:49 -0500756 if len( batchInstallLat ) > 0 and int( i ) > numIgnore:
757 maxInstallLat.append( max( batchInstallLat ) )
758 elif len( batchInstallLat ) == 0:
759 # If I failed to read anything from the file,
760 # increase the wait time before checking intents
761 sleepTime += 30
762 if len( batchWithdrawLat ) > 0 and int( i ) > numIgnore:
763 maxWithdrawLat.append( max( batchWithdrawLat ) )
764 batchInstallLat = []
765 batchWithdrawLat = []
766
767 # Sleep in between iterations
768 time.sleep( 5 )
769
770 if maxInstallLat:
andrewonlabd019a6b2015-02-05 00:05:22 -0500771 avgInstallLat = str( round(
772 sum( maxInstallLat ) /
773 len( maxInstallLat )
774 , 2 ))
andrewonlaba57a3042015-01-23 13:53:05 -0500775 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500776 avgInstallLat = "NA"
777 main.log.report( "Batch installation failed" )
andrewonlaba57a3042015-01-23 13:53:05 -0500778 assertion = main.FALSE
andrewonlabeb1d0542014-12-03 20:12:01 -0500779
andrewonlab79244cc2015-01-26 01:11:49 -0500780 if maxWithdrawLat:
andrewonlabd019a6b2015-02-05 00:05:22 -0500781 avgWithdrawLat = str( round(
782 sum( maxWithdrawLat ) /
783 len( maxWithdrawLat )
784 , 2 ))
andrewonlaba57a3042015-01-23 13:53:05 -0500785 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500786 avgWithdrawLat = "NA"
787 main.log.report( "Batch withdraw failed" )
andrewonlaba57a3042015-01-23 13:53:05 -0500788 assertion = main.FALSE
andrewonlabeb1d0542014-12-03 20:12:01 -0500789
andrewonlab79244cc2015-01-26 01:11:49 -0500790 main.log.report( "Avg of batch installation latency " +
791 "of size " + str( batchIntentSize ) + ": " +
792 str( avgInstallLat ) + " ms" )
793 main.log.report( "Std Deviation of batch installation latency " +
andrewonlabd019a6b2015-02-05 00:05:22 -0500794 ": " +
795 str( round(numpy.std( maxInstallLat ),2)) +
796 " ms" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500797
andrewonlab79244cc2015-01-26 01:11:49 -0500798 main.log.report( "Avg of batch withdraw latency " +
799 "of size " + str( batchIntentSize ) + ": " +
800 str( avgWithdrawLat ) + " ms" )
801 main.log.report( "Std Deviation of batch withdraw latency " +
802 ": " +
andrewonlabd019a6b2015-02-05 00:05:22 -0500803 str( round(numpy.std( maxWithdrawLat ),2)) +
andrewonlab79244cc2015-01-26 01:11:49 -0500804 " ms" )
805
andrewonlabd019a6b2015-02-05 00:05:22 -0500806 if batch == 0:
807 batchIntentSize = 10
808 elif batch == 1:
809 batchIntentSize = 100
810 elif batch == 2:
811 batchIntentSize = 1000
812 elif batch == 3:
813 batchIntentSize = 2000
814 if batch < 4:
815 main.log.report( "Increasing batch intent size to " +
andrewonlab79244cc2015-01-26 01:11:49 -0500816 str(batchIntentSize) )
817
818 #main.log.info( "Removing all intents for next test case" )
819 #jsonTemp = main.ONOS1cli.intents( jsonFormat=True )
820 #jsonObjIntents = json.loads( jsonTemp )
821 # if jsonObjIntents:
822 # for intents in jsonObjIntents:
823 # tempId = intents[ 'id' ]
824 # main.ONOS1cli.removeIntent( tempId )
825 # main.ONOS1cli.removeIntent( tempId )
826
827 utilities.assert_equals(
828 expect=main.TRUE,
829 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500830 onpass="Batch intent install/withdraw test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500831 onfail="Batch intent install/withdraw test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800832
andrewonlab79244cc2015-01-26 01:11:49 -0500833 def CASE5( self, main ):
834 """
andrewonlab4293dcb2014-12-02 15:48:05 -0500835 Increase number of nodes and initiate CLI
andrewonlab79244cc2015-01-26 01:11:49 -0500836 """
andrewonlab4293dcb2014-12-02 15:48:05 -0500837 import time
838 import json
839
andrewonlab79244cc2015-01-26 01:11:49 -0500840 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
841 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
842 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
843 ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
844 ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
845 ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
846 ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
andrewonlab4293dcb2014-12-02 15:48:05 -0500847
andrewonlab79244cc2015-01-26 01:11:49 -0500848 global clusterCount
849 clusterCount += 2
850 main.log.report( "Increasing cluster size to " +
851 str( clusterCount ) )
andrewonlab4293dcb2014-12-02 15:48:05 -0500852
andrewonlab79244cc2015-01-26 01:11:49 -0500853 installResult = main.FALSE
andrewonlab4293dcb2014-12-02 15:48:05 -0500854
andrewonlab79244cc2015-01-26 01:11:49 -0500855 if clusterCount == 3:
856 installResult1 = \
857 main.ONOSbench.onosInstall( node=ONOS2Ip )
858 installResult2 = \
859 main.ONOSbench.onosInstall( node=ONOS3Ip )
860 time.sleep( 5 )
andrewonlab4293dcb2014-12-02 15:48:05 -0500861
andrewonlab79244cc2015-01-26 01:11:49 -0500862 main.log.info( "Starting ONOS CLI" )
863 main.ONOS2cli.startOnosCli( ONOS2Ip )
864 main.ONOS3cli.startOnosCli( ONOS3Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500865
andrewonlab79244cc2015-01-26 01:11:49 -0500866 installResult = installResult1 and installResult2
andrewonlab4293dcb2014-12-02 15:48:05 -0500867
andrewonlab79244cc2015-01-26 01:11:49 -0500868 if clusterCount == 5:
869 main.log.info( "Installing ONOS on node 4 and 5" )
870 installResult1 = \
871 main.ONOSbench.onosInstall( node=ONOS4Ip )
872 installResult2 = \
873 main.ONOSbench.onosInstall( node=ONOS5Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500874
andrewonlab79244cc2015-01-26 01:11:49 -0500875 main.log.info( "Starting ONOS CLI" )
876 main.ONOS4cli.startOnosCli( ONOS4Ip )
877 main.ONOS5cli.startOnosCli( ONOS5Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500878
andrewonlab79244cc2015-01-26 01:11:49 -0500879 installResult = installResult1 and installResult2
andrewonlab4293dcb2014-12-02 15:48:05 -0500880
andrewonlab79244cc2015-01-26 01:11:49 -0500881 if clusterCount == 7:
882 main.log.info( "Installing ONOS on node 6 and 7" )
883 installResult1 = \
884 main.ONOSbench.onosInstall( node=ONOS6Ip )
885 installResult2 = \
886 main.ONOSbench.onosInstall( node=ONOS7Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500887
andrewonlab79244cc2015-01-26 01:11:49 -0500888 main.log.info( "Starting ONOS CLI" )
889 main.ONOS6cli.startOnosCli( ONOS6Ip )
890 main.ONOS7cli.startOnosCli( ONOS7Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500891
andrewonlab79244cc2015-01-26 01:11:49 -0500892 installResult = installResult1 and installResult2
andrewonlab4293dcb2014-12-02 15:48:05 -0500893
andrewonlab79244cc2015-01-26 01:11:49 -0500894 time.sleep( 5 )
andrewonlab4293dcb2014-12-02 15:48:05 -0500895
andrewonlab79244cc2015-01-26 01:11:49 -0500896 if installResult == main.TRUE:
andrewonlab4293dcb2014-12-02 15:48:05 -0500897 assertion = main.TRUE
898 else:
899 assertion = main.FALSE
900
andrewonlab79244cc2015-01-26 01:11:49 -0500901 utilities.assert_equals( expect=main.TRUE, actual=assertion,
902 onpass="Scale out to " + str( clusterCount ) +
903 " nodes successful",
904 onfail="Scale out to " + str( clusterCount ) +
905 " nodes failed" )
andrewonlab4293dcb2014-12-02 15:48:05 -0500906
andrewonlab79244cc2015-01-26 01:11:49 -0500907 def CASE7( self, main ):
908 # TODO: Fix for scale-out scenario
909 """
andrewonlaba57a3042015-01-23 13:53:05 -0500910 Batch intent reroute latency
andrewonlab79244cc2015-01-26 01:11:49 -0500911 """
andrewonlaba57a3042015-01-23 13:53:05 -0500912 import time
913 import json
914 import requests
915 import os
916 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500917 global clusterCount
andrewonlaba57a3042015-01-23 13:53:05 -0500918
andrewonlab79244cc2015-01-26 01:11:49 -0500919 ONOSIpList = []
920 for i in range( 1, 8 ):
921 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlaba57a3042015-01-23 13:53:05 -0500922
andrewonlab79244cc2015-01-26 01:11:49 -0500923 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
924 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500925
andrewonlab79244cc2015-01-26 01:11:49 -0500926 batchIntentSize = main.params[ 'TEST' ][ 'batchIntentSize' ]
927 batchThreshMin = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
928 batchThreshMax = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
929 intfs = main.params[ 'TEST' ][ 'intfs' ]
930 installTime = main.params[ 'JSON' ][ 'installedTime' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500931
andrewonlab79244cc2015-01-26 01:11:49 -0500932 # number of iterations of case
933 numIter = main.params[ 'TEST' ][ 'numIter' ]
934 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
935 numSwitch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
936 nThread = main.params[ 'TEST' ][ 'numMult' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500937
andrewonlab79244cc2015-01-26 01:11:49 -0500938 main.log.report( "Batch intent installation test of " +
939 batchIntentSize + " intents" )
andrewonlaba57a3042015-01-23 13:53:05 -0500940
andrewonlab79244cc2015-01-26 01:11:49 -0500941 batchResultList = []
andrewonlaba57a3042015-01-23 13:53:05 -0500942
andrewonlab79244cc2015-01-26 01:11:49 -0500943 time.sleep( 10 )
andrewonlaba57a3042015-01-23 13:53:05 -0500944
andrewonlab79244cc2015-01-26 01:11:49 -0500945 main.log.info( "Getting list of available devices" )
946 deviceIdList = []
947 jsonStr = main.ONOS1cli.devices()
948 jsonObj = json.loads( jsonStr )
949 for device in jsonObj:
950 deviceIdList.append( device[ 'id' ] )
andrewonlaba57a3042015-01-23 13:53:05 -0500951
andrewonlab79244cc2015-01-26 01:11:49 -0500952 batchInstallLat = []
953 batchWithdrawLat = []
954 sleepTime = 10
andrewonlaba57a3042015-01-23 13:53:05 -0500955
andrewonlab79244cc2015-01-26 01:11:49 -0500956 baseDir = "/tmp/"
957 maxInstallLat = []
958
959 for i in range( 0, int( numIter ) ):
960 main.log.info( "Pushing " +
961 str( int( batchIntentSize ) * int( nThread ) ) +
962 " intents. Iteration " + str( i ) )
963
964 main.ONOSbench.pushTestIntentsShell(
965 deviceIdList[ 0 ] + "/2",
966 deviceIdList[ 7 ] + "/2",
967 batchIntentSize, "/tmp/batch_install.txt",
968 ONOSIpList[ 0 ], numMult="1", appId="1",
969 report=False, options="--install" )
970 # main.ONOSbench.pushTestIntentsShell(
andrewonlaba57a3042015-01-23 13:53:05 -0500971 # "of:0000000000001002/1",
972 # "of:0000000000002002/1",
973 # 133, "/tmp/temp2.txt", "10.128.174.2",
andrewonlab79244cc2015-01-26 01:11:49 -0500974 # numMult="6", appId="2",report=False )
975
976 # TODO: Check for installation success then proceed
977 time.sleep( 30 )
978
979 # NOTE: this interface is specific to
andrewonlaba57a3042015-01-23 13:53:05 -0500980 # topo-intentFlower.py topology
981 # reroute case.
andrewonlab79244cc2015-01-26 01:11:49 -0500982 main.log.info( "Disabling interface " + intfs )
andrewonlaba57a3042015-01-23 13:53:05 -0500983 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500984 "sh ifconfig " + intfs + " down" )
985 t0System = time.time() * 1000
andrewonlaba57a3042015-01-23 13:53:05 -0500986
andrewonlab79244cc2015-01-26 01:11:49 -0500987 # TODO: Wait sufficient time for intents to install
988 time.sleep( 10 )
andrewonlaba57a3042015-01-23 13:53:05 -0500989
andrewonlab79244cc2015-01-26 01:11:49 -0500990 # TODO: get intent installation time
991
992 # Obtain metrics from ONOS 1, 2, 3
993 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
994 intentsJsonObj1 = json.loads( intentsJsonStr1 )
995 # Parse values from the json object
996 intentInstall1 = \
997 intentsJsonObj1[ installTime ][ 'value' ]
998 intentRerouteLat1 = \
999 int( intentInstall1 ) - int( t0System )
1000
1001 if clusterCount == 3:
1002 intentsJsonStr2 =\
1003 main.ONOS2cli.intentsEventsMetrics()
1004 intentsJsonStr3 =\
1005 main.ONOS3cli.intentsEventsMetrics()
1006 intentsJsonObj2 = json.loads( intentsJsonStr2 )
1007 intentsJsonObj3 = json.loads( intentsJsonStr3 )
1008 intentInstall2 = \
1009 intentsJsonObj2[ installTime ][ 'value' ]
1010 intentInstall3 = \
1011 intentsJsonObj3[ installTime ][ 'value' ]
1012 intentRerouteLat2 = \
1013 int( intentInstall2 ) - int( t0System )
1014 intentRerouteLat3 = \
1015 int( intentInstall3 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -05001016 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001017 intentRerouteLat2 = 0
1018 intentRerouteLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001019
andrewonlab79244cc2015-01-26 01:11:49 -05001020 if clusterCount == 5:
1021 intentsJsonStr4 =\
1022 main.ONOS4cli.intentsEventsMetrics()
1023 intentsJsonStr5 =\
1024 main.ONOS5cli.intentsEventsMetrics()
1025 intentsJsonObj4 = json.loads( intentsJsonStr4 )
1026 intentsJsonObj5 = json.loads( intentsJsonStr5 )
1027 intentInstall4 = \
1028 intentsJsonObj4[ installTime ][ 'value' ]
1029 intentInstall5 = \
1030 intentsJsonObj5[ installTime ][ 'value' ]
1031 intentRerouteLat4 = \
1032 int( intentInstall4 ) - int( t0System )
1033 intentRerouteLat5 = \
1034 int( intentInstall5 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -05001035 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001036 intentRerouteLat4 = 0
1037 intentRerouteLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001038
andrewonlab79244cc2015-01-26 01:11:49 -05001039 if clusterCount == 7:
1040 intentsJsonStr6 =\
1041 main.ONOS6cli.intentsEventsMetrics()
1042 intentsJsonStr7 =\
1043 main.ONOS7cli.intentsEventsMetrics()
1044 intentsJsonObj6 = json.loads( intentsJsonStr6 )
1045 intentsJsonObj7 = json.loads( intentsJsonStr7 )
1046 intentInstall6 = \
1047 intentsJsonObj6[ installTime ][ 'value' ]
1048 intentInstall7 = \
1049 intentsJsonObj7[ installTime ][ 'value' ]
1050 intentRerouteLat6 = \
1051 int( intentInstall6 ) - int( t0System )
1052 intentRerouteLat7 = \
1053 int( intentInstall7 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -05001054 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001055 intentRerouteLat6 = 0
1056 intentRerouteLat7 = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001057
andrewonlab79244cc2015-01-26 01:11:49 -05001058 intentRerouteLatAvg = \
1059 ( intentRerouteLat1 +
1060 intentRerouteLat2 +
1061 intentRerouteLat3 +
1062 intentRerouteLat4 +
1063 intentRerouteLat5 +
1064 intentRerouteLat6 +
1065 intentRerouteLat7 ) / clusterCount
andrewonlaba57a3042015-01-23 13:53:05 -05001066
andrewonlab79244cc2015-01-26 01:11:49 -05001067 main.log.info( "Intent reroute latency avg for iteration " +
1068 str( i ) + ": " + str( intentRerouteLatAvg ) )
1069 # TODO: Remove intents for next iteration
1070
1071 time.sleep( 5 )
1072
1073 intentsStr = main.ONOS1cli.intents()
1074 intentsJson = json.loads( intentsStr )
1075 for intents in intentsJson:
1076 intentId = intents[ 'id' ]
1077 # TODO: make sure this removes all intents
1078 # print intentId
1079 if intentId:
1080 main.ONOS1cli.removeIntent( intentId )
andrewonlaba57a3042015-01-23 13:53:05 -05001081
1082 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001083 "sh ifconfig " + intfs + " up" )
andrewonlaba57a3042015-01-23 13:53:05 -05001084
andrewonlab79244cc2015-01-26 01:11:49 -05001085 main.log.info( "Intents removed and port back up" )
1086
1087 def CASE9( self, main ):
andrewonlabeb1d0542014-12-03 20:12:01 -05001088 count = 0
andrewonlab79244cc2015-01-26 01:11:49 -05001089 swNum1 = 1
1090 swNum2 = 1
andrewonlabeb1d0542014-12-03 20:12:01 -05001091 appid = 0
andrewonlab79244cc2015-01-26 01:11:49 -05001092 portNum1 = 1
1093 portNum2 = 1
1094
1095 time.sleep( 30 )
andrewonlab4cf9dd22014-11-18 21:28:38 -05001096
andrewonlabeb1d0542014-12-03 20:12:01 -05001097 while True:
andrewonlab79244cc2015-01-26 01:11:49 -05001098 # main.ONOS1cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001099 #"of:0000000000001001/1",
1100 #"of:0000000000002001/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001101 # 100, numMult="10", appId="1" )
1102 # main.ONOS2cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001103 # "of:0000000000001002/1",
1104 # "of:0000000000002002/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001105 # 100, numMult="10", appId="2" )
1106 # main.ONOS2cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001107 # "of:0000000000001003/1",
1108 # "of:0000000000002003/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001109 # 100, numMult="10", appId="3" )
andrewonlabeb1d0542014-12-03 20:12:01 -05001110 count += 1
andrewonlab79244cc2015-01-26 01:11:49 -05001111
andrewonlabeb1d0542014-12-03 20:12:01 -05001112 if count >= 100:
1113 main.ONOSbench.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001114 "onos 10.128.174.1 intents-events-metrics >>" +
1115 " /tmp/metrics_intents_temp.txt &" )
andrewonlabeb1d0542014-12-03 20:12:01 -05001116 count = 0
1117
andrewonlab79244cc2015-01-26 01:11:49 -05001118 arg1 = "of:000000000000100" + str( swNum1 ) + "/" + str( portNum1 )
1119 arg2 = "of:000000000000200" + str( swNum2 ) + "/" + str( portNum2 )
andrewonlabeb1d0542014-12-03 20:12:01 -05001120
andrewonlab79244cc2015-01-26 01:11:49 -05001121 swNum1 += 1
1122
1123 if swNum1 > 7:
1124 swNum1 = 1
1125 swNum2 += 1
1126 if swNum2 > 7:
andrewonlabeb1d0542014-12-03 20:12:01 -05001127 appid += 1
1128
andrewonlab79244cc2015-01-26 01:11:49 -05001129 if swNum2 > 7:
1130 swNum2 = 1
1131
1132 main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001133 arg1,
andrewonlab79244cc2015-01-26 01:11:49 -05001134 arg2,
andrewonlab042b3912014-12-10 16:40:50 -05001135 100, "/tmp/temp.txt", "10.128.174.1",
andrewonlab79244cc2015-01-26 01:11:49 -05001136 numMult="10", appId=appid, report=False )
1137 # main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001138 # "of:0000000000001002/1",
1139 # "of:0000000000002002/1",
1140 # 133, "/tmp/temp2.txt", "10.128.174.2",
andrewonlab79244cc2015-01-26 01:11:49 -05001141 # numMult="6", appId="2",report=False )
1142 # main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001143 # "of:0000000000001003/1",
1144 # "of:0000000000002003/1",
1145 # 133, "/tmp/temp3.txt", "10.128.174.3",
andrewonlab79244cc2015-01-26 01:11:49 -05001146 # numMult="6", appId="3",report=False )
andrewonlab92ea3672014-11-04 20:22:14 -05001147
andrewonlab79244cc2015-01-26 01:11:49 -05001148 time.sleep( 0.2 )