blob: 140d089bb0de4a24a954f2dcaf02c53883d8599e [file] [log] [blame]
Hari Krishnac195f3b2015-07-08 20:02:24 -07001import sys
2import os
3import re
4import time
5import json
6import itertools
7
8
Hari Krishna6185fc12015-07-13 15:42:31 -07009class CHOtest:
Hari Krishnac195f3b2015-07-08 20:02:24 -070010
11 def __init__( self ):
12 self.default = ''
13
14 def CASE1( self, main ):
15 """
16 Startup sequence:
Hari Krishna6185fc12015-07-13 15:42:31 -070017 apply cell <name>
Hari Krishnac195f3b2015-07-08 20:02:24 -070018 git pull
19 mvn clean install
20 onos-package
Hari Krishnac195f3b2015-07-08 20:02:24 -070021 onos-verify-cell
22 onos-uninstall
Hari Krishna6185fc12015-07-13 15:42:31 -070023 onos-install
Hari Krishnac195f3b2015-07-08 20:02:24 -070024 onos-start-cli
25 """
26 import time
27
28 global intentState
29 main.threadID = 0
30 main.pingTimeout = 300
31 main.numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
Hari Krishnac195f3b2015-07-08 20:02:24 -070032 git_pull = main.params[ 'GIT' ][ 'autoPull' ]
33 git_branch = main.params[ 'GIT' ][ 'branch' ]
Hari Krishna10065772015-07-10 15:55:53 -070034 karafTimeout = main.params['CTRL']['karafCliTimeout']
Hari Krishnac195f3b2015-07-08 20:02:24 -070035 main.newTopo = ""
36 main.CLIs = []
Hari Krishnac195f3b2015-07-08 20:02:24 -070037
38 for i in range( 1, int(main.numCtrls) + 1 ):
39 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
Hari Krishnac195f3b2015-07-08 20:02:24 -070040
41 main.case( "Set up test environment" )
42 main.log.report( "Set up test environment" )
43 main.log.report( "_______________________" )
44
Hari Krishna6185fc12015-07-13 15:42:31 -070045 main.step( "Apply Cell environment for ONOS" )
46 if ( main.onoscell ):
47 cellName = main.onoscell
48 cell_result = main.ONOSbench.setCell( cellName )
Hari Krishna6185fc12015-07-13 15:42:31 -070049 utilities.assert_equals( expect=main.TRUE, actual=cell_result,
50 onpass="Test step PASS",
51 onfail="Test step FAIL" )
52 else:
53 main.log.error( "Please provide onoscell option at TestON CLI to run CHO tests" )
54 main.log.error( "Example: ~/TestON/bin/cli.py run OnosCHO onoscell <cellName>" )
55 main.clean()
56 main.exit()
57
Hari Krishnac195f3b2015-07-08 20:02:24 -070058 main.step( "Git checkout and pull " + git_branch )
59 if git_pull == 'on':
60 checkout_result = main.ONOSbench.gitCheckout( git_branch )
61 pull_result = main.ONOSbench.gitPull()
62 cp_result = ( checkout_result and pull_result )
63 else:
64 checkout_result = main.TRUE
65 pull_result = main.TRUE
66 main.log.info( "Skipped git checkout and pull" )
67 cp_result = ( checkout_result and pull_result )
68 utilities.assert_equals( expect=main.TRUE, actual=cp_result,
69 onpass="Test step PASS",
70 onfail="Test step FAIL" )
71
72 main.step( "mvn clean & install" )
73 if git_pull == 'on':
74 mvn_result = main.ONOSbench.cleanInstall()
75 utilities.assert_equals( expect=main.TRUE, actual=mvn_result,
76 onpass="Test step PASS",
77 onfail="Test step FAIL" )
78 else:
79 mvn_result = main.TRUE
80 main.log.info("Skipped mvn clean install as git pull is disabled in params file")
81
82 main.ONOSbench.getVersion( report=True )
83
Hari Krishnac195f3b2015-07-08 20:02:24 -070084 main.step( "Create ONOS package" )
85 packageResult = main.ONOSbench.onosPackage()
86 utilities.assert_equals( expect=main.TRUE, actual=packageResult,
87 onpass="Test step PASS",
88 onfail="Test step FAIL" )
89
90 main.step( "Uninstall ONOS package on all Nodes" )
91 uninstallResult = main.TRUE
92 for i in range( int( main.numCtrls ) ):
93 main.log.info( "Uninstalling package on ONOS Node IP: " + main.onosIPs[i] )
94 u_result = main.ONOSbench.onosUninstall( main.onosIPs[i] )
95 utilities.assert_equals( expect=main.TRUE, actual=u_result,
96 onpass="Test step PASS",
97 onfail="Test step FAIL" )
98 uninstallResult = ( uninstallResult and u_result )
99
100 main.step( "Install ONOS package on all Nodes" )
101 installResult = main.TRUE
102 for i in range( int( main.numCtrls ) ):
103 main.log.info( "Intsalling package on ONOS Node IP: " + main.onosIPs[i] )
104 i_result = main.ONOSbench.onosInstall( node=main.onosIPs[i] )
105 utilities.assert_equals( expect=main.TRUE, actual=i_result,
106 onpass="Test step PASS",
107 onfail="Test step FAIL" )
108 installResult = ( installResult and i_result )
109
110 main.step( "Verify ONOS nodes UP status" )
111 statusResult = main.TRUE
112 for i in range( int( main.numCtrls ) ):
113 main.log.info( "ONOS Node " + main.onosIPs[i] + " status:" )
114 onos_status = main.ONOSbench.onosStatus( node=main.onosIPs[i] )
115 utilities.assert_equals( expect=main.TRUE, actual=onos_status,
116 onpass="Test step PASS",
117 onfail="Test step FAIL" )
118 statusResult = ( statusResult and onos_status )
Jon Hall4ba53f02015-07-29 13:07:41 -0700119
Hari Krishnac195f3b2015-07-08 20:02:24 -0700120 main.step( "Start ONOS CLI on all nodes" )
121 cliResult = main.TRUE
Hari Krishnac195f3b2015-07-08 20:02:24 -0700122 main.log.step(" Start ONOS cli using thread ")
123 startCliResult = main.TRUE
124 pool = []
125 time1 = time.time()
126 for i in range( int( main.numCtrls) ):
127 t = main.Thread( target=main.CLIs[i].startOnosCli,
128 threadID=main.threadID,
129 name="startOnosCli",
130 args=[ main.onosIPs[i], karafTimeout ] )
131 pool.append(t)
132 t.start()
133 main.threadID = main.threadID + 1
134 for t in pool:
135 t.join()
136 startCliResult = startCliResult and t.result
137 time2 = time.time()
Jon Hall4ba53f02015-07-29 13:07:41 -0700138
Hari Krishnac195f3b2015-07-08 20:02:24 -0700139 if not startCliResult:
140 main.log.info("ONOS CLI did not start up properly")
141 main.cleanup()
142 main.exit()
143 else:
144 main.log.info("Successful CLI startup")
145 startCliResult = main.TRUE
146 case1Result = installResult and uninstallResult and statusResult and startCliResult
147 time.sleep(30)
148 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
149 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
150 onpass="Set up test environment PASS",
151 onfail="Set up test environment FAIL" )
152
153 def CASE20( self, main ):
154 """
155 This test script Loads a new Topology (Att) on CHO setup and balances all switches
156 """
157 import re
158 import time
159 import copy
160
161 main.numMNswitches = int ( main.params[ 'TOPO1' ][ 'numSwitches' ] )
162 main.numMNlinks = int ( main.params[ 'TOPO1' ][ 'numLinks' ] )
163 main.numMNhosts = int ( main.params[ 'TOPO1' ][ 'numHosts' ] )
164 main.pingTimeout = 300
165 main.log.report(
166 "Load Att topology and Balance all Mininet switches across controllers" )
167 main.log.report(
168 "________________________________________________________________________" )
169 main.case(
170 "Assign and Balance all Mininet switches across controllers" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700171
Hari Krishnac195f3b2015-07-08 20:02:24 -0700172 main.step( "Stop any previous Mininet network topology" )
173 cliResult = main.TRUE
174 if main.newTopo == main.params['TOPO3']['topo']:
175 stopStatus = main.Mininet1.stopNet( fileName = "topoSpine" )
176
177 main.step( "Start Mininet with Att topology" )
178 main.newTopo = main.params['TOPO1']['topo']
179 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
Jon Hall4ba53f02015-07-29 13:07:41 -0700180
Hari Krishnac195f3b2015-07-08 20:02:24 -0700181 main.step( "Assign switches to controllers" )
182 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
183 main.Mininet1.assignSwController(
184 sw="s" + str( i ),
Hari Krishna10065772015-07-10 15:55:53 -0700185 ip=main.onosIPs )
Hari Krishnac195f3b2015-07-08 20:02:24 -0700186
187 switch_mastership = main.TRUE
188 for i in range( 1, ( main.numMNswitches + 1 ) ):
189 response = main.Mininet1.getSwController( "s" + str( i ) )
190 print( "Response is " + str( response ) )
191 if re.search( "tcp:" + main.onosIPs[0], response ):
192 switch_mastership = switch_mastership and main.TRUE
193 else:
194 switch_mastership = main.FALSE
195
196 if switch_mastership == main.TRUE:
197 main.log.report( "Controller assignment successfull" )
198 else:
199 main.log.report( "Controller assignment failed" )
200
201 time.sleep(30) # waiting here to make sure topology converges across all nodes
202
203 main.step( "Balance devices across controllers" )
204 balanceResult = main.ONOScli1.balanceMasters()
Jon Hall4ba53f02015-07-29 13:07:41 -0700205 # giving some breathing time for ONOS to complete re-balance
Hari Krishnac195f3b2015-07-08 20:02:24 -0700206 time.sleep( 5 )
207
208 topology_output = main.ONOScli1.topology()
209 topology_result = main.ONOSbench.getTopology( topology_output )
210 case2Result = ( switch_mastership and startStatus )
211 utilities.assert_equals(
212 expect=main.TRUE,
213 actual=case2Result,
214 onpass="Starting new Att topology test PASS",
215 onfail="Starting new Att topology test FAIL" )
216
217 def CASE21( self, main ):
218 """
219 This test script Loads a new Topology (Chordal) on CHO setup and balances all switches
220 """
221 import re
222 import time
223 import copy
224
225 main.newTopo = main.params['TOPO2']['topo']
226 main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] )
227 main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] )
228 main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] )
229 main.pingTimeout = 300
230 main.log.report(
231 "Load Chordal topology and Balance all Mininet switches across controllers" )
232 main.log.report(
233 "________________________________________________________________________" )
234 main.case(
235 "Assign and Balance all Mininet switches across controllers" )
236
237 main.step( "Stop any previous Mininet network topology" )
238 stopStatus = main.Mininet1.stopNet(fileName = "topoAtt" )
239
240 main.step( "Start Mininet with Chordal topology" )
241 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
242
243 main.step( "Assign switches to controllers" )
244
245 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
246 main.Mininet1.assignSwController(
247 sw="s" + str( i ),
Hari Krishna10065772015-07-10 15:55:53 -0700248 ip=main.onosIPs )
Hari Krishnac195f3b2015-07-08 20:02:24 -0700249
250 switch_mastership = main.TRUE
251 for i in range( 1, ( main.numMNswitches + 1 ) ):
252 response = main.Mininet1.getSwController( "s" + str( i ) )
253 print( "Response is " + str( response ) )
254 if re.search( "tcp:" + main.onosIPs[0], response ):
255 switch_mastership = switch_mastership and main.TRUE
256 else:
257 switch_mastership = main.FALSE
258
259 if switch_mastership == main.TRUE:
260 main.log.report( "Controller assignment successfull" )
261 else:
262 main.log.report( "Controller assignment failed" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700263
Hari Krishnac195f3b2015-07-08 20:02:24 -0700264 main.step( "Balance devices across controllers" )
265 balanceResult = main.ONOScli1.balanceMasters()
Jon Hall4ba53f02015-07-29 13:07:41 -0700266 # giving some breathing time for ONOS to complete re-balance
Hari Krishnac195f3b2015-07-08 20:02:24 -0700267 time.sleep( 5 )
268
269 case21Result = switch_mastership
270 time.sleep(30)
271 utilities.assert_equals(
272 expect=main.TRUE,
273 actual=case21Result,
274 onpass="Starting new Chordal topology test PASS",
275 onfail="Starting new Chordal topology test FAIL" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700276
Hari Krishnac195f3b2015-07-08 20:02:24 -0700277 def CASE22( self, main ):
278 """
279 This test script Loads a new Topology (Spine) on CHO setup and balances all switches
280 """
281 import re
282 import time
283 import copy
284
285 main.newTopo = main.params['TOPO3']['topo']
286 main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] )
287 main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] )
288 main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] )
289 main.pingTimeout = 600
Jon Hall4ba53f02015-07-29 13:07:41 -0700290
Hari Krishnac195f3b2015-07-08 20:02:24 -0700291 main.log.report(
292 "Load Spine and Leaf topology and Balance all Mininet switches across controllers" )
293 main.log.report(
294 "________________________________________________________________________" )
295 main.case(
296 "Assign and Balance all Mininet switches across controllers" )
297 main.step( "Stop any previous Mininet network topology" )
298 stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" )
299 main.step( "Start Mininet with Spine topology" )
300 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
301 time.sleep(60)
302 main.step( "Assign switches to controllers" )
303
304 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
305 main.Mininet1.assignSwController(
306 sw="s" + str( i ),
Hari Krishna10065772015-07-10 15:55:53 -0700307 ip=main.onosIPs )
Hari Krishnac195f3b2015-07-08 20:02:24 -0700308
309 switch_mastership = main.TRUE
310 for i in range( 1, ( main.numMNswitches + 1 ) ):
311 response = main.Mininet1.getSwController( "s" + str( i ) )
312 print( "Response is " + str( response ) )
313 if re.search( "tcp:" + main.onosIPs[0], response ):
314 switch_mastership = switch_mastership and main.TRUE
315 else:
316 switch_mastership = main.FALSE
Jon Hall4ba53f02015-07-29 13:07:41 -0700317
Hari Krishnac195f3b2015-07-08 20:02:24 -0700318 if switch_mastership == main.TRUE:
319 main.log.report( "Controller assignment successfull" )
320 else:
321 main.log.report( "Controller assignment failed" )
322 time.sleep( 5 )
323
324 main.step( "Balance devices across controllers" )
325 for i in range( int( main.numCtrls ) ):
326 balanceResult = main.ONOScli1.balanceMasters()
327 # giving some breathing time for ONOS to complete re-balance
328 time.sleep( 3 )
329
330 case22Result = switch_mastership
331 time.sleep(60)
332 utilities.assert_equals(
333 expect=main.TRUE,
334 actual=case22Result,
335 onpass="Starting new Spine topology test PASS",
336 onfail="Starting new Spine topology test FAIL" )
337
338 def CASE3( self, main ):
339 """
340 This Test case will be extended to collect and store more data related
341 ONOS state.
342 """
343 import re
344 import copy
345 main.deviceDPIDs = []
346 main.hostMACs = []
347 main.deviceLinks = []
348 main.deviceActiveLinksCount = []
349 main.devicePortsEnabledCount = []
Jon Hall4ba53f02015-07-29 13:07:41 -0700350
Hari Krishnac195f3b2015-07-08 20:02:24 -0700351 main.log.report(
352 "Collect and Store topology details from ONOS before running any Tests" )
353 main.log.report(
354 "____________________________________________________________________" )
355 main.case( "Collect and Store Topology Details from ONOS" )
356 main.step( "Collect and store current number of switches and links" )
357 topology_output = main.ONOScli1.topology()
358 topology_result = main.ONOSbench.getTopology( topology_output )
359 numOnosDevices = topology_result[ 'devices' ]
360 numOnosLinks = topology_result[ 'links' ]
361 topoResult = main.TRUE
362
363 if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks == int(numOnosLinks) ) ):
364 main.step( "Store Device DPIDs" )
365 for i in range( 1, (main.numMNswitches+1) ):
366 main.deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
367 print "Device DPIDs in Store: \n", str( main.deviceDPIDs )
368
369 main.step( "Store Host MACs" )
370 for i in range( 1, ( main.numMNhosts + 1 ) ):
371 main.hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
372 print "Host MACs in Store: \n", str( main.hostMACs )
373 main.MACsDict = {}
374 print "Creating dictionary of DPID and HostMacs"
375 for i in range(len(main.hostMACs)):
376 main.MACsDict[main.deviceDPIDs[i]] = main.hostMACs[i].split('/')[0]
377 print main.MACsDict
378 main.step( "Collect and store all Devices Links" )
379 linksResult = main.ONOScli1.links( jsonFormat=False )
380 ansi_escape = re.compile( r'\x1b[^m]*m' )
381 linksResult = ansi_escape.sub( '', linksResult )
382 linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
383 linksResult = linksResult.splitlines()
384 main.deviceLinks = copy.copy( linksResult )
385 print "Device Links Stored: \n", str( main.deviceLinks )
386 # this will be asserted to check with the params provided count of
387 # links
388 print "Length of Links Store", len( main.deviceLinks )
389
390 main.step( "Collect and store each Device ports enabled Count" )
391 time1 = time.time()
392 for i in xrange(1,(main.numMNswitches + 1), int( main.numCtrls ) ):
393 pool = []
394 for cli in main.CLIs:
395 if i >= main.numMNswitches + 1:
396 break
397 dpid = "of:00000000000000" + format( i,'02x' )
398 t = main.Thread(target = cli.getDevicePortsEnabledCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid])
399 t.start()
400 pool.append(t)
401 i = i + 1
402 main.threadID = main.threadID + 1
403 for thread in pool:
404 thread.join()
405 portResult = thread.result
406 main.devicePortsEnabledCount.append( portResult )
407 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
408 time2 = time.time()
409 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
410
411 main.step( "Collect and store each Device active links Count" )
412 time1 = time.time()
Jon Hall4ba53f02015-07-29 13:07:41 -0700413
Hari Krishnac195f3b2015-07-08 20:02:24 -0700414 for i in xrange( 1,( main.numMNswitches + 1 ), int( main.numCtrls) ):
415 pool = []
416 for cli in main.CLIs:
417 if i >= main.numMNswitches + 1:
418 break
419 dpid = "of:00000000000000" + format( i,'02x' )
420 t = main.Thread( target = cli.getDeviceLinksActiveCount,
421 threadID = main.threadID,
422 name = "getDevicePortsEnabledCount",
423 args = [dpid])
424 t.start()
425 pool.append(t)
426 i = i + 1
427 main.threadID = main.threadID + 1
428 for thread in pool:
429 thread.join()
430 linkCountResult = thread.result
431 main.deviceActiveLinksCount.append( linkCountResult )
432 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
433 time2 = time.time()
434 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
435
436 else:
Jon Hall4ba53f02015-07-29 13:07:41 -0700437 main.log.info("Devices (expected): %s, Links (expected): %s" %
Hari Krishnac195f3b2015-07-08 20:02:24 -0700438 ( str( main.numMNswitches ), str( main.numMNlinks ) ) )
439 main.log.info("Devices (actual): %s, Links (actual): %s" %
440 ( numOnosDevices , numOnosLinks ) )
441 main.log.info("Topology does not match, exiting CHO test...")
442 topoResult = main.FALSE
Jon Hall4ba53f02015-07-29 13:07:41 -0700443 # It's better exit here from running the test
Hari Krishnac195f3b2015-07-08 20:02:24 -0700444 main.cleanup()
445 main.exit()
446
447 # just returning TRUE for now as this one just collects data
448 case3Result = topoResult
449 utilities.assert_equals( expect=main.TRUE, actual=case3Result,
450 onpass="Saving ONOS topology data test PASS",
451 onfail="Saving ONOS topology data test FAIL" )
452
453 def CASE40( self, main ):
454 """
455 Verify Reactive forwarding (Att Topology)
456 """
457 import re
458 import copy
459 import time
460 main.log.report( "Verify Reactive forwarding (Att Topology)" )
461 main.log.report( "______________________________________________" )
462 main.case( "Enable Reactive forwarding and Verify ping all" )
463 main.step( "Enable Reactive forwarding" )
464 installResult = main.TRUE
465 # Activate fwd app
466 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
467 appCheck = main.TRUE
468 pool = []
469 for cli in main.CLIs:
470 t = main.Thread( target=cli.appToIDCheck,
471 name="appToIDCheck-" + str( i ),
472 args=[] )
473 pool.append( t )
474 t.start()
475 for t in pool:
476 t.join()
477 appCheck = appCheck and t.result
478 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
479 onpass="App Ids seem to be correct",
480 onfail="Something is wrong with app Ids" )
481 if appCheck != main.TRUE:
482 main.log.warn( main.CLIs[0].apps() )
483 main.log.warn( main.CLIs[0].appIDs() )
Jon Hall4ba53f02015-07-29 13:07:41 -0700484
Hari Krishnac195f3b2015-07-08 20:02:24 -0700485 time.sleep( 10 )
486
487 main.step( "Verify Pingall" )
488 ping_result = main.FALSE
489 time1 = time.time()
490 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
491 time2 = time.time()
492 timeDiff = round( ( time2 - time1 ), 2 )
493 main.log.report(
494 "Time taken for Ping All: " +
495 str( timeDiff ) +
496 " seconds" )
497
498 if ping_result == main.TRUE:
499 main.log.report( "Pingall Test in Reactive mode successful" )
500 else:
501 main.log.report( "Pingall Test in Reactive mode failed" )
502
503 main.step( "Disable Reactive forwarding" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700504
Hari Krishnac195f3b2015-07-08 20:02:24 -0700505 main.log.info( "Uninstall reactive forwarding app" )
506 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
507 pool = []
508 for cli in main.CLIs:
509 t = main.Thread( target=cli.appToIDCheck,
510 name="appToIDCheck-" + str( i ),
511 args=[] )
512 pool.append( t )
513 t.start()
514
515 for t in pool:
516 t.join()
517 appCheck = appCheck and t.result
518 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
519 onpass="App Ids seem to be correct",
520 onfail="Something is wrong with app Ids" )
521 if appCheck != main.TRUE:
522 main.log.warn( main.CLIs[0].apps() )
523 main.log.warn( main.CLIs[0].appIDs() )
524
525 # Waiting for reative flows to be cleared.
526 time.sleep( 30 )
527 case40Result = installResult and uninstallResult and ping_result
528 utilities.assert_equals( expect=main.TRUE, actual=case40Result,
529 onpass="Reactive Mode Pingall test PASS",
530 onfail="Reactive Mode Pingall test FAIL" )
531
532 def CASE41( self, main ):
533 """
534 Verify Reactive forwarding (Chordal Topology)
535 """
536 import re
537 import copy
538 import time
539 main.log.report( "Verify Reactive forwarding (Chordal Topology)" )
540 main.log.report( "______________________________________________" )
541 main.case( "Enable Reactive forwarding and Verify ping all" )
542 main.step( "Enable Reactive forwarding" )
543 installResult = main.TRUE
544 # Activate fwd app
545 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
546
547 appCheck = main.TRUE
548 pool = []
549 for cli in main.CLIs:
550 t = main.Thread( target=cli.appToIDCheck,
551 name="appToIDCheck-" + str( i ),
552 args=[] )
553 pool.append( t )
554 t.start()
555 for t in pool:
556 t.join()
557 appCheck = appCheck and t.result
558 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
559 onpass="App Ids seem to be correct",
560 onfail="Something is wrong with app Ids" )
561 if appCheck != main.TRUE:
562 main.log.warn( main.CLIs[0].apps() )
563 main.log.warn( main.CLIs[0].appIDs() )
Jon Hall4ba53f02015-07-29 13:07:41 -0700564
Hari Krishnac195f3b2015-07-08 20:02:24 -0700565 time.sleep( 10 )
566
567 main.step( "Verify Pingall" )
568 ping_result = main.FALSE
569 time1 = time.time()
570 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
571 time2 = time.time()
572 timeDiff = round( ( time2 - time1 ), 2 )
573 main.log.report(
574 "Time taken for Ping All: " +
575 str( timeDiff ) +
576 " seconds" )
577
578 if ping_result == main.TRUE:
579 main.log.report( "Pingall Test in Reactive mode successful" )
580 else:
581 main.log.report( "Pingall Test in Reactive mode failed" )
582
583 main.step( "Disable Reactive forwarding" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700584
Hari Krishnac195f3b2015-07-08 20:02:24 -0700585 main.log.info( "Uninstall reactive forwarding app" )
586 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
587 pool = []
588 for cli in main.CLIs:
589 t = main.Thread( target=cli.appToIDCheck,
590 name="appToIDCheck-" + str( i ),
591 args=[] )
592 pool.append( t )
593 t.start()
594
595 for t in pool:
596 t.join()
597 appCheck = appCheck and t.result
598 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
599 onpass="App Ids seem to be correct",
600 onfail="Something is wrong with app Ids" )
601 if appCheck != main.TRUE:
602 main.log.warn( main.CLIs[0].apps() )
603 main.log.warn( main.CLIs[0].appIDs() )
604
605 # Waiting for reative flows to be cleared.
606 time.sleep( 30 )
607 case41Result = installResult and uninstallResult and ping_result
608 utilities.assert_equals( expect=main.TRUE, actual=case41Result,
609 onpass="Reactive Mode Pingall test PASS",
610 onfail="Reactive Mode Pingall test FAIL" )
611
612 def CASE42( self, main ):
613 """
614 Verify Reactive forwarding (Spine Topology)
615 """
616 import re
617 import copy
618 import time
619 main.log.report( "Verify Reactive forwarding (Spine Topology)" )
620 main.log.report( "______________________________________________" )
621 main.case( "Enable Reactive forwarding and Verify ping all" )
622 main.step( "Enable Reactive forwarding" )
623 installResult = main.TRUE
624 # Activate fwd app
625 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
626
627 appCheck = main.TRUE
628 pool = []
629 for cli in main.CLIs:
630 t = main.Thread( target=cli.appToIDCheck,
631 name="appToIDCheck-" + str( i ),
632 args=[] )
633 pool.append( t )
634 t.start()
635 for t in pool:
636 t.join()
637 appCheck = appCheck and t.result
638 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
639 onpass="App Ids seem to be correct",
640 onfail="Something is wrong with app Ids" )
641 if appCheck != main.TRUE:
642 main.log.warn( main.CLIs[0].apps() )
643 main.log.warn( main.CLIs[0].appIDs() )
Jon Hall4ba53f02015-07-29 13:07:41 -0700644
Hari Krishnac195f3b2015-07-08 20:02:24 -0700645 time.sleep( 10 )
646
647 main.step( "Verify Pingall" )
648 ping_result = main.FALSE
649 time1 = time.time()
650 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
651 time2 = time.time()
652 timeDiff = round( ( time2 - time1 ), 2 )
653 main.log.report(
654 "Time taken for Ping All: " +
655 str( timeDiff ) +
656 " seconds" )
657
658 if ping_result == main.TRUE:
659 main.log.report( "Pingall Test in Reactive mode successful" )
660 else:
661 main.log.report( "Pingall Test in Reactive mode failed" )
662
663 main.step( "Disable Reactive forwarding" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700664
Hari Krishnac195f3b2015-07-08 20:02:24 -0700665 main.log.info( "Uninstall reactive forwarding app" )
666 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
667 pool = []
668 for cli in main.CLIs:
669 t = main.Thread( target=cli.appToIDCheck,
670 name="appToIDCheck-" + str( i ),
671 args=[] )
672 pool.append( t )
673 t.start()
674
675 for t in pool:
676 t.join()
677 appCheck = appCheck and t.result
678 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
679 onpass="App Ids seem to be correct",
680 onfail="Something is wrong with app Ids" )
681 if appCheck != main.TRUE:
682 main.log.warn( main.CLIs[0].apps() )
683 main.log.warn( main.CLIs[0].appIDs() )
684
685 # Waiting for reative flows to be cleared.
686 time.sleep( 30 )
687 case42Result = installResult and uninstallResult and ping_result
688 utilities.assert_equals( expect=main.TRUE, actual=case42Result,
689 onpass="Reactive Mode Pingall test PASS",
690 onfail="Reactive Mode Pingall test FAIL" )
691
692 def CASE5( self, main ):
693 """
694 Compare current ONOS topology with reference data
695 """
696 import re
Jon Hall4ba53f02015-07-29 13:07:41 -0700697
Hari Krishnac195f3b2015-07-08 20:02:24 -0700698 devicesDPIDTemp = []
699 hostMACsTemp = []
700 deviceLinksTemp = []
701 deviceActiveLinksCountTemp = []
702 devicePortsEnabledCountTemp = []
703
704 main.log.report(
705 "Compare ONOS topology with reference data in Stores" )
706 main.log.report( "__________________________________________________" )
707 main.case( "Compare ONOS topology with reference data" )
708
709 main.step( "Compare current Device ports enabled with reference" )
710 time1 = time.time()
711 for i in xrange( 1,(main.numMNswitches + 1), int( main.numCtrls ) ):
712 pool = []
713 for cli in main.CLIs:
714 if i >= main.numMNswitches + 1:
715 break
716 dpid = "of:00000000000000" + format( i,'02x' )
717 t = main.Thread(target = cli.getDevicePortsEnabledCount,
718 threadID = main.threadID,
719 name = "getDevicePortsEnabledCount",
720 args = [dpid])
721 t.start()
722 pool.append(t)
723 i = i + 1
724 main.threadID = main.threadID + 1
725 for thread in pool:
726 thread.join()
727 portResult = thread.result
728 #portTemp = re.split( r'\t+', portResult )
729 #portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
730 devicePortsEnabledCountTemp.append( portResult )
731
732 time2 = time.time()
733 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
734 main.log.info (
Jon Hall4ba53f02015-07-29 13:07:41 -0700735 "Device Enabled ports EXPECTED: %s" %
736 str( main.devicePortsEnabledCount ) )
Hari Krishnac195f3b2015-07-08 20:02:24 -0700737 main.log.info (
Jon Hall4ba53f02015-07-29 13:07:41 -0700738 "Device Enabled ports ACTUAL: %s" %
Hari Krishnac195f3b2015-07-08 20:02:24 -0700739 str( devicePortsEnabledCountTemp ) )
Jon Hall4ba53f02015-07-29 13:07:41 -0700740
Hari Krishnac195f3b2015-07-08 20:02:24 -0700741 if ( cmp( main.devicePortsEnabledCount,
742 devicePortsEnabledCountTemp ) == 0 ):
743 stepResult1 = main.TRUE
744 else:
745 stepResult1 = main.FALSE
746
747 main.step( "Compare Device active links with reference" )
748 time1 = time.time()
749 for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ):
750 pool = []
751 for cli in main.CLIs:
752 if i >= main.numMNswitches + 1:
753 break
754 dpid = "of:00000000000000" + format( i,'02x' )
755 t = main.Thread(target = cli.getDeviceLinksActiveCount,
756 threadID = main.threadID,
757 name = "getDeviceLinksActiveCount",
758 args = [dpid])
759 t.start()
760 pool.append(t)
761 i = i + 1
762 main.threadID = main.threadID + 1
763 for thread in pool:
764 thread.join()
765 linkCountResult = thread.result
766 #linkCountTemp = re.split( r'\t+', linkCountResult )
767 #linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
768 deviceActiveLinksCountTemp.append( linkCountResult )
769
770 time2 = time.time()
771 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
772 main.log.info (
773 "Device Active links EXPECTED: %s" %
774 str( main.deviceActiveLinksCount ) )
775 main.log.info (
776 "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
777 if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
778 stepResult2 = main.TRUE
779 else:
780 stepResult2 = main.FALSE
781
782 """
783 place holder for comparing devices, hosts, paths and intents if required.
784 Links and ports data would be incorrect with out devices anyways.
785 """
786 case5Result = ( stepResult1 and stepResult2 )
787 utilities.assert_equals( expect=main.TRUE, actual=case5Result,
788 onpass="Compare Topology test PASS",
789 onfail="Compare Topology test FAIL" )
790
791 def CASE60( self ):
792 """
793 Install 300 host intents and verify ping all (Att Topology)
794 """
795 main.log.report( "Add 300 host intents and verify pingall (Att Topology)" )
796 main.log.report( "_______________________________________" )
797 import itertools
798 import time
799 main.case( "Install 300 host intents" )
800 main.step( "Add host Intents" )
801 intentResult = main.TRUE
Jon Hall4ba53f02015-07-29 13:07:41 -0700802 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
803
Hari Krishnac195f3b2015-07-08 20:02:24 -0700804 intentIdList = []
805 time1 = time.time()
806 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
807 pool = []
808 for cli in main.CLIs:
809 if i >= len( hostCombos ):
810 break
811 t = main.Thread( target=cli.addHostIntent,
812 threadID=main.threadID,
813 name="addHostIntent",
814 args=[hostCombos[i][0],hostCombos[i][1]])
815 pool.append(t)
816 t.start()
817 i = i + 1
818 main.threadID = main.threadID + 1
819 for thread in pool:
820 thread.join()
821 intentIdList.append(thread.result)
822 time2 = time.time()
823 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
824
825 intentResult = main.TRUE
Hari Krishna6185fc12015-07-13 15:42:31 -0700826 intentsJson = main.ONOScli1.intents()
Hari Krishnac195f3b2015-07-08 20:02:24 -0700827 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
828 intentsJson = intentsJson)
829 print "len of intent ID", str(len(intentIdList))
830 print "len of intent state results", str(len(getIntentStateResult))
831 print getIntentStateResult
832 # Takes awhile for all the onos to get the intents
833 time.sleep( 30 )
834 """intentState = main.TRUE
835 for i in getIntentStateResult:
836 if getIntentStateResult.get( 'state' ) != 'INSTALLED':
837 """
838
839
840 main.step( "Verify Ping across all hosts" )
841 pingResult = main.FALSE
842 time1 = time.time()
843 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
844 time2 = time.time()
845 timeDiff = round( ( time2 - time1 ), 2 )
846 main.log.report(
847 "Time taken for Ping All: " +
848 str( timeDiff ) +
849 " seconds" )
850 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
851 onpass="PING ALL PASS",
852 onfail="PING ALL FAIL" )
853
854 case60Result = ( intentResult and pingResult )
Hari Krishnac195f3b2015-07-08 20:02:24 -0700855 utilities.assert_equals(
856 expect=main.TRUE,
857 actual=case60Result,
858 onpass="Install 300 Host Intents and Ping All test PASS",
859 onfail="Install 300 Host Intents and Ping All test FAIL" )
860
861 def CASE61( self ):
862 """
863 Install 600 host intents and verify ping all for Chordal Topology
864 """
865 main.log.report( "Add 600 host intents and verify pingall (Chordal Topo)" )
866 main.log.report( "_______________________________________" )
867 import itertools
Jon Hall4ba53f02015-07-29 13:07:41 -0700868
Hari Krishnac195f3b2015-07-08 20:02:24 -0700869 main.case( "Install 600 host intents" )
870 main.step( "Add host Intents" )
871 intentResult = main.TRUE
Jon Hall4ba53f02015-07-29 13:07:41 -0700872 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
873
Hari Krishnac195f3b2015-07-08 20:02:24 -0700874 intentIdList = []
875 time1 = time.time()
Jon Hall4ba53f02015-07-29 13:07:41 -0700876
Hari Krishnac195f3b2015-07-08 20:02:24 -0700877 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
878 pool = []
879 for cli in main.CLIs:
880 if i >= len( hostCombos ):
881 break
882 t = main.Thread( target=cli.addHostIntent,
883 threadID=main.threadID,
884 name="addHostIntent",
885 args=[hostCombos[i][0],hostCombos[i][1]])
886 pool.append(t)
887 t.start()
888 i = i + 1
889 main.threadID = main.threadID + 1
890 for thread in pool:
891 thread.join()
892 intentIdList.append(thread.result)
893 time2 = time.time()
894 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
895 intentResult = main.TRUE
Hari Krishna6185fc12015-07-13 15:42:31 -0700896 intentsJson = main.ONOScli1.intents()
Hari Krishnac195f3b2015-07-08 20:02:24 -0700897 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
898 intentsJson = intentsJson)
899 print getIntentStateResult
900
901 main.step( "Verify Ping across all hosts" )
902 pingResult = main.FALSE
903 time1 = time.time()
904 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
905 time2 = time.time()
906 timeDiff = round( ( time2 - time1 ), 2 )
907 main.log.report(
908 "Time taken for Ping All: " +
909 str( timeDiff ) +
910 " seconds" )
911 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
912 onpass="PING ALL PASS",
913 onfail="PING ALL FAIL" )
914
915 case14Result = ( intentResult and pingResult )
Jon Hall4ba53f02015-07-29 13:07:41 -0700916
Hari Krishnac195f3b2015-07-08 20:02:24 -0700917 utilities.assert_equals(
918 expect=main.TRUE,
919 actual=case14Result,
920 onpass="Install 300 Host Intents and Ping All test PASS",
921 onfail="Install 300 Host Intents and Ping All test FAIL" )
922
923 def CASE62( self ):
924 """
925 Install 2278 host intents and verify ping all for Spine Topology
926 """
927 main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" )
928 main.log.report( "_______________________________________" )
929 import itertools
Jon Hall4ba53f02015-07-29 13:07:41 -0700930
Hari Krishnac195f3b2015-07-08 20:02:24 -0700931 main.case( "Install 2278 host intents" )
932 main.step( "Add host Intents" )
933 intentResult = main.TRUE
Jon Hall4ba53f02015-07-29 13:07:41 -0700934 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
Hari Krishnac195f3b2015-07-08 20:02:24 -0700935 main.pingTimeout = 300
936 intentIdList = []
937 time1 = time.time()
938 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
939 pool = []
940 for cli in main.CLIs:
941 if i >= len( hostCombos ):
942 break
943 t = main.Thread( target=cli.addHostIntent,
944 threadID=main.threadID,
945 name="addHostIntent",
946 args=[hostCombos[i][0],hostCombos[i][1]])
947 pool.append(t)
948 t.start()
949 i = i + 1
950 main.threadID = main.threadID + 1
951 for thread in pool:
952 thread.join()
953 intentIdList.append(thread.result)
954 time2 = time.time()
955 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
956 intentResult = main.TRUE
Hari Krishna6185fc12015-07-13 15:42:31 -0700957 intentsJson = main.ONOScli1.intents()
Hari Krishnac195f3b2015-07-08 20:02:24 -0700958 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
959 intentsJson = intentsJson)
960 print getIntentStateResult
961
962 main.step( "Verify Ping across all hosts" )
963 pingResult = main.FALSE
964 time1 = time.time()
965 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
966 time2 = time.time()
967 timeDiff = round( ( time2 - time1 ), 2 )
968 main.log.report(
969 "Time taken for Ping All: " +
970 str( timeDiff ) +
971 " seconds" )
972 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
973 onpass="PING ALL PASS",
974 onfail="PING ALL FAIL" )
975
976 case15Result = ( intentResult and pingResult )
Jon Hall4ba53f02015-07-29 13:07:41 -0700977
Hari Krishnac195f3b2015-07-08 20:02:24 -0700978 utilities.assert_equals(
979 expect=main.TRUE,
980 actual=case15Result,
981 onpass="Install 2278 Host Intents and Ping All test PASS",
982 onfail="Install 2278 Host Intents and Ping All test FAIL" )
983
984 def CASE70( self, main ):
985 """
986 Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
987 """
988 import random
989 main.randomLink1 = []
990 main.randomLink2 = []
991 main.randomLink3 = []
992 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
993 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
994 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
995 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
996 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
997 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
998 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
999 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1000
1001 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
1002 main.log.report( "___________________________________________________________________________" )
1003 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1004 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
1005 if ( int( switchLinksToToggle ) ==
1006 0 or int( switchLinksToToggle ) > 5 ):
1007 main.log.info( "Please check your PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
1008 #main.cleanup()
1009 #main.exit()
1010 else:
1011 main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
1012
1013 main.step( "Cut links on Core devices using user provided range" )
1014 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1015 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1016 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
1017 for i in range( int( switchLinksToToggle ) ):
1018 main.Mininet1.link(
1019 END1=link1End1,
1020 END2=main.randomLink1[ i ],
1021 OPTION="down" )
1022 time.sleep( link_sleep )
1023 main.Mininet1.link(
1024 END1=link2End1,
1025 END2=main.randomLink2[ i ],
1026 OPTION="down" )
1027 time.sleep( link_sleep )
1028 main.Mininet1.link(
1029 END1=link3End1,
1030 END2=main.randomLink3[ i ],
1031 OPTION="down" )
1032 time.sleep( link_sleep )
1033
Hari Krishna6185fc12015-07-13 15:42:31 -07001034 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001035 linkDown = main.ONOSbench.checkStatus(
1036 topology_output, main.numMNswitches, str(
1037 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
1038 utilities.assert_equals(
1039 expect=main.TRUE,
1040 actual=linkDown,
1041 onpass="Link Down discovered properly",
1042 onfail="Link down was not discovered in " +
1043 str( link_sleep ) +
1044 " seconds" )
1045
1046 main.step( "Verify Ping across all hosts" )
1047 pingResultLinkDown = main.FALSE
1048 time1 = time.time()
1049 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout )
1050 time2 = time.time()
1051 timeDiff = round( ( time2 - time1 ), 2 )
1052 main.log.report(
1053 "Time taken for Ping All: " +
1054 str( timeDiff ) +
1055 " seconds" )
1056 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1057 onpass="PING ALL PASS",
1058 onfail="PING ALL FAIL" )
1059
1060 caseResult70 = linkDown and pingResultLinkDown
1061 utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
1062 onpass="Random Link cut Test PASS",
1063 onfail="Random Link cut Test FAIL" )
1064
1065 def CASE80( self, main ):
1066 """
1067 Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
1068 """
1069 import random
1070 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1071 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1072 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1073 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1074 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
1075
1076 main.log.report(
1077 "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
1078 main.log.report(
1079 "__________________________________________________________________" )
1080 main.case(
1081 "Host intents - Bring the core links up that are down and verify ping all" )
1082 main.step( "Bring randomly cut links on Core devices up" )
1083 for i in range( int( switchLinksToToggle ) ):
1084 main.Mininet1.link(
1085 END1=link1End1,
1086 END2=main.randomLink1[ i ],
1087 OPTION="up" )
1088 time.sleep( link_sleep )
1089 main.Mininet1.link(
1090 END1=link2End1,
1091 END2=main.randomLink2[ i ],
1092 OPTION="up" )
1093 time.sleep( link_sleep )
1094 main.Mininet1.link(
1095 END1=link3End1,
1096 END2=main.randomLink3[ i ],
1097 OPTION="up" )
1098 time.sleep( link_sleep )
1099
Hari Krishna6185fc12015-07-13 15:42:31 -07001100 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001101 linkUp = main.ONOSbench.checkStatus(
1102 topology_output,
1103 main.numMNswitches,
1104 str( main.numMNlinks ) )
1105 utilities.assert_equals(
1106 expect=main.TRUE,
1107 actual=linkUp,
1108 onpass="Link up discovered properly",
1109 onfail="Link up was not discovered in " +
1110 str( link_sleep ) +
1111 " seconds" )
1112
1113 main.step( "Verify Ping across all hosts" )
1114 pingResultLinkUp = main.FALSE
1115 time1 = time.time()
1116 pingResultLinkUp = main.Mininet1.pingall( timeout=main.pingTimeout )
1117 time2 = time.time()
1118 timeDiff = round( ( time2 - time1 ), 2 )
1119 main.log.report(
1120 "Time taken for Ping All: " +
1121 str( timeDiff ) +
1122 " seconds" )
1123 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1124 onpass="PING ALL PASS",
1125 onfail="PING ALL FAIL" )
1126
1127 caseResult80 = linkUp and pingResultLinkUp
1128 utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
1129 onpass="Link Up Test PASS",
1130 onfail="Link Up Test FAIL" )
1131
1132 def CASE71( self, main ):
1133 """
1134 Randomly bring some core links down and verify ping all ( Point Intents-Att Topo)
1135 """
1136 import random
1137 main.randomLink1 = []
1138 main.randomLink2 = []
1139 main.randomLink3 = []
1140 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1141 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1142 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1143 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1144 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1145 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1146 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
1147 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1148
1149 main.log.report( "Randomly bring some core links down and verify ping all (Point Intents-Att Topo)" )
1150 main.log.report( "___________________________________________________________________________" )
1151 main.case( "Point intents - Randomly bring some core links down and verify ping all" )
1152 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
1153 if ( int( switchLinksToToggle ) ==
1154 0 or int( switchLinksToToggle ) > 5 ):
1155 main.log.info( "Please check your PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
1156 #main.cleanup()
1157 #main.exit()
1158 else:
1159 main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
1160
1161 main.step( "Cut links on Core devices using user provided range" )
1162 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1163 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1164 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
1165 for i in range( int( switchLinksToToggle ) ):
1166 main.Mininet1.link(
1167 END1=link1End1,
1168 END2=main.randomLink1[ i ],
1169 OPTION="down" )
1170 time.sleep( link_sleep )
1171 main.Mininet1.link(
1172 END1=link2End1,
1173 END2=main.randomLink2[ i ],
1174 OPTION="down" )
1175 time.sleep( link_sleep )
1176 main.Mininet1.link(
1177 END1=link3End1,
1178 END2=main.randomLink3[ i ],
1179 OPTION="down" )
1180 time.sleep( link_sleep )
1181
Hari Krishna6185fc12015-07-13 15:42:31 -07001182 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001183 linkDown = main.ONOSbench.checkStatus(
1184 topology_output, main.numMNswitches, str(
1185 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
1186 utilities.assert_equals(
1187 expect=main.TRUE,
1188 actual=linkDown,
1189 onpass="Link Down discovered properly",
1190 onfail="Link down was not discovered in " +
1191 str( link_sleep ) +
1192 " seconds" )
1193
1194 main.step( "Verify Ping across all hosts" )
1195 pingResultLinkDown = main.FALSE
1196 time1 = time.time()
1197 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
1198 time2 = time.time()
1199 timeDiff = round( ( time2 - time1 ), 2 )
1200 main.log.report(
1201 "Time taken for Ping All: " +
1202 str( timeDiff ) +
1203 " seconds" )
1204 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1205 onpass="PING ALL PASS",
1206 onfail="PING ALL FAIL" )
1207
1208 caseResult71 = linkDown and pingResultLinkDown
1209 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
1210 onpass="Random Link cut Test PASS",
1211 onfail="Random Link cut Test FAIL" )
1212
1213 def CASE81( self, main ):
1214 """
1215 Bring the core links up that are down and verify ping all ( Point Intents-Att Topo )
1216 """
1217 import random
1218 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1219 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1220 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1221 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1222 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
1223
1224 main.log.report(
1225 "Bring the core links up that are down and verify ping all ( Point Intents-Att Topo" )
1226 main.log.report(
1227 "__________________________________________________________________" )
1228 main.case(
1229 "Point intents - Bring the core links up that are down and verify ping all" )
1230 main.step( "Bring randomly cut links on Core devices up" )
1231 for i in range( int( switchLinksToToggle ) ):
1232 main.Mininet1.link(
1233 END1=link1End1,
1234 END2=main.randomLink1[ i ],
1235 OPTION="up" )
1236 time.sleep( link_sleep )
1237 main.Mininet1.link(
1238 END1=link2End1,
1239 END2=main.randomLink2[ i ],
1240 OPTION="up" )
1241 time.sleep( link_sleep )
1242 main.Mininet1.link(
1243 END1=link3End1,
1244 END2=main.randomLink3[ i ],
1245 OPTION="up" )
1246 time.sleep( link_sleep )
1247
Hari Krishna6185fc12015-07-13 15:42:31 -07001248 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001249 linkUp = main.ONOSbench.checkStatus(
1250 topology_output,
1251 main.numMNswitches,
1252 str( main.numMNlinks ) )
1253 utilities.assert_equals(
1254 expect=main.TRUE,
1255 actual=linkUp,
1256 onpass="Link up discovered properly",
1257 onfail="Link up was not discovered in " +
1258 str( link_sleep ) +
1259 " seconds" )
1260
1261 main.step( "Verify Ping across all hosts" )
1262 pingResultLinkUp = main.FALSE
1263 time1 = time.time()
1264 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout )
1265 time2 = time.time()
1266 timeDiff = round( ( time2 - time1 ), 2 )
1267 main.log.report(
1268 "Time taken for Ping All: " +
1269 str( timeDiff ) +
1270 " seconds" )
1271 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1272 onpass="PING ALL PASS",
1273 onfail="PING ALL FAIL" )
1274
1275 caseResult81 = linkUp and pingResultLinkUp
1276 utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
1277 onpass="Link Up Test PASS",
1278 onfail="Link Up Test FAIL" )
1279
1280 def CASE72( self, main ):
1281 """
1282 Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
1283 """
1284 import random
Jon Hall4ba53f02015-07-29 13:07:41 -07001285 import itertools
Hari Krishnac195f3b2015-07-08 20:02:24 -07001286 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Jon Hall4ba53f02015-07-29 13:07:41 -07001287
Hari Krishnac195f3b2015-07-08 20:02:24 -07001288 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
1289 main.log.report( "___________________________________________________________________________" )
1290 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1291 switches = []
1292 switchesComb = []
1293 for i in range( main.numMNswitches ):
1294 switches.append('s%d'%(i+1))
1295 switchesLinksComb = list(itertools.combinations(switches,2))
1296 main.randomLinks = random.sample(switchesLinksComb, 5 )
1297 print main.randomLinks
1298 main.step( "Cut links on random devices" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001299
Hari Krishnac195f3b2015-07-08 20:02:24 -07001300 for switch in main.randomLinks:
1301 main.Mininet1.link(
1302 END1=switch[0],
1303 END2=switch[1],
1304 OPTION="down")
1305 time.sleep( link_sleep )
1306
Hari Krishna6185fc12015-07-13 15:42:31 -07001307 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001308 linkDown = main.ONOSbench.checkStatus(
1309 topology_output, main.numMNswitches, str(
1310 int( main.numMNlinks ) - 5 * 2 ) )
1311 utilities.assert_equals(
1312 expect=main.TRUE,
1313 actual=linkDown,
1314 onpass="Link Down discovered properly",
1315 onfail="Link down was not discovered in " +
1316 str( link_sleep ) +
1317 " seconds" )
1318
1319 main.step( "Verify Ping across all hosts" )
1320 pingResultLinkDown = main.FALSE
1321 time1 = time.time()
1322 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1323 time2 = time.time()
1324 timeDiff = round( ( time2 - time1 ), 2 )
1325 main.log.report(
1326 "Time taken for Ping All: " +
1327 str( timeDiff ) +
1328 " seconds" )
1329 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1330 onpass="PING ALL PASS",
1331 onfail="PING ALL FAIL" )
1332
1333 caseResult71 = pingResultLinkDown
1334 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
1335 onpass="Random Link cut Test PASS",
1336 onfail="Random Link cut Test FAIL" )
1337
1338 def CASE82( self, main ):
1339 """
1340 Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
1341 """
1342 import random
1343 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Jon Hall4ba53f02015-07-29 13:07:41 -07001344
Hari Krishnac195f3b2015-07-08 20:02:24 -07001345 main.log.report(
1346 "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
1347 main.log.report(
1348 "__________________________________________________________________" )
1349 main.case(
1350 "Host intents - Bring the core links up that are down and verify ping all" )
1351 main.step( "Bring randomly cut links on devices up" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001352
Hari Krishnac195f3b2015-07-08 20:02:24 -07001353 for switch in main.randomLinks:
1354 main.Mininet1.link(
1355 END1=switch[0],
1356 END2=switch[1],
1357 OPTION="up")
1358 time.sleep( link_sleep )
1359
Hari Krishna6185fc12015-07-13 15:42:31 -07001360 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001361 linkUp = main.ONOSbench.checkStatus(
1362 topology_output,
1363 main.numMNswitches,
1364 str( main.numMNlinks ) )
1365 utilities.assert_equals(
1366 expect=main.TRUE,
1367 actual=linkUp,
1368 onpass="Link up discovered properly",
1369 onfail="Link up was not discovered in " +
1370 str( link_sleep ) +
1371 " seconds" )
1372
1373 main.step( "Verify Ping across all hosts" )
1374 pingResultLinkUp = main.FALSE
1375 time1 = time.time()
1376 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1377 time2 = time.time()
1378 timeDiff = round( ( time2 - time1 ), 2 )
1379 main.log.report(
1380 "Time taken for Ping All: " +
1381 str( timeDiff ) +
1382 " seconds" )
1383 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1384 onpass="PING ALL PASS",
1385 onfail="PING ALL FAIL" )
1386
1387 caseResult82 = linkUp and pingResultLinkUp
1388 utilities.assert_equals( expect=main.TRUE, actual=caseResult82,
1389 onpass="Link Up Test PASS",
1390 onfail="Link Up Test FAIL" )
1391
1392 def CASE73( self, main ):
1393 """
1394 Randomly bring some links down and verify ping all ( Point Intents-Chordal Topo)
1395 """
1396 import random
Jon Hall4ba53f02015-07-29 13:07:41 -07001397 import itertools
Hari Krishnac195f3b2015-07-08 20:02:24 -07001398 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Jon Hall4ba53f02015-07-29 13:07:41 -07001399
Hari Krishnac195f3b2015-07-08 20:02:24 -07001400 main.log.report( "Randomly bring some core links down and verify ping all ( Point Intents-Chordal Topo)" )
1401 main.log.report( "___________________________________________________________________________" )
1402 main.case( "Point intents - Randomly bring some core links down and verify ping all" )
1403 switches = []
1404 switchesComb = []
1405 for i in range( main.numMNswitches ):
1406 switches.append('s%d'%(i+1))
1407 switchesLinksComb = list(itertools.combinations(switches,2))
1408 main.randomLinks = random.sample(switchesLinksComb, 5 )
1409 print main.randomLinks
1410 main.step( "Cut links on random devices" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001411
Hari Krishnac195f3b2015-07-08 20:02:24 -07001412 for switch in main.randomLinks:
1413 main.Mininet1.link(
1414 END1=switch[0],
1415 END2=switch[1],
1416 OPTION="down")
1417 time.sleep( link_sleep )
1418
Hari Krishna6185fc12015-07-13 15:42:31 -07001419 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001420 linkDown = main.ONOSbench.checkStatus(
1421 topology_output, main.numMNswitches, str(
1422 int( main.numMNlinks ) - 5 * 2 ) )
1423 utilities.assert_equals(
1424 expect=main.TRUE,
1425 actual=linkDown,
1426 onpass="Link Down discovered properly",
1427 onfail="Link down was not discovered in " +
1428 str( link_sleep ) +
1429 " seconds" )
1430
1431 main.step( "Verify Ping across all hosts" )
1432 pingResultLinkDown = main.FALSE
1433 time1 = time.time()
1434 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1435 time2 = time.time()
1436 timeDiff = round( ( time2 - time1 ), 2 )
1437 main.log.report(
1438 "Time taken for Ping All: " +
1439 str( timeDiff ) +
1440 " seconds" )
1441 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1442 onpass="PING ALL PASS",
1443 onfail="PING ALL FAIL" )
1444
1445 caseResult73 = pingResultLinkDown
1446 utilities.assert_equals( expect=main.TRUE, actual=caseResult73,
1447 onpass="Random Link cut Test PASS",
1448 onfail="Random Link cut Test FAIL" )
1449
1450 def CASE83( self, main ):
1451 """
1452 Bring the core links up that are down and verify ping all ( Point Intents Chordal Topo )
1453 """
1454 import random
1455 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Jon Hall4ba53f02015-07-29 13:07:41 -07001456
Hari Krishnac195f3b2015-07-08 20:02:24 -07001457 main.log.report(
1458 "Bring the core links up that are down and verify ping all ( Point Intents-Chordal Topo" )
1459 main.log.report(
1460 "__________________________________________________________________" )
1461 main.case(
1462 "Point intents - Bring the core links up that are down and verify ping all" )
1463 main.step( "Bring randomly cut links on devices up" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001464
Hari Krishnac195f3b2015-07-08 20:02:24 -07001465 for switch in main.randomLinks:
1466 main.Mininet1.link(
1467 END1=switch[0],
1468 END2=switch[1],
1469 OPTION="up")
1470 time.sleep( link_sleep )
1471
Hari Krishna6185fc12015-07-13 15:42:31 -07001472 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001473 linkUp = main.ONOSbench.checkStatus(
1474 topology_output,
1475 main.numMNswitches,
1476 str( main.numMNlinks ) )
1477 utilities.assert_equals(
1478 expect=main.TRUE,
1479 actual=linkUp,
1480 onpass="Link up discovered properly",
1481 onfail="Link up was not discovered in " +
1482 str( link_sleep ) +
1483 " seconds" )
1484
1485 main.step( "Verify Ping across all hosts" )
1486 pingResultLinkUp = main.FALSE
1487 time1 = time.time()
1488 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1489 time2 = time.time()
1490 timeDiff = round( ( time2 - time1 ), 2 )
1491 main.log.report(
1492 "Time taken for Ping All: " +
1493 str( timeDiff ) +
1494 " seconds" )
1495 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1496 onpass="PING ALL PASS",
1497 onfail="PING ALL FAIL" )
1498
1499 caseResult83 = linkUp and pingResultLinkUp
1500 utilities.assert_equals( expect=main.TRUE, actual=caseResult83,
1501 onpass="Link Up Test PASS",
1502 onfail="Link Up Test FAIL" )
1503
1504 def CASE74( self, main ):
1505 """
1506 Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo)
1507 """
1508 import random
1509 main.randomLink1 = []
1510 main.randomLink2 = []
1511 main.randomLink3 = []
1512 main.randomLink4 = []
1513 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1514 link1End2top = main.params[ 'SPINECORELINKS' ][ 'linkS9top' ].split( ',' )
1515 link1End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS9bot' ].split( ',' )
1516 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1517 link2End2top = main.params[ 'SPINECORELINKS' ][ 'linkS10top' ].split( ',' )
1518 link2End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS10bot' ].split( ',' )
1519 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1520 main.pingTimeout = 400
Jon Hall4ba53f02015-07-29 13:07:41 -07001521
Hari Krishnac195f3b2015-07-08 20:02:24 -07001522 main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" )
1523 main.log.report( "___________________________________________________________________________" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001524
Hari Krishnac195f3b2015-07-08 20:02:24 -07001525 linkIndex = range(4)
Hari Krishna6185fc12015-07-13 15:42:31 -07001526 linkIndexS9 = random.sample(linkIndex,1)[0]
Hari Krishnac195f3b2015-07-08 20:02:24 -07001527 linkIndex.remove(linkIndexS9)
1528 linkIndexS10 = random.sample(linkIndex,1)[0]
1529 main.randomLink1 = link1End2top[linkIndexS9]
1530 main.randomLink2 = link2End2top[linkIndexS10]
1531 main.randomLink3 = random.sample(link1End2bot,1)[0]
1532 main.randomLink4 = random.sample(link2End2bot,1)[0]
Hari Krishna6185fc12015-07-13 15:42:31 -07001533
1534 # Work around for link state propagation delay. Added some sleep time.
Hari Krishnac195f3b2015-07-08 20:02:24 -07001535 # main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="down" )
1536 # main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="down" )
1537 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="down" )
1538 time.sleep( link_sleep )
1539 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="down" )
1540 time.sleep( link_sleep )
1541
Hari Krishna6185fc12015-07-13 15:42:31 -07001542 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001543 linkDown = main.ONOSbench.checkStatus(
1544 topology_output, main.numMNswitches, str(
1545 int( main.numMNlinks ) - 8 ))
1546 utilities.assert_equals(
1547 expect=main.TRUE,
1548 actual=linkDown,
1549 onpass="Link Down discovered properly",
1550 onfail="Link down was not discovered in " +
1551 str( link_sleep ) +
1552 " seconds" )
1553
1554 main.step( "Verify Ping across all hosts" )
1555 pingResultLinkDown = main.FALSE
1556 time1 = time.time()
1557 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1558 time2 = time.time()
1559 timeDiff = round( ( time2 - time1 ), 2 )
1560 main.log.report(
1561 "Time taken for Ping All: " +
1562 str( timeDiff ) +
1563 " seconds" )
1564 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1565 onpass="PING ALL PASS",
1566 onfail="PING ALL FAIL" )
1567
1568 caseResult74 = linkDown and pingResultLinkDown
1569 utilities.assert_equals( expect=main.TRUE, actual=caseResult74,
1570 onpass="Random Link cut Test PASS",
1571 onfail="Random Link cut Test FAIL" )
1572
1573 def CASE84( self, main ):
1574 """
1575 Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo )
1576 """
1577 import random
1578 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1579 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1580 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1581 main.log.report(
1582 "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" )
1583 main.log.report(
1584 "__________________________________________________________________" )
1585 main.case(
1586 "Host intents - Bring the core links up that are down and verify ping all" )
Hari Krishna6185fc12015-07-13 15:42:31 -07001587
1588 # Work around for link state propagation delay. Added some sleep time.
1589 # main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="up" )
1590 # main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="up" )
Hari Krishnac195f3b2015-07-08 20:02:24 -07001591 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="up" )
1592 time.sleep( link_sleep )
1593 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="up" )
1594 time.sleep( link_sleep )
1595
Hari Krishna6185fc12015-07-13 15:42:31 -07001596 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001597 linkUp = main.ONOSbench.checkStatus(
1598 topology_output,
1599 main.numMNswitches,
1600 str( main.numMNlinks ) )
1601 utilities.assert_equals(
1602 expect=main.TRUE,
1603 actual=linkUp,
1604 onpass="Link up discovered properly",
1605 onfail="Link up was not discovered in " +
1606 str( link_sleep ) +
1607 " seconds" )
1608
1609 main.step( "Verify Ping across all hosts" )
1610 pingResultLinkUp = main.FALSE
1611 time1 = time.time()
1612 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1613 time2 = time.time()
1614 timeDiff = round( ( time2 - time1 ), 2 )
1615 main.log.report(
1616 "Time taken for Ping All: " +
1617 str( timeDiff ) +
1618 " seconds" )
1619 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1620 onpass="PING ALL PASS",
1621 onfail="PING ALL FAIL" )
1622
1623 caseResult84 = linkUp and pingResultLinkUp
1624 utilities.assert_equals( expect=main.TRUE, actual=caseResult84,
1625 onpass="Link Up Test PASS",
1626 onfail="Link Up Test FAIL" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001627
Hari Krishnac195f3b2015-07-08 20:02:24 -07001628 def CASE90( self ):
1629 """
1630 Install 600 point intents and verify ping all (Att Topology)
1631 """
1632 main.log.report( "Add 600 point intents and verify pingall (Att Topology)" )
1633 main.log.report( "_______________________________________" )
1634 import itertools
1635 import time
1636 main.case( "Install 600 point intents" )
1637 main.step( "Add point Intents" )
1638 intentResult = main.TRUE
Jon Hall4ba53f02015-07-29 13:07:41 -07001639 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1640
Hari Krishnac195f3b2015-07-08 20:02:24 -07001641 intentIdList = []
1642 time1 = time.time()
1643 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1644 pool = []
1645 for cli in main.CLIs:
1646 if i >= len( deviceCombos ):
1647 break
1648 t = main.Thread( target=cli.addPointIntent,
1649 threadID=main.threadID,
1650 name="addPointIntent",
1651 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4",main.MACsDict.get(deviceCombos[i][0]),main.MACsDict.get(deviceCombos[i][1])])
1652 pool.append(t)
Hari Krishnac195f3b2015-07-08 20:02:24 -07001653 t.start()
1654 i = i + 1
1655 main.threadID = main.threadID + 1
1656 for thread in pool:
1657 thread.join()
1658 intentIdList.append(thread.result)
1659 time2 = time.time()
Hari Krishna6185fc12015-07-13 15:42:31 -07001660 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
Hari Krishnac195f3b2015-07-08 20:02:24 -07001661 intentResult = main.TRUE
Hari Krishna6185fc12015-07-13 15:42:31 -07001662 intentsJson = main.ONOScli1.intents()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001663 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1664 intentsJson = intentsJson)
1665 print getIntentStateResult
1666 # Takes awhile for all the onos to get the intents
1667 time.sleep(60)
1668 main.step( "Verify Ping across all hosts" )
1669 pingResult = main.FALSE
1670 time1 = time.time()
1671 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1672 time2 = time.time()
1673 timeDiff = round( ( time2 - time1 ), 2 )
1674 main.log.report(
1675 "Time taken for Ping All: " +
1676 str( timeDiff ) +
1677 " seconds" )
1678 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1679 onpass="PING tALL PASS",
1680 onfail="PING ALL FAIL" )
1681
1682 case90Result = ( intentResult and pingResult )
Jon Hall4ba53f02015-07-29 13:07:41 -07001683
Hari Krishnac195f3b2015-07-08 20:02:24 -07001684 utilities.assert_equals(
1685 expect=main.TRUE,
1686 actual=case90Result,
1687 onpass="Install 600 point Intents and Ping All test PASS",
1688 onfail="Install 600 point Intents and Ping All test FAIL" )
1689
1690 def CASE91( self ):
1691 """
1692 Install 600 point intents and verify ping all (Chordal Topology)
1693 """
1694 main.log.report( "Add 600 point intents and verify pingall (Chordal Topology)" )
1695 main.log.report( "_______________________________________" )
1696 import itertools
1697 import time
1698 main.case( "Install 600 point intents" )
1699 main.step( "Add point Intents" )
1700 intentResult = main.TRUE
Jon Hall4ba53f02015-07-29 13:07:41 -07001701 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1702
Hari Krishnac195f3b2015-07-08 20:02:24 -07001703 intentIdList = []
1704 time1 = time.time()
1705 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1706 pool = []
1707 for cli in main.CLIs:
1708 if i >= len( deviceCombos ):
1709 break
1710 t = main.Thread( target=cli.addPointIntent,
1711 threadID=main.threadID,
1712 name="addPointIntent",
1713 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1714 pool.append(t)
1715 #time.sleep(1)
1716 t.start()
1717 i = i + 1
1718 main.threadID = main.threadID + 1
1719 for thread in pool:
1720 thread.join()
1721 intentIdList.append(thread.result)
1722 time2 = time.time()
Hari Krishna6185fc12015-07-13 15:42:31 -07001723 main.log.info( "Time for adding point intents: %2f seconds" %(time2-time1) )
Hari Krishnac195f3b2015-07-08 20:02:24 -07001724 intentResult = main.TRUE
Hari Krishna6185fc12015-07-13 15:42:31 -07001725 intentsJson = main.ONOScli1.intents()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001726 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1727 intentsJson = intentsJson)
1728 print getIntentStateResult
1729 # Takes awhile for all the onos to get the intents
1730 time.sleep(30)
1731 main.step( "Verify Ping across all hosts" )
1732 pingResult = main.FALSE
1733 time1 = time.time()
1734 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1735 time2 = time.time()
1736 timeDiff = round( ( time2 - time1 ), 2 )
1737 main.log.report(
1738 "Time taken for Ping All: " +
1739 str( timeDiff ) +
1740 " seconds" )
1741 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1742 onpass="PING ALL PASS",
1743 onfail="PING ALL FAIL" )
1744
1745 case91Result = ( intentResult and pingResult )
Jon Hall4ba53f02015-07-29 13:07:41 -07001746
Hari Krishnac195f3b2015-07-08 20:02:24 -07001747 utilities.assert_equals(
1748 expect=main.TRUE,
1749 actual=case91Result,
1750 onpass="Install 600 point Intents and Ping All test PASS",
1751 onfail="Install 600 point Intents and Ping All test FAIL" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001752
Hari Krishnac195f3b2015-07-08 20:02:24 -07001753 def CASE92( self ):
1754 """
1755 Install 4556 point intents and verify ping all (Spine Topology)
1756 """
1757 main.log.report( "Add 4556 point intents and verify pingall (Spine Topology)" )
1758 main.log.report( "_______________________________________" )
1759 import itertools
1760 import time
1761 main.case( "Install 4556 point intents" )
1762 main.step( "Add point Intents" )
1763 intentResult = main.TRUE
1764 main.pingTimeout = 600
1765 for i in range(len(main.hostMACs)):
1766 main.MACsDict[main.deviceDPIDs[i+10]] = main.hostMACs[i].split('/')[0]
1767 print main.MACsDict
1768 deviceCombos = list( itertools.permutations( main.deviceDPIDs[10:], 2 ) )
1769 intentIdList = []
1770 time1 = time.time()
1771 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1772 pool = []
1773 for cli in main.CLIs:
1774 if i >= len( deviceCombos ):
1775 break
1776 t = main.Thread( target=cli.addPointIntent,
1777 threadID=main.threadID,
1778 name="addPointIntent",
1779 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1780 pool.append(t)
1781 #time.sleep(1)
1782 t.start()
1783 i = i + 1
1784 main.threadID = main.threadID + 1
1785 for thread in pool:
1786 thread.join()
1787 intentIdList.append(thread.result)
1788 time2 = time.time()
Hari Krishna6185fc12015-07-13 15:42:31 -07001789 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
Hari Krishnac195f3b2015-07-08 20:02:24 -07001790 intentResult = main.TRUE
Hari Krishna6185fc12015-07-13 15:42:31 -07001791 intentsJson = main.ONOScli1.intents()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001792 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1793 intentsJson = intentsJson)
1794 #print getIntentStateResult
1795 # Takes awhile for all the onos to get the intents
1796 time.sleep(60)
1797 main.step( "Verify Ping across all hosts" )
1798 pingResult = main.FALSE
1799 time1 = time.time()
1800 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1801 time2 = time.time()
1802 timeDiff = round( ( time2 - time1 ), 2 )
1803 main.log.report(
1804 "Time taken for Ping All: " +
1805 str( timeDiff ) +
1806 " seconds" )
1807 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1808 onpass="PING ALL PASS",
1809 onfail="PING ALL FAIL" )
1810
1811 case92Result = ( intentResult and pingResult )
Jon Hall4ba53f02015-07-29 13:07:41 -07001812
Hari Krishnac195f3b2015-07-08 20:02:24 -07001813 utilities.assert_equals(
1814 expect=main.TRUE,
1815 actual=case92Result,
1816 onpass="Install 4556 point Intents and Ping All test PASS",
1817 onfail="Install 4556 point Intents and Ping All test FAIL" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001818
Hari Krishnac195f3b2015-07-08 20:02:24 -07001819 def CASE93( self ):
1820 """
1821 Install multi-single point intents and verify Ping all works
1822 for att topology
1823 """
1824 import copy
1825 import time
1826 main.log.report( "Install multi-single point intents and verify Ping all" )
1827 main.log.report( "___________________________________________" )
1828 main.case( "Install multi-single point intents and Ping all" )
1829 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1830 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1831 intentIdList = []
1832 print "MACsDict", main.MACsDict
1833 time1 = time.time()
1834 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1835 pool = []
1836 for cli in main.CLIs:
1837 egressDevice = deviceDPIDsCopy[i]
1838 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1839 ingressDeviceList.remove(egressDevice)
1840 if i >= len( deviceDPIDsCopy ):
1841 break
1842 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1843 threadID=main.threadID,
1844 name="addMultipointToSinglepointIntent",
1845 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1846 pool.append(t)
1847 #time.sleep(1)
1848 t.start()
1849 i = i + 1
1850 main.threadID = main.threadID + 1
1851 for thread in pool:
1852 thread.join()
1853 intentIdList.append(thread.result)
1854 time2 = time.time()
1855 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1856 time.sleep(30)
1857 print "getting all intents ID"
1858 intentIdTemp = main.ONOScli1.getAllIntentsId()
1859 print intentIdTemp
1860 print len(intentIdList)
1861 print intentIdList
1862 checkIntentStateResult = main.TRUE
1863 print "Checking intents state"
1864 checkIntentStateResult = main.ONOScli1.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1865 checkIntentStateResult = main.ONOScli2.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1866 checkIntentStateResult = main.ONOScli3.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1867 checkIntentStateResult = main.ONOScli4.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1868 checkIntentStateResult = main.ONOScli5.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
Jon Hall4ba53f02015-07-29 13:07:41 -07001869
Hari Krishnac195f3b2015-07-08 20:02:24 -07001870 if checkIntentStateResult:
1871 main.log.info( "All intents are installed correctly " )
1872
1873 print "Checking flows state "
1874 checkFlowsState = main.ONOScli1.checkFlowsState()
1875 time.sleep(50)
1876 main.step( "Verify Ping across all hosts" )
1877 pingResult = main.FALSE
1878 time1 = time.time()
1879 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1880 time2 = time.time()
1881 timeDiff = round( ( time2 - time1 ), 2 )
1882 main.log.report(
1883 "Time taken for Ping All: " +
1884 str( timeDiff ) +
1885 " seconds" )
1886 checkFlowsState = main.ONOScli1.checkFlowsState()
1887 case93Result = pingResult
1888 utilities.assert_equals(
1889 expect=main.TRUE,
1890 actual=case93Result,
1891 onpass="Install 25 multi to single point Intents and Ping All test PASS",
1892 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001893
Hari Krishnac195f3b2015-07-08 20:02:24 -07001894 def CASE94( self ):
1895 """
1896 Install multi-single point intents and verify Ping all works
1897 for Chordal topology
1898 """
1899 import copy
1900 import time
1901 main.log.report( "Install multi-single point intents and verify Ping all" )
1902 main.log.report( "___________________________________________" )
1903 main.case( "Install multi-single point intents and Ping all" )
1904 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1905 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1906 intentIdList = []
1907 print "MACsDict", main.MACsDict
1908 time1 = time.time()
1909 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1910 pool = []
1911 for cli in main.CLIs:
1912 egressDevice = deviceDPIDsCopy[i]
1913 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1914 ingressDeviceList.remove(egressDevice)
1915 if i >= len( deviceDPIDsCopy ):
1916 break
1917 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1918 threadID=main.threadID,
1919 name="addMultipointToSinglepointIntent",
1920 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1921 pool.append(t)
1922 #time.sleep(1)
1923 t.start()
1924 i = i + 1
1925 main.threadID = main.threadID + 1
1926 for thread in pool:
1927 thread.join()
1928 intentIdList.append(thread.result)
1929 time2 = time.time()
Jon Hall4ba53f02015-07-29 13:07:41 -07001930 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
Hari Krishnac195f3b2015-07-08 20:02:24 -07001931 time.sleep(5)
1932 main.step( "Verify Ping across all hosts" )
1933 pingResult = main.FALSE
1934 time1 = time.time()
1935 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1936 time2 = time.time()
1937 timeDiff = round( ( time2 - time1 ), 2 )
1938 main.log.report(
1939 "Time taken for Ping All: " +
1940 str( timeDiff ) +
1941 " seconds" )
1942
1943 case94Result = pingResult
1944 utilities.assert_equals(
1945 expect=main.TRUE,
1946 actual=case94Result,
1947 onpass="Install 25 multi to single point Intents and Ping All test PASS",
1948 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001949
Hari Krishnac195f3b2015-07-08 20:02:24 -07001950 #def CASE95 multi-single point intent for Spine
1951
1952 def CASE96( self ):
1953 """
1954 Install single-multi point intents and verify Ping all works
1955 for att topology
1956 """
1957 import copy
1958 main.log.report( "Install single-multi point intents and verify Ping all" )
1959 main.log.report( "___________________________________________" )
1960 main.case( "Install single-multi point intents and Ping all" )
1961 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1962 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
1963 intentIdList = []
1964 print "MACsDict", main.MACsDict
1965 time1 = time.time()
1966 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1967 pool = []
1968 for cli in main.CLIs:
1969 ingressDevice = deviceDPIDsCopy[i]
1970 egressDeviceList = copy.copy(deviceDPIDsCopy)
1971 egressDeviceList.remove(ingressDevice)
1972 if i >= len( deviceDPIDsCopy ):
1973 break
1974 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
1975 threadID=main.threadID,
1976 name="addSinglepointToMultipointIntent",
1977 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice)])
1978 pool.append(t)
1979 #time.sleep(1)
1980 t.start()
1981 i = i + 1
1982 main.threadID = main.threadID + 1
1983 for thread in pool:
1984 thread.join()
1985 intentIdList.append(thread.result)
1986 time2 = time.time()
Jon Hall4ba53f02015-07-29 13:07:41 -07001987 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
Hari Krishnac195f3b2015-07-08 20:02:24 -07001988 time.sleep(5)
1989 main.step( "Verify Ping across all hosts" )
1990 pingResult = main.FALSE
1991 time1 = time.time()
1992 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1993 time2 = time.time()
1994 timeDiff = round( ( time2 - time1 ), 2 )
1995 main.log.report(
1996 "Time taken for Ping All: " +
1997 str( timeDiff ) +
1998 " seconds" )
1999
2000 case96Result = pingResult
2001 utilities.assert_equals(
2002 expect=main.TRUE,
2003 actual=case96Result,
2004 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2005 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
2006
2007 def CASE97( self ):
2008 """
2009 Install single-multi point intents and verify Ping all works
2010 for Chordal topology
2011 """
2012 import copy
2013 main.log.report( "Install single-multi point intents and verify Ping all" )
2014 main.log.report( "___________________________________________" )
2015 main.case( "Install single-multi point intents and Ping all" )
2016 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
2017 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
2018 intentIdList = []
2019 print "MACsDict", main.MACsDict
2020 time1 = time.time()
2021 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2022 pool = []
2023 for cli in main.CLIs:
2024 ingressDevice = deviceDPIDsCopy[i]
2025 egressDeviceList = copy.copy(deviceDPIDsCopy)
2026 egressDeviceList.remove(ingressDevice)
2027 if i >= len( deviceDPIDsCopy ):
2028 break
2029 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2030 threadID=main.threadID,
2031 name="addSinglepointToMultipointIntent",
2032 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice),''])
2033 pool.append(t)
2034 #time.sleep(1)
2035 t.start()
2036 i = i + 1
2037 main.threadID = main.threadID + 1
2038 for thread in pool:
2039 thread.join()
2040 intentIdList.append(thread.result)
2041 time2 = time.time()
Jon Hall4ba53f02015-07-29 13:07:41 -07002042 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
Hari Krishnac195f3b2015-07-08 20:02:24 -07002043 time.sleep(5)
2044 main.step( "Verify Ping across all hosts" )
2045 pingResult = main.FALSE
2046 time1 = time.time()
2047 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
2048 time2 = time.time()
2049 timeDiff = round( ( time2 - time1 ), 2 )
2050 main.log.report(
2051 "Time taken for Ping All: " +
2052 str( timeDiff ) +
2053 " seconds" )
2054
2055 case97Result = pingResult
2056 utilities.assert_equals(
2057 expect=main.TRUE,
2058 actual=case97Result,
2059 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2060 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
2061
2062 def CASE98( self ):
2063 """
2064 Install single-multi point intents and verify Ping all works
2065 for Spine topology
2066 """
2067 import copy
2068 main.log.report( "Install single-multi point intents and verify Ping all" )
2069 main.log.report( "___________________________________________" )
2070 main.case( "Install single-multi point intents and Ping all" )
2071 deviceDPIDsCopy = copy.copy( main.deviceDPIDs )
2072 deviceDPIDsCopy = deviceDPIDsCopy[ 10: ]
2073 portEgressList = [ '1' ]*(len(deviceDPIDsCopy) - 1)
2074 intentIdList = []
2075 MACsDictCopy = {}
2076 for i in range( len( deviceDPIDsCopy ) ):
2077 MACsDictCopy[ deviceDPIDsCopy[ i ] ] = main.hostMACs[i].split( '/' )[ 0 ]
2078
2079 print "deviceDPIDsCopy", deviceDPIDsCopy
2080 print ""
2081 print "MACsDictCopy", MACsDictCopy
2082 time1 = time.time()
2083 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2084 pool = []
2085 for cli in main.CLIs:
2086 if i >= len( deviceDPIDsCopy ):
2087 break
2088 ingressDevice = deviceDPIDsCopy[i]
2089 egressDeviceList = copy.copy(deviceDPIDsCopy)
2090 egressDeviceList.remove(ingressDevice)
2091 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2092 threadID=main.threadID,
2093 name="addSinglepointToMultipointIntent",
2094 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',MACsDictCopy.get(ingressDevice),''])
2095 pool.append(t)
2096 #time.sleep(1)
2097 t.start()
2098 i = i + 1
2099 main.threadID = main.threadID + 1
2100 for thread in pool:
2101 thread.join()
2102 intentIdList.append(thread.result)
2103 time2 = time.time()
Jon Hall4ba53f02015-07-29 13:07:41 -07002104 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
Hari Krishnac195f3b2015-07-08 20:02:24 -07002105 time.sleep(5)
2106 main.step( "Verify Ping across all hosts" )
2107 pingResult = main.FALSE
2108 time1 = time.time()
2109 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
2110 time2 = time.time()
2111 timeDiff = round( ( time2 - time1 ), 2 )
2112 main.log.report(
2113 "Time taken for Ping All: " +
2114 str( timeDiff ) +
2115 " seconds" )
2116
2117 case98Result = pingResult
2118 utilities.assert_equals(
2119 expect=main.TRUE,
2120 actual=case98Result,
2121 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2122 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
2123
2124 def CASE10( self ):
2125 import time
2126 """
2127 Remove all Intents
2128 """
2129 main.log.report( "Remove all intents that were installed previously" )
2130 main.log.report( "______________________________________________" )
2131 main.log.info( "Remove all intents" )
2132 main.case( "Removing intents" )
2133 main.step( "Obtain the intent id's first" )
2134 intentsList = main.ONOScli1.getAllIntentIds()
2135 ansi_escape = re.compile( r'\x1b[^m]*m' )
2136 intentsList = ansi_escape.sub( '', intentsList )
2137 intentsList = intentsList.replace(
2138 " onos:intents | grep id=",
2139 "" ).replace(
2140 "id=",
2141 "" ).replace(
2142 "\r\r",
2143 "" )
2144 intentsList = intentsList.splitlines()
Hari Krishnac195f3b2015-07-08 20:02:24 -07002145 intentIdList = []
2146 step1Result = main.TRUE
2147 moreIntents = main.TRUE
2148 removeIntentCount = 0
2149 intentsCount = len(intentsList)
2150 main.log.info ( "Current number of intents: " + str(intentsCount) )
2151 if ( len( intentsList ) > 1 ):
2152 results = main.TRUE
2153 main.log.info("Removing intent...")
2154 while moreIntents:
Hari Krishna6185fc12015-07-13 15:42:31 -07002155 # This is a work around only: cycle through intents removal for up to 5 times.
Hari Krishnac195f3b2015-07-08 20:02:24 -07002156 if removeIntentCount == 5:
2157 break
2158 removeIntentCount = removeIntentCount + 1
2159 intentsList1 = main.ONOScli1.getAllIntentIds()
2160 if len( intentsList1 ) == 0:
2161 break
2162 ansi_escape = re.compile( r'\x1b[^m]*m' )
2163 intentsList1 = ansi_escape.sub( '', intentsList1 )
2164 intentsList1 = intentsList1.replace(
2165 " onos:intents | grep id=",
2166 "" ).replace(
2167 " state=",
2168 "" ).replace(
2169 "\r\r",
2170 "" )
2171 intentsList1 = intentsList1.splitlines()
Hari Krishnac195f3b2015-07-08 20:02:24 -07002172 main.log.info ( "Round %d intents to remove: " %(removeIntentCount) )
2173 print intentsList1
2174 intentIdList1 = []
2175 if ( len( intentsList1 ) > 0 ):
2176 moreIntents = main.TRUE
2177 for i in range( len( intentsList1 ) ):
2178 intentsTemp1 = intentsList1[ i ].split( ',' )
2179 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
2180 main.log.info ( "Leftover Intent IDs: " + str(intentIdList1) )
2181 main.log.info ( "Length of Leftover Intents list: " + str(len(intentIdList1)) )
2182 time1 = time.time()
2183 for i in xrange( 0, len( intentIdList1 ), int(main.numCtrls) ):
2184 pool = []
2185 for cli in main.CLIs:
2186 if i >= len( intentIdList1 ):
2187 break
2188 t = main.Thread( target=cli.removeIntent,
2189 threadID=main.threadID,
2190 name="removeIntent",
2191 args=[intentIdList1[i],'org.onosproject.cli',False,False])
2192 pool.append(t)
2193 t.start()
2194 i = i + 1
2195 main.threadID = main.threadID + 1
2196 for thread in pool:
2197 thread.join()
2198 intentIdList.append(thread.result)
2199 #time.sleep(2)
2200 time2 = time.time()
2201 main.log.info("Time for removing host intents: %2f seconds" %(time2-time1))
2202 time.sleep(10)
2203 main.log.info("Purging WITHDRAWN Intents")
Hari Krishna6185fc12015-07-13 15:42:31 -07002204 purgeResult = main.ONOScli1.purgeWithdrawnIntents()
Hari Krishnac195f3b2015-07-08 20:02:24 -07002205 else:
2206 time.sleep(10)
2207 if len( main.ONOScli1.intents()):
2208 continue
2209 break
2210 time.sleep(10)
2211 else:
2212 print "Removed %d intents" %(intentsCount)
2213 step1Result = main.TRUE
2214 else:
2215 print "No Intent IDs found in Intents list: ", intentsList
2216 step1Result = main.FALSE
2217
2218 print main.ONOScli1.intents()
2219 caseResult10 = step1Result
2220 utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
2221 onpass="Intent removal test successful",
2222 onfail="Intent removal test failed" )
2223
2224 def CASE12( self, main ):
2225 """
2226 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
2227 """
2228 import re
2229 import copy
2230 import time
2231
Hari Krishnac195f3b2015-07-08 20:02:24 -07002232 threadID = 0
2233
2234 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
2235 main.log.report( "_____________________________________________________" )
2236 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
2237 main.step( "Enable intent based Reactive forwarding" )
2238 installResult = main.FALSE
2239 feature = "onos-app-ifwd"
Hari Krishna6185fc12015-07-13 15:42:31 -07002240
Hari Krishnac195f3b2015-07-08 20:02:24 -07002241 pool = []
2242 time1 = time.time()
2243 for cli,feature in main.CLIs:
2244 t = main.Thread(target=cli,threadID=threadID,
2245 name="featureInstall",args=[feature])
2246 pool.append(t)
2247 t.start()
2248 threadID = threadID + 1
Jon Hall4ba53f02015-07-29 13:07:41 -07002249
Hari Krishnac195f3b2015-07-08 20:02:24 -07002250 results = []
2251 for thread in pool:
2252 thread.join()
2253 results.append(thread.result)
2254 time2 = time.time()
Jon Hall4ba53f02015-07-29 13:07:41 -07002255
Hari Krishnac195f3b2015-07-08 20:02:24 -07002256 if( all(result == main.TRUE for result in results) == False):
2257 main.log.info("Did not install onos-app-ifwd feature properly")
2258 #main.cleanup()
2259 #main.exit()
2260 else:
2261 main.log.info("Successful feature:install onos-app-ifwd")
2262 installResult = main.TRUE
2263 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
Jon Hall4ba53f02015-07-29 13:07:41 -07002264
Hari Krishnac195f3b2015-07-08 20:02:24 -07002265 main.step( "Verify Pingall" )
2266 ping_result = main.FALSE
2267 time1 = time.time()
2268 ping_result = main.Mininet1.pingall(timeout=600)
2269 time2 = time.time()
2270 timeDiff = round( ( time2 - time1 ), 2 )
2271 main.log.report(
2272 "Time taken for Ping All: " +
2273 str( timeDiff ) +
2274 " seconds" )
Jon Hall4ba53f02015-07-29 13:07:41 -07002275
Hari Krishnac195f3b2015-07-08 20:02:24 -07002276 if ping_result == main.TRUE:
2277 main.log.report( "Pingall Test in Reactive mode successful" )
2278 else:
2279 main.log.report( "Pingall Test in Reactive mode failed" )
2280
2281 main.step( "Disable Intent based Reactive forwarding" )
2282 uninstallResult = main.FALSE
Jon Hall4ba53f02015-07-29 13:07:41 -07002283
Hari Krishnac195f3b2015-07-08 20:02:24 -07002284 pool = []
2285 time1 = time.time()
2286 for cli,feature in main.CLIs:
2287 t = main.Thread(target=cli,threadID=threadID,
2288 name="featureUninstall",args=[feature])
2289 pool.append(t)
2290 t.start()
2291 threadID = threadID + 1
Jon Hall4ba53f02015-07-29 13:07:41 -07002292
Hari Krishnac195f3b2015-07-08 20:02:24 -07002293 results = []
2294 for thread in pool:
2295 thread.join()
2296 results.append(thread.result)
2297 time2 = time.time()
Jon Hall4ba53f02015-07-29 13:07:41 -07002298
Hari Krishnac195f3b2015-07-08 20:02:24 -07002299 if( all(result == main.TRUE for result in results) == False):
2300 main.log.info("Did not uninstall onos-app-ifwd feature properly")
2301 uninstallResult = main.FALSE
2302 #main.cleanup()
2303 #main.exit()
2304 else:
2305 main.log.info("Successful feature:uninstall onos-app-ifwd")
2306 uninstallResult = main.TRUE
2307 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
2308
2309 # Waiting for reative flows to be cleared.
2310 time.sleep( 10 )
2311
2312 case11Result = installResult and ping_result and uninstallResult
2313 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
2314 onpass="Intent based Reactive forwarding Pingall test PASS",
2315 onfail="Intent based Reactive forwarding Pingall test FAIL" )