blob: c9656127eb32ec3a15510707e1a4c0fd61dd706f [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
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,
54 "onos-core,onos-app-metrics,onos-gui",
55 ONOS1Ip )
andrewonlab92ea3672014-11-04 20:22:14 -050056
andrewonlab79244cc2015-01-26 01:11:49 -050057 main.step( "Applying cell file to environment" )
58 cellApplyResult = main.ONOSbench.setCell( cellName )
59 verifyCellResult = main.ONOSbench.verifyCell()
andrewonlab4293dcb2014-12-02 15:48:05 -050060
andrewonlab79244cc2015-01-26 01:11:49 -050061 main.step( "Removing raft logs" )
62 main.ONOSbench.onosRemoveRaftLogs()
63
64 main.step( "Git checkout and pull " + checkoutBranch )
65 if gitPull == 'on':
66 checkoutResult = \
67 main.ONOSbench.gitCheckout( checkoutBranch )
68 pullResult = main.ONOSbench.gitPull()
69
70 # If you used git pull, auto compile
71 main.step( "Using onos-build to compile ONOS" )
72 buildResult = main.ONOSbench.onosBuild()
andrewonlab92ea3672014-11-04 20:22:14 -050073 else:
andrewonlab79244cc2015-01-26 01:11:49 -050074 checkoutResult = main.TRUE
75 pullResult = main.TRUE
76 buildResult = main.TRUE
77 main.log.info( "Git pull skipped by configuration" )
andrewonlab92ea3672014-11-04 20:22:14 -050078
andrewonlab79244cc2015-01-26 01:11:49 -050079 main.log.report( "Commit information - " )
80 main.ONOSbench.getVersion( report=True )
andrewonlab4cf9dd22014-11-18 21:28:38 -050081
andrewonlab79244cc2015-01-26 01:11:49 -050082 main.step( "Creating ONOS package" )
83 packageResult = main.ONOSbench.onosPackage()
andrewonlab92ea3672014-11-04 20:22:14 -050084
andrewonlab79244cc2015-01-26 01:11:49 -050085 main.step( "Installing ONOS package" )
86 install1Result = main.ONOSbench.onosInstall( node=ONOS1Ip )
87 #install2Result = main.ONOSbench.onosInstall( node=ONOS2Ip )
88 #install3Result = main.ONOSbench.onosInstall( node=ONOS3Ip )
andrewonlab92ea3672014-11-04 20:22:14 -050089
andrewonlab79244cc2015-01-26 01:11:49 -050090 main.step( "Set cell for ONOScli env" )
91 main.ONOS1cli.setCell( cellName )
92 # main.ONOS2cli.setCell( cellName )
93 # main.ONOS3cli.setCell( cellName )
andrewonlab92ea3672014-11-04 20:22:14 -050094
andrewonlab79244cc2015-01-26 01:11:49 -050095 time.sleep( 5 )
andrewonlab92ea3672014-11-04 20:22:14 -050096
andrewonlab79244cc2015-01-26 01:11:49 -050097 main.step( "Start onos cli" )
98 cli1 = main.ONOS1cli.startOnosCli( ONOS1Ip )
99 #cli2 = main.ONOS2cli.startOnosCli( ONOS2Ip )
100 #cli3 = main.ONOS3cli.startOnosCli( ONOS3Ip )
andrewonlab92ea3672014-11-04 20:22:14 -0500101
andrewonlab79244cc2015-01-26 01:11:49 -0500102 utilities.assert_equals( expect=main.TRUE,
103 actual=cellFileResult and cellApplyResult and
104 verifyCellResult and checkoutResult and
105 pullResult and buildResult and
106 install1Result, # and install2Result and
107 # install3Result,
108 onpass="ONOS started successfully",
109 onfail="Failed to start ONOS" )
andrewonlab92ea3672014-11-04 20:22:14 -0500110
andrewonlab79244cc2015-01-26 01:11:49 -0500111 def CASE2( self, main ):
112 """
andrewonlab92ea3672014-11-04 20:22:14 -0500113 Single intent add latency
114
andrewonlab79244cc2015-01-26 01:11:49 -0500115 """
andrewonlab92ea3672014-11-04 20:22:14 -0500116 import time
117 import json
118 import requests
119 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500120 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500121 global clusterCount
andrewonlab92ea3672014-11-04 20:22:14 -0500122
andrewonlab79244cc2015-01-26 01:11:49 -0500123 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
124 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
125 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
126 ONOSIpList = []
127 for i in range( 1, 8 ):
128 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlab92ea3672014-11-04 20:22:14 -0500129
andrewonlab79244cc2015-01-26 01:11:49 -0500130 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab92ea3672014-11-04 20:22:14 -0500131
andrewonlab79244cc2015-01-26 01:11:49 -0500132 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab92ea3672014-11-04 20:22:14 -0500133
andrewonlab79244cc2015-01-26 01:11:49 -0500134 # number of iterations of case
135 numIter = main.params[ 'TEST' ][ 'numIter' ]
136 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
137
138 # Timestamp keys for json metrics output
139 submitTime = main.params[ 'JSON' ][ 'submittedTime' ]
140 installTime = main.params[ 'JSON' ][ 'installedTime' ]
141 wdRequestTime = main.params[ 'JSON' ][ 'wdRequestTime' ]
142 withdrawnTime = main.params[ 'JSON' ][ 'withdrawnTime' ]
143
andrewonlaba57a3042015-01-23 13:53:05 -0500144 assertion = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800145
andrewonlab79244cc2015-01-26 01:11:49 -0500146 intentAddLatList = []
147
148 # Distribute switches according to cluster count
149 for i in range( 1, 9 ):
150 if clusterCount == 1:
151 main.Mininet1.assignSwController(
152 sw=str( i ), ip1=ONOSIpList[ 0 ],
153 port1=defaultSwPort
154 )
155 elif clusterCount == 3:
andrewonlaba57a3042015-01-23 13:53:05 -0500156 if i < 3:
157 index = 0
158 elif i < 6 and i >= 3:
159 index = 1
160 else:
161 index = 2
andrewonlab79244cc2015-01-26 01:11:49 -0500162 main.Mininet1.assignSwController(
163 sw=str( i ), ip1=ONOSIpList[ index ],
164 port1=defaultSwPort
165 )
166 elif clusterCount == 5:
andrewonlaba57a3042015-01-23 13:53:05 -0500167 if i < 3:
168 index = 0
169 elif i < 5 and i >= 3:
170 index = 1
171 elif i < 7 and i >= 5:
172 index = 2
173 elif i == 7:
174 index = 3
175 else:
176 index = 4
andrewonlab79244cc2015-01-26 01:11:49 -0500177 main.Mininet1.assignSwController(
178 sw=str( i ), ip1=ONOSIpList[ index ],
179 port1=defaultSwPort
180 )
181 elif clusterCount == 7:
andrewonlaba57a3042015-01-23 13:53:05 -0500182 if i < 6:
183 index = i
184 else:
185 index = 6
andrewonlab79244cc2015-01-26 01:11:49 -0500186 main.Mininet1.assignSwController(
187 sw=str( i ), ip1=ONOSIpList[ index ],
188 port1=defaultSwPort
189 )
andrewonlab70decc02014-11-19 18:50:23 -0500190
andrewonlab79244cc2015-01-26 01:11:49 -0500191 time.sleep( 10 )
andrewonlab70decc02014-11-19 18:50:23 -0500192
andrewonlab79244cc2015-01-26 01:11:49 -0500193 main.log.report( "Single intent add latency test" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500194
andrewonlab79244cc2015-01-26 01:11:49 -0500195 devicesJsonStr = main.ONOS1cli.devices()
196 devicesJsonObj = json.loads( devicesJsonStr )
197
198 if not devicesJsonObj:
199 main.log.report( "Devices not discovered" )
200 main.log.report( "Aborting test" )
andrewonlaba57a3042015-01-23 13:53:05 -0500201 main.exit()
202 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500203 main.log.info( "Devices discovered successfully" )
andrewonlaba57a3042015-01-23 13:53:05 -0500204
andrewonlab79244cc2015-01-26 01:11:49 -0500205 deviceIdList = []
andrewonlab92ea3672014-11-04 20:22:14 -0500206
andrewonlab79244cc2015-01-26 01:11:49 -0500207 # Obtain device id list in ONOS format.
208 # They should already be in order ( 1,2,3,10,11,12,13, etc )
209 for device in devicesJsonObj:
210 deviceIdList.append( device[ 'id' ] )
andrewonlab92ea3672014-11-04 20:22:14 -0500211
andrewonlab79244cc2015-01-26 01:11:49 -0500212 for i in range( 0, int( numIter ) ):
213 # addPointIntent( ingrDevice, egrDevice,
214 # ingrPort, egrPort )
215 main.ONOS1cli.addPointIntent(
216 deviceIdList[ 0 ] + "/2", deviceIdList[ 7 ] + "/2" )
217
218 # Allow some time for intents to propagate
219 time.sleep( 5 )
220
221 intentsStr = main.ONOS1cli.intents( jsonFormat=True )
222 intentsObj = json.loads( intentsStr )
223 for intent in intentsObj:
224 if intent[ 'state' ] == "INSTALLED":
225 main.log.info( "Intent installed successfully" )
226 intentId = intent[ 'id' ]
227 main.log.info( "Intent id: " + str( intentId ) )
andrewonlaba57a3042015-01-23 13:53:05 -0500228 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500229 # TODO: Add error handling
230 main.log.info( "Intent installation failed" )
231 intentId = ""
andrewonlab92ea3672014-11-04 20:22:14 -0500232
andrewonlab79244cc2015-01-26 01:11:49 -0500233 # Obtain metrics from ONOS 1, 2, 3
234 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
235 intentsJsonObj1 = json.loads( intentsJsonStr1 )
236 # Parse values from the json object
237 intentSubmit1 = \
238 intentsJsonObj1[ submitTime ][ 'value' ]
239 intentInstall1 = \
240 intentsJsonObj1[ installTime ][ 'value' ]
241 intentInstallLat1 = \
242 int( intentInstall1 ) - int( intentSubmit1 )
243
244 if clusterCount == 3:
245 intentsJsonStr2 = main.ONOS2cli.intentsEventsMetrics()
246 intentsJsonStr3 = main.ONOS3cli.intentsEventsMetrics()
247 intentsJsonObj2 = json.loads( intentsJsonStr2 )
248 intentsJsonObj3 = json.loads( intentsJsonStr3 )
249 intentSubmit2 = \
250 intentsJsonObj2[ submitTime ][ 'value' ]
251 intentSubmit3 = \
252 intentsJsonObj3[ submitTime ][ 'value' ]
253 intentInstall2 = \
254 intentsJsonObj2[ installTime ][ 'value' ]
255 intentInstall3 = \
256 intentsJsonObj3[ installTime ][ 'value' ]
257 intentInstallLat2 = \
258 int( intentInstall2 ) - int( intentSubmit2 )
259 intentInstallLat3 = \
260 int( intentInstall3 ) - int( intentSubmit3 )
andrewonlaba57a3042015-01-23 13:53:05 -0500261 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500262 intentInstallLat2 = 0
263 intentInstallLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500264
andrewonlab79244cc2015-01-26 01:11:49 -0500265 if clusterCount == 5:
266 intentsJsonStr4 = main.ONOS4cli.intentsEventsMetrics()
267 intentsJsonStr5 = main.ONOS5cli.intentsEventsMetrics()
268 intentsJsonObj4 = json.loads( intentsJsonStr4 )
269 intentsJsonObj5 = json.loads( intentsJsonStr5 )
270 intentSubmit4 = \
271 intentsJsonObj4[ submitTime ][ 'value' ]
272 intentSubmit5 = \
273 intentsJsonObj5[ submitTime ][ 'value' ]
274 intentInstall4 = \
275 intentsJsonObj5[ installTime ][ 'value' ]
276 intentInstall5 = \
277 intentsJsonObj5[ installTime ][ 'value' ]
278 intentInstallLat4 = \
279 int( intentInstall4 ) - int( intentSubmit4 )
280 intentInstallLat5 = \
281 int( intentInstall5 ) - int( intentSubmit5 )
andrewonlaba57a3042015-01-23 13:53:05 -0500282 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500283 intentInstallLat4 = 0
284 intentInstallLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500285
andrewonlab79244cc2015-01-26 01:11:49 -0500286 if clusterCount == 7:
287 intentsJsonStr6 = main.ONOS6cli.intentsEventsMetrics()
288 intentsJsonStr7 = main.ONOS7cli.intentsEventsMetrics()
289 intentsJsonObj6 = json.loads( intentsJsonStr6 )
290 intentsJsonObj7 = json.loads( intentsJsonStr7 )
291 intentSubmit6 = \
292 intentsJsonObj6[ submitTime ][ 'value' ]
293 intentSubmit7 = \
294 intentsJsonObj6[ submitTime ][ 'value' ]
295 intentInstall6 = \
296 intentsJsonObj6[ installTime ][ 'value' ]
297 intentInstall7 = \
298 intentsJsonObj7[ installTime ][ 'value' ]
299 intentInstallLat6 = \
300 int( intentInstall6 ) - int( intentSubmit6 )
301 intentInstallLat7 = \
302 int( intentInstall7 ) - int( intentSubmit7 )
andrewonlaba57a3042015-01-23 13:53:05 -0500303 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500304 intentInstallLat6 = 0
305 intentInstallLat7 = 0
andrewonlab8790abb2014-11-06 13:51:54 -0500306
andrewonlab79244cc2015-01-26 01:11:49 -0500307 intentInstallLatAvg = \
308 ( intentInstallLat1 +
309 intentInstallLat2 +
310 intentInstallLat3 +
311 intentInstallLat4 +
312 intentInstallLat5 +
313 intentInstallLat6 +
314 intentInstallLat7 ) / clusterCount
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800315
andrewonlab79244cc2015-01-26 01:11:49 -0500316 main.log.info( "Intent add latency avg for iteration " + str( i ) +
317 ": " + str( intentInstallLatAvg ) + " ms" )
andrewonlab8790abb2014-11-06 13:51:54 -0500318
andrewonlab79244cc2015-01-26 01:11:49 -0500319 if intentInstallLatAvg > 0.0 and \
320 intentInstallLatAvg < 1000 and i > numIgnore:
321 intentAddLatList.append( intentInstallLatAvg )
andrewonlab8790abb2014-11-06 13:51:54 -0500322 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500323 main.log.info( "Intent add latency exceeded " +
324 "threshold. Skipping iteration " + str( i ) )
andrewonlab8790abb2014-11-06 13:51:54 -0500325
andrewonlab79244cc2015-01-26 01:11:49 -0500326 time.sleep( 3 )
327
328 # TODO: Only remove intents that were installed
andrewonlaba57a3042015-01-23 13:53:05 -0500329 # in this case... Otherwise many other intents
330 # may show up distorting the results
andrewonlab79244cc2015-01-26 01:11:49 -0500331 main.log.info( "Removing intents for next iteration" )
332 jsonTemp = \
333 main.ONOS1cli.intents( jsonFormat=True )
334 jsonObjIntents = json.loads( jsonTemp )
335 if jsonObjIntents:
336 for intents in jsonObjIntents:
337 tempId = intents[ 'id' ]
338 # main.ONOS1cli.removeIntent( tempId )
339 main.log.info( "Removing intent id: " +
340 str( tempId ) )
341 main.ONOS1cli.removeIntent( tempId )
andrewonlab8790abb2014-11-06 13:51:54 -0500342 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500343 main.log.info( "Intents were not installed correctly" )
andrewonlab8790abb2014-11-06 13:51:54 -0500344
andrewonlab79244cc2015-01-26 01:11:49 -0500345 time.sleep( 5 )
andrewonlab8790abb2014-11-06 13:51:54 -0500346
andrewonlab79244cc2015-01-26 01:11:49 -0500347 if intentAddLatList:
348 intentAddLatAvg = sum( intentAddLatList ) /\
349 len( intentAddLatList )
andrewonlaba57a3042015-01-23 13:53:05 -0500350 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500351 main.log.report( "Intent installation latency test failed" )
352 intentAddLatAvg = "NA"
andrewonlaba57a3042015-01-23 13:53:05 -0500353 assertion = main.FALSE
354
andrewonlab79244cc2015-01-26 01:11:49 -0500355 intentAddLatStd = \
356 round( numpy.std( intentAddLatList ), 1 )
357 # END ITERATION FOR LOOP
358 main.log.report( "Single intent add latency - " )
359 main.log.report( "Avg: " + str( intentAddLatAvg ) + " ms" )
360 main.log.report( "Std Deviation: " + str( intentAddLatStd ) + " ms" )
361
362 utilities.assert_equals(
363 expect=main.TRUE,
364 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500365 onpass="Single intent install latency test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500366 onfail="Single intent install latency test failed" )
andrewonlab92ea3672014-11-04 20:22:14 -0500367
andrewonlab79244cc2015-01-26 01:11:49 -0500368 def CASE3( self, main ):
369 """
andrewonlab4cf9dd22014-11-18 21:28:38 -0500370 Intent Reroute latency
andrewonlab79244cc2015-01-26 01:11:49 -0500371 """
andrewonlab4cf9dd22014-11-18 21:28:38 -0500372 import time
373 import json
374 import requests
375 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500376 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500377 global clusterCount
andrewonlab4cf9dd22014-11-18 21:28:38 -0500378
andrewonlab79244cc2015-01-26 01:11:49 -0500379 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
380 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
381 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
382 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab4cf9dd22014-11-18 21:28:38 -0500383
andrewonlab79244cc2015-01-26 01:11:49 -0500384 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab4cf9dd22014-11-18 21:28:38 -0500385
andrewonlab79244cc2015-01-26 01:11:49 -0500386 # number of iterations of case
387 numIter = main.params[ 'TEST' ][ 'numIter' ]
388 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
andrewonlaba57a3042015-01-23 13:53:05 -0500389 assertion = main.TRUE
andrewonlab4cf9dd22014-11-18 21:28:38 -0500390
andrewonlab79244cc2015-01-26 01:11:49 -0500391 # Timestamp keys for json metrics output
392 submitTime = main.params[ 'JSON' ][ 'submittedTime' ]
393 installTime = main.params[ 'JSON' ][ 'installedTime' ]
394 wdRequestTime = main.params[ 'JSON' ][ 'wdRequestTime' ]
395 withdrawnTime = main.params[ 'JSON' ][ 'withdrawnTime' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500396
andrewonlab79244cc2015-01-26 01:11:49 -0500397 # NOTE: May need to configure interface depending on topology
398 intfs = main.params[ 'TEST' ][ 'intfs' ]
andrewonlab70decc02014-11-19 18:50:23 -0500399
andrewonlab79244cc2015-01-26 01:11:49 -0500400 devicesJsonStr = main.ONOS1cli.devices()
401 devicesJsonObj = json.loads( devicesJsonStr )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500402
andrewonlab79244cc2015-01-26 01:11:49 -0500403 deviceIdList = []
andrewonlab4cf9dd22014-11-18 21:28:38 -0500404
andrewonlab79244cc2015-01-26 01:11:49 -0500405 # Obtain device id list in ONOS format.
406 # They should already be in order ( 1,2,3,10,11,12,13, etc )
407 for device in devicesJsonObj:
408 deviceIdList.append( device[ 'id' ] )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500409
andrewonlab79244cc2015-01-26 01:11:49 -0500410 intentRerouteLatList = []
andrewonlab4cf9dd22014-11-18 21:28:38 -0500411
andrewonlab79244cc2015-01-26 01:11:49 -0500412 for i in range( 0, int( numIter ) ):
413 # addPointIntent( ingrDevice, ingrPort,
414 # egrDevice, egrPort )
415 if len( deviceIdList ) > 0:
416 main.ONOS1cli.addPointIntent(
417 deviceIdList[ 0 ] + "/2", deviceIdList[ 7 ] + "/2" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500418 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500419 main.log.info( "Failed to fetch devices from ONOS" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500420
andrewonlab79244cc2015-01-26 01:11:49 -0500421 time.sleep( 5 )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500422
andrewonlab79244cc2015-01-26 01:11:49 -0500423 intentsStr = main.ONOS1cli.intents( jsonFormat=True )
424 intentsObj = json.loads( intentsStr )
425 for intent in intentsObj:
426 if intent[ 'state' ] == "INSTALLED":
427 main.log.info( "Intent installed successfully" )
428 intentId = intent[ 'id' ]
429 main.log.info( "Intent id: " + str( intentId ) )
andrewonlab70decc02014-11-19 18:50:23 -0500430 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500431 # TODO: Add error handling
432 main.log.info( "Intent installation failed" )
433 intentId = ""
434
435 main.log.info( "Disabling interface " + intfs )
436 t0System = time.time() * 1000
andrewonlab4cf9dd22014-11-18 21:28:38 -0500437 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500438 "sh ifconfig " + intfs + " down" )
439 main.Mininet1.handle.expect( "mininet>" )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500440
andrewonlab79244cc2015-01-26 01:11:49 -0500441 # TODO: Check for correct intent reroute
442 time.sleep( 1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800443
andrewonlab79244cc2015-01-26 01:11:49 -0500444 # Obtain metrics from ONOS 1, 2, 3
445 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
446 intentsJsonObj1 = json.loads( intentsJsonStr1 )
447 # Parse values from the json object
448 intentInstall1 = \
449 intentsJsonObj1[ installTime ][ 'value' ]
450 intentRerouteLat1 = \
451 int( intentInstall1 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500452
andrewonlab79244cc2015-01-26 01:11:49 -0500453 if clusterCount == 3:
454 intentsJsonStr2 = main.ONOS2cli.intentsEventsMetrics()
455 intentsJsonStr3 = main.ONOS3cli.intentsEventsMetrics()
456
457 intentsJsonObj2 = json.loads( intentsJsonStr2 )
458 intentsJsonObj3 = json.loads( intentsJsonStr3 )
459 intentInstall2 = \
460 intentsJsonObj2[ installTime ][ 'value' ]
461 intentInstall3 = \
462 intentsJsonObj3[ installTime ][ 'value' ]
463 intentRerouteLat2 = \
464 int( intentInstall2 ) - int( t0System )
465 intentRerouteLat3 = \
466 int( intentInstall3 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500467 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500468 intentRerouteLat2 = 0
469 intentRerouteLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500470
andrewonlab79244cc2015-01-26 01:11:49 -0500471 if clusterCount == 5:
472 intentsJsonStr4 = main.ONOS4cli.intentsEventsMetrics()
473 intentsJsonStr5 = main.ONOS5cli.intentsEventsMetrics()
andrewonlaba57a3042015-01-23 13:53:05 -0500474
andrewonlab79244cc2015-01-26 01:11:49 -0500475 intentsJsonObj4 = json.loads( intentsJsonStr4 )
476 intentsJsonObj5 = json.loads( intentsJsonStr5 )
477 intentInstall4 = \
478 intentsJsonObj4[ installTime ][ 'value' ]
479 intentInstall5 = \
480 intentsJsonObj5[ installTime ][ 'value' ]
481 intentRerouteLat4 = \
482 int( intentInstall4 ) - int( t0System )
483 intentRerouteLat5 = \
484 int( intentInstall5 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500485 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500486 intentRerouteLat4 = 0
487 intentRerouteLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500488
andrewonlab79244cc2015-01-26 01:11:49 -0500489 if clusterCount == 7:
490 intentsJsonStr6 = main.ONOS6cli.intentsEventsMetrics()
491 intentsJsonStr7 = main.ONOS7cli.intentsEventsMetrics()
andrewonlaba57a3042015-01-23 13:53:05 -0500492
andrewonlab79244cc2015-01-26 01:11:49 -0500493 intentsJsonObj6 = json.loads( intentsJsonStr6 )
494 intentsJsonObj7 = json.loads( intentsJsonStr7 )
495 intentInstall6 = \
496 intentsJsonObj6[ installTime ][ 'value' ]
497 intentInstall7 = \
498 intentsJsonObj7[ installTime ][ 'value' ]
499 intentRerouteLat6 = \
500 int( intentInstall6 ) - int( t0System )
501 intentRerouteLat7 = \
502 int( intentInstall7 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500503 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500504 intentRerouteLat6 = 0
505 intentRerouteLat7 = 0
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800506
andrewonlab79244cc2015-01-26 01:11:49 -0500507 intentRerouteLatAvg = \
508 ( intentRerouteLat1 +
509 intentRerouteLat2 +
510 intentRerouteLat3 +
511 intentRerouteLat4 +
512 intentRerouteLat5 +
513 intentRerouteLat6 +
514 intentRerouteLat7 ) / clusterCount
andrewonlab4cf9dd22014-11-18 21:28:38 -0500515
andrewonlab79244cc2015-01-26 01:11:49 -0500516 main.log.info( "Intent reroute latency avg for iteration " +
517 str( i ) + ": " + str( intentRerouteLatAvg ) )
518
519 if intentRerouteLatAvg > 0.0 and \
520 intentRerouteLatAvg < 1000 and i > numIgnore:
521 intentRerouteLatList.append( intentRerouteLatAvg )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500522 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500523 main.log.info( "Intent reroute latency exceeded " +
524 "threshold. Skipping iteration " + str( i ) )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500525
andrewonlab79244cc2015-01-26 01:11:49 -0500526 main.log.info( "Removing intents for next iteration" )
527 main.ONOS1cli.removeIntent( intentId )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800528
andrewonlab79244cc2015-01-26 01:11:49 -0500529 main.log.info( "Bringing Mininet interface up for next " +
530 "iteration" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500531 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500532 "sh ifconfig " + intfs + " up" )
533 main.Mininet1.handle.expect( "mininet>" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800534
andrewonlab79244cc2015-01-26 01:11:49 -0500535 if intentRerouteLatList:
536 intentRerouteLatAvg = sum( intentRerouteLatList ) /\
537 len( intentRerouteLatList )
andrewonlaba57a3042015-01-23 13:53:05 -0500538 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500539 main.log.report( "Intent reroute test failed. Results NA" )
540 intentRerouteLatAvg = "NA"
541 # NOTE: fails test when list is empty
andrewonlaba57a3042015-01-23 13:53:05 -0500542 assertion = main.FALSE
andrewonlab79244cc2015-01-26 01:11:49 -0500543
544 intentRerouteLatStd = \
545 round( numpy.std( intentRerouteLatList ), 1 )
546 # END ITERATION FOR LOOP
547 main.log.report( "Single intent reroute latency - " )
548 main.log.report( "Avg: " + str( intentRerouteLatAvg ) + " ms" )
549 main.log.report(
550 "Std Deviation: " +
551 str( intentRerouteLatStd ) +
552 " ms" )
553
554 utilities.assert_equals(
555 expect=main.TRUE,
556 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500557 onpass="Single intent reroute latency test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500558 onfail="Single intent reroute latency test failed" )
559
560 def CASE4( self, main ):
561 """
andrewonlab042b3912014-12-10 16:40:50 -0500562 Batch intent install
andrewonlab79244cc2015-01-26 01:11:49 -0500563 """
andrewonlab70decc02014-11-19 18:50:23 -0500564 import time
565 import json
566 import requests
567 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500568 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500569 global clusterCount
andrewonlab70decc02014-11-19 18:50:23 -0500570
andrewonlab79244cc2015-01-26 01:11:49 -0500571 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
572 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
573 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
574 ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
575 ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
576 ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
577 ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500578
579 assertion = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800580
andrewonlab79244cc2015-01-26 01:11:49 -0500581 ONOSIpList = []
582 for i in range( 1, 8 ):
583 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlab4293dcb2014-12-02 15:48:05 -0500584
andrewonlab79244cc2015-01-26 01:11:49 -0500585 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab70decc02014-11-19 18:50:23 -0500586
andrewonlab79244cc2015-01-26 01:11:49 -0500587 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab70decc02014-11-19 18:50:23 -0500588
andrewonlab79244cc2015-01-26 01:11:49 -0500589 batchIntentSize = int( main.params[ 'TEST' ][ 'batchIntentSize' ] )
590 batchThreshMin = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
591 batchThreshMax = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
andrewonlab4293dcb2014-12-02 15:48:05 -0500592
andrewonlab79244cc2015-01-26 01:11:49 -0500593 # number of iterations of case
594 numIter = main.params[ 'TEST' ][ 'numIter' ]
595 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
596 numSwitch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
597 nThread = main.params[ 'TEST' ][ 'numMult' ]
598 #nThread = 105
599
600 # Switch assignment NOTE: hardcoded
601 if clusterCount == 1:
602 for i in range( 1, numSwitch + 1 ):
603 main.Mininet1.assignSwController(
604 sw=str( i ),
605 ip1=ONOS1Ip,
606 port1=defaultSwPort )
607 if clusterCount == 3:
608 for i in range( 1, 3 ):
609 main.Mininet1.assignSwController(
610 sw=str( i ),
611 ip1=ONOS1Ip,
612 port1=defaultSwPort )
613 for i in range( 3, 6 ):
614 main.Mininet1.assignSwController(
615 sw=str( i ),
616 ip1=ONOS2Ip,
617 port1=defaultSwPort )
618 for i in range( 6, 9 ):
619 main.Mininet1.assignSwController(
620 sw=str( i ),
621 ip1=ONOS3Ip,
622 port1=defaultSwPort )
623 if clusterCount == 5:
624 main.Mininet1.assignSwController(
625 sw="1",
626 ip1=ONOS1Ip,
627 port1=defaultSwPort )
628 main.Mininet1.assignSwController(
629 sw="2",
630 ip1=ONOS2Ip,
631 port1=defaultSwPort )
632 for i in range( 3, 6 ):
633 main.Mininet1.assignSwController(
634 sw=str( i ),
635 ip1=ONOS3Ip,
636 port1=defaultSwPort )
637 main.Mininet1.assignSwController(
638 sw="6",
639 ip1=ONOS4Ip,
640 port1=defaultSwPort )
641 main.Mininet1.assignSwController(
642 sw="7",
643 ip1=ONOS5Ip,
644 port1=defaultSwPort )
645 main.Mininet1.assignSwController(
646 sw="8",
647 ip1=ONOS5Ip,
648 port1=defaultSwPort )
649
650 if clusterCount == 7:
651 for i in range( 1, 9 ):
andrewonlabeb1d0542014-12-03 20:12:01 -0500652 if i < 8:
andrewonlab79244cc2015-01-26 01:11:49 -0500653 main.Mininet1.assignSwController(
654 sw=str( i ),
655 ip1=ONOSIpList[ i - 1 ],
656 port1=defaultSwPort )
657 elif i >= 8:
658 main.Mininet1.assignSwController(
659 sw=str( i ),
660 ip1=ONOSIpList[ 6 ],
661 port1=defaultSwPort )
andrewonlab70decc02014-11-19 18:50:23 -0500662
andrewonlab79244cc2015-01-26 01:11:49 -0500663 time.sleep( 20 )
andrewonlabeb1d0542014-12-03 20:12:01 -0500664
andrewonlab79244cc2015-01-26 01:11:49 -0500665 main.log.report( "Batch intent installation test of " +
666 str( batchIntentSize ) + " intent(s)" )
andrewonlab4293dcb2014-12-02 15:48:05 -0500667
andrewonlab79244cc2015-01-26 01:11:49 -0500668 batchResultList = []
andrewonlab70decc02014-11-19 18:50:23 -0500669
andrewonlab79244cc2015-01-26 01:11:49 -0500670 main.log.info( "Getting list of available devices" )
671 deviceIdList = []
672 jsonStr = main.ONOS1cli.devices()
673 jsonObj = json.loads( jsonStr )
674 for device in jsonObj:
675 deviceIdList.append( device[ 'id' ] )
andrewonlab70decc02014-11-19 18:50:23 -0500676
andrewonlab79244cc2015-01-26 01:11:49 -0500677 batchInstallLat = []
678 batchWithdrawLat = []
andrewonlab70decc02014-11-19 18:50:23 -0500679
andrewonlab79244cc2015-01-26 01:11:49 -0500680 # Max intent install measurement of all nodes
681 maxInstallLat = []
682 maxWithdrawLat = []
683 sleepTime = 10
684
685 baseDir = "/tmp/"
686
687 for batch in range( 0, 5 ):
688 for i in range( 0, int( numIter ) ):
689 main.log.info( "Pushing " +
690 str( int( batchIntentSize ) * int( nThread ) ) +
691 " intents. Iteration " + str( i ) )
692
693 for node in range( 1, clusterCount + 1 ):
694 saveDir = baseDir + "batch_intent_" + str( node ) + ".txt"
695 main.ONOSbench.pushTestIntentsShell(
696 deviceIdList[ 0 ] + "/2",
697 deviceIdList[ 7 ] + "/2",
698 batchIntentSize,
699 saveDir, ONOSIpList[ node - 1 ],
700 numMult=nThread, appId=node )
701
702 # Wait sufficient time for intents to start
703 # installing
704 time.sleep( sleepTime )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800705
andrewonlaba57a3042015-01-23 13:53:05 -0500706 intent = ""
707 counter = 300
andrewonlab79244cc2015-01-26 01:11:49 -0500708 while len( intent ) > 0 and counter > 0:
andrewonlaba57a3042015-01-23 13:53:05 -0500709 main.ONOS1cli.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500710 "intents | wc -l" )
andrewonlaba57a3042015-01-23 13:53:05 -0500711 main.ONOS1cli.handle.expect(
andrewonlab79244cc2015-01-26 01:11:49 -0500712 "intents | wc -l" )
andrewonlaba57a3042015-01-23 13:53:05 -0500713 main.ONOS1cli.handle.expect(
andrewonlab79244cc2015-01-26 01:11:49 -0500714 "onos>" )
715 intentTemp = main.ONOS1cli.handle.before()
andrewonlaba57a3042015-01-23 13:53:05 -0500716 intent = main.ONOS1cli.intents()
andrewonlab79244cc2015-01-26 01:11:49 -0500717 intent = json.loads( intent )
718 counter = counter - 1
719 time.sleep( 1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800720
andrewonlab79244cc2015-01-26 01:11:49 -0500721 time.sleep( 5 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800722
andrewonlab79244cc2015-01-26 01:11:49 -0500723 for node in range( 1, clusterCount + 1 ):
724 saveDir = baseDir + "batch_intent_" + str( node ) + ".txt"
725 with open( saveDir ) as fOnos:
726 lineCount = 0
727 for line in fOnos:
728 line = line[ 1: ]
729 line = line.split( ": " )
730 main.log.info( "Line read: " + str( line ) )
andrewonlabd019a6b2015-02-05 00:05:22 -0500731 #Prevent split method if line doesn't have
732 #space
733 if " " in str(line):
734 result = line[ 1 ].split( " " )[ 0 ]
735 else:
736 main.log.warn( "Empty line read" )
737 result = 0
andrewonlab79244cc2015-01-26 01:11:49 -0500738 # TODO: add parameters before appending latency
739 if lineCount == 0:
740 batchInstallLat.append( int( result ) )
741 installResult = result
742 elif lineCount == 1:
743 batchWithdrawLat.append( int( result ) )
744 withdrawResult = result
andrewonlabd019a6b2015-02-05 00:05:22 -0500745 else:
746 main.log.warn("Invalid results")
747 installResult = 'NA'
748 withdrawResult = 'NA'
andrewonlab79244cc2015-01-26 01:11:49 -0500749 lineCount += 1
750 main.log.info( "Batch install latency for ONOS" +
751 str( node ) + " with " +
752 str( batchIntentSize ) + "intents: " +
753 str( installResult ) + " ms" )
754 main.log.info( "Batch withdraw latency for ONOS" +
755 str( node ) + " with " +
756 str( batchIntentSize ) + "intents: " +
757 str( withdrawResult ) + " ms" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500758
andrewonlab79244cc2015-01-26 01:11:49 -0500759 if len( batchInstallLat ) > 0 and int( i ) > numIgnore:
760 maxInstallLat.append( max( batchInstallLat ) )
761 elif len( batchInstallLat ) == 0:
762 # If I failed to read anything from the file,
763 # increase the wait time before checking intents
764 sleepTime += 30
765 if len( batchWithdrawLat ) > 0 and int( i ) > numIgnore:
766 maxWithdrawLat.append( max( batchWithdrawLat ) )
767 batchInstallLat = []
768 batchWithdrawLat = []
769
770 # Sleep in between iterations
771 time.sleep( 5 )
772
773 if maxInstallLat:
andrewonlabd019a6b2015-02-05 00:05:22 -0500774 avgInstallLat = str( round(
775 sum( maxInstallLat ) /
776 len( maxInstallLat )
777 , 2 ))
andrewonlaba57a3042015-01-23 13:53:05 -0500778 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500779 avgInstallLat = "NA"
780 main.log.report( "Batch installation failed" )
andrewonlaba57a3042015-01-23 13:53:05 -0500781 assertion = main.FALSE
andrewonlabeb1d0542014-12-03 20:12:01 -0500782
andrewonlab79244cc2015-01-26 01:11:49 -0500783 if maxWithdrawLat:
andrewonlabd019a6b2015-02-05 00:05:22 -0500784 avgWithdrawLat = str( round(
785 sum( maxWithdrawLat ) /
786 len( maxWithdrawLat )
787 , 2 ))
andrewonlaba57a3042015-01-23 13:53:05 -0500788 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500789 avgWithdrawLat = "NA"
790 main.log.report( "Batch withdraw failed" )
andrewonlaba57a3042015-01-23 13:53:05 -0500791 assertion = main.FALSE
andrewonlabeb1d0542014-12-03 20:12:01 -0500792
andrewonlab79244cc2015-01-26 01:11:49 -0500793 main.log.report( "Avg of batch installation latency " +
794 "of size " + str( batchIntentSize ) + ": " +
795 str( avgInstallLat ) + " ms" )
796 main.log.report( "Std Deviation of batch installation latency " +
andrewonlabd019a6b2015-02-05 00:05:22 -0500797 ": " +
798 str( round(numpy.std( maxInstallLat ),2)) +
799 " ms" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500800
andrewonlab79244cc2015-01-26 01:11:49 -0500801 main.log.report( "Avg of batch withdraw latency " +
802 "of size " + str( batchIntentSize ) + ": " +
803 str( avgWithdrawLat ) + " ms" )
804 main.log.report( "Std Deviation of batch withdraw latency " +
805 ": " +
andrewonlabd019a6b2015-02-05 00:05:22 -0500806 str( round(numpy.std( maxWithdrawLat ),2)) +
andrewonlab79244cc2015-01-26 01:11:49 -0500807 " ms" )
808
andrewonlabd019a6b2015-02-05 00:05:22 -0500809 if batch == 0:
810 batchIntentSize = 10
811 elif batch == 1:
812 batchIntentSize = 100
813 elif batch == 2:
814 batchIntentSize = 1000
815 elif batch == 3:
816 batchIntentSize = 2000
817 if batch < 4:
818 main.log.report( "Increasing batch intent size to " +
andrewonlab79244cc2015-01-26 01:11:49 -0500819 str(batchIntentSize) )
820
821 #main.log.info( "Removing all intents for next test case" )
822 #jsonTemp = main.ONOS1cli.intents( jsonFormat=True )
823 #jsonObjIntents = json.loads( jsonTemp )
824 # if jsonObjIntents:
825 # for intents in jsonObjIntents:
826 # tempId = intents[ 'id' ]
827 # main.ONOS1cli.removeIntent( tempId )
828 # main.ONOS1cli.removeIntent( tempId )
829
830 utilities.assert_equals(
831 expect=main.TRUE,
832 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500833 onpass="Batch intent install/withdraw test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500834 onfail="Batch intent install/withdraw test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800835
andrewonlab79244cc2015-01-26 01:11:49 -0500836 def CASE5( self, main ):
837 """
andrewonlab4293dcb2014-12-02 15:48:05 -0500838 Increase number of nodes and initiate CLI
andrewonlab79244cc2015-01-26 01:11:49 -0500839 """
andrewonlab4293dcb2014-12-02 15:48:05 -0500840 import time
841 import json
842
andrewonlab79244cc2015-01-26 01:11:49 -0500843 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
844 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
845 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
846 ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
847 ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
848 ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
849 ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
andrewonlab4293dcb2014-12-02 15:48:05 -0500850
andrewonlab79244cc2015-01-26 01:11:49 -0500851 global clusterCount
852 clusterCount += 2
853 main.log.report( "Increasing cluster size to " +
854 str( clusterCount ) )
andrewonlab4293dcb2014-12-02 15:48:05 -0500855
andrewonlab79244cc2015-01-26 01:11:49 -0500856 installResult = main.FALSE
andrewonlab4293dcb2014-12-02 15:48:05 -0500857
andrewonlab79244cc2015-01-26 01:11:49 -0500858 if clusterCount == 3:
859 installResult1 = \
860 main.ONOSbench.onosInstall( node=ONOS2Ip )
861 installResult2 = \
862 main.ONOSbench.onosInstall( node=ONOS3Ip )
863 time.sleep( 5 )
andrewonlab4293dcb2014-12-02 15:48:05 -0500864
andrewonlab79244cc2015-01-26 01:11:49 -0500865 main.log.info( "Starting ONOS CLI" )
866 main.ONOS2cli.startOnosCli( ONOS2Ip )
867 main.ONOS3cli.startOnosCli( ONOS3Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500868
andrewonlab79244cc2015-01-26 01:11:49 -0500869 installResult = installResult1 and installResult2
andrewonlab4293dcb2014-12-02 15:48:05 -0500870
andrewonlab79244cc2015-01-26 01:11:49 -0500871 if clusterCount == 5:
872 main.log.info( "Installing ONOS on node 4 and 5" )
873 installResult1 = \
874 main.ONOSbench.onosInstall( node=ONOS4Ip )
875 installResult2 = \
876 main.ONOSbench.onosInstall( node=ONOS5Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500877
andrewonlab79244cc2015-01-26 01:11:49 -0500878 main.log.info( "Starting ONOS CLI" )
879 main.ONOS4cli.startOnosCli( ONOS4Ip )
880 main.ONOS5cli.startOnosCli( ONOS5Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500881
andrewonlab79244cc2015-01-26 01:11:49 -0500882 installResult = installResult1 and installResult2
andrewonlab4293dcb2014-12-02 15:48:05 -0500883
andrewonlab79244cc2015-01-26 01:11:49 -0500884 if clusterCount == 7:
885 main.log.info( "Installing ONOS on node 6 and 7" )
886 installResult1 = \
887 main.ONOSbench.onosInstall( node=ONOS6Ip )
888 installResult2 = \
889 main.ONOSbench.onosInstall( node=ONOS7Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500890
andrewonlab79244cc2015-01-26 01:11:49 -0500891 main.log.info( "Starting ONOS CLI" )
892 main.ONOS6cli.startOnosCli( ONOS6Ip )
893 main.ONOS7cli.startOnosCli( ONOS7Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500894
andrewonlab79244cc2015-01-26 01:11:49 -0500895 installResult = installResult1 and installResult2
andrewonlab4293dcb2014-12-02 15:48:05 -0500896
andrewonlab79244cc2015-01-26 01:11:49 -0500897 time.sleep( 5 )
andrewonlab4293dcb2014-12-02 15:48:05 -0500898
andrewonlab79244cc2015-01-26 01:11:49 -0500899 if installResult == main.TRUE:
andrewonlab4293dcb2014-12-02 15:48:05 -0500900 assertion = main.TRUE
901 else:
902 assertion = main.FALSE
903
andrewonlab79244cc2015-01-26 01:11:49 -0500904 utilities.assert_equals( expect=main.TRUE, actual=assertion,
905 onpass="Scale out to " + str( clusterCount ) +
906 " nodes successful",
907 onfail="Scale out to " + str( clusterCount ) +
908 " nodes failed" )
andrewonlab4293dcb2014-12-02 15:48:05 -0500909
andrewonlab79244cc2015-01-26 01:11:49 -0500910 def CASE7( self, main ):
911 # TODO: Fix for scale-out scenario
912 """
andrewonlaba57a3042015-01-23 13:53:05 -0500913 Batch intent reroute latency
andrewonlab79244cc2015-01-26 01:11:49 -0500914 """
andrewonlaba57a3042015-01-23 13:53:05 -0500915 import time
916 import json
917 import requests
918 import os
919 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500920 global clusterCount
andrewonlaba57a3042015-01-23 13:53:05 -0500921
andrewonlab79244cc2015-01-26 01:11:49 -0500922 ONOSIpList = []
923 for i in range( 1, 8 ):
924 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlaba57a3042015-01-23 13:53:05 -0500925
andrewonlab79244cc2015-01-26 01:11:49 -0500926 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
927 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500928
andrewonlab79244cc2015-01-26 01:11:49 -0500929 batchIntentSize = main.params[ 'TEST' ][ 'batchIntentSize' ]
930 batchThreshMin = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
931 batchThreshMax = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
932 intfs = main.params[ 'TEST' ][ 'intfs' ]
933 installTime = main.params[ 'JSON' ][ 'installedTime' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500934
andrewonlab79244cc2015-01-26 01:11:49 -0500935 # number of iterations of case
936 numIter = main.params[ 'TEST' ][ 'numIter' ]
937 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
938 numSwitch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
939 nThread = main.params[ 'TEST' ][ 'numMult' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500940
andrewonlab79244cc2015-01-26 01:11:49 -0500941 main.log.report( "Batch intent installation test of " +
942 batchIntentSize + " intents" )
andrewonlaba57a3042015-01-23 13:53:05 -0500943
andrewonlab79244cc2015-01-26 01:11:49 -0500944 batchResultList = []
andrewonlaba57a3042015-01-23 13:53:05 -0500945
andrewonlab79244cc2015-01-26 01:11:49 -0500946 time.sleep( 10 )
andrewonlaba57a3042015-01-23 13:53:05 -0500947
andrewonlab79244cc2015-01-26 01:11:49 -0500948 main.log.info( "Getting list of available devices" )
949 deviceIdList = []
950 jsonStr = main.ONOS1cli.devices()
951 jsonObj = json.loads( jsonStr )
952 for device in jsonObj:
953 deviceIdList.append( device[ 'id' ] )
andrewonlaba57a3042015-01-23 13:53:05 -0500954
andrewonlab79244cc2015-01-26 01:11:49 -0500955 batchInstallLat = []
956 batchWithdrawLat = []
957 sleepTime = 10
andrewonlaba57a3042015-01-23 13:53:05 -0500958
andrewonlab79244cc2015-01-26 01:11:49 -0500959 baseDir = "/tmp/"
960 maxInstallLat = []
961
962 for i in range( 0, int( numIter ) ):
963 main.log.info( "Pushing " +
964 str( int( batchIntentSize ) * int( nThread ) ) +
965 " intents. Iteration " + str( i ) )
966
967 main.ONOSbench.pushTestIntentsShell(
968 deviceIdList[ 0 ] + "/2",
969 deviceIdList[ 7 ] + "/2",
970 batchIntentSize, "/tmp/batch_install.txt",
971 ONOSIpList[ 0 ], numMult="1", appId="1",
972 report=False, options="--install" )
973 # main.ONOSbench.pushTestIntentsShell(
andrewonlaba57a3042015-01-23 13:53:05 -0500974 # "of:0000000000001002/1",
975 # "of:0000000000002002/1",
976 # 133, "/tmp/temp2.txt", "10.128.174.2",
andrewonlab79244cc2015-01-26 01:11:49 -0500977 # numMult="6", appId="2",report=False )
978
979 # TODO: Check for installation success then proceed
980 time.sleep( 30 )
981
982 # NOTE: this interface is specific to
andrewonlaba57a3042015-01-23 13:53:05 -0500983 # topo-intentFlower.py topology
984 # reroute case.
andrewonlab79244cc2015-01-26 01:11:49 -0500985 main.log.info( "Disabling interface " + intfs )
andrewonlaba57a3042015-01-23 13:53:05 -0500986 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500987 "sh ifconfig " + intfs + " down" )
988 t0System = time.time() * 1000
andrewonlaba57a3042015-01-23 13:53:05 -0500989
andrewonlab79244cc2015-01-26 01:11:49 -0500990 # TODO: Wait sufficient time for intents to install
991 time.sleep( 10 )
andrewonlaba57a3042015-01-23 13:53:05 -0500992
andrewonlab79244cc2015-01-26 01:11:49 -0500993 # TODO: get intent installation time
994
995 # Obtain metrics from ONOS 1, 2, 3
996 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
997 intentsJsonObj1 = json.loads( intentsJsonStr1 )
998 # Parse values from the json object
999 intentInstall1 = \
1000 intentsJsonObj1[ installTime ][ 'value' ]
1001 intentRerouteLat1 = \
1002 int( intentInstall1 ) - int( t0System )
1003
1004 if clusterCount == 3:
1005 intentsJsonStr2 =\
1006 main.ONOS2cli.intentsEventsMetrics()
1007 intentsJsonStr3 =\
1008 main.ONOS3cli.intentsEventsMetrics()
1009 intentsJsonObj2 = json.loads( intentsJsonStr2 )
1010 intentsJsonObj3 = json.loads( intentsJsonStr3 )
1011 intentInstall2 = \
1012 intentsJsonObj2[ installTime ][ 'value' ]
1013 intentInstall3 = \
1014 intentsJsonObj3[ installTime ][ 'value' ]
1015 intentRerouteLat2 = \
1016 int( intentInstall2 ) - int( t0System )
1017 intentRerouteLat3 = \
1018 int( intentInstall3 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -05001019 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001020 intentRerouteLat2 = 0
1021 intentRerouteLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001022
andrewonlab79244cc2015-01-26 01:11:49 -05001023 if clusterCount == 5:
1024 intentsJsonStr4 =\
1025 main.ONOS4cli.intentsEventsMetrics()
1026 intentsJsonStr5 =\
1027 main.ONOS5cli.intentsEventsMetrics()
1028 intentsJsonObj4 = json.loads( intentsJsonStr4 )
1029 intentsJsonObj5 = json.loads( intentsJsonStr5 )
1030 intentInstall4 = \
1031 intentsJsonObj4[ installTime ][ 'value' ]
1032 intentInstall5 = \
1033 intentsJsonObj5[ installTime ][ 'value' ]
1034 intentRerouteLat4 = \
1035 int( intentInstall4 ) - int( t0System )
1036 intentRerouteLat5 = \
1037 int( intentInstall5 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -05001038 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001039 intentRerouteLat4 = 0
1040 intentRerouteLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001041
andrewonlab79244cc2015-01-26 01:11:49 -05001042 if clusterCount == 7:
1043 intentsJsonStr6 =\
1044 main.ONOS6cli.intentsEventsMetrics()
1045 intentsJsonStr7 =\
1046 main.ONOS7cli.intentsEventsMetrics()
1047 intentsJsonObj6 = json.loads( intentsJsonStr6 )
1048 intentsJsonObj7 = json.loads( intentsJsonStr7 )
1049 intentInstall6 = \
1050 intentsJsonObj6[ installTime ][ 'value' ]
1051 intentInstall7 = \
1052 intentsJsonObj7[ installTime ][ 'value' ]
1053 intentRerouteLat6 = \
1054 int( intentInstall6 ) - int( t0System )
1055 intentRerouteLat7 = \
1056 int( intentInstall7 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -05001057 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001058 intentRerouteLat6 = 0
1059 intentRerouteLat7 = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001060
andrewonlab79244cc2015-01-26 01:11:49 -05001061 intentRerouteLatAvg = \
1062 ( intentRerouteLat1 +
1063 intentRerouteLat2 +
1064 intentRerouteLat3 +
1065 intentRerouteLat4 +
1066 intentRerouteLat5 +
1067 intentRerouteLat6 +
1068 intentRerouteLat7 ) / clusterCount
andrewonlaba57a3042015-01-23 13:53:05 -05001069
andrewonlab79244cc2015-01-26 01:11:49 -05001070 main.log.info( "Intent reroute latency avg for iteration " +
1071 str( i ) + ": " + str( intentRerouteLatAvg ) )
1072 # TODO: Remove intents for next iteration
1073
1074 time.sleep( 5 )
1075
1076 intentsStr = main.ONOS1cli.intents()
1077 intentsJson = json.loads( intentsStr )
1078 for intents in intentsJson:
1079 intentId = intents[ 'id' ]
1080 # TODO: make sure this removes all intents
1081 # print intentId
1082 if intentId:
1083 main.ONOS1cli.removeIntent( intentId )
andrewonlaba57a3042015-01-23 13:53:05 -05001084
1085 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001086 "sh ifconfig " + intfs + " up" )
andrewonlaba57a3042015-01-23 13:53:05 -05001087
andrewonlab79244cc2015-01-26 01:11:49 -05001088 main.log.info( "Intents removed and port back up" )
1089
1090 def CASE9( self, main ):
andrewonlabeb1d0542014-12-03 20:12:01 -05001091 count = 0
andrewonlab79244cc2015-01-26 01:11:49 -05001092 swNum1 = 1
1093 swNum2 = 1
andrewonlabeb1d0542014-12-03 20:12:01 -05001094 appid = 0
andrewonlab79244cc2015-01-26 01:11:49 -05001095 portNum1 = 1
1096 portNum2 = 1
1097
1098 time.sleep( 30 )
andrewonlab4cf9dd22014-11-18 21:28:38 -05001099
andrewonlabeb1d0542014-12-03 20:12:01 -05001100 while True:
andrewonlab79244cc2015-01-26 01:11:49 -05001101 # main.ONOS1cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001102 #"of:0000000000001001/1",
1103 #"of:0000000000002001/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001104 # 100, numMult="10", appId="1" )
1105 # main.ONOS2cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001106 # "of:0000000000001002/1",
1107 # "of:0000000000002002/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001108 # 100, numMult="10", appId="2" )
1109 # main.ONOS2cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001110 # "of:0000000000001003/1",
1111 # "of:0000000000002003/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001112 # 100, numMult="10", appId="3" )
andrewonlabeb1d0542014-12-03 20:12:01 -05001113 count += 1
andrewonlab79244cc2015-01-26 01:11:49 -05001114
andrewonlabeb1d0542014-12-03 20:12:01 -05001115 if count >= 100:
1116 main.ONOSbench.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001117 "onos 10.128.174.1 intents-events-metrics >>" +
1118 " /tmp/metrics_intents_temp.txt &" )
andrewonlabeb1d0542014-12-03 20:12:01 -05001119 count = 0
1120
andrewonlab79244cc2015-01-26 01:11:49 -05001121 arg1 = "of:000000000000100" + str( swNum1 ) + "/" + str( portNum1 )
1122 arg2 = "of:000000000000200" + str( swNum2 ) + "/" + str( portNum2 )
andrewonlabeb1d0542014-12-03 20:12:01 -05001123
andrewonlab79244cc2015-01-26 01:11:49 -05001124 swNum1 += 1
1125
1126 if swNum1 > 7:
1127 swNum1 = 1
1128 swNum2 += 1
1129 if swNum2 > 7:
andrewonlabeb1d0542014-12-03 20:12:01 -05001130 appid += 1
1131
andrewonlab79244cc2015-01-26 01:11:49 -05001132 if swNum2 > 7:
1133 swNum2 = 1
1134
1135 main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001136 arg1,
andrewonlab79244cc2015-01-26 01:11:49 -05001137 arg2,
andrewonlab042b3912014-12-10 16:40:50 -05001138 100, "/tmp/temp.txt", "10.128.174.1",
andrewonlab79244cc2015-01-26 01:11:49 -05001139 numMult="10", appId=appid, report=False )
1140 # main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001141 # "of:0000000000001002/1",
1142 # "of:0000000000002002/1",
1143 # 133, "/tmp/temp2.txt", "10.128.174.2",
andrewonlab79244cc2015-01-26 01:11:49 -05001144 # numMult="6", appId="2",report=False )
1145 # main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001146 # "of:0000000000001003/1",
1147 # "of:0000000000002003/1",
1148 # 133, "/tmp/temp3.txt", "10.128.174.3",
andrewonlab79244cc2015-01-26 01:11:49 -05001149 # numMult="6", appId="3",report=False )
andrewonlab92ea3672014-11-04 20:22:14 -05001150
andrewonlab79244cc2015-01-26 01:11:49 -05001151 time.sleep( 0.2 )