blob: 40a1276df2a623cb90ec387ef3840ea4a7b6d6d5 [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 )
40 main.ONOSbench.onosUninstall( nodeIp=ONOS7Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -050041
andrewonlab79244cc2015-01-26 01:11:49 -050042 MN1Ip = main.params[ 'MN' ][ 'ip1' ]
43 BENCHIp = main.params[ 'BENCH' ][ 'ip' ]
andrewonlab92ea3672014-11-04 20:22:14 -050044
andrewonlab79244cc2015-01-26 01:11:49 -050045 main.case( "Setting up test environment" )
andrewonlab92ea3672014-11-04 20:22:14 -050046
andrewonlab79244cc2015-01-26 01:11:49 -050047 main.step( "Creating cell file" )
48 cellFileResult = main.ONOSbench.createCellFile(
49 BENCHIp, cellName, MN1Ip,
50 "onos-core,onos-app-metrics,onos-gui",
51 ONOS1Ip )
andrewonlab92ea3672014-11-04 20:22:14 -050052
andrewonlab79244cc2015-01-26 01:11:49 -050053 main.step( "Applying cell file to environment" )
54 cellApplyResult = main.ONOSbench.setCell( cellName )
55 verifyCellResult = main.ONOSbench.verifyCell()
andrewonlab4293dcb2014-12-02 15:48:05 -050056
andrewonlab79244cc2015-01-26 01:11:49 -050057 main.step( "Removing raft logs" )
58 main.ONOSbench.onosRemoveRaftLogs()
59
60 main.step( "Git checkout and pull " + checkoutBranch )
61 if gitPull == 'on':
62 checkoutResult = \
63 main.ONOSbench.gitCheckout( checkoutBranch )
64 pullResult = main.ONOSbench.gitPull()
65
66 # If you used git pull, auto compile
67 main.step( "Using onos-build to compile ONOS" )
68 buildResult = main.ONOSbench.onosBuild()
andrewonlab92ea3672014-11-04 20:22:14 -050069 else:
andrewonlab79244cc2015-01-26 01:11:49 -050070 checkoutResult = main.TRUE
71 pullResult = main.TRUE
72 buildResult = main.TRUE
73 main.log.info( "Git pull skipped by configuration" )
andrewonlab92ea3672014-11-04 20:22:14 -050074
andrewonlab79244cc2015-01-26 01:11:49 -050075 main.log.report( "Commit information - " )
76 main.ONOSbench.getVersion( report=True )
andrewonlab4cf9dd22014-11-18 21:28:38 -050077
andrewonlab79244cc2015-01-26 01:11:49 -050078 main.step( "Creating ONOS package" )
79 packageResult = main.ONOSbench.onosPackage()
andrewonlab92ea3672014-11-04 20:22:14 -050080
andrewonlab79244cc2015-01-26 01:11:49 -050081 main.step( "Installing ONOS package" )
82 install1Result = main.ONOSbench.onosInstall( node=ONOS1Ip )
83 #install2Result = main.ONOSbench.onosInstall( node=ONOS2Ip )
84 #install3Result = main.ONOSbench.onosInstall( node=ONOS3Ip )
andrewonlab92ea3672014-11-04 20:22:14 -050085
andrewonlab79244cc2015-01-26 01:11:49 -050086 main.step( "Set cell for ONOScli env" )
87 main.ONOS1cli.setCell( cellName )
88 # main.ONOS2cli.setCell( cellName )
89 # main.ONOS3cli.setCell( cellName )
andrewonlab92ea3672014-11-04 20:22:14 -050090
andrewonlab79244cc2015-01-26 01:11:49 -050091 time.sleep( 5 )
andrewonlab92ea3672014-11-04 20:22:14 -050092
andrewonlab79244cc2015-01-26 01:11:49 -050093 main.step( "Start onos cli" )
94 cli1 = main.ONOS1cli.startOnosCli( ONOS1Ip )
95 #cli2 = main.ONOS2cli.startOnosCli( ONOS2Ip )
96 #cli3 = main.ONOS3cli.startOnosCli( ONOS3Ip )
andrewonlab92ea3672014-11-04 20:22:14 -050097
andrewonlab79244cc2015-01-26 01:11:49 -050098 utilities.assert_equals( expect=main.TRUE,
99 actual=cellFileResult and cellApplyResult and
100 verifyCellResult and checkoutResult and
101 pullResult and buildResult and
102 install1Result, # and install2Result and
103 # install3Result,
104 onpass="ONOS started successfully",
105 onfail="Failed to start ONOS" )
andrewonlab92ea3672014-11-04 20:22:14 -0500106
andrewonlab79244cc2015-01-26 01:11:49 -0500107 def CASE2( self, main ):
108 """
andrewonlab92ea3672014-11-04 20:22:14 -0500109 Single intent add latency
110
andrewonlab79244cc2015-01-26 01:11:49 -0500111 """
andrewonlab92ea3672014-11-04 20:22:14 -0500112 import time
113 import json
114 import requests
115 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500116 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500117 global clusterCount
andrewonlab92ea3672014-11-04 20:22:14 -0500118
andrewonlab79244cc2015-01-26 01:11:49 -0500119 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
120 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
121 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
122 ONOSIpList = []
123 for i in range( 1, 8 ):
124 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlab92ea3672014-11-04 20:22:14 -0500125
andrewonlab79244cc2015-01-26 01:11:49 -0500126 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab92ea3672014-11-04 20:22:14 -0500127
andrewonlab79244cc2015-01-26 01:11:49 -0500128 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab92ea3672014-11-04 20:22:14 -0500129
andrewonlab79244cc2015-01-26 01:11:49 -0500130 # number of iterations of case
131 numIter = main.params[ 'TEST' ][ 'numIter' ]
132 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
133
134 # Timestamp keys for json metrics output
135 submitTime = main.params[ 'JSON' ][ 'submittedTime' ]
136 installTime = main.params[ 'JSON' ][ 'installedTime' ]
137 wdRequestTime = main.params[ 'JSON' ][ 'wdRequestTime' ]
138 withdrawnTime = main.params[ 'JSON' ][ 'withdrawnTime' ]
139
andrewonlaba57a3042015-01-23 13:53:05 -0500140 assertion = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800141
andrewonlab79244cc2015-01-26 01:11:49 -0500142 intentAddLatList = []
143
144 # Distribute switches according to cluster count
145 for i in range( 1, 9 ):
146 if clusterCount == 1:
147 main.Mininet1.assignSwController(
148 sw=str( i ), ip1=ONOSIpList[ 0 ],
149 port1=defaultSwPort
150 )
151 elif clusterCount == 3:
andrewonlaba57a3042015-01-23 13:53:05 -0500152 if i < 3:
153 index = 0
154 elif i < 6 and i >= 3:
155 index = 1
156 else:
157 index = 2
andrewonlab79244cc2015-01-26 01:11:49 -0500158 main.Mininet1.assignSwController(
159 sw=str( i ), ip1=ONOSIpList[ index ],
160 port1=defaultSwPort
161 )
162 elif clusterCount == 5:
andrewonlaba57a3042015-01-23 13:53:05 -0500163 if i < 3:
164 index = 0
165 elif i < 5 and i >= 3:
166 index = 1
167 elif i < 7 and i >= 5:
168 index = 2
169 elif i == 7:
170 index = 3
171 else:
172 index = 4
andrewonlab79244cc2015-01-26 01:11:49 -0500173 main.Mininet1.assignSwController(
174 sw=str( i ), ip1=ONOSIpList[ index ],
175 port1=defaultSwPort
176 )
177 elif clusterCount == 7:
andrewonlaba57a3042015-01-23 13:53:05 -0500178 if i < 6:
179 index = i
180 else:
181 index = 6
andrewonlab79244cc2015-01-26 01:11:49 -0500182 main.Mininet1.assignSwController(
183 sw=str( i ), ip1=ONOSIpList[ index ],
184 port1=defaultSwPort
185 )
andrewonlab70decc02014-11-19 18:50:23 -0500186
andrewonlab79244cc2015-01-26 01:11:49 -0500187 time.sleep( 10 )
andrewonlab70decc02014-11-19 18:50:23 -0500188
andrewonlab79244cc2015-01-26 01:11:49 -0500189 main.log.report( "Single intent add latency test" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500190
andrewonlab79244cc2015-01-26 01:11:49 -0500191 devicesJsonStr = main.ONOS1cli.devices()
192 devicesJsonObj = json.loads( devicesJsonStr )
193
194 if not devicesJsonObj:
195 main.log.report( "Devices not discovered" )
196 main.log.report( "Aborting test" )
andrewonlaba57a3042015-01-23 13:53:05 -0500197 main.exit()
198 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500199 main.log.info( "Devices discovered successfully" )
andrewonlaba57a3042015-01-23 13:53:05 -0500200
andrewonlab79244cc2015-01-26 01:11:49 -0500201 deviceIdList = []
andrewonlab92ea3672014-11-04 20:22:14 -0500202
andrewonlab79244cc2015-01-26 01:11:49 -0500203 # Obtain device id list in ONOS format.
204 # They should already be in order ( 1,2,3,10,11,12,13, etc )
205 for device in devicesJsonObj:
206 deviceIdList.append( device[ 'id' ] )
andrewonlab92ea3672014-11-04 20:22:14 -0500207
andrewonlab79244cc2015-01-26 01:11:49 -0500208 for i in range( 0, int( numIter ) ):
209 # addPointIntent( ingrDevice, egrDevice,
210 # ingrPort, egrPort )
211 main.ONOS1cli.addPointIntent(
212 deviceIdList[ 0 ] + "/2", deviceIdList[ 7 ] + "/2" )
213
214 # Allow some time for intents to propagate
215 time.sleep( 5 )
216
217 intentsStr = main.ONOS1cli.intents( jsonFormat=True )
218 intentsObj = json.loads( intentsStr )
219 for intent in intentsObj:
220 if intent[ 'state' ] == "INSTALLED":
221 main.log.info( "Intent installed successfully" )
222 intentId = intent[ 'id' ]
223 main.log.info( "Intent id: " + str( intentId ) )
andrewonlaba57a3042015-01-23 13:53:05 -0500224 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500225 # TODO: Add error handling
226 main.log.info( "Intent installation failed" )
227 intentId = ""
andrewonlab92ea3672014-11-04 20:22:14 -0500228
andrewonlab79244cc2015-01-26 01:11:49 -0500229 # Obtain metrics from ONOS 1, 2, 3
230 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
231 intentsJsonObj1 = json.loads( intentsJsonStr1 )
232 # Parse values from the json object
233 intentSubmit1 = \
234 intentsJsonObj1[ submitTime ][ 'value' ]
235 intentInstall1 = \
236 intentsJsonObj1[ installTime ][ 'value' ]
237 intentInstallLat1 = \
238 int( intentInstall1 ) - int( intentSubmit1 )
239
240 if clusterCount == 3:
241 intentsJsonStr2 = main.ONOS2cli.intentsEventsMetrics()
242 intentsJsonStr3 = main.ONOS3cli.intentsEventsMetrics()
243 intentsJsonObj2 = json.loads( intentsJsonStr2 )
244 intentsJsonObj3 = json.loads( intentsJsonStr3 )
245 intentSubmit2 = \
246 intentsJsonObj2[ submitTime ][ 'value' ]
247 intentSubmit3 = \
248 intentsJsonObj3[ submitTime ][ 'value' ]
249 intentInstall2 = \
250 intentsJsonObj2[ installTime ][ 'value' ]
251 intentInstall3 = \
252 intentsJsonObj3[ installTime ][ 'value' ]
253 intentInstallLat2 = \
254 int( intentInstall2 ) - int( intentSubmit2 )
255 intentInstallLat3 = \
256 int( intentInstall3 ) - int( intentSubmit3 )
andrewonlaba57a3042015-01-23 13:53:05 -0500257 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500258 intentInstallLat2 = 0
259 intentInstallLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500260
andrewonlab79244cc2015-01-26 01:11:49 -0500261 if clusterCount == 5:
262 intentsJsonStr4 = main.ONOS4cli.intentsEventsMetrics()
263 intentsJsonStr5 = main.ONOS5cli.intentsEventsMetrics()
264 intentsJsonObj4 = json.loads( intentsJsonStr4 )
265 intentsJsonObj5 = json.loads( intentsJsonStr5 )
266 intentSubmit4 = \
267 intentsJsonObj4[ submitTime ][ 'value' ]
268 intentSubmit5 = \
269 intentsJsonObj5[ submitTime ][ 'value' ]
270 intentInstall4 = \
271 intentsJsonObj5[ installTime ][ 'value' ]
272 intentInstall5 = \
273 intentsJsonObj5[ installTime ][ 'value' ]
274 intentInstallLat4 = \
275 int( intentInstall4 ) - int( intentSubmit4 )
276 intentInstallLat5 = \
277 int( intentInstall5 ) - int( intentSubmit5 )
andrewonlaba57a3042015-01-23 13:53:05 -0500278 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500279 intentInstallLat4 = 0
280 intentInstallLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500281
andrewonlab79244cc2015-01-26 01:11:49 -0500282 if clusterCount == 7:
283 intentsJsonStr6 = main.ONOS6cli.intentsEventsMetrics()
284 intentsJsonStr7 = main.ONOS7cli.intentsEventsMetrics()
285 intentsJsonObj6 = json.loads( intentsJsonStr6 )
286 intentsJsonObj7 = json.loads( intentsJsonStr7 )
287 intentSubmit6 = \
288 intentsJsonObj6[ submitTime ][ 'value' ]
289 intentSubmit7 = \
290 intentsJsonObj6[ submitTime ][ 'value' ]
291 intentInstall6 = \
292 intentsJsonObj6[ installTime ][ 'value' ]
293 intentInstall7 = \
294 intentsJsonObj7[ installTime ][ 'value' ]
295 intentInstallLat6 = \
296 int( intentInstall6 ) - int( intentSubmit6 )
297 intentInstallLat7 = \
298 int( intentInstall7 ) - int( intentSubmit7 )
andrewonlaba57a3042015-01-23 13:53:05 -0500299 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500300 intentInstallLat6 = 0
301 intentInstallLat7 = 0
andrewonlab8790abb2014-11-06 13:51:54 -0500302
andrewonlab79244cc2015-01-26 01:11:49 -0500303 intentInstallLatAvg = \
304 ( intentInstallLat1 +
305 intentInstallLat2 +
306 intentInstallLat3 +
307 intentInstallLat4 +
308 intentInstallLat5 +
309 intentInstallLat6 +
310 intentInstallLat7 ) / clusterCount
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800311
andrewonlab79244cc2015-01-26 01:11:49 -0500312 main.log.info( "Intent add latency avg for iteration " + str( i ) +
313 ": " + str( intentInstallLatAvg ) + " ms" )
andrewonlab8790abb2014-11-06 13:51:54 -0500314
andrewonlab79244cc2015-01-26 01:11:49 -0500315 if intentInstallLatAvg > 0.0 and \
316 intentInstallLatAvg < 1000 and i > numIgnore:
317 intentAddLatList.append( intentInstallLatAvg )
andrewonlab8790abb2014-11-06 13:51:54 -0500318 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500319 main.log.info( "Intent add latency exceeded " +
320 "threshold. Skipping iteration " + str( i ) )
andrewonlab8790abb2014-11-06 13:51:54 -0500321
andrewonlab79244cc2015-01-26 01:11:49 -0500322 time.sleep( 3 )
323
324 # TODO: Only remove intents that were installed
andrewonlaba57a3042015-01-23 13:53:05 -0500325 # in this case... Otherwise many other intents
326 # may show up distorting the results
andrewonlab79244cc2015-01-26 01:11:49 -0500327 main.log.info( "Removing intents for next iteration" )
328 jsonTemp = \
329 main.ONOS1cli.intents( jsonFormat=True )
330 jsonObjIntents = json.loads( jsonTemp )
331 if jsonObjIntents:
332 for intents in jsonObjIntents:
333 tempId = intents[ 'id' ]
334 # main.ONOS1cli.removeIntent( tempId )
335 main.log.info( "Removing intent id: " +
336 str( tempId ) )
337 main.ONOS1cli.removeIntent( tempId )
andrewonlab8790abb2014-11-06 13:51:54 -0500338 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500339 main.log.info( "Intents were not installed correctly" )
andrewonlab8790abb2014-11-06 13:51:54 -0500340
andrewonlab79244cc2015-01-26 01:11:49 -0500341 time.sleep( 5 )
andrewonlab8790abb2014-11-06 13:51:54 -0500342
andrewonlab79244cc2015-01-26 01:11:49 -0500343 if intentAddLatList:
344 intentAddLatAvg = sum( intentAddLatList ) /\
345 len( intentAddLatList )
andrewonlaba57a3042015-01-23 13:53:05 -0500346 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500347 main.log.report( "Intent installation latency test failed" )
348 intentAddLatAvg = "NA"
andrewonlaba57a3042015-01-23 13:53:05 -0500349 assertion = main.FALSE
350
andrewonlab79244cc2015-01-26 01:11:49 -0500351 intentAddLatStd = \
352 round( numpy.std( intentAddLatList ), 1 )
353 # END ITERATION FOR LOOP
354 main.log.report( "Single intent add latency - " )
355 main.log.report( "Avg: " + str( intentAddLatAvg ) + " ms" )
356 main.log.report( "Std Deviation: " + str( intentAddLatStd ) + " ms" )
357
358 utilities.assert_equals(
359 expect=main.TRUE,
360 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500361 onpass="Single intent install latency test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500362 onfail="Single intent install latency test failed" )
andrewonlab92ea3672014-11-04 20:22:14 -0500363
andrewonlab79244cc2015-01-26 01:11:49 -0500364 def CASE3( self, main ):
365 """
andrewonlab4cf9dd22014-11-18 21:28:38 -0500366 Intent Reroute latency
andrewonlab79244cc2015-01-26 01:11:49 -0500367 """
andrewonlab4cf9dd22014-11-18 21:28:38 -0500368 import time
369 import json
370 import requests
371 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500372 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500373 global clusterCount
andrewonlab4cf9dd22014-11-18 21:28:38 -0500374
andrewonlab79244cc2015-01-26 01:11:49 -0500375 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
376 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
377 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
378 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab4cf9dd22014-11-18 21:28:38 -0500379
andrewonlab79244cc2015-01-26 01:11:49 -0500380 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab4cf9dd22014-11-18 21:28:38 -0500381
andrewonlab79244cc2015-01-26 01:11:49 -0500382 # number of iterations of case
383 numIter = main.params[ 'TEST' ][ 'numIter' ]
384 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
andrewonlaba57a3042015-01-23 13:53:05 -0500385 assertion = main.TRUE
andrewonlab4cf9dd22014-11-18 21:28:38 -0500386
andrewonlab79244cc2015-01-26 01:11:49 -0500387 # Timestamp keys for json metrics output
388 submitTime = main.params[ 'JSON' ][ 'submittedTime' ]
389 installTime = main.params[ 'JSON' ][ 'installedTime' ]
390 wdRequestTime = main.params[ 'JSON' ][ 'wdRequestTime' ]
391 withdrawnTime = main.params[ 'JSON' ][ 'withdrawnTime' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500392
andrewonlab79244cc2015-01-26 01:11:49 -0500393 # NOTE: May need to configure interface depending on topology
394 intfs = main.params[ 'TEST' ][ 'intfs' ]
andrewonlab70decc02014-11-19 18:50:23 -0500395
andrewonlab79244cc2015-01-26 01:11:49 -0500396 devicesJsonStr = main.ONOS1cli.devices()
397 devicesJsonObj = json.loads( devicesJsonStr )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500398
andrewonlab79244cc2015-01-26 01:11:49 -0500399 deviceIdList = []
andrewonlab4cf9dd22014-11-18 21:28:38 -0500400
andrewonlab79244cc2015-01-26 01:11:49 -0500401 # Obtain device id list in ONOS format.
402 # They should already be in order ( 1,2,3,10,11,12,13, etc )
403 for device in devicesJsonObj:
404 deviceIdList.append( device[ 'id' ] )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500405
andrewonlab79244cc2015-01-26 01:11:49 -0500406 intentRerouteLatList = []
andrewonlab4cf9dd22014-11-18 21:28:38 -0500407
andrewonlab79244cc2015-01-26 01:11:49 -0500408 for i in range( 0, int( numIter ) ):
409 # addPointIntent( ingrDevice, ingrPort,
410 # egrDevice, egrPort )
411 if len( deviceIdList ) > 0:
412 main.ONOS1cli.addPointIntent(
413 deviceIdList[ 0 ] + "/2", deviceIdList[ 7 ] + "/2" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500414 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500415 main.log.info( "Failed to fetch devices from ONOS" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500416
andrewonlab79244cc2015-01-26 01:11:49 -0500417 time.sleep( 5 )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500418
andrewonlab79244cc2015-01-26 01:11:49 -0500419 intentsStr = main.ONOS1cli.intents( jsonFormat=True )
420 intentsObj = json.loads( intentsStr )
421 for intent in intentsObj:
422 if intent[ 'state' ] == "INSTALLED":
423 main.log.info( "Intent installed successfully" )
424 intentId = intent[ 'id' ]
425 main.log.info( "Intent id: " + str( intentId ) )
andrewonlab70decc02014-11-19 18:50:23 -0500426 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500427 # TODO: Add error handling
428 main.log.info( "Intent installation failed" )
429 intentId = ""
430
431 main.log.info( "Disabling interface " + intfs )
432 t0System = time.time() * 1000
andrewonlab4cf9dd22014-11-18 21:28:38 -0500433 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500434 "sh ifconfig " + intfs + " down" )
435 main.Mininet1.handle.expect( "mininet>" )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500436
andrewonlab79244cc2015-01-26 01:11:49 -0500437 # TODO: Check for correct intent reroute
438 time.sleep( 1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800439
andrewonlab79244cc2015-01-26 01:11:49 -0500440 # Obtain metrics from ONOS 1, 2, 3
441 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
442 intentsJsonObj1 = json.loads( intentsJsonStr1 )
443 # Parse values from the json object
444 intentInstall1 = \
445 intentsJsonObj1[ installTime ][ 'value' ]
446 intentRerouteLat1 = \
447 int( intentInstall1 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500448
andrewonlab79244cc2015-01-26 01:11:49 -0500449 if clusterCount == 3:
450 intentsJsonStr2 = main.ONOS2cli.intentsEventsMetrics()
451 intentsJsonStr3 = main.ONOS3cli.intentsEventsMetrics()
452
453 intentsJsonObj2 = json.loads( intentsJsonStr2 )
454 intentsJsonObj3 = json.loads( intentsJsonStr3 )
455 intentInstall2 = \
456 intentsJsonObj2[ installTime ][ 'value' ]
457 intentInstall3 = \
458 intentsJsonObj3[ installTime ][ 'value' ]
459 intentRerouteLat2 = \
460 int( intentInstall2 ) - int( t0System )
461 intentRerouteLat3 = \
462 int( intentInstall3 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500463 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500464 intentRerouteLat2 = 0
465 intentRerouteLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500466
andrewonlab79244cc2015-01-26 01:11:49 -0500467 if clusterCount == 5:
468 intentsJsonStr4 = main.ONOS4cli.intentsEventsMetrics()
469 intentsJsonStr5 = main.ONOS5cli.intentsEventsMetrics()
andrewonlaba57a3042015-01-23 13:53:05 -0500470
andrewonlab79244cc2015-01-26 01:11:49 -0500471 intentsJsonObj4 = json.loads( intentsJsonStr4 )
472 intentsJsonObj5 = json.loads( intentsJsonStr5 )
473 intentInstall4 = \
474 intentsJsonObj4[ installTime ][ 'value' ]
475 intentInstall5 = \
476 intentsJsonObj5[ installTime ][ 'value' ]
477 intentRerouteLat4 = \
478 int( intentInstall4 ) - int( t0System )
479 intentRerouteLat5 = \
480 int( intentInstall5 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500481 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500482 intentRerouteLat4 = 0
483 intentRerouteLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500484
andrewonlab79244cc2015-01-26 01:11:49 -0500485 if clusterCount == 7:
486 intentsJsonStr6 = main.ONOS6cli.intentsEventsMetrics()
487 intentsJsonStr7 = main.ONOS7cli.intentsEventsMetrics()
andrewonlaba57a3042015-01-23 13:53:05 -0500488
andrewonlab79244cc2015-01-26 01:11:49 -0500489 intentsJsonObj6 = json.loads( intentsJsonStr6 )
490 intentsJsonObj7 = json.loads( intentsJsonStr7 )
491 intentInstall6 = \
492 intentsJsonObj6[ installTime ][ 'value' ]
493 intentInstall7 = \
494 intentsJsonObj7[ installTime ][ 'value' ]
495 intentRerouteLat6 = \
496 int( intentInstall6 ) - int( t0System )
497 intentRerouteLat7 = \
498 int( intentInstall7 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500499 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500500 intentRerouteLat6 = 0
501 intentRerouteLat7 = 0
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800502
andrewonlab79244cc2015-01-26 01:11:49 -0500503 intentRerouteLatAvg = \
504 ( intentRerouteLat1 +
505 intentRerouteLat2 +
506 intentRerouteLat3 +
507 intentRerouteLat4 +
508 intentRerouteLat5 +
509 intentRerouteLat6 +
510 intentRerouteLat7 ) / clusterCount
andrewonlab4cf9dd22014-11-18 21:28:38 -0500511
andrewonlab79244cc2015-01-26 01:11:49 -0500512 main.log.info( "Intent reroute latency avg for iteration " +
513 str( i ) + ": " + str( intentRerouteLatAvg ) )
514
515 if intentRerouteLatAvg > 0.0 and \
516 intentRerouteLatAvg < 1000 and i > numIgnore:
517 intentRerouteLatList.append( intentRerouteLatAvg )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500518 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500519 main.log.info( "Intent reroute latency exceeded " +
520 "threshold. Skipping iteration " + str( i ) )
andrewonlab4cf9dd22014-11-18 21:28:38 -0500521
andrewonlab79244cc2015-01-26 01:11:49 -0500522 main.log.info( "Removing intents for next iteration" )
523 main.ONOS1cli.removeIntent( intentId )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800524
andrewonlab79244cc2015-01-26 01:11:49 -0500525 main.log.info( "Bringing Mininet interface up for next " +
526 "iteration" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500527 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500528 "sh ifconfig " + intfs + " up" )
529 main.Mininet1.handle.expect( "mininet>" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800530
andrewonlab79244cc2015-01-26 01:11:49 -0500531 if intentRerouteLatList:
532 intentRerouteLatAvg = sum( intentRerouteLatList ) /\
533 len( intentRerouteLatList )
andrewonlaba57a3042015-01-23 13:53:05 -0500534 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500535 main.log.report( "Intent reroute test failed. Results NA" )
536 intentRerouteLatAvg = "NA"
537 # NOTE: fails test when list is empty
andrewonlaba57a3042015-01-23 13:53:05 -0500538 assertion = main.FALSE
andrewonlab79244cc2015-01-26 01:11:49 -0500539
540 intentRerouteLatStd = \
541 round( numpy.std( intentRerouteLatList ), 1 )
542 # END ITERATION FOR LOOP
543 main.log.report( "Single intent reroute latency - " )
544 main.log.report( "Avg: " + str( intentRerouteLatAvg ) + " ms" )
545 main.log.report(
546 "Std Deviation: " +
547 str( intentRerouteLatStd ) +
548 " ms" )
549
550 utilities.assert_equals(
551 expect=main.TRUE,
552 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500553 onpass="Single intent reroute latency test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500554 onfail="Single intent reroute latency test failed" )
555
556 def CASE4( self, main ):
557 """
andrewonlab042b3912014-12-10 16:40:50 -0500558 Batch intent install
andrewonlab79244cc2015-01-26 01:11:49 -0500559 """
andrewonlab70decc02014-11-19 18:50:23 -0500560 import time
561 import json
562 import requests
563 import os
andrewonlabeb1d0542014-12-03 20:12:01 -0500564 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500565 global clusterCount
andrewonlab70decc02014-11-19 18:50:23 -0500566
andrewonlab79244cc2015-01-26 01:11:49 -0500567 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
568 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
569 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
570 ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
571 ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
572 ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
573 ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500574
575 assertion = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800576
andrewonlab79244cc2015-01-26 01:11:49 -0500577 ONOSIpList = []
578 for i in range( 1, 8 ):
579 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlab4293dcb2014-12-02 15:48:05 -0500580
andrewonlab79244cc2015-01-26 01:11:49 -0500581 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
andrewonlab70decc02014-11-19 18:50:23 -0500582
andrewonlab79244cc2015-01-26 01:11:49 -0500583 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlab70decc02014-11-19 18:50:23 -0500584
andrewonlab79244cc2015-01-26 01:11:49 -0500585 batchIntentSize = int( main.params[ 'TEST' ][ 'batchIntentSize' ] )
586 batchThreshMin = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
587 batchThreshMax = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
andrewonlab4293dcb2014-12-02 15:48:05 -0500588
andrewonlab79244cc2015-01-26 01:11:49 -0500589 # number of iterations of case
590 numIter = main.params[ 'TEST' ][ 'numIter' ]
591 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
592 numSwitch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
593 nThread = main.params[ 'TEST' ][ 'numMult' ]
594 #nThread = 105
595
596 # Switch assignment NOTE: hardcoded
597 if clusterCount == 1:
598 for i in range( 1, numSwitch + 1 ):
599 main.Mininet1.assignSwController(
600 sw=str( i ),
601 ip1=ONOS1Ip,
602 port1=defaultSwPort )
603 if clusterCount == 3:
604 for i in range( 1, 3 ):
605 main.Mininet1.assignSwController(
606 sw=str( i ),
607 ip1=ONOS1Ip,
608 port1=defaultSwPort )
609 for i in range( 3, 6 ):
610 main.Mininet1.assignSwController(
611 sw=str( i ),
612 ip1=ONOS2Ip,
613 port1=defaultSwPort )
614 for i in range( 6, 9 ):
615 main.Mininet1.assignSwController(
616 sw=str( i ),
617 ip1=ONOS3Ip,
618 port1=defaultSwPort )
619 if clusterCount == 5:
620 main.Mininet1.assignSwController(
621 sw="1",
622 ip1=ONOS1Ip,
623 port1=defaultSwPort )
624 main.Mininet1.assignSwController(
625 sw="2",
626 ip1=ONOS2Ip,
627 port1=defaultSwPort )
628 for i in range( 3, 6 ):
629 main.Mininet1.assignSwController(
630 sw=str( i ),
631 ip1=ONOS3Ip,
632 port1=defaultSwPort )
633 main.Mininet1.assignSwController(
634 sw="6",
635 ip1=ONOS4Ip,
636 port1=defaultSwPort )
637 main.Mininet1.assignSwController(
638 sw="7",
639 ip1=ONOS5Ip,
640 port1=defaultSwPort )
641 main.Mininet1.assignSwController(
642 sw="8",
643 ip1=ONOS5Ip,
644 port1=defaultSwPort )
645
646 if clusterCount == 7:
647 for i in range( 1, 9 ):
andrewonlabeb1d0542014-12-03 20:12:01 -0500648 if i < 8:
andrewonlab79244cc2015-01-26 01:11:49 -0500649 main.Mininet1.assignSwController(
650 sw=str( i ),
651 ip1=ONOSIpList[ i - 1 ],
652 port1=defaultSwPort )
653 elif i >= 8:
654 main.Mininet1.assignSwController(
655 sw=str( i ),
656 ip1=ONOSIpList[ 6 ],
657 port1=defaultSwPort )
andrewonlab70decc02014-11-19 18:50:23 -0500658
andrewonlab79244cc2015-01-26 01:11:49 -0500659 time.sleep( 20 )
andrewonlabeb1d0542014-12-03 20:12:01 -0500660
andrewonlab79244cc2015-01-26 01:11:49 -0500661 main.log.report( "Batch intent installation test of " +
662 str( batchIntentSize ) + " intent(s)" )
andrewonlab4293dcb2014-12-02 15:48:05 -0500663
andrewonlab79244cc2015-01-26 01:11:49 -0500664 batchResultList = []
andrewonlab70decc02014-11-19 18:50:23 -0500665
andrewonlab79244cc2015-01-26 01:11:49 -0500666 main.log.info( "Getting list of available devices" )
667 deviceIdList = []
668 jsonStr = main.ONOS1cli.devices()
669 jsonObj = json.loads( jsonStr )
670 for device in jsonObj:
671 deviceIdList.append( device[ 'id' ] )
andrewonlab70decc02014-11-19 18:50:23 -0500672
andrewonlab79244cc2015-01-26 01:11:49 -0500673 batchInstallLat = []
674 batchWithdrawLat = []
andrewonlab70decc02014-11-19 18:50:23 -0500675
andrewonlab79244cc2015-01-26 01:11:49 -0500676 # Max intent install measurement of all nodes
677 maxInstallLat = []
678 maxWithdrawLat = []
679 sleepTime = 10
680
681 baseDir = "/tmp/"
682
683 for batch in range( 0, 5 ):
684 for i in range( 0, int( numIter ) ):
685 main.log.info( "Pushing " +
686 str( int( batchIntentSize ) * int( nThread ) ) +
687 " intents. Iteration " + str( i ) )
688
689 for node in range( 1, clusterCount + 1 ):
690 saveDir = baseDir + "batch_intent_" + str( node ) + ".txt"
691 main.ONOSbench.pushTestIntentsShell(
692 deviceIdList[ 0 ] + "/2",
693 deviceIdList[ 7 ] + "/2",
694 batchIntentSize,
695 saveDir, ONOSIpList[ node - 1 ],
696 numMult=nThread, appId=node )
697
698 # Wait sufficient time for intents to start
699 # installing
700 time.sleep( sleepTime )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800701
andrewonlaba57a3042015-01-23 13:53:05 -0500702 intent = ""
703 counter = 300
andrewonlab79244cc2015-01-26 01:11:49 -0500704 while len( intent ) > 0 and counter > 0:
andrewonlaba57a3042015-01-23 13:53:05 -0500705 main.ONOS1cli.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500706 "intents | wc -l" )
andrewonlaba57a3042015-01-23 13:53:05 -0500707 main.ONOS1cli.handle.expect(
andrewonlab79244cc2015-01-26 01:11:49 -0500708 "intents | wc -l" )
andrewonlaba57a3042015-01-23 13:53:05 -0500709 main.ONOS1cli.handle.expect(
andrewonlab79244cc2015-01-26 01:11:49 -0500710 "onos>" )
711 intentTemp = main.ONOS1cli.handle.before()
andrewonlaba57a3042015-01-23 13:53:05 -0500712 intent = main.ONOS1cli.intents()
andrewonlab79244cc2015-01-26 01:11:49 -0500713 intent = json.loads( intent )
714 counter = counter - 1
715 time.sleep( 1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800716
andrewonlab79244cc2015-01-26 01:11:49 -0500717 time.sleep( 5 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800718
andrewonlab79244cc2015-01-26 01:11:49 -0500719 for node in range( 1, clusterCount + 1 ):
720 saveDir = baseDir + "batch_intent_" + str( node ) + ".txt"
721 with open( saveDir ) as fOnos:
722 lineCount = 0
723 for line in fOnos:
724 line = line[ 1: ]
725 line = line.split( ": " )
726 main.log.info( "Line read: " + str( line ) )
727 result = line[ 1 ].split( " " )[ 0 ]
728 # TODO: add parameters before appending latency
729 if lineCount == 0:
730 batchInstallLat.append( int( result ) )
731 installResult = result
732 elif lineCount == 1:
733 batchWithdrawLat.append( int( result ) )
734 withdrawResult = result
735 lineCount += 1
736 main.log.info( "Batch install latency for ONOS" +
737 str( node ) + " with " +
738 str( batchIntentSize ) + "intents: " +
739 str( installResult ) + " ms" )
740 main.log.info( "Batch withdraw latency for ONOS" +
741 str( node ) + " with " +
742 str( batchIntentSize ) + "intents: " +
743 str( withdrawResult ) + " ms" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500744
andrewonlab79244cc2015-01-26 01:11:49 -0500745 if len( batchInstallLat ) > 0 and int( i ) > numIgnore:
746 maxInstallLat.append( max( batchInstallLat ) )
747 elif len( batchInstallLat ) == 0:
748 # If I failed to read anything from the file,
749 # increase the wait time before checking intents
750 sleepTime += 30
751 if len( batchWithdrawLat ) > 0 and int( i ) > numIgnore:
752 maxWithdrawLat.append( max( batchWithdrawLat ) )
753 batchInstallLat = []
754 batchWithdrawLat = []
755
756 # Sleep in between iterations
757 time.sleep( 5 )
758
759 if maxInstallLat:
760 avgInstallLat = str( sum( maxInstallLat ) /
761 len( maxInstallLat ) )
andrewonlaba57a3042015-01-23 13:53:05 -0500762 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500763 avgInstallLat = "NA"
764 main.log.report( "Batch installation failed" )
andrewonlaba57a3042015-01-23 13:53:05 -0500765 assertion = main.FALSE
andrewonlabeb1d0542014-12-03 20:12:01 -0500766
andrewonlab79244cc2015-01-26 01:11:49 -0500767 if maxWithdrawLat:
768 avgWithdrawLat = str( sum( maxWithdrawLat ) /
769 len( maxWithdrawLat ) )
andrewonlaba57a3042015-01-23 13:53:05 -0500770 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500771 avgWithdrawLat = "NA"
772 main.log.report( "Batch withdraw failed" )
andrewonlaba57a3042015-01-23 13:53:05 -0500773 assertion = main.FALSE
andrewonlabeb1d0542014-12-03 20:12:01 -0500774
andrewonlab79244cc2015-01-26 01:11:49 -0500775 main.log.report( "Avg of batch installation latency " +
776 "of size " + str( batchIntentSize ) + ": " +
777 str( avgInstallLat ) + " ms" )
778 main.log.report( "Std Deviation of batch installation latency " +
779 ": " + str( numpy.std( maxInstallLat ) ) + " ms" )
andrewonlabeb1d0542014-12-03 20:12:01 -0500780
andrewonlab79244cc2015-01-26 01:11:49 -0500781 main.log.report( "Avg of batch withdraw latency " +
782 "of size " + str( batchIntentSize ) + ": " +
783 str( avgWithdrawLat ) + " ms" )
784 main.log.report( "Std Deviation of batch withdraw latency " +
785 ": " +
786 str( numpy.std( maxWithdrawLat ) ) +
787 " ms" )
788
789 batchIntentSize = batchIntentSize + 1000
790 main.log.report( "Increasing batch intent size to " +
791 str(batchIntentSize) )
792
793 #main.log.info( "Removing all intents for next test case" )
794 #jsonTemp = main.ONOS1cli.intents( jsonFormat=True )
795 #jsonObjIntents = json.loads( jsonTemp )
796 # if jsonObjIntents:
797 # for intents in jsonObjIntents:
798 # tempId = intents[ 'id' ]
799 # main.ONOS1cli.removeIntent( tempId )
800 # main.ONOS1cli.removeIntent( tempId )
801
802 utilities.assert_equals(
803 expect=main.TRUE,
804 actual=assertion,
andrewonlaba57a3042015-01-23 13:53:05 -0500805 onpass="Batch intent install/withdraw test successful",
andrewonlab79244cc2015-01-26 01:11:49 -0500806 onfail="Batch intent install/withdraw test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800807
andrewonlab79244cc2015-01-26 01:11:49 -0500808 def CASE5( self, main ):
809 """
andrewonlab4293dcb2014-12-02 15:48:05 -0500810 Increase number of nodes and initiate CLI
andrewonlab79244cc2015-01-26 01:11:49 -0500811 """
andrewonlab4293dcb2014-12-02 15:48:05 -0500812 import time
813 import json
814
andrewonlab79244cc2015-01-26 01:11:49 -0500815 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
816 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
817 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
818 ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ]
819 ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ]
820 ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ]
821 ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ]
andrewonlab4293dcb2014-12-02 15:48:05 -0500822
andrewonlab79244cc2015-01-26 01:11:49 -0500823 global clusterCount
824 clusterCount += 2
825 main.log.report( "Increasing cluster size to " +
826 str( clusterCount ) )
andrewonlab4293dcb2014-12-02 15:48:05 -0500827
andrewonlab79244cc2015-01-26 01:11:49 -0500828 installResult = main.FALSE
andrewonlab4293dcb2014-12-02 15:48:05 -0500829
andrewonlab79244cc2015-01-26 01:11:49 -0500830 if clusterCount == 3:
831 installResult1 = \
832 main.ONOSbench.onosInstall( node=ONOS2Ip )
833 installResult2 = \
834 main.ONOSbench.onosInstall( node=ONOS3Ip )
835 time.sleep( 5 )
andrewonlab4293dcb2014-12-02 15:48:05 -0500836
andrewonlab79244cc2015-01-26 01:11:49 -0500837 main.log.info( "Starting ONOS CLI" )
838 main.ONOS2cli.startOnosCli( ONOS2Ip )
839 main.ONOS3cli.startOnosCli( ONOS3Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500840
andrewonlab79244cc2015-01-26 01:11:49 -0500841 installResult = installResult1 and installResult2
andrewonlab4293dcb2014-12-02 15:48:05 -0500842
andrewonlab79244cc2015-01-26 01:11:49 -0500843 if clusterCount == 5:
844 main.log.info( "Installing ONOS on node 4 and 5" )
845 installResult1 = \
846 main.ONOSbench.onosInstall( node=ONOS4Ip )
847 installResult2 = \
848 main.ONOSbench.onosInstall( node=ONOS5Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500849
andrewonlab79244cc2015-01-26 01:11:49 -0500850 main.log.info( "Starting ONOS CLI" )
851 main.ONOS4cli.startOnosCli( ONOS4Ip )
852 main.ONOS5cli.startOnosCli( ONOS5Ip )
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 == 7:
857 main.log.info( "Installing ONOS on node 6 and 7" )
858 installResult1 = \
859 main.ONOSbench.onosInstall( node=ONOS6Ip )
860 installResult2 = \
861 main.ONOSbench.onosInstall( node=ONOS7Ip )
andrewonlab4293dcb2014-12-02 15:48:05 -0500862
andrewonlab79244cc2015-01-26 01:11:49 -0500863 main.log.info( "Starting ONOS CLI" )
864 main.ONOS6cli.startOnosCli( ONOS6Ip )
865 main.ONOS7cli.startOnosCli( ONOS7Ip )
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 time.sleep( 5 )
andrewonlab4293dcb2014-12-02 15:48:05 -0500870
andrewonlab79244cc2015-01-26 01:11:49 -0500871 if installResult == main.TRUE:
andrewonlab4293dcb2014-12-02 15:48:05 -0500872 assertion = main.TRUE
873 else:
874 assertion = main.FALSE
875
andrewonlab79244cc2015-01-26 01:11:49 -0500876 utilities.assert_equals( expect=main.TRUE, actual=assertion,
877 onpass="Scale out to " + str( clusterCount ) +
878 " nodes successful",
879 onfail="Scale out to " + str( clusterCount ) +
880 " nodes failed" )
andrewonlab4293dcb2014-12-02 15:48:05 -0500881
andrewonlab79244cc2015-01-26 01:11:49 -0500882 def CASE7( self, main ):
883 # TODO: Fix for scale-out scenario
884 """
andrewonlaba57a3042015-01-23 13:53:05 -0500885 Batch intent reroute latency
andrewonlab79244cc2015-01-26 01:11:49 -0500886 """
andrewonlaba57a3042015-01-23 13:53:05 -0500887 import time
888 import json
889 import requests
890 import os
891 import numpy
andrewonlab79244cc2015-01-26 01:11:49 -0500892 global clusterCount
andrewonlaba57a3042015-01-23 13:53:05 -0500893
andrewonlab79244cc2015-01-26 01:11:49 -0500894 ONOSIpList = []
895 for i in range( 1, 8 ):
896 ONOSIpList.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] )
andrewonlaba57a3042015-01-23 13:53:05 -0500897
andrewonlab79244cc2015-01-26 01:11:49 -0500898 ONOSUser = main.params[ 'CTRL' ][ 'user' ]
899 defaultSwPort = main.params[ 'CTRL' ][ 'port1' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500900
andrewonlab79244cc2015-01-26 01:11:49 -0500901 batchIntentSize = main.params[ 'TEST' ][ 'batchIntentSize' ]
902 batchThreshMin = int( main.params[ 'TEST' ][ 'batchThresholdMin' ] )
903 batchThreshMax = int( main.params[ 'TEST' ][ 'batchThresholdMax' ] )
904 intfs = main.params[ 'TEST' ][ 'intfs' ]
905 installTime = main.params[ 'JSON' ][ 'installedTime' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500906
andrewonlab79244cc2015-01-26 01:11:49 -0500907 # number of iterations of case
908 numIter = main.params[ 'TEST' ][ 'numIter' ]
909 numIgnore = int( main.params[ 'TEST' ][ 'numIgnore' ] )
910 numSwitch = int( main.params[ 'TEST' ][ 'numSwitch' ] )
911 nThread = main.params[ 'TEST' ][ 'numMult' ]
andrewonlaba57a3042015-01-23 13:53:05 -0500912
andrewonlab79244cc2015-01-26 01:11:49 -0500913 main.log.report( "Batch intent installation test of " +
914 batchIntentSize + " intents" )
andrewonlaba57a3042015-01-23 13:53:05 -0500915
andrewonlab79244cc2015-01-26 01:11:49 -0500916 batchResultList = []
andrewonlaba57a3042015-01-23 13:53:05 -0500917
andrewonlab79244cc2015-01-26 01:11:49 -0500918 time.sleep( 10 )
andrewonlaba57a3042015-01-23 13:53:05 -0500919
andrewonlab79244cc2015-01-26 01:11:49 -0500920 main.log.info( "Getting list of available devices" )
921 deviceIdList = []
922 jsonStr = main.ONOS1cli.devices()
923 jsonObj = json.loads( jsonStr )
924 for device in jsonObj:
925 deviceIdList.append( device[ 'id' ] )
andrewonlaba57a3042015-01-23 13:53:05 -0500926
andrewonlab79244cc2015-01-26 01:11:49 -0500927 batchInstallLat = []
928 batchWithdrawLat = []
929 sleepTime = 10
andrewonlaba57a3042015-01-23 13:53:05 -0500930
andrewonlab79244cc2015-01-26 01:11:49 -0500931 baseDir = "/tmp/"
932 maxInstallLat = []
933
934 for i in range( 0, int( numIter ) ):
935 main.log.info( "Pushing " +
936 str( int( batchIntentSize ) * int( nThread ) ) +
937 " intents. Iteration " + str( i ) )
938
939 main.ONOSbench.pushTestIntentsShell(
940 deviceIdList[ 0 ] + "/2",
941 deviceIdList[ 7 ] + "/2",
942 batchIntentSize, "/tmp/batch_install.txt",
943 ONOSIpList[ 0 ], numMult="1", appId="1",
944 report=False, options="--install" )
945 # main.ONOSbench.pushTestIntentsShell(
andrewonlaba57a3042015-01-23 13:53:05 -0500946 # "of:0000000000001002/1",
947 # "of:0000000000002002/1",
948 # 133, "/tmp/temp2.txt", "10.128.174.2",
andrewonlab79244cc2015-01-26 01:11:49 -0500949 # numMult="6", appId="2",report=False )
950
951 # TODO: Check for installation success then proceed
952 time.sleep( 30 )
953
954 # NOTE: this interface is specific to
andrewonlaba57a3042015-01-23 13:53:05 -0500955 # topo-intentFlower.py topology
956 # reroute case.
andrewonlab79244cc2015-01-26 01:11:49 -0500957 main.log.info( "Disabling interface " + intfs )
andrewonlaba57a3042015-01-23 13:53:05 -0500958 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -0500959 "sh ifconfig " + intfs + " down" )
960 t0System = time.time() * 1000
andrewonlaba57a3042015-01-23 13:53:05 -0500961
andrewonlab79244cc2015-01-26 01:11:49 -0500962 # TODO: Wait sufficient time for intents to install
963 time.sleep( 10 )
andrewonlaba57a3042015-01-23 13:53:05 -0500964
andrewonlab79244cc2015-01-26 01:11:49 -0500965 # TODO: get intent installation time
966
967 # Obtain metrics from ONOS 1, 2, 3
968 intentsJsonStr1 = main.ONOS1cli.intentsEventsMetrics()
969 intentsJsonObj1 = json.loads( intentsJsonStr1 )
970 # Parse values from the json object
971 intentInstall1 = \
972 intentsJsonObj1[ installTime ][ 'value' ]
973 intentRerouteLat1 = \
974 int( intentInstall1 ) - int( t0System )
975
976 if clusterCount == 3:
977 intentsJsonStr2 =\
978 main.ONOS2cli.intentsEventsMetrics()
979 intentsJsonStr3 =\
980 main.ONOS3cli.intentsEventsMetrics()
981 intentsJsonObj2 = json.loads( intentsJsonStr2 )
982 intentsJsonObj3 = json.loads( intentsJsonStr3 )
983 intentInstall2 = \
984 intentsJsonObj2[ installTime ][ 'value' ]
985 intentInstall3 = \
986 intentsJsonObj3[ installTime ][ 'value' ]
987 intentRerouteLat2 = \
988 int( intentInstall2 ) - int( t0System )
989 intentRerouteLat3 = \
990 int( intentInstall3 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -0500991 else:
andrewonlab79244cc2015-01-26 01:11:49 -0500992 intentRerouteLat2 = 0
993 intentRerouteLat3 = 0
andrewonlaba57a3042015-01-23 13:53:05 -0500994
andrewonlab79244cc2015-01-26 01:11:49 -0500995 if clusterCount == 5:
996 intentsJsonStr4 =\
997 main.ONOS4cli.intentsEventsMetrics()
998 intentsJsonStr5 =\
999 main.ONOS5cli.intentsEventsMetrics()
1000 intentsJsonObj4 = json.loads( intentsJsonStr4 )
1001 intentsJsonObj5 = json.loads( intentsJsonStr5 )
1002 intentInstall4 = \
1003 intentsJsonObj4[ installTime ][ 'value' ]
1004 intentInstall5 = \
1005 intentsJsonObj5[ installTime ][ 'value' ]
1006 intentRerouteLat4 = \
1007 int( intentInstall4 ) - int( t0System )
1008 intentRerouteLat5 = \
1009 int( intentInstall5 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -05001010 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001011 intentRerouteLat4 = 0
1012 intentRerouteLat5 = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001013
andrewonlab79244cc2015-01-26 01:11:49 -05001014 if clusterCount == 7:
1015 intentsJsonStr6 =\
1016 main.ONOS6cli.intentsEventsMetrics()
1017 intentsJsonStr7 =\
1018 main.ONOS7cli.intentsEventsMetrics()
1019 intentsJsonObj6 = json.loads( intentsJsonStr6 )
1020 intentsJsonObj7 = json.loads( intentsJsonStr7 )
1021 intentInstall6 = \
1022 intentsJsonObj6[ installTime ][ 'value' ]
1023 intentInstall7 = \
1024 intentsJsonObj7[ installTime ][ 'value' ]
1025 intentRerouteLat6 = \
1026 int( intentInstall6 ) - int( t0System )
1027 intentRerouteLat7 = \
1028 int( intentInstall7 ) - int( t0System )
andrewonlaba57a3042015-01-23 13:53:05 -05001029 else:
andrewonlab79244cc2015-01-26 01:11:49 -05001030 intentRerouteLat6 = 0
1031 intentRerouteLat7 = 0
andrewonlaba57a3042015-01-23 13:53:05 -05001032
andrewonlab79244cc2015-01-26 01:11:49 -05001033 intentRerouteLatAvg = \
1034 ( intentRerouteLat1 +
1035 intentRerouteLat2 +
1036 intentRerouteLat3 +
1037 intentRerouteLat4 +
1038 intentRerouteLat5 +
1039 intentRerouteLat6 +
1040 intentRerouteLat7 ) / clusterCount
andrewonlaba57a3042015-01-23 13:53:05 -05001041
andrewonlab79244cc2015-01-26 01:11:49 -05001042 main.log.info( "Intent reroute latency avg for iteration " +
1043 str( i ) + ": " + str( intentRerouteLatAvg ) )
1044 # TODO: Remove intents for next iteration
1045
1046 time.sleep( 5 )
1047
1048 intentsStr = main.ONOS1cli.intents()
1049 intentsJson = json.loads( intentsStr )
1050 for intents in intentsJson:
1051 intentId = intents[ 'id' ]
1052 # TODO: make sure this removes all intents
1053 # print intentId
1054 if intentId:
1055 main.ONOS1cli.removeIntent( intentId )
andrewonlaba57a3042015-01-23 13:53:05 -05001056
1057 main.Mininet1.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001058 "sh ifconfig " + intfs + " up" )
andrewonlaba57a3042015-01-23 13:53:05 -05001059
andrewonlab79244cc2015-01-26 01:11:49 -05001060 main.log.info( "Intents removed and port back up" )
1061
1062 def CASE9( self, main ):
andrewonlabeb1d0542014-12-03 20:12:01 -05001063 count = 0
andrewonlab79244cc2015-01-26 01:11:49 -05001064 swNum1 = 1
1065 swNum2 = 1
andrewonlabeb1d0542014-12-03 20:12:01 -05001066 appid = 0
andrewonlab79244cc2015-01-26 01:11:49 -05001067 portNum1 = 1
1068 portNum2 = 1
1069
1070 time.sleep( 30 )
andrewonlab4cf9dd22014-11-18 21:28:38 -05001071
andrewonlabeb1d0542014-12-03 20:12:01 -05001072 while True:
andrewonlab79244cc2015-01-26 01:11:49 -05001073 # main.ONOS1cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001074 #"of:0000000000001001/1",
1075 #"of:0000000000002001/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001076 # 100, numMult="10", appId="1" )
1077 # main.ONOS2cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001078 # "of:0000000000001002/1",
1079 # "of:0000000000002002/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001080 # 100, numMult="10", appId="2" )
1081 # main.ONOS2cli.pushTestIntents(
andrewonlabeb1d0542014-12-03 20:12:01 -05001082 # "of:0000000000001003/1",
1083 # "of:0000000000002003/1",
andrewonlab79244cc2015-01-26 01:11:49 -05001084 # 100, numMult="10", appId="3" )
andrewonlabeb1d0542014-12-03 20:12:01 -05001085 count += 1
andrewonlab79244cc2015-01-26 01:11:49 -05001086
andrewonlabeb1d0542014-12-03 20:12:01 -05001087 if count >= 100:
1088 main.ONOSbench.handle.sendline(
andrewonlab79244cc2015-01-26 01:11:49 -05001089 "onos 10.128.174.1 intents-events-metrics >>" +
1090 " /tmp/metrics_intents_temp.txt &" )
andrewonlabeb1d0542014-12-03 20:12:01 -05001091 count = 0
1092
andrewonlab79244cc2015-01-26 01:11:49 -05001093 arg1 = "of:000000000000100" + str( swNum1 ) + "/" + str( portNum1 )
1094 arg2 = "of:000000000000200" + str( swNum2 ) + "/" + str( portNum2 )
andrewonlabeb1d0542014-12-03 20:12:01 -05001095
andrewonlab79244cc2015-01-26 01:11:49 -05001096 swNum1 += 1
1097
1098 if swNum1 > 7:
1099 swNum1 = 1
1100 swNum2 += 1
1101 if swNum2 > 7:
andrewonlabeb1d0542014-12-03 20:12:01 -05001102 appid += 1
1103
andrewonlab79244cc2015-01-26 01:11:49 -05001104 if swNum2 > 7:
1105 swNum2 = 1
1106
1107 main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001108 arg1,
andrewonlab79244cc2015-01-26 01:11:49 -05001109 arg2,
andrewonlab042b3912014-12-10 16:40:50 -05001110 100, "/tmp/temp.txt", "10.128.174.1",
andrewonlab79244cc2015-01-26 01:11:49 -05001111 numMult="10", appId=appid, report=False )
1112 # main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001113 # "of:0000000000001002/1",
1114 # "of:0000000000002002/1",
1115 # 133, "/tmp/temp2.txt", "10.128.174.2",
andrewonlab79244cc2015-01-26 01:11:49 -05001116 # numMult="6", appId="2",report=False )
1117 # main.ONOSbench.pushTestIntentsShell(
andrewonlabeb1d0542014-12-03 20:12:01 -05001118 # "of:0000000000001003/1",
1119 # "of:0000000000002003/1",
1120 # 133, "/tmp/temp3.txt", "10.128.174.3",
andrewonlab79244cc2015-01-26 01:11:49 -05001121 # numMult="6", appId="3",report=False )
andrewonlab92ea3672014-11-04 20:22:14 -05001122
andrewonlab79244cc2015-01-26 01:11:49 -05001123 time.sleep( 0.2 )