blob: 8fd8089f839ddd40bc0161d36dfbf178379d93b0 [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
andrewonlab082dfc32015-02-06 13:59:51 -050026 ONOSIp = []
27 for i in range(1, 8):
28 ONOSIp.append(main.params[ 'CTRL' ][ 'ip'+str(i) ])
29 main.ONOSbench.onosUninstall( nodeIp = ONOSIp[i-1] )
andrewonlab4293dcb2014-12-02 15:48:05 -050030
andrewonlab79244cc2015-01-26 01:11:49 -050031 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
32 BENCHIp = main.params[ 'BENCH' ][ 'ip' ]
andrewonlab92ea3672014-11-04 20:22:14 -050033
andrewonlab79244cc2015-01-26 01:11:49 -050034 main.case( "Setting up test environment" )
andrewonlab92ea3672014-11-04 20:22:14 -050035
andrewonlab5b954b02015-02-05 13:03:46 -050036 main.step( "Starting mininet topology" )
37 main.Mininet1.startNet()
38
andrewonlab79244cc2015-01-26 01:11:49 -050039 main.step( "Creating cell file" )
40 cellFileResult = main.ONOSbench.createCellFile(
41 BENCHIp, cellName, MN1Ip,
42 "onos-core,onos-app-metrics,onos-gui",
andrewonlab082dfc32015-02-06 13:59:51 -050043 ONOSIp[0] )
andrewonlab92ea3672014-11-04 20:22:14 -050044
andrewonlab79244cc2015-01-26 01:11:49 -050045 main.step( "Applying cell file to environment" )
46 cellApplyResult = main.ONOSbench.setCell( cellName )
47 verifyCellResult = main.ONOSbench.verifyCell()
andrewonlab4293dcb2014-12-02 15:48:05 -050048
andrewonlab79244cc2015-01-26 01:11:49 -050049 main.step( "Removing raft logs" )
50 main.ONOSbench.onosRemoveRaftLogs()
51
52 main.step( "Git checkout and pull " + checkoutBranch )
53 if gitPull == 'on':
54 checkoutResult = \
55 main.ONOSbench.gitCheckout( checkoutBranch )
56 pullResult = main.ONOSbench.gitPull()
57
58 # If you used git pull, auto compile
59 main.step( "Using onos-build to compile ONOS" )
60 buildResult = main.ONOSbench.onosBuild()
andrewonlab92ea3672014-11-04 20:22:14 -050061 else:
andrewonlab79244cc2015-01-26 01:11:49 -050062 checkoutResult = main.TRUE
63 pullResult = main.TRUE
64 buildResult = main.TRUE
65 main.log.info( "Git pull skipped by configuration" )
andrewonlab92ea3672014-11-04 20:22:14 -050066
andrewonlab79244cc2015-01-26 01:11:49 -050067 main.log.report( "Commit information - " )
68 main.ONOSbench.getVersion( report=True )
andrewonlab4cf9dd22014-11-18 21:28:38 -050069
andrewonlab79244cc2015-01-26 01:11:49 -050070 main.step( "Creating ONOS package" )
71 packageResult = main.ONOSbench.onosPackage()
andrewonlab92ea3672014-11-04 20:22:14 -050072
andrewonlab79244cc2015-01-26 01:11:49 -050073 main.step( "Installing ONOS package" )
andrewonlab082dfc32015-02-06 13:59:51 -050074 install1Result = main.ONOSbench.onosInstall( node=ONOSIp[0] )
andrewonlab92ea3672014-11-04 20:22:14 -050075
andrewonlab79244cc2015-01-26 01:11:49 -050076 main.step( "Set cell for ONOScli env" )
77 main.ONOS1cli.setCell( cellName )
andrewonlab92ea3672014-11-04 20:22:14 -050078
andrewonlab79244cc2015-01-26 01:11:49 -050079 time.sleep( 5 )
andrewonlab92ea3672014-11-04 20:22:14 -050080
andrewonlab79244cc2015-01-26 01:11:49 -050081 main.step( "Start onos cli" )
andrewonlab082dfc32015-02-06 13:59:51 -050082 cli1 = main.ONOS1cli.startOnosCli( ONOSIp[0] )
andrewonlab92ea3672014-11-04 20:22:14 -050083
andrewonlab79244cc2015-01-26 01:11:49 -050084 utilities.assert_equals( expect=main.TRUE,
85 actual=cellFileResult and cellApplyResult and
86 verifyCellResult and checkoutResult and
87 pullResult and buildResult and
88 install1Result, # and install2Result and
89 # install3Result,
90 onpass="ONOS started successfully",
91 onfail="Failed to start ONOS" )
andrewonlab92ea3672014-11-04 20:22:14 -050092
andrewonlab79244cc2015-01-26 01:11:49 -050093 def CASE2( self, main ):
94 """
andrewonlab92ea3672014-11-04 20:22:14 -050095 Single intent add latency
96
andrewonlab79244cc2015-01-26 01:11:49 -050097 """
andrewonlab92ea3672014-11-04 20:22:14 -050098 import time
99 import json
100 import requests
101 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500102 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500103 global clusterCount
andrewonlab92ea3672014-11-04 20:22:14 -0500104
andrewonlab79244cc2015-01-26 01:11:49 -0500105 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
106 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
107 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
108 ONOSIpList = []
109 for i in range( 1, 8 ):
110 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlab92ea3672014-11-04 20:22:14 -0500111
andrewonlab79244cc2015-01-26 01:11:49 -0500112 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab92ea3672014-11-04 20:22:14 -0500113
andrewonlab79244cc2015-01-26 01:11:49 -0500114 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab92ea3672014-11-04 20:22:14 -0500115
andrewonlab79244cc2015-01-26 01:11:49 -0500116 # number of iterations of case
117 numIter = main.params[ 'TEST' ][ 'numIter' ]
118 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
119
120 # Timestamp keys for json metrics output
121 submitTime = main.params[ 'JSON' ][ 'submittedTime' ]
122 installTime = main.params[ 'JSON' ][ 'installedTime' ]
123 wdRequestTime = main.params[ 'JSON' ][ 'wdRequestTime' ]
124 withdrawnTime = main.params[ 'JSON' ][ 'withdrawnTime' ]
125
andrewonlaba57a3042015-01-23 13:53:05 -0500126 assertion = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800127
andrewonlab79244cc2015-01-26 01:11:49 -0500128 intentAddLatList = []
129
130 # Distribute switches according to cluster count
131 for i in range( 1, 9 ):
132 if clusterCount == 1:
133 main.Mininet1.assignSwController(
134 sw=str( i ), ip1=ONOSIpList[ 0 ],
135 port1=defaultSwPort
136 )
137 elif clusterCount == 3:
andrewonlaba57a3042015-01-23 13:53:05 -0500138 if i < 3:
139 index = 0
140 elif i < 6 and i >= 3:
141 index = 1
142 else:
143 index = 2
andrewonlab79244cc2015-01-26 01:11:49 -0500144 main.Mininet1.assignSwController(
145 sw=str( i ), ip1=ONOSIpList[ index ],
146 port1=defaultSwPort
147 )
148 elif clusterCount == 5:
andrewonlaba57a3042015-01-23 13:53:05 -0500149 if i < 3:
150 index = 0
151 elif i < 5 and i >= 3:
152 index = 1
153 elif i < 7 and i >= 5:
154 index = 2
155 elif i == 7:
156 index = 3
157 else:
158 index = 4
andrewonlab79244cc2015-01-26 01:11:49 -0500159 main.Mininet1.assignSwController(
160 sw=str( i ), ip1=ONOSIpList[ index ],
161 port1=defaultSwPort
162 )
163 elif clusterCount == 7:
andrewonlaba57a3042015-01-23 13:53:05 -0500164 if i < 6:
165 index = i
166 else:
167 index = 6
andrewonlab79244cc2015-01-26 01:11:49 -0500168 main.Mininet1.assignSwController(
169 sw=str( i ), ip1=ONOSIpList[ index ],
170 port1=defaultSwPort
171 )
andrewonlab70decc02014-11-19 18:50:23 -0500172
andrewonlab79244cc2015-01-26 01:11:49 -0500173 time.sleep( 10 )
andrewonlab70decc02014-11-19 18:50:23 -0500174
andrewonlab79244cc2015-01-26 01:11:49 -0500175 main.log.report( "Single intent add latency test" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500176
andrewonlab79244cc2015-01-26 01:11:49 -0500177 devicesJsonStr = main.ONOS1cli.devices()
178 devicesJsonObj = json.loads( devicesJsonStr )
179
180 if not devicesJsonObj:
181 main.log.report( "Devices not discovered" )
182 main.log.report( "Aborting test" )
andrewonlaba57a3042015-01-23 13:53:05 -0500183 main.exit()
184 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500185 main.log.info( "Devices discovered successfully" )
andrewonlaba57a3042015-01-23 13:53:05 -0500186
andrewonlab79244cc2015-01-26 01:11:49 -0500187 deviceIdList = []
andrewonlab92ea3672014-11-04 20:22:14 -0500188
andrewonlab79244cc2015-01-26 01:11:49 -0500189 # Obtain device id list in ONOS format.
190 # They should already be in order ( 1,2,3,10,11,12,13, etc )
191 for device in devicesJsonObj:
192 deviceIdList.append( device[ 'id' ] )
andrewonlab92ea3672014-11-04 20:22:14 -0500193
andrewonlab79244cc2015-01-26 01:11:49 -0500194 for i in range( 0, int( numIter ) ):
195 # addPointIntent( ingrDevice, egrDevice,
196 # ingrPort, egrPort )
197 main.ONOS1cli.addPointIntent(
198 deviceIdList[ 0 ] + "/2", deviceIdList[ 7 ] + "/2" )
199
200 # Allow some time for intents to propagate
201 time.sleep( 5 )
202
203 intentsStr = main.ONOS1cli.intents( jsonFormat=True )
204 intentsObj = json.loads( intentsStr )
205 for intent in intentsObj:
206 if intent[ 'state' ] == "INSTALLED":
207 main.log.info( "Intent installed successfully" )
208 intentId = intent[ 'id' ]
209 main.log.info( "Intent id: " + str( intentId ) )
andrewonlaba57a3042015-01-23 13:53:05 -0500210 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500211 # TODO: Add error handling
212 main.log.info( "Intent installation failed" )
213 intentId = ""
andrewonlab92ea3672014-11-04 20:22:14 -0500214
andrewonlab79244cc2015-01-26 01:11:49 -0500215 # Obtain metrics from ONOS 1, 2, 3
216 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
217 intentsJsonObj1 = json.loads( intentsJsonStr1 )
218 # Parse values from the json object
219 intentSubmit1 = \
220 intentsJsonObj1[ submitTime ][ 'value' ]
221 intentInstall1 = \
222 intentsJsonObj1[ installTime ][ 'value' ]
223 intentInstallLat1 = \
224 int( intentInstall1 ) - int( intentSubmit1 )
225
226 if clusterCount == 3:
227 intentsJsonStr2 = main.ONOS2cli.intentsEventsMetrics()
228 intentsJsonStr3 = main.ONOS3cli.intentsEventsMetrics()
229 intentsJsonObj2 = json.loads( intentsJsonStr2 )
230 intentsJsonObj3 = json.loads( intentsJsonStr3 )
231 intentSubmit2 = \
232 intentsJsonObj2[ submitTime ][ 'value' ]
233 intentSubmit3 = \
234 intentsJsonObj3[ submitTime ][ 'value' ]
235 intentInstall2 = \
236 intentsJsonObj2[ installTime ][ 'value' ]
237 intentInstall3 = \
238 intentsJsonObj3[ installTime ][ 'value' ]
239 intentInstallLat2 = \
240 int( intentInstall2 ) - int( intentSubmit2 )
241 intentInstallLat3 = \
242 int( intentInstall3 ) - int( intentSubmit3 )
andrewonlaba57a3042015-01-23 13:53:05 -0500243 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500244 intentInstallLat2 = 0
245 intentInstallLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500246
andrewonlab79244cc2015-01-26 01:11:49 -0500247 if clusterCount == 5:
248 intentsJsonStr4 = main.ONOS4cli.intentsEventsMetrics()
249 intentsJsonStr5 = main.ONOS5cli.intentsEventsMetrics()
250 intentsJsonObj4 = json.loads( intentsJsonStr4 )
251 intentsJsonObj5 = json.loads( intentsJsonStr5 )
252 intentSubmit4 = \
253 intentsJsonObj4[ submitTime ][ 'value' ]
254 intentSubmit5 = \
255 intentsJsonObj5[ submitTime ][ 'value' ]
256 intentInstall4 = \
257 intentsJsonObj5[ installTime ][ 'value' ]
258 intentInstall5 = \
259 intentsJsonObj5[ installTime ][ 'value' ]
260 intentInstallLat4 = \
261 int( intentInstall4 ) - int( intentSubmit4 )
262 intentInstallLat5 = \
263 int( intentInstall5 ) - int( intentSubmit5 )
andrewonlaba57a3042015-01-23 13:53:05 -0500264 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500265 intentInstallLat4 = 0
266 intentInstallLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500267
andrewonlab79244cc2015-01-26 01:11:49 -0500268 if clusterCount == 7:
269 intentsJsonStr6 = main.ONOS6cli.intentsEventsMetrics()
270 intentsJsonStr7 = main.ONOS7cli.intentsEventsMetrics()
271 intentsJsonObj6 = json.loads( intentsJsonStr6 )
272 intentsJsonObj7 = json.loads( intentsJsonStr7 )
273 intentSubmit6 = \
274 intentsJsonObj6[ submitTime ][ 'value' ]
275 intentSubmit7 = \
276 intentsJsonObj6[ submitTime ][ 'value' ]
277 intentInstall6 = \
278 intentsJsonObj6[ installTime ][ 'value' ]
279 intentInstall7 = \
280 intentsJsonObj7[ installTime ][ 'value' ]
281 intentInstallLat6 = \
282 int( intentInstall6 ) - int( intentSubmit6 )
283 intentInstallLat7 = \
284 int( intentInstall7 ) - int( intentSubmit7 )
andrewonlaba57a3042015-01-23 13:53:05 -0500285 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500286 intentInstallLat6 = 0
287 intentInstallLat7 = 0
andrewonlab8790abb2014-11-06 13:51:54 -0500288
andrewonlab79244cc2015-01-26 01:11:49 -0500289 intentInstallLatAvg = \
290 ( intentInstallLat1 +
291 intentInstallLat2 +
292 intentInstallLat3 +
293 intentInstallLat4 +
294 intentInstallLat5 +
295 intentInstallLat6 +
296 intentInstallLat7 ) / clusterCount
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800297
andrewonlab79244cc2015-01-26 01:11:49 -0500298 main.log.info( "Intent add latency avg for iteration " + str( i ) +
299 ": " + str( intentInstallLatAvg ) + " ms" )
andrewonlab8790abb2014-11-06 13:51:54 -0500300
andrewonlab79244cc2015-01-26 01:11:49 -0500301 if intentInstallLatAvg > 0.0 and \
302 intentInstallLatAvg < 1000 and i > numIgnore:
303 intentAddLatList.append( intentInstallLatAvg )
andrewonlab8790abb2014-11-06 13:51:54 -0500304 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500305 main.log.info( "Intent add latency exceeded " +
306 "threshold. Skipping iteration " + str( i ) )
andrewonlab8790abb2014-11-06 13:51:54 -0500307
andrewonlab79244cc2015-01-26 01:11:49 -0500308 time.sleep( 3 )
309
310 # TODO: Only remove intents that were installed
andrewonlaba57a3042015-01-23 13:53:05 -0500311 # in this case... Otherwise many other intents
312 # may show up distorting the results
andrewonlab79244cc2015-01-26 01:11:49 -0500313 main.log.info( "Removing intents for next iteration" )
314 jsonTemp = \
315 main.ONOS1cli.intents( jsonFormat=True )
316 jsonObjIntents = json.loads( jsonTemp )
317 if jsonObjIntents:
318 for intents in jsonObjIntents:
319 tempId = intents[ 'id' ]
320 # main.ONOS1cli.removeIntent( tempId )
321 main.log.info( "Removing intent id: " +
322 str( tempId ) )
323 main.ONOS1cli.removeIntent( tempId )
andrewonlab8790abb2014-11-06 13:51:54 -0500324 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500325 main.log.info( "Intents were not installed correctly" )
andrewonlab8790abb2014-11-06 13:51:54 -0500326
andrewonlab79244cc2015-01-26 01:11:49 -0500327 time.sleep( 5 )
andrewonlab8790abb2014-11-06 13:51:54 -0500328
andrewonlab79244cc2015-01-26 01:11:49 -0500329 if intentAddLatList:
330 intentAddLatAvg = sum( intentAddLatList ) /\
331 len( intentAddLatList )
andrewonlaba57a3042015-01-23 13:53:05 -0500332 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500333 main.log.report( "Intent installation latency test failed" )
334 intentAddLatAvg = "NA"
andrewonlaba57a3042015-01-23 13:53:05 -0500335 assertion = main.FALSE
336
andrewonlab79244cc2015-01-26 01:11:49 -0500337 intentAddLatStd = \
338 round( numpy.std( intentAddLatList ), 1 )
339 # END ITERATION FOR LOOP
340 main.log.report( "Single intent add latency - " )
341 main.log.report( "Avg: " + str( intentAddLatAvg ) + " ms" )
342 main.log.report( "Std Deviation: " + str( intentAddLatStd ) + " ms" )
343
344 utilities.assert_equals(
345 expect=main.TRUE,
346 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500347 onpass="Single intent install latency test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500348 onfail="Single intent install latency test failed" )
andrewonlab92ea3672014-11-04 20:22:14 -0500349
andrewonlab79244cc2015-01-26 01:11:49 -0500350 def CASE3( self, main ):
351 """
andrewonlab4cf9dd22014-11-18 21:28:38 -0500352 Intent Reroute latency
andrewonlab79244cc2015-01-26 01:11:49 -0500353 """
andrewonlab4cf9dd22014-11-18 21:28:38 -0500354 import time
355 import json
356 import requests
357 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500358 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500359 global clusterCount
andrewonlab4cf9dd22014-11-18 21:28:38 -0500360
andrewonlab79244cc2015-01-26 01:11:49 -0500361 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
362 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
363 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
364 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab4cf9dd22014-11-18 21:28:38 -0500365
andrewonlab79244cc2015-01-26 01:11:49 -0500366 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab4cf9dd22014-11-18 21:28:38 -0500367
andrewonlab79244cc2015-01-26 01:11:49 -0500368 # number of iterations of case
369 numIter = main.params[ 'TEST' ][ 'numIter' ]
370 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
andrewonlaba57a3042015-01-23 13:53:05 -0500371 assertion = main.TRUE
andrewonlab4cf9dd22014-11-18 21:28:38 -0500372
andrewonlab79244cc2015-01-26 01:11:49 -0500373 # Timestamp keys for json metrics output
374 submitTime = main.params[ 'JSON' ][ 'submittedTime' ]
375 installTime = main.params[ 'JSON' ][ 'installedTime' ]
376 wdRequestTime = main.params[ 'JSON' ][ 'wdRequestTime' ]
377 withdrawnTime = main.params[ 'JSON' ][ 'withdrawnTime' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500378
andrewonlab79244cc2015-01-26 01:11:49 -0500379 # NOTE: May need to configure interface depending on topology
380 intfs = main.params[ 'TEST' ][ 'intfs' ]
andrewonlab70decc02014-11-19 18:50:23 -0500381
andrewonlab79244cc2015-01-26 01:11:49 -0500382 devicesJsonStr = main.ONOS1cli.devices()
383 devicesJsonObj = json.loads( devicesJsonStr )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500384
andrewonlab79244cc2015-01-26 01:11:49 -0500385 deviceIdList = []
andrewonlab4cf9dd22014-11-18 21:28:38 -0500386
andrewonlab79244cc2015-01-26 01:11:49 -0500387 # Obtain device id list in ONOS format.
388 # They should already be in order ( 1,2,3,10,11,12,13, etc )
389 for device in devicesJsonObj:
390 deviceIdList.append( device[ 'id' ] )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500391
andrewonlab79244cc2015-01-26 01:11:49 -0500392 intentRerouteLatList = []
andrewonlab4cf9dd22014-11-18 21:28:38 -0500393
andrewonlab79244cc2015-01-26 01:11:49 -0500394 for i in range( 0, int( numIter ) ):
395 # addPointIntent( ingrDevice, ingrPort,
396 # egrDevice, egrPort )
397 if len( deviceIdList ) > 0:
398 main.ONOS1cli.addPointIntent(
399 deviceIdList[ 0 ] + "/2", deviceIdList[ 7 ] + "/2" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500400 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500401 main.log.info( "Failed to fetch devices from ONOS" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500402
andrewonlab79244cc2015-01-26 01:11:49 -0500403 time.sleep( 5 )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500404
andrewonlab79244cc2015-01-26 01:11:49 -0500405 intentsStr = main.ONOS1cli.intents( jsonFormat=True )
406 intentsObj = json.loads( intentsStr )
407 for intent in intentsObj:
408 if intent[ 'state' ] == "INSTALLED":
409 main.log.info( "Intent installed successfully" )
410 intentId = intent[ 'id' ]
411 main.log.info( "Intent id: " + str( intentId ) )
andrewonlab70decc02014-11-19 18:50:23 -0500412 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500413 # TODO: Add error handling
414 main.log.info( "Intent installation failed" )
415 intentId = ""
416
417 main.log.info( "Disabling interface " + intfs )
418 t0System = time.time() * 1000
andrewonlab4cf9dd22014-11-18 21:28:38 -0500419 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500420 "sh ifconfig " + intfs + " down" )
421 main.Mininet1.handle.expect( "mininet>" )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500422
andrewonlab79244cc2015-01-26 01:11:49 -0500423 # TODO: Check for correct intent reroute
424 time.sleep( 1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800425
andrewonlab79244cc2015-01-26 01:11:49 -0500426 # Obtain metrics from ONOS 1, 2, 3
427 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
428 intentsJsonObj1 = json.loads( intentsJsonStr1 )
429 # Parse values from the json object
430 intentInstall1 = \
431 intentsJsonObj1[ installTime ][ 'value' ]
432 intentRerouteLat1 = \
433 int( intentInstall1 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500434
andrewonlab79244cc2015-01-26 01:11:49 -0500435 if clusterCount == 3:
436 intentsJsonStr2 = main.ONOS2cli.intentsEventsMetrics()
437 intentsJsonStr3 = main.ONOS3cli.intentsEventsMetrics()
438
439 intentsJsonObj2 = json.loads( intentsJsonStr2 )
440 intentsJsonObj3 = json.loads( intentsJsonStr3 )
441 intentInstall2 = \
442 intentsJsonObj2[ installTime ][ 'value' ]
443 intentInstall3 = \
444 intentsJsonObj3[ installTime ][ 'value' ]
445 intentRerouteLat2 = \
446 int( intentInstall2 ) - int( t0System )
447 intentRerouteLat3 = \
448 int( intentInstall3 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500449 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500450 intentRerouteLat2 = 0
451 intentRerouteLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500452
andrewonlab79244cc2015-01-26 01:11:49 -0500453 if clusterCount == 5:
454 intentsJsonStr4 = main.ONOS4cli.intentsEventsMetrics()
455 intentsJsonStr5 = main.ONOS5cli.intentsEventsMetrics()
andrewonlaba57a3042015-01-23 13:53:05 -0500456
andrewonlab79244cc2015-01-26 01:11:49 -0500457 intentsJsonObj4 = json.loads( intentsJsonStr4 )
458 intentsJsonObj5 = json.loads( intentsJsonStr5 )
459 intentInstall4 = \
460 intentsJsonObj4[ installTime ][ 'value' ]
461 intentInstall5 = \
462 intentsJsonObj5[ installTime ][ 'value' ]
463 intentRerouteLat4 = \
464 int( intentInstall4 ) - int( t0System )
465 intentRerouteLat5 = \
466 int( intentInstall5 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500467 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500468 intentRerouteLat4 = 0
469 intentRerouteLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500470
andrewonlab79244cc2015-01-26 01:11:49 -0500471 if clusterCount == 7:
472 intentsJsonStr6 = main.ONOS6cli.intentsEventsMetrics()
473 intentsJsonStr7 = main.ONOS7cli.intentsEventsMetrics()
andrewonlaba57a3042015-01-23 13:53:05 -0500474
andrewonlab79244cc2015-01-26 01:11:49 -0500475 intentsJsonObj6 = json.loads( intentsJsonStr6 )
476 intentsJsonObj7 = json.loads( intentsJsonStr7 )
477 intentInstall6 = \
478 intentsJsonObj6[ installTime ][ 'value' ]
479 intentInstall7 = \
480 intentsJsonObj7[ installTime ][ 'value' ]
481 intentRerouteLat6 = \
482 int( intentInstall6 ) - int( t0System )
483 intentRerouteLat7 = \
484 int( intentInstall7 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500485 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500486 intentRerouteLat6 = 0
487 intentRerouteLat7 = 0
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800488
andrewonlab79244cc2015-01-26 01:11:49 -0500489 intentRerouteLatAvg = \
490 ( intentRerouteLat1 +
491 intentRerouteLat2 +
492 intentRerouteLat3 +
493 intentRerouteLat4 +
494 intentRerouteLat5 +
495 intentRerouteLat6 +
496 intentRerouteLat7 ) / clusterCount
andrewonlab4cf9dd22014-11-18 21:28:38 -0500497
andrewonlab79244cc2015-01-26 01:11:49 -0500498 main.log.info( "Intent reroute latency avg for iteration " +
499 str( i ) + ": " + str( intentRerouteLatAvg ) )
500
501 if intentRerouteLatAvg > 0.0 and \
502 intentRerouteLatAvg < 1000 and i > numIgnore:
503 intentRerouteLatList.append( intentRerouteLatAvg )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500504 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500505 main.log.info( "Intent reroute latency exceeded " +
506 "threshold. Skipping iteration " + str( i ) )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500507
andrewonlab79244cc2015-01-26 01:11:49 -0500508 main.log.info( "Removing intents for next iteration" )
509 main.ONOS1cli.removeIntent( intentId )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800510
andrewonlab79244cc2015-01-26 01:11:49 -0500511 main.log.info( "Bringing Mininet interface up for next " +
512 "iteration" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500513 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500514 "sh ifconfig " + intfs + " up" )
515 main.Mininet1.handle.expect( "mininet>" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800516
andrewonlab79244cc2015-01-26 01:11:49 -0500517 if intentRerouteLatList:
518 intentRerouteLatAvg = sum( intentRerouteLatList ) /\
519 len( intentRerouteLatList )
andrewonlaba57a3042015-01-23 13:53:05 -0500520 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500521 main.log.report( "Intent reroute test failed. Results NA" )
522 intentRerouteLatAvg = "NA"
523 # NOTE: fails test when list is empty
andrewonlaba57a3042015-01-23 13:53:05 -0500524 assertion = main.FALSE
andrewonlab79244cc2015-01-26 01:11:49 -0500525
526 intentRerouteLatStd = \
527 round( numpy.std( intentRerouteLatList ), 1 )
528 # END ITERATION FOR LOOP
529 main.log.report( "Single intent reroute latency - " )
530 main.log.report( "Avg: " + str( intentRerouteLatAvg ) + " ms" )
531 main.log.report(
532 "Std Deviation: " +
533 str( intentRerouteLatStd ) +
534 " ms" )
535
536 utilities.assert_equals(
537 expect=main.TRUE,
538 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500539 onpass="Single intent reroute latency test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500540 onfail="Single intent reroute latency test failed" )
541
542 def CASE4( self, main ):
543 """
andrewonlab042b3912014-12-10 16:40:50 -0500544 Batch intent install
andrewonlab082dfc32015-02-06 13:59:51 -0500545
546 Supports scale-out scenarios and increasing
547 number of intents within each iteration
andrewonlab79244cc2015-01-26 01:11:49 -0500548 """
andrewonlab70decc02014-11-19 18:50:23 -0500549 import time
550 import json
551 import requests
552 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500553 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500554 global clusterCount
andrewonlab70decc02014-11-19 18:50:23 -0500555
andrewonlab79244cc2015-01-26 01:11:49 -0500556 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
557 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
558 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
559 ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
560 ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
561 ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
562 ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500563
564 assertion = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800565
andrewonlab79244cc2015-01-26 01:11:49 -0500566 ONOSIpList = []
567 for i in range( 1, 8 ):
568 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlab4293dcb2014-12-02 15:48:05 -0500569
andrewonlab79244cc2015-01-26 01:11:49 -0500570 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab70decc02014-11-19 18:50:23 -0500571
andrewonlab79244cc2015-01-26 01:11:49 -0500572 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab70decc02014-11-19 18:50:23 -0500573
andrewonlab79244cc2015-01-26 01:11:49 -0500574 batchIntentSize = int( main.params[ 'TEST' ][ 'batchIntentSize' ] )
575 batchThreshMin = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
576 batchThreshMax = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
andrewonlab4293dcb2014-12-02 15:48:05 -0500577
andrewonlab79244cc2015-01-26 01:11:49 -0500578 # number of iterations of case
579 numIter = main.params[ 'TEST' ][ 'numIter' ]
580 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
581 numSwitch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
582 nThread = main.params[ 'TEST' ][ 'numMult' ]
583 #nThread = 105
584
585 # Switch assignment NOTE: hardcoded
586 if clusterCount == 1:
587 for i in range( 1, numSwitch + 1 ):
588 main.Mininet1.assignSwController(
589 sw=str( i ),
590 ip1=ONOS1Ip,
591 port1=defaultSwPort )
592 if clusterCount == 3:
593 for i in range( 1, 3 ):
594 main.Mininet1.assignSwController(
595 sw=str( i ),
596 ip1=ONOS1Ip,
597 port1=defaultSwPort )
598 for i in range( 3, 6 ):
599 main.Mininet1.assignSwController(
600 sw=str( i ),
601 ip1=ONOS2Ip,
602 port1=defaultSwPort )
603 for i in range( 6, 9 ):
604 main.Mininet1.assignSwController(
605 sw=str( i ),
606 ip1=ONOS3Ip,
607 port1=defaultSwPort )
608 if clusterCount == 5:
609 main.Mininet1.assignSwController(
610 sw="1",
611 ip1=ONOS1Ip,
612 port1=defaultSwPort )
613 main.Mininet1.assignSwController(
614 sw="2",
615 ip1=ONOS2Ip,
616 port1=defaultSwPort )
617 for i in range( 3, 6 ):
618 main.Mininet1.assignSwController(
619 sw=str( i ),
620 ip1=ONOS3Ip,
621 port1=defaultSwPort )
622 main.Mininet1.assignSwController(
623 sw="6",
624 ip1=ONOS4Ip,
625 port1=defaultSwPort )
626 main.Mininet1.assignSwController(
627 sw="7",
628 ip1=ONOS5Ip,
629 port1=defaultSwPort )
630 main.Mininet1.assignSwController(
631 sw="8",
632 ip1=ONOS5Ip,
633 port1=defaultSwPort )
634
635 if clusterCount == 7:
636 for i in range( 1, 9 ):
andrewonlabeb1d0542014-12-03 20:12:01 -0500637 if i < 8:
andrewonlab79244cc2015-01-26 01:11:49 -0500638 main.Mininet1.assignSwController(
639 sw=str( i ),
640 ip1=ONOSIpList[ i - 1 ],
641 port1=defaultSwPort )
642 elif i >= 8:
643 main.Mininet1.assignSwController(
644 sw=str( i ),
645 ip1=ONOSIpList[ 6 ],
646 port1=defaultSwPort )
andrewonlab70decc02014-11-19 18:50:23 -0500647
andrewonlab79244cc2015-01-26 01:11:49 -0500648 time.sleep( 20 )
andrewonlabeb1d0542014-12-03 20:12:01 -0500649
andrewonlab79244cc2015-01-26 01:11:49 -0500650 main.log.report( "Batch intent installation test of " +
651 str( batchIntentSize ) + " intent(s)" )
andrewonlab4293dcb2014-12-02 15:48:05 -0500652
andrewonlab79244cc2015-01-26 01:11:49 -0500653 batchResultList = []
andrewonlab70decc02014-11-19 18:50:23 -0500654
andrewonlab79244cc2015-01-26 01:11:49 -0500655 main.log.info( "Getting list of available devices" )
656 deviceIdList = []
657 jsonStr = main.ONOS1cli.devices()
658 jsonObj = json.loads( jsonStr )
659 for device in jsonObj:
660 deviceIdList.append( device[ 'id' ] )
andrewonlab70decc02014-11-19 18:50:23 -0500661
andrewonlab79244cc2015-01-26 01:11:49 -0500662 batchInstallLat = []
663 batchWithdrawLat = []
andrewonlab70decc02014-11-19 18:50:23 -0500664
andrewonlab79244cc2015-01-26 01:11:49 -0500665 # Max intent install measurement of all nodes
666 maxInstallLat = []
667 maxWithdrawLat = []
668 sleepTime = 10
669
670 baseDir = "/tmp/"
671
672 for batch in range( 0, 5 ):
673 for i in range( 0, int( numIter ) ):
674 main.log.info( "Pushing " +
675 str( int( batchIntentSize ) * int( nThread ) ) +
676 " intents. Iteration " + str( i ) )
677
678 for node in range( 1, clusterCount + 1 ):
679 saveDir = baseDir + "batch_intent_" + str( node ) + ".txt"
680 main.ONOSbench.pushTestIntentsShell(
681 deviceIdList[ 0 ] + "/2",
682 deviceIdList[ 7 ] + "/2",
683 batchIntentSize,
684 saveDir, ONOSIpList[ node - 1 ],
685 numMult=nThread, appId=node )
686
687 # Wait sufficient time for intents to start
688 # installing
689 time.sleep( sleepTime )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800690
andrewonlaba57a3042015-01-23 13:53:05 -0500691 intent = ""
692 counter = 300
andrewonlab79244cc2015-01-26 01:11:49 -0500693 while len( intent ) > 0 and counter > 0:
andrewonlaba57a3042015-01-23 13:53:05 -0500694 main.ONOS1cli.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500695 "intents | wc -l" )
andrewonlaba57a3042015-01-23 13:53:05 -0500696 main.ONOS1cli.handle.expect(
andrewonlab79244cc2015-01-26 01:11:49 -0500697 "intents | wc -l" )
andrewonlaba57a3042015-01-23 13:53:05 -0500698 main.ONOS1cli.handle.expect(
andrewonlab79244cc2015-01-26 01:11:49 -0500699 "onos>" )
700 intentTemp = main.ONOS1cli.handle.before()
andrewonlaba57a3042015-01-23 13:53:05 -0500701 intent = main.ONOS1cli.intents()
andrewonlab79244cc2015-01-26 01:11:49 -0500702 intent = json.loads( intent )
703 counter = counter - 1
704 time.sleep( 1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800705
andrewonlab79244cc2015-01-26 01:11:49 -0500706 time.sleep( 5 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800707
andrewonlab79244cc2015-01-26 01:11:49 -0500708 for node in range( 1, clusterCount + 1 ):
709 saveDir = baseDir + "batch_intent_" + str( node ) + ".txt"
710 with open( saveDir ) as fOnos:
711 lineCount = 0
712 for line in fOnos:
713 line = line[ 1: ]
714 line = line.split( ": " )
715 main.log.info( "Line read: " + str( line ) )
andrewonlabd019a6b2015-02-05 00:05:22 -0500716 #Prevent split method if line doesn't have
717 #space
718 if " " in str(line):
719 result = line[ 1 ].split( " " )[ 0 ]
720 else:
721 main.log.warn( "Empty line read" )
722 result = 0
andrewonlab79244cc2015-01-26 01:11:49 -0500723 # TODO: add parameters before appending latency
724 if lineCount == 0:
725 batchInstallLat.append( int( result ) )
726 installResult = result
727 elif lineCount == 1:
728 batchWithdrawLat.append( int( result ) )
729 withdrawResult = result
andrewonlabd019a6b2015-02-05 00:05:22 -0500730 else:
731 main.log.warn("Invalid results")
732 installResult = 'NA'
733 withdrawResult = 'NA'
andrewonlab79244cc2015-01-26 01:11:49 -0500734 lineCount += 1
735 main.log.info( "Batch install latency for ONOS" +
736 str( node ) + " with " +
737 str( batchIntentSize ) + "intents: " +
738 str( installResult ) + " ms" )
739 main.log.info( "Batch withdraw latency for ONOS" +
740 str( node ) + " with " +
741 str( batchIntentSize ) + "intents: " +
742 str( withdrawResult ) + " ms" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500743
andrewonlab79244cc2015-01-26 01:11:49 -0500744 if len( batchInstallLat ) > 0 and int( i ) > numIgnore:
745 maxInstallLat.append( max( batchInstallLat ) )
746 elif len( batchInstallLat ) == 0:
747 # If I failed to read anything from the file,
748 # increase the wait time before checking intents
749 sleepTime += 30
750 if len( batchWithdrawLat ) > 0 and int( i ) > numIgnore:
751 maxWithdrawLat.append( max( batchWithdrawLat ) )
752 batchInstallLat = []
753 batchWithdrawLat = []
754
755 # Sleep in between iterations
756 time.sleep( 5 )
757
758 if maxInstallLat:
andrewonlabd019a6b2015-02-05 00:05:22 -0500759 avgInstallLat = str( round(
760 sum( maxInstallLat ) /
761 len( maxInstallLat )
762 , 2 ))
andrewonlaba57a3042015-01-23 13:53:05 -0500763 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500764 avgInstallLat = "NA"
765 main.log.report( "Batch installation failed" )
andrewonlaba57a3042015-01-23 13:53:05 -0500766 assertion = main.FALSE
andrewonlabeb1d0542014-12-03 20:12:01 -0500767
andrewonlab79244cc2015-01-26 01:11:49 -0500768 if maxWithdrawLat:
andrewonlabd019a6b2015-02-05 00:05:22 -0500769 avgWithdrawLat = str( round(
770 sum( maxWithdrawLat ) /
771 len( maxWithdrawLat )
772 , 2 ))
andrewonlaba57a3042015-01-23 13:53:05 -0500773 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500774 avgWithdrawLat = "NA"
775 main.log.report( "Batch withdraw failed" )
andrewonlaba57a3042015-01-23 13:53:05 -0500776 assertion = main.FALSE
andrewonlabeb1d0542014-12-03 20:12:01 -0500777
andrewonlab79244cc2015-01-26 01:11:49 -0500778 main.log.report( "Avg of batch installation latency " +
779 "of size " + str( batchIntentSize ) + ": " +
780 str( avgInstallLat ) + " ms" )
781 main.log.report( "Std Deviation of batch installation latency " +
andrewonlabd019a6b2015-02-05 00:05:22 -0500782 ": " +
783 str( round(numpy.std( maxInstallLat ),2)) +
784 " ms" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500785
andrewonlab79244cc2015-01-26 01:11:49 -0500786 main.log.report( "Avg of batch withdraw latency " +
787 "of size " + str( batchIntentSize ) + ": " +
788 str( avgWithdrawLat ) + " ms" )
789 main.log.report( "Std Deviation of batch withdraw latency " +
790 ": " +
andrewonlabd019a6b2015-02-05 00:05:22 -0500791 str( round(numpy.std( maxWithdrawLat ),2)) +
andrewonlab79244cc2015-01-26 01:11:49 -0500792 " ms" )
793
andrewonlabd019a6b2015-02-05 00:05:22 -0500794 if batch == 0:
795 batchIntentSize = 10
796 elif batch == 1:
797 batchIntentSize = 100
798 elif batch == 2:
799 batchIntentSize = 1000
800 elif batch == 3:
801 batchIntentSize = 2000
802 if batch < 4:
803 main.log.report( "Increasing batch intent size to " +
andrewonlab79244cc2015-01-26 01:11:49 -0500804 str(batchIntentSize) )
805
806 #main.log.info( "Removing all intents for next test case" )
807 #jsonTemp = main.ONOS1cli.intents( jsonFormat=True )
808 #jsonObjIntents = json.loads( jsonTemp )
809 # if jsonObjIntents:
810 # for intents in jsonObjIntents:
811 # tempId = intents[ 'id' ]
812 # main.ONOS1cli.removeIntent( tempId )
813 # main.ONOS1cli.removeIntent( tempId )
814
815 utilities.assert_equals(
816 expect=main.TRUE,
817 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500818 onpass="Batch intent install/withdraw test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500819 onfail="Batch intent install/withdraw test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800820
andrewonlab79244cc2015-01-26 01:11:49 -0500821 def CASE5( self, main ):
822 """
andrewonlab4293dcb2014-12-02 15:48:05 -0500823 Increase number of nodes and initiate CLI
andrewonlab79244cc2015-01-26 01:11:49 -0500824 """
andrewonlab4293dcb2014-12-02 15:48:05 -0500825 import time
826 import json
827
andrewonlab79244cc2015-01-26 01:11:49 -0500828 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
829 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
830 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
831 ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
832 ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
833 ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
834 ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
andrewonlab4293dcb2014-12-02 15:48:05 -0500835
andrewonlab79244cc2015-01-26 01:11:49 -0500836 global clusterCount
837 clusterCount += 2
838 main.log.report( "Increasing cluster size to " +
839 str( clusterCount ) )
andrewonlab4293dcb2014-12-02 15:48:05 -0500840
andrewonlab79244cc2015-01-26 01:11:49 -0500841 installResult = main.FALSE
andrewonlab4293dcb2014-12-02 15:48:05 -0500842
andrewonlab79244cc2015-01-26 01:11:49 -0500843 if clusterCount == 3:
844 installResult1 = \
845 main.ONOSbench.onosInstall( node=ONOS2Ip )
846 installResult2 = \
847 main.ONOSbench.onosInstall( node=ONOS3Ip )
848 time.sleep( 5 )
andrewonlab4293dcb2014-12-02 15:48:05 -0500849
andrewonlab79244cc2015-01-26 01:11:49 -0500850 main.log.info( "Starting ONOS CLI" )
851 main.ONOS2cli.startOnosCli( ONOS2Ip )
852 main.ONOS3cli.startOnosCli( ONOS3Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500853
andrewonlab79244cc2015-01-26 01:11:49 -0500854 installResult = installResult1 and installResult2
andrewonlab4293dcb2014-12-02 15:48:05 -0500855
andrewonlab79244cc2015-01-26 01:11:49 -0500856 if clusterCount == 5:
857 main.log.info( "Installing ONOS on node 4 and 5" )
858 installResult1 = \
859 main.ONOSbench.onosInstall( node=ONOS4Ip )
860 installResult2 = \
861 main.ONOSbench.onosInstall( node=ONOS5Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500862
andrewonlab79244cc2015-01-26 01:11:49 -0500863 main.log.info( "Starting ONOS CLI" )
864 main.ONOS4cli.startOnosCli( ONOS4Ip )
865 main.ONOS5cli.startOnosCli( ONOS5Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500866
andrewonlab79244cc2015-01-26 01:11:49 -0500867 installResult = installResult1 and installResult2
andrewonlab4293dcb2014-12-02 15:48:05 -0500868
andrewonlab79244cc2015-01-26 01:11:49 -0500869 if clusterCount == 7:
870 main.log.info( "Installing ONOS on node 6 and 7" )
871 installResult1 = \
872 main.ONOSbench.onosInstall( node=ONOS6Ip )
873 installResult2 = \
874 main.ONOSbench.onosInstall( node=ONOS7Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500875
andrewonlab79244cc2015-01-26 01:11:49 -0500876 main.log.info( "Starting ONOS CLI" )
877 main.ONOS6cli.startOnosCli( ONOS6Ip )
878 main.ONOS7cli.startOnosCli( ONOS7Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500879
andrewonlab79244cc2015-01-26 01:11:49 -0500880 installResult = installResult1 and installResult2
andrewonlab4293dcb2014-12-02 15:48:05 -0500881
andrewonlab79244cc2015-01-26 01:11:49 -0500882 time.sleep( 5 )
andrewonlab4293dcb2014-12-02 15:48:05 -0500883
andrewonlab79244cc2015-01-26 01:11:49 -0500884 if installResult == main.TRUE:
andrewonlab4293dcb2014-12-02 15:48:05 -0500885 assertion = main.TRUE
886 else:
887 assertion = main.FALSE
888
andrewonlab79244cc2015-01-26 01:11:49 -0500889 utilities.assert_equals( expect=main.TRUE, actual=assertion,
890 onpass="Scale out to " + str( clusterCount ) +
891 " nodes successful",
892 onfail="Scale out to " + str( clusterCount ) +
893 " nodes failed" )
andrewonlab4293dcb2014-12-02 15:48:05 -0500894
andrewonlab79244cc2015-01-26 01:11:49 -0500895 def CASE7( self, main ):
896 # TODO: Fix for scale-out scenario
897 """
andrewonlaba57a3042015-01-23 13:53:05 -0500898 Batch intent reroute latency
andrewonlab79244cc2015-01-26 01:11:49 -0500899 """
andrewonlaba57a3042015-01-23 13:53:05 -0500900 import time
901 import json
902 import requests
903 import os
904 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500905 global clusterCount
andrewonlaba57a3042015-01-23 13:53:05 -0500906
andrewonlab79244cc2015-01-26 01:11:49 -0500907 ONOSIpList = []
908 for i in range( 1, 8 ):
909 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlaba57a3042015-01-23 13:53:05 -0500910
andrewonlab79244cc2015-01-26 01:11:49 -0500911 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
912 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500913
andrewonlab79244cc2015-01-26 01:11:49 -0500914 batchIntentSize = main.params[ 'TEST' ][ 'batchIntentSize' ]
915 batchThreshMin = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
916 batchThreshMax = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
917 intfs = main.params[ 'TEST' ][ 'intfs' ]
918 installTime = main.params[ 'JSON' ][ 'installedTime' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500919
andrewonlab79244cc2015-01-26 01:11:49 -0500920 # number of iterations of case
921 numIter = main.params[ 'TEST' ][ 'numIter' ]
922 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
923 numSwitch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
924 nThread = main.params[ 'TEST' ][ 'numMult' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500925
andrewonlab79244cc2015-01-26 01:11:49 -0500926 main.log.report( "Batch intent installation test of " +
927 batchIntentSize + " intents" )
andrewonlaba57a3042015-01-23 13:53:05 -0500928
andrewonlab79244cc2015-01-26 01:11:49 -0500929 batchResultList = []
andrewonlaba57a3042015-01-23 13:53:05 -0500930
andrewonlab79244cc2015-01-26 01:11:49 -0500931 time.sleep( 10 )
andrewonlaba57a3042015-01-23 13:53:05 -0500932
andrewonlab79244cc2015-01-26 01:11:49 -0500933 main.log.info( "Getting list of available devices" )
934 deviceIdList = []
935 jsonStr = main.ONOS1cli.devices()
936 jsonObj = json.loads( jsonStr )
937 for device in jsonObj:
938 deviceIdList.append( device[ 'id' ] )
andrewonlaba57a3042015-01-23 13:53:05 -0500939
andrewonlab79244cc2015-01-26 01:11:49 -0500940 batchInstallLat = []
941 batchWithdrawLat = []
942 sleepTime = 10
andrewonlaba57a3042015-01-23 13:53:05 -0500943
andrewonlab79244cc2015-01-26 01:11:49 -0500944 baseDir = "/tmp/"
945 maxInstallLat = []
946
947 for i in range( 0, int( numIter ) ):
948 main.log.info( "Pushing " +
949 str( int( batchIntentSize ) * int( nThread ) ) +
950 " intents. Iteration " + str( i ) )
951
952 main.ONOSbench.pushTestIntentsShell(
953 deviceIdList[ 0 ] + "/2",
954 deviceIdList[ 7 ] + "/2",
955 batchIntentSize, "/tmp/batch_install.txt",
956 ONOSIpList[ 0 ], numMult="1", appId="1",
957 report=False, options="--install" )
958 # main.ONOSbench.pushTestIntentsShell(
andrewonlaba57a3042015-01-23 13:53:05 -0500959 # "of:0000000000001002/1",
960 # "of:0000000000002002/1",
961 # 133, "/tmp/temp2.txt", "10.128.174.2",
andrewonlab79244cc2015-01-26 01:11:49 -0500962 # numMult="6", appId="2",report=False )
963
964 # TODO: Check for installation success then proceed
965 time.sleep( 30 )
966
967 # NOTE: this interface is specific to
andrewonlaba57a3042015-01-23 13:53:05 -0500968 # topo-intentFlower.py topology
969 # reroute case.
andrewonlab79244cc2015-01-26 01:11:49 -0500970 main.log.info( "Disabling interface " + intfs )
andrewonlaba57a3042015-01-23 13:53:05 -0500971 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500972 "sh ifconfig " + intfs + " down" )
973 t0System = time.time() * 1000
andrewonlaba57a3042015-01-23 13:53:05 -0500974
andrewonlab79244cc2015-01-26 01:11:49 -0500975 # TODO: Wait sufficient time for intents to install
976 time.sleep( 10 )
andrewonlaba57a3042015-01-23 13:53:05 -0500977
andrewonlab79244cc2015-01-26 01:11:49 -0500978 # TODO: get intent installation time
979
980 # Obtain metrics from ONOS 1, 2, 3
981 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
982 intentsJsonObj1 = json.loads( intentsJsonStr1 )
983 # Parse values from the json object
984 intentInstall1 = \
985 intentsJsonObj1[ installTime ][ 'value' ]
986 intentRerouteLat1 = \
987 int( intentInstall1 ) - int( t0System )
988
989 if clusterCount == 3:
990 intentsJsonStr2 =\
991 main.ONOS2cli.intentsEventsMetrics()
992 intentsJsonStr3 =\
993 main.ONOS3cli.intentsEventsMetrics()
994 intentsJsonObj2 = json.loads( intentsJsonStr2 )
995 intentsJsonObj3 = json.loads( intentsJsonStr3 )
996 intentInstall2 = \
997 intentsJsonObj2[ installTime ][ 'value' ]
998 intentInstall3 = \
999 intentsJsonObj3[ installTime ][ 'value' ]
1000 intentRerouteLat2 = \
1001 int( intentInstall2 ) - int( t0System )
1002 intentRerouteLat3 = \
1003 int( intentInstall3 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -05001004 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001005 intentRerouteLat2 = 0
1006 intentRerouteLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001007
andrewonlab79244cc2015-01-26 01:11:49 -05001008 if clusterCount == 5:
1009 intentsJsonStr4 =\
1010 main.ONOS4cli.intentsEventsMetrics()
1011 intentsJsonStr5 =\
1012 main.ONOS5cli.intentsEventsMetrics()
1013 intentsJsonObj4 = json.loads( intentsJsonStr4 )
1014 intentsJsonObj5 = json.loads( intentsJsonStr5 )
1015 intentInstall4 = \
1016 intentsJsonObj4[ installTime ][ 'value' ]
1017 intentInstall5 = \
1018 intentsJsonObj5[ installTime ][ 'value' ]
1019 intentRerouteLat4 = \
1020 int( intentInstall4 ) - int( t0System )
1021 intentRerouteLat5 = \
1022 int( intentInstall5 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -05001023 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001024 intentRerouteLat4 = 0
1025 intentRerouteLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001026
andrewonlab79244cc2015-01-26 01:11:49 -05001027 if clusterCount == 7:
1028 intentsJsonStr6 =\
1029 main.ONOS6cli.intentsEventsMetrics()
1030 intentsJsonStr7 =\
1031 main.ONOS7cli.intentsEventsMetrics()
1032 intentsJsonObj6 = json.loads( intentsJsonStr6 )
1033 intentsJsonObj7 = json.loads( intentsJsonStr7 )
1034 intentInstall6 = \
1035 intentsJsonObj6[ installTime ][ 'value' ]
1036 intentInstall7 = \
1037 intentsJsonObj7[ installTime ][ 'value' ]
1038 intentRerouteLat6 = \
1039 int( intentInstall6 ) - int( t0System )
1040 intentRerouteLat7 = \
1041 int( intentInstall7 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -05001042 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001043 intentRerouteLat6 = 0
1044 intentRerouteLat7 = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001045
andrewonlab79244cc2015-01-26 01:11:49 -05001046 intentRerouteLatAvg = \
1047 ( intentRerouteLat1 +
1048 intentRerouteLat2 +
1049 intentRerouteLat3 +
1050 intentRerouteLat4 +
1051 intentRerouteLat5 +
1052 intentRerouteLat6 +
1053 intentRerouteLat7 ) / clusterCount
andrewonlaba57a3042015-01-23 13:53:05 -05001054
andrewonlab79244cc2015-01-26 01:11:49 -05001055 main.log.info( "Intent reroute latency avg for iteration " +
1056 str( i ) + ": " + str( intentRerouteLatAvg ) )
1057 # TODO: Remove intents for next iteration
1058
1059 time.sleep( 5 )
1060
1061 intentsStr = main.ONOS1cli.intents()
1062 intentsJson = json.loads( intentsStr )
1063 for intents in intentsJson:
1064 intentId = intents[ 'id' ]
1065 # TODO: make sure this removes all intents
1066 # print intentId
1067 if intentId:
1068 main.ONOS1cli.removeIntent( intentId )
andrewonlaba57a3042015-01-23 13:53:05 -05001069
1070 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001071 "sh ifconfig " + intfs + " up" )
andrewonlaba57a3042015-01-23 13:53:05 -05001072
andrewonlab79244cc2015-01-26 01:11:49 -05001073 main.log.info( "Intents removed and port back up" )
1074
1075 def CASE9( self, main ):
andrewonlabeb1d0542014-12-03 20:12:01 -05001076 count = 0
andrewonlab79244cc2015-01-26 01:11:49 -05001077 swNum1 = 1
1078 swNum2 = 1
andrewonlabeb1d0542014-12-03 20:12:01 -05001079 appid = 0
andrewonlab79244cc2015-01-26 01:11:49 -05001080 portNum1 = 1
1081 portNum2 = 1
1082
1083 time.sleep( 30 )
andrewonlab4cf9dd22014-11-18 21:28:38 -05001084
andrewonlabeb1d0542014-12-03 20:12:01 -05001085 while True:
andrewonlab79244cc2015-01-26 01:11:49 -05001086 # main.ONOS1cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001087 #"of:0000000000001001/1",
1088 #"of:0000000000002001/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001089 # 100, numMult="10", appId="1" )
1090 # main.ONOS2cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001091 # "of:0000000000001002/1",
1092 # "of:0000000000002002/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001093 # 100, numMult="10", appId="2" )
1094 # main.ONOS2cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001095 # "of:0000000000001003/1",
1096 # "of:0000000000002003/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001097 # 100, numMult="10", appId="3" )
andrewonlabeb1d0542014-12-03 20:12:01 -05001098 count += 1
andrewonlab79244cc2015-01-26 01:11:49 -05001099
andrewonlabeb1d0542014-12-03 20:12:01 -05001100 if count >= 100:
1101 main.ONOSbench.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001102 "onos 10.128.174.1 intents-events-metrics >>" +
1103 " /tmp/metrics_intents_temp.txt &" )
andrewonlabeb1d0542014-12-03 20:12:01 -05001104 count = 0
1105
andrewonlab79244cc2015-01-26 01:11:49 -05001106 arg1 = "of:000000000000100" + str( swNum1 ) + "/" + str( portNum1 )
1107 arg2 = "of:000000000000200" + str( swNum2 ) + "/" + str( portNum2 )
andrewonlabeb1d0542014-12-03 20:12:01 -05001108
andrewonlab79244cc2015-01-26 01:11:49 -05001109 swNum1 += 1
1110
1111 if swNum1 > 7:
1112 swNum1 = 1
1113 swNum2 += 1
1114 if swNum2 > 7:
andrewonlabeb1d0542014-12-03 20:12:01 -05001115 appid += 1
1116
andrewonlab79244cc2015-01-26 01:11:49 -05001117 if swNum2 > 7:
1118 swNum2 = 1
1119
1120 main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001121 arg1,
andrewonlab79244cc2015-01-26 01:11:49 -05001122 arg2,
andrewonlab042b3912014-12-10 16:40:50 -05001123 100, "/tmp/temp.txt", "10.128.174.1",
andrewonlab79244cc2015-01-26 01:11:49 -05001124 numMult="10", appId=appid, report=False )
1125 # main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001126 # "of:0000000000001002/1",
1127 # "of:0000000000002002/1",
1128 # 133, "/tmp/temp2.txt", "10.128.174.2",
andrewonlab79244cc2015-01-26 01:11:49 -05001129 # numMult="6", appId="2",report=False )
1130 # main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001131 # "of:0000000000001003/1",
1132 # "of:0000000000002003/1",
1133 # 133, "/tmp/temp3.txt", "10.128.174.3",
andrewonlab79244cc2015-01-26 01:11:49 -05001134 # numMult="6", appId="3",report=False )
andrewonlab92ea3672014-11-04 20:22:14 -05001135
andrewonlab79244cc2015-01-26 01:11:49 -05001136 time.sleep( 0.2 )