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