blob: 6e58b68a534589ed808432ef628a034104ab34c2 [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']
GlennRCc6cd2a62015-08-10 16:08:22 -0700179 mininetDir = main.Mininet1.home + "/custom/"
180 topoPath = main.testDir + "/" + main.TEST + "/Dependencies/" + main.newTopo
181 main.ONOSbench.secureCopy(main.Mininet1.user_name, main.Mininet1.ip_address, topoPath, mininetDir, direction="to")
182 topoPath = mininetDir + main.newTopo
183 startStatus = main.Mininet1.startNet(topoFile = topoPath)
Jon Hall4ba53f02015-07-29 13:07:41 -0700184
Hari Krishnac195f3b2015-07-08 20:02:24 -0700185 main.step( "Assign switches to controllers" )
186 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
187 main.Mininet1.assignSwController(
188 sw="s" + str( i ),
Hari Krishna10065772015-07-10 15:55:53 -0700189 ip=main.onosIPs )
Hari Krishnac195f3b2015-07-08 20:02:24 -0700190
191 switch_mastership = main.TRUE
192 for i in range( 1, ( main.numMNswitches + 1 ) ):
193 response = main.Mininet1.getSwController( "s" + str( i ) )
194 print( "Response is " + str( response ) )
195 if re.search( "tcp:" + main.onosIPs[0], response ):
196 switch_mastership = switch_mastership and main.TRUE
197 else:
198 switch_mastership = main.FALSE
199
200 if switch_mastership == main.TRUE:
201 main.log.report( "Controller assignment successfull" )
202 else:
203 main.log.report( "Controller assignment failed" )
204
205 time.sleep(30) # waiting here to make sure topology converges across all nodes
206
207 main.step( "Balance devices across controllers" )
208 balanceResult = main.ONOScli1.balanceMasters()
Jon Hall4ba53f02015-07-29 13:07:41 -0700209 # giving some breathing time for ONOS to complete re-balance
Hari Krishnac195f3b2015-07-08 20:02:24 -0700210 time.sleep( 5 )
211
212 topology_output = main.ONOScli1.topology()
213 topology_result = main.ONOSbench.getTopology( topology_output )
214 case2Result = ( switch_mastership and startStatus )
215 utilities.assert_equals(
216 expect=main.TRUE,
217 actual=case2Result,
218 onpass="Starting new Att topology test PASS",
219 onfail="Starting new Att topology test FAIL" )
220
221 def CASE21( self, main ):
222 """
223 This test script Loads a new Topology (Chordal) on CHO setup and balances all switches
224 """
225 import re
226 import time
227 import copy
228
229 main.newTopo = main.params['TOPO2']['topo']
230 main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] )
231 main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] )
232 main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] )
233 main.pingTimeout = 300
234 main.log.report(
235 "Load Chordal topology and Balance all Mininet switches across controllers" )
236 main.log.report(
237 "________________________________________________________________________" )
238 main.case(
239 "Assign and Balance all Mininet switches across controllers" )
240
241 main.step( "Stop any previous Mininet network topology" )
242 stopStatus = main.Mininet1.stopNet(fileName = "topoAtt" )
243
GlennRCc6cd2a62015-08-10 16:08:22 -0700244 main.step("Start Mininet with Chordal topology")
245 mininetDir = main.Mininet1.home + "/custom/"
246 topoPath = main.testDir + "/" + main.TEST + "/Dependencies/" + main.newTopo
247 main.ONOSbench.secureCopy(main.Mininet1.user_name, main.Mininet1.ip_address, topoPath, mininetDir, direction="to")
248 topoPath = mininetDir + main.newTopo
249 startStatus = main.Mininet1.startNet(topoFile = topoPath)
Hari Krishnac195f3b2015-07-08 20:02:24 -0700250
251 main.step( "Assign switches to controllers" )
252
253 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
254 main.Mininet1.assignSwController(
255 sw="s" + str( i ),
Hari Krishna10065772015-07-10 15:55:53 -0700256 ip=main.onosIPs )
Hari Krishnac195f3b2015-07-08 20:02:24 -0700257
258 switch_mastership = main.TRUE
259 for i in range( 1, ( main.numMNswitches + 1 ) ):
260 response = main.Mininet1.getSwController( "s" + str( i ) )
261 print( "Response is " + str( response ) )
262 if re.search( "tcp:" + main.onosIPs[0], response ):
263 switch_mastership = switch_mastership and main.TRUE
264 else:
265 switch_mastership = main.FALSE
266
267 if switch_mastership == main.TRUE:
268 main.log.report( "Controller assignment successfull" )
269 else:
270 main.log.report( "Controller assignment failed" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700271
Hari Krishnac195f3b2015-07-08 20:02:24 -0700272 main.step( "Balance devices across controllers" )
273 balanceResult = main.ONOScli1.balanceMasters()
Jon Hall4ba53f02015-07-29 13:07:41 -0700274 # giving some breathing time for ONOS to complete re-balance
Hari Krishnac195f3b2015-07-08 20:02:24 -0700275 time.sleep( 5 )
276
277 case21Result = switch_mastership
278 time.sleep(30)
279 utilities.assert_equals(
280 expect=main.TRUE,
281 actual=case21Result,
282 onpass="Starting new Chordal topology test PASS",
283 onfail="Starting new Chordal topology test FAIL" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700284
Hari Krishnac195f3b2015-07-08 20:02:24 -0700285 def CASE22( self, main ):
286 """
287 This test script Loads a new Topology (Spine) on CHO setup and balances all switches
288 """
289 import re
290 import time
291 import copy
292
293 main.newTopo = main.params['TOPO3']['topo']
294 main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] )
295 main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] )
296 main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] )
297 main.pingTimeout = 600
Jon Hall4ba53f02015-07-29 13:07:41 -0700298
Hari Krishnac195f3b2015-07-08 20:02:24 -0700299 main.log.report(
300 "Load Spine and Leaf topology and Balance all Mininet switches across controllers" )
301 main.log.report(
302 "________________________________________________________________________" )
303 main.case(
304 "Assign and Balance all Mininet switches across controllers" )
305 main.step( "Stop any previous Mininet network topology" )
306 stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" )
GlennRCc6cd2a62015-08-10 16:08:22 -0700307
308 main.step("Start Mininet with Spine topology")
309 mininetDir = main.Mininet1.home + "/custom/"
310 topoPath = main.testDir + "/" + main.TEST + "/Dependencies/" + main.newTopo
311 main.ONOSbench.secureCopy(main.Mininet1.user_name, main.Mininet1.ip_address, topoPath, mininetDir, direction="to")
312 topoPath = mininetDir + main.newTopo
313 startStatus = main.Mininet1.startNet(topoFile = topoPath)
314
Hari Krishnac195f3b2015-07-08 20:02:24 -0700315 time.sleep(60)
316 main.step( "Assign switches to controllers" )
317
318 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
319 main.Mininet1.assignSwController(
320 sw="s" + str( i ),
Hari Krishna10065772015-07-10 15:55:53 -0700321 ip=main.onosIPs )
Hari Krishnac195f3b2015-07-08 20:02:24 -0700322
323 switch_mastership = main.TRUE
324 for i in range( 1, ( main.numMNswitches + 1 ) ):
325 response = main.Mininet1.getSwController( "s" + str( i ) )
326 print( "Response is " + str( response ) )
327 if re.search( "tcp:" + main.onosIPs[0], response ):
328 switch_mastership = switch_mastership and main.TRUE
329 else:
330 switch_mastership = main.FALSE
Jon Hall4ba53f02015-07-29 13:07:41 -0700331
Hari Krishnac195f3b2015-07-08 20:02:24 -0700332 if switch_mastership == main.TRUE:
333 main.log.report( "Controller assignment successfull" )
334 else:
335 main.log.report( "Controller assignment failed" )
336 time.sleep( 5 )
337
338 main.step( "Balance devices across controllers" )
339 for i in range( int( main.numCtrls ) ):
340 balanceResult = main.ONOScli1.balanceMasters()
341 # giving some breathing time for ONOS to complete re-balance
342 time.sleep( 3 )
343
344 case22Result = switch_mastership
345 time.sleep(60)
346 utilities.assert_equals(
347 expect=main.TRUE,
348 actual=case22Result,
349 onpass="Starting new Spine topology test PASS",
350 onfail="Starting new Spine topology test FAIL" )
351
352 def CASE3( self, main ):
353 """
354 This Test case will be extended to collect and store more data related
355 ONOS state.
356 """
357 import re
358 import copy
359 main.deviceDPIDs = []
360 main.hostMACs = []
361 main.deviceLinks = []
362 main.deviceActiveLinksCount = []
363 main.devicePortsEnabledCount = []
Jon Hall4ba53f02015-07-29 13:07:41 -0700364
Hari Krishnac195f3b2015-07-08 20:02:24 -0700365 main.log.report(
366 "Collect and Store topology details from ONOS before running any Tests" )
367 main.log.report(
368 "____________________________________________________________________" )
369 main.case( "Collect and Store Topology Details from ONOS" )
370 main.step( "Collect and store current number of switches and links" )
371 topology_output = main.ONOScli1.topology()
372 topology_result = main.ONOSbench.getTopology( topology_output )
373 numOnosDevices = topology_result[ 'devices' ]
374 numOnosLinks = topology_result[ 'links' ]
375 topoResult = main.TRUE
376
377 if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks == int(numOnosLinks) ) ):
378 main.step( "Store Device DPIDs" )
379 for i in range( 1, (main.numMNswitches+1) ):
380 main.deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
381 print "Device DPIDs in Store: \n", str( main.deviceDPIDs )
382
383 main.step( "Store Host MACs" )
384 for i in range( 1, ( main.numMNhosts + 1 ) ):
385 main.hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
386 print "Host MACs in Store: \n", str( main.hostMACs )
387 main.MACsDict = {}
388 print "Creating dictionary of DPID and HostMacs"
389 for i in range(len(main.hostMACs)):
390 main.MACsDict[main.deviceDPIDs[i]] = main.hostMACs[i].split('/')[0]
391 print main.MACsDict
392 main.step( "Collect and store all Devices Links" )
393 linksResult = main.ONOScli1.links( jsonFormat=False )
394 ansi_escape = re.compile( r'\x1b[^m]*m' )
395 linksResult = ansi_escape.sub( '', linksResult )
396 linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
397 linksResult = linksResult.splitlines()
398 main.deviceLinks = copy.copy( linksResult )
399 print "Device Links Stored: \n", str( main.deviceLinks )
400 # this will be asserted to check with the params provided count of
401 # links
402 print "Length of Links Store", len( main.deviceLinks )
403
404 main.step( "Collect and store each Device ports enabled Count" )
405 time1 = time.time()
406 for i in xrange(1,(main.numMNswitches + 1), int( main.numCtrls ) ):
407 pool = []
408 for cli in main.CLIs:
409 if i >= main.numMNswitches + 1:
410 break
411 dpid = "of:00000000000000" + format( i,'02x' )
412 t = main.Thread(target = cli.getDevicePortsEnabledCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid])
413 t.start()
414 pool.append(t)
415 i = i + 1
416 main.threadID = main.threadID + 1
417 for thread in pool:
418 thread.join()
419 portResult = thread.result
420 main.devicePortsEnabledCount.append( portResult )
421 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
422 time2 = time.time()
423 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
424
425 main.step( "Collect and store each Device active links Count" )
426 time1 = time.time()
Jon Hall4ba53f02015-07-29 13:07:41 -0700427
Hari Krishnac195f3b2015-07-08 20:02:24 -0700428 for i in xrange( 1,( main.numMNswitches + 1 ), int( main.numCtrls) ):
429 pool = []
430 for cli in main.CLIs:
431 if i >= main.numMNswitches + 1:
432 break
433 dpid = "of:00000000000000" + format( i,'02x' )
434 t = main.Thread( target = cli.getDeviceLinksActiveCount,
435 threadID = main.threadID,
436 name = "getDevicePortsEnabledCount",
437 args = [dpid])
438 t.start()
439 pool.append(t)
440 i = i + 1
441 main.threadID = main.threadID + 1
442 for thread in pool:
443 thread.join()
444 linkCountResult = thread.result
445 main.deviceActiveLinksCount.append( linkCountResult )
446 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
447 time2 = time.time()
448 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
449
450 else:
Jon Hall4ba53f02015-07-29 13:07:41 -0700451 main.log.info("Devices (expected): %s, Links (expected): %s" %
Hari Krishnac195f3b2015-07-08 20:02:24 -0700452 ( str( main.numMNswitches ), str( main.numMNlinks ) ) )
453 main.log.info("Devices (actual): %s, Links (actual): %s" %
454 ( numOnosDevices , numOnosLinks ) )
455 main.log.info("Topology does not match, exiting CHO test...")
456 topoResult = main.FALSE
Jon Hall4ba53f02015-07-29 13:07:41 -0700457 # It's better exit here from running the test
Hari Krishnac195f3b2015-07-08 20:02:24 -0700458 main.cleanup()
459 main.exit()
460
461 # just returning TRUE for now as this one just collects data
462 case3Result = topoResult
463 utilities.assert_equals( expect=main.TRUE, actual=case3Result,
464 onpass="Saving ONOS topology data test PASS",
465 onfail="Saving ONOS topology data test FAIL" )
466
467 def CASE40( self, main ):
468 """
469 Verify Reactive forwarding (Att Topology)
470 """
471 import re
472 import copy
473 import time
474 main.log.report( "Verify Reactive forwarding (Att Topology)" )
475 main.log.report( "______________________________________________" )
476 main.case( "Enable Reactive forwarding and Verify ping all" )
477 main.step( "Enable Reactive forwarding" )
478 installResult = main.TRUE
479 # Activate fwd app
480 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
481 appCheck = main.TRUE
482 pool = []
483 for cli in main.CLIs:
484 t = main.Thread( target=cli.appToIDCheck,
485 name="appToIDCheck-" + str( i ),
486 args=[] )
487 pool.append( t )
488 t.start()
489 for t in pool:
490 t.join()
491 appCheck = appCheck and t.result
492 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
493 onpass="App Ids seem to be correct",
494 onfail="Something is wrong with app Ids" )
495 if appCheck != main.TRUE:
496 main.log.warn( main.CLIs[0].apps() )
497 main.log.warn( main.CLIs[0].appIDs() )
Jon Hall4ba53f02015-07-29 13:07:41 -0700498
Hari Krishnac195f3b2015-07-08 20:02:24 -0700499 time.sleep( 10 )
500
501 main.step( "Verify Pingall" )
502 ping_result = main.FALSE
503 time1 = time.time()
504 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
505 time2 = time.time()
506 timeDiff = round( ( time2 - time1 ), 2 )
507 main.log.report(
508 "Time taken for Ping All: " +
509 str( timeDiff ) +
510 " seconds" )
511
512 if ping_result == main.TRUE:
513 main.log.report( "Pingall Test in Reactive mode successful" )
514 else:
515 main.log.report( "Pingall Test in Reactive mode failed" )
516
517 main.step( "Disable Reactive forwarding" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700518
Hari Krishnac195f3b2015-07-08 20:02:24 -0700519 main.log.info( "Uninstall reactive forwarding app" )
520 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
521 pool = []
522 for cli in main.CLIs:
523 t = main.Thread( target=cli.appToIDCheck,
524 name="appToIDCheck-" + str( i ),
525 args=[] )
526 pool.append( t )
527 t.start()
528
529 for t in pool:
530 t.join()
531 appCheck = appCheck and t.result
532 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
533 onpass="App Ids seem to be correct",
534 onfail="Something is wrong with app Ids" )
535 if appCheck != main.TRUE:
536 main.log.warn( main.CLIs[0].apps() )
537 main.log.warn( main.CLIs[0].appIDs() )
538
539 # Waiting for reative flows to be cleared.
540 time.sleep( 30 )
541 case40Result = installResult and uninstallResult and ping_result
542 utilities.assert_equals( expect=main.TRUE, actual=case40Result,
543 onpass="Reactive Mode Pingall test PASS",
544 onfail="Reactive Mode Pingall test FAIL" )
545
546 def CASE41( self, main ):
547 """
548 Verify Reactive forwarding (Chordal Topology)
549 """
550 import re
551 import copy
552 import time
553 main.log.report( "Verify Reactive forwarding (Chordal Topology)" )
554 main.log.report( "______________________________________________" )
555 main.case( "Enable Reactive forwarding and Verify ping all" )
556 main.step( "Enable Reactive forwarding" )
557 installResult = main.TRUE
558 # Activate fwd app
559 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
560
561 appCheck = main.TRUE
562 pool = []
563 for cli in main.CLIs:
564 t = main.Thread( target=cli.appToIDCheck,
565 name="appToIDCheck-" + str( i ),
566 args=[] )
567 pool.append( t )
568 t.start()
569 for t in pool:
570 t.join()
571 appCheck = appCheck and t.result
572 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
573 onpass="App Ids seem to be correct",
574 onfail="Something is wrong with app Ids" )
575 if appCheck != main.TRUE:
576 main.log.warn( main.CLIs[0].apps() )
577 main.log.warn( main.CLIs[0].appIDs() )
Jon Hall4ba53f02015-07-29 13:07:41 -0700578
Hari Krishnac195f3b2015-07-08 20:02:24 -0700579 time.sleep( 10 )
580
581 main.step( "Verify Pingall" )
582 ping_result = main.FALSE
583 time1 = time.time()
584 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
585 time2 = time.time()
586 timeDiff = round( ( time2 - time1 ), 2 )
587 main.log.report(
588 "Time taken for Ping All: " +
589 str( timeDiff ) +
590 " seconds" )
591
592 if ping_result == main.TRUE:
593 main.log.report( "Pingall Test in Reactive mode successful" )
594 else:
595 main.log.report( "Pingall Test in Reactive mode failed" )
596
597 main.step( "Disable Reactive forwarding" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700598
Hari Krishnac195f3b2015-07-08 20:02:24 -0700599 main.log.info( "Uninstall reactive forwarding app" )
600 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
601 pool = []
602 for cli in main.CLIs:
603 t = main.Thread( target=cli.appToIDCheck,
604 name="appToIDCheck-" + str( i ),
605 args=[] )
606 pool.append( t )
607 t.start()
608
609 for t in pool:
610 t.join()
611 appCheck = appCheck and t.result
612 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
613 onpass="App Ids seem to be correct",
614 onfail="Something is wrong with app Ids" )
615 if appCheck != main.TRUE:
616 main.log.warn( main.CLIs[0].apps() )
617 main.log.warn( main.CLIs[0].appIDs() )
618
619 # Waiting for reative flows to be cleared.
620 time.sleep( 30 )
621 case41Result = installResult and uninstallResult and ping_result
622 utilities.assert_equals( expect=main.TRUE, actual=case41Result,
623 onpass="Reactive Mode Pingall test PASS",
624 onfail="Reactive Mode Pingall test FAIL" )
625
626 def CASE42( self, main ):
627 """
628 Verify Reactive forwarding (Spine Topology)
629 """
630 import re
631 import copy
632 import time
633 main.log.report( "Verify Reactive forwarding (Spine Topology)" )
634 main.log.report( "______________________________________________" )
635 main.case( "Enable Reactive forwarding and Verify ping all" )
636 main.step( "Enable Reactive forwarding" )
637 installResult = main.TRUE
638 # Activate fwd app
639 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
640
641 appCheck = main.TRUE
642 pool = []
643 for cli in main.CLIs:
644 t = main.Thread( target=cli.appToIDCheck,
645 name="appToIDCheck-" + str( i ),
646 args=[] )
647 pool.append( t )
648 t.start()
649 for t in pool:
650 t.join()
651 appCheck = appCheck and t.result
652 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
653 onpass="App Ids seem to be correct",
654 onfail="Something is wrong with app Ids" )
655 if appCheck != main.TRUE:
656 main.log.warn( main.CLIs[0].apps() )
657 main.log.warn( main.CLIs[0].appIDs() )
Jon Hall4ba53f02015-07-29 13:07:41 -0700658
Hari Krishnac195f3b2015-07-08 20:02:24 -0700659 time.sleep( 10 )
660
661 main.step( "Verify Pingall" )
662 ping_result = main.FALSE
663 time1 = time.time()
664 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
665 time2 = time.time()
666 timeDiff = round( ( time2 - time1 ), 2 )
667 main.log.report(
668 "Time taken for Ping All: " +
669 str( timeDiff ) +
670 " seconds" )
671
672 if ping_result == main.TRUE:
673 main.log.report( "Pingall Test in Reactive mode successful" )
674 else:
675 main.log.report( "Pingall Test in Reactive mode failed" )
676
677 main.step( "Disable Reactive forwarding" )
Jon Hall4ba53f02015-07-29 13:07:41 -0700678
Hari Krishnac195f3b2015-07-08 20:02:24 -0700679 main.log.info( "Uninstall reactive forwarding app" )
680 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
681 pool = []
682 for cli in main.CLIs:
683 t = main.Thread( target=cli.appToIDCheck,
684 name="appToIDCheck-" + str( i ),
685 args=[] )
686 pool.append( t )
687 t.start()
688
689 for t in pool:
690 t.join()
691 appCheck = appCheck and t.result
692 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
693 onpass="App Ids seem to be correct",
694 onfail="Something is wrong with app Ids" )
695 if appCheck != main.TRUE:
696 main.log.warn( main.CLIs[0].apps() )
697 main.log.warn( main.CLIs[0].appIDs() )
698
699 # Waiting for reative flows to be cleared.
700 time.sleep( 30 )
701 case42Result = installResult and uninstallResult and ping_result
702 utilities.assert_equals( expect=main.TRUE, actual=case42Result,
703 onpass="Reactive Mode Pingall test PASS",
704 onfail="Reactive Mode Pingall test FAIL" )
705
706 def CASE5( self, main ):
707 """
708 Compare current ONOS topology with reference data
709 """
710 import re
Jon Hall4ba53f02015-07-29 13:07:41 -0700711
Hari Krishnac195f3b2015-07-08 20:02:24 -0700712 devicesDPIDTemp = []
713 hostMACsTemp = []
714 deviceLinksTemp = []
715 deviceActiveLinksCountTemp = []
716 devicePortsEnabledCountTemp = []
717
718 main.log.report(
719 "Compare ONOS topology with reference data in Stores" )
720 main.log.report( "__________________________________________________" )
721 main.case( "Compare ONOS topology with reference data" )
722
723 main.step( "Compare current Device ports enabled with reference" )
724 time1 = time.time()
725 for i in xrange( 1,(main.numMNswitches + 1), int( main.numCtrls ) ):
726 pool = []
727 for cli in main.CLIs:
728 if i >= main.numMNswitches + 1:
729 break
730 dpid = "of:00000000000000" + format( i,'02x' )
731 t = main.Thread(target = cli.getDevicePortsEnabledCount,
732 threadID = main.threadID,
733 name = "getDevicePortsEnabledCount",
734 args = [dpid])
735 t.start()
736 pool.append(t)
737 i = i + 1
738 main.threadID = main.threadID + 1
739 for thread in pool:
740 thread.join()
741 portResult = thread.result
742 #portTemp = re.split( r'\t+', portResult )
743 #portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
744 devicePortsEnabledCountTemp.append( portResult )
745
746 time2 = time.time()
747 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
748 main.log.info (
Jon Hall4ba53f02015-07-29 13:07:41 -0700749 "Device Enabled ports EXPECTED: %s" %
750 str( main.devicePortsEnabledCount ) )
Hari Krishnac195f3b2015-07-08 20:02:24 -0700751 main.log.info (
Jon Hall4ba53f02015-07-29 13:07:41 -0700752 "Device Enabled ports ACTUAL: %s" %
Hari Krishnac195f3b2015-07-08 20:02:24 -0700753 str( devicePortsEnabledCountTemp ) )
Jon Hall4ba53f02015-07-29 13:07:41 -0700754
Hari Krishnac195f3b2015-07-08 20:02:24 -0700755 if ( cmp( main.devicePortsEnabledCount,
756 devicePortsEnabledCountTemp ) == 0 ):
757 stepResult1 = main.TRUE
758 else:
759 stepResult1 = main.FALSE
760
761 main.step( "Compare Device active links with reference" )
762 time1 = time.time()
763 for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ):
764 pool = []
765 for cli in main.CLIs:
766 if i >= main.numMNswitches + 1:
767 break
768 dpid = "of:00000000000000" + format( i,'02x' )
769 t = main.Thread(target = cli.getDeviceLinksActiveCount,
770 threadID = main.threadID,
771 name = "getDeviceLinksActiveCount",
772 args = [dpid])
773 t.start()
774 pool.append(t)
775 i = i + 1
776 main.threadID = main.threadID + 1
777 for thread in pool:
778 thread.join()
779 linkCountResult = thread.result
780 #linkCountTemp = re.split( r'\t+', linkCountResult )
781 #linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
782 deviceActiveLinksCountTemp.append( linkCountResult )
783
784 time2 = time.time()
785 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
786 main.log.info (
787 "Device Active links EXPECTED: %s" %
788 str( main.deviceActiveLinksCount ) )
789 main.log.info (
790 "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
791 if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
792 stepResult2 = main.TRUE
793 else:
794 stepResult2 = main.FALSE
795
796 """
797 place holder for comparing devices, hosts, paths and intents if required.
798 Links and ports data would be incorrect with out devices anyways.
799 """
800 case5Result = ( stepResult1 and stepResult2 )
801 utilities.assert_equals( expect=main.TRUE, actual=case5Result,
802 onpass="Compare Topology test PASS",
803 onfail="Compare Topology test FAIL" )
804
805 def CASE60( self ):
806 """
807 Install 300 host intents and verify ping all (Att Topology)
808 """
809 main.log.report( "Add 300 host intents and verify pingall (Att Topology)" )
810 main.log.report( "_______________________________________" )
811 import itertools
812 import time
813 main.case( "Install 300 host intents" )
814 main.step( "Add host Intents" )
815 intentResult = main.TRUE
Jon Hall4ba53f02015-07-29 13:07:41 -0700816 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
817
Hari Krishnac195f3b2015-07-08 20:02:24 -0700818 intentIdList = []
819 time1 = time.time()
820 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
821 pool = []
822 for cli in main.CLIs:
823 if i >= len( hostCombos ):
824 break
825 t = main.Thread( target=cli.addHostIntent,
826 threadID=main.threadID,
827 name="addHostIntent",
828 args=[hostCombos[i][0],hostCombos[i][1]])
829 pool.append(t)
830 t.start()
831 i = i + 1
832 main.threadID = main.threadID + 1
833 for thread in pool:
834 thread.join()
835 intentIdList.append(thread.result)
836 time2 = time.time()
837 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
838
839 intentResult = main.TRUE
Hari Krishna6185fc12015-07-13 15:42:31 -0700840 intentsJson = main.ONOScli1.intents()
Hari Krishnac195f3b2015-07-08 20:02:24 -0700841 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
842 intentsJson = intentsJson)
843 print "len of intent ID", str(len(intentIdList))
844 print "len of intent state results", str(len(getIntentStateResult))
845 print getIntentStateResult
846 # Takes awhile for all the onos to get the intents
847 time.sleep( 30 )
848 """intentState = main.TRUE
849 for i in getIntentStateResult:
850 if getIntentStateResult.get( 'state' ) != 'INSTALLED':
851 """
852
853
854 main.step( "Verify Ping across all hosts" )
855 pingResult = main.FALSE
856 time1 = time.time()
857 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
858 time2 = time.time()
859 timeDiff = round( ( time2 - time1 ), 2 )
860 main.log.report(
861 "Time taken for Ping All: " +
862 str( timeDiff ) +
863 " seconds" )
864 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
865 onpass="PING ALL PASS",
866 onfail="PING ALL FAIL" )
867
868 case60Result = ( intentResult and pingResult )
Hari Krishnac195f3b2015-07-08 20:02:24 -0700869 utilities.assert_equals(
870 expect=main.TRUE,
871 actual=case60Result,
872 onpass="Install 300 Host Intents and Ping All test PASS",
873 onfail="Install 300 Host Intents and Ping All test FAIL" )
874
875 def CASE61( self ):
876 """
877 Install 600 host intents and verify ping all for Chordal Topology
878 """
879 main.log.report( "Add 600 host intents and verify pingall (Chordal Topo)" )
880 main.log.report( "_______________________________________" )
881 import itertools
Jon Hall4ba53f02015-07-29 13:07:41 -0700882
Hari Krishnac195f3b2015-07-08 20:02:24 -0700883 main.case( "Install 600 host intents" )
884 main.step( "Add host Intents" )
885 intentResult = main.TRUE
Jon Hall4ba53f02015-07-29 13:07:41 -0700886 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
887
Hari Krishnac195f3b2015-07-08 20:02:24 -0700888 intentIdList = []
889 time1 = time.time()
Jon Hall4ba53f02015-07-29 13:07:41 -0700890
Hari Krishnac195f3b2015-07-08 20:02:24 -0700891 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
892 pool = []
893 for cli in main.CLIs:
894 if i >= len( hostCombos ):
895 break
896 t = main.Thread( target=cli.addHostIntent,
897 threadID=main.threadID,
898 name="addHostIntent",
899 args=[hostCombos[i][0],hostCombos[i][1]])
900 pool.append(t)
901 t.start()
902 i = i + 1
903 main.threadID = main.threadID + 1
904 for thread in pool:
905 thread.join()
906 intentIdList.append(thread.result)
907 time2 = time.time()
908 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
909 intentResult = main.TRUE
Hari Krishna6185fc12015-07-13 15:42:31 -0700910 intentsJson = main.ONOScli1.intents()
Hari Krishnac195f3b2015-07-08 20:02:24 -0700911 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
912 intentsJson = intentsJson)
913 print getIntentStateResult
914
915 main.step( "Verify Ping across all hosts" )
916 pingResult = main.FALSE
917 time1 = time.time()
918 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
919 time2 = time.time()
920 timeDiff = round( ( time2 - time1 ), 2 )
921 main.log.report(
922 "Time taken for Ping All: " +
923 str( timeDiff ) +
924 " seconds" )
925 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
926 onpass="PING ALL PASS",
927 onfail="PING ALL FAIL" )
928
929 case14Result = ( intentResult and pingResult )
Jon Hall4ba53f02015-07-29 13:07:41 -0700930
Hari Krishnac195f3b2015-07-08 20:02:24 -0700931 utilities.assert_equals(
932 expect=main.TRUE,
933 actual=case14Result,
934 onpass="Install 300 Host Intents and Ping All test PASS",
935 onfail="Install 300 Host Intents and Ping All test FAIL" )
936
937 def CASE62( self ):
938 """
939 Install 2278 host intents and verify ping all for Spine Topology
940 """
941 main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" )
942 main.log.report( "_______________________________________" )
943 import itertools
Jon Hall4ba53f02015-07-29 13:07:41 -0700944
Hari Krishnac195f3b2015-07-08 20:02:24 -0700945 main.case( "Install 2278 host intents" )
946 main.step( "Add host Intents" )
947 intentResult = main.TRUE
Jon Hall4ba53f02015-07-29 13:07:41 -0700948 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
Hari Krishnac195f3b2015-07-08 20:02:24 -0700949 main.pingTimeout = 300
950 intentIdList = []
951 time1 = time.time()
952 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
953 pool = []
954 for cli in main.CLIs:
955 if i >= len( hostCombos ):
956 break
957 t = main.Thread( target=cli.addHostIntent,
958 threadID=main.threadID,
959 name="addHostIntent",
960 args=[hostCombos[i][0],hostCombos[i][1]])
961 pool.append(t)
962 t.start()
963 i = i + 1
964 main.threadID = main.threadID + 1
965 for thread in pool:
966 thread.join()
967 intentIdList.append(thread.result)
968 time2 = time.time()
969 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
970 intentResult = main.TRUE
Hari Krishna6185fc12015-07-13 15:42:31 -0700971 intentsJson = main.ONOScli1.intents()
Hari Krishnac195f3b2015-07-08 20:02:24 -0700972 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
973 intentsJson = intentsJson)
974 print getIntentStateResult
975
976 main.step( "Verify Ping across all hosts" )
977 pingResult = main.FALSE
978 time1 = time.time()
979 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
980 time2 = time.time()
981 timeDiff = round( ( time2 - time1 ), 2 )
982 main.log.report(
983 "Time taken for Ping All: " +
984 str( timeDiff ) +
985 " seconds" )
986 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
987 onpass="PING ALL PASS",
988 onfail="PING ALL FAIL" )
989
990 case15Result = ( intentResult and pingResult )
Jon Hall4ba53f02015-07-29 13:07:41 -0700991
Hari Krishnac195f3b2015-07-08 20:02:24 -0700992 utilities.assert_equals(
993 expect=main.TRUE,
994 actual=case15Result,
995 onpass="Install 2278 Host Intents and Ping All test PASS",
996 onfail="Install 2278 Host Intents and Ping All test FAIL" )
997
998 def CASE70( self, main ):
999 """
1000 Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
1001 """
1002 import random
1003 main.randomLink1 = []
1004 main.randomLink2 = []
1005 main.randomLink3 = []
1006 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1007 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1008 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1009 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1010 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1011 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1012 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
1013 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1014
1015 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
1016 main.log.report( "___________________________________________________________________________" )
1017 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1018 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
1019 if ( int( switchLinksToToggle ) ==
1020 0 or int( switchLinksToToggle ) > 5 ):
1021 main.log.info( "Please check your PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
1022 #main.cleanup()
1023 #main.exit()
1024 else:
1025 main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
1026
1027 main.step( "Cut links on Core devices using user provided range" )
1028 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1029 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1030 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
1031 for i in range( int( switchLinksToToggle ) ):
1032 main.Mininet1.link(
1033 END1=link1End1,
1034 END2=main.randomLink1[ i ],
1035 OPTION="down" )
1036 time.sleep( link_sleep )
1037 main.Mininet1.link(
1038 END1=link2End1,
1039 END2=main.randomLink2[ i ],
1040 OPTION="down" )
1041 time.sleep( link_sleep )
1042 main.Mininet1.link(
1043 END1=link3End1,
1044 END2=main.randomLink3[ i ],
1045 OPTION="down" )
1046 time.sleep( link_sleep )
1047
Hari Krishna6185fc12015-07-13 15:42:31 -07001048 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001049 linkDown = main.ONOSbench.checkStatus(
1050 topology_output, main.numMNswitches, str(
1051 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
1052 utilities.assert_equals(
1053 expect=main.TRUE,
1054 actual=linkDown,
1055 onpass="Link Down discovered properly",
1056 onfail="Link down was not discovered in " +
1057 str( link_sleep ) +
1058 " seconds" )
1059
1060 main.step( "Verify Ping across all hosts" )
1061 pingResultLinkDown = main.FALSE
1062 time1 = time.time()
1063 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout )
1064 time2 = time.time()
1065 timeDiff = round( ( time2 - time1 ), 2 )
1066 main.log.report(
1067 "Time taken for Ping All: " +
1068 str( timeDiff ) +
1069 " seconds" )
1070 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1071 onpass="PING ALL PASS",
1072 onfail="PING ALL FAIL" )
1073
1074 caseResult70 = linkDown and pingResultLinkDown
1075 utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
1076 onpass="Random Link cut Test PASS",
1077 onfail="Random Link cut Test FAIL" )
1078
1079 def CASE80( self, main ):
1080 """
1081 Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
1082 """
1083 import random
1084 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1085 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1086 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1087 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1088 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
1089
1090 main.log.report(
1091 "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
1092 main.log.report(
1093 "__________________________________________________________________" )
1094 main.case(
1095 "Host intents - Bring the core links up that are down and verify ping all" )
1096 main.step( "Bring randomly cut links on Core devices up" )
1097 for i in range( int( switchLinksToToggle ) ):
1098 main.Mininet1.link(
1099 END1=link1End1,
1100 END2=main.randomLink1[ i ],
1101 OPTION="up" )
1102 time.sleep( link_sleep )
1103 main.Mininet1.link(
1104 END1=link2End1,
1105 END2=main.randomLink2[ i ],
1106 OPTION="up" )
1107 time.sleep( link_sleep )
1108 main.Mininet1.link(
1109 END1=link3End1,
1110 END2=main.randomLink3[ i ],
1111 OPTION="up" )
1112 time.sleep( link_sleep )
1113
Hari Krishna6185fc12015-07-13 15:42:31 -07001114 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001115 linkUp = main.ONOSbench.checkStatus(
1116 topology_output,
1117 main.numMNswitches,
1118 str( main.numMNlinks ) )
1119 utilities.assert_equals(
1120 expect=main.TRUE,
1121 actual=linkUp,
1122 onpass="Link up discovered properly",
1123 onfail="Link up was not discovered in " +
1124 str( link_sleep ) +
1125 " seconds" )
1126
1127 main.step( "Verify Ping across all hosts" )
1128 pingResultLinkUp = main.FALSE
1129 time1 = time.time()
1130 pingResultLinkUp = main.Mininet1.pingall( timeout=main.pingTimeout )
1131 time2 = time.time()
1132 timeDiff = round( ( time2 - time1 ), 2 )
1133 main.log.report(
1134 "Time taken for Ping All: " +
1135 str( timeDiff ) +
1136 " seconds" )
1137 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1138 onpass="PING ALL PASS",
1139 onfail="PING ALL FAIL" )
1140
1141 caseResult80 = linkUp and pingResultLinkUp
1142 utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
1143 onpass="Link Up Test PASS",
1144 onfail="Link Up Test FAIL" )
1145
1146 def CASE71( self, main ):
1147 """
1148 Randomly bring some core links down and verify ping all ( Point Intents-Att Topo)
1149 """
1150 import random
1151 main.randomLink1 = []
1152 main.randomLink2 = []
1153 main.randomLink3 = []
1154 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1155 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1156 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1157 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1158 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1159 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1160 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
1161 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1162
1163 main.log.report( "Randomly bring some core links down and verify ping all (Point Intents-Att Topo)" )
1164 main.log.report( "___________________________________________________________________________" )
1165 main.case( "Point intents - Randomly bring some core links down and verify ping all" )
1166 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
1167 if ( int( switchLinksToToggle ) ==
1168 0 or int( switchLinksToToggle ) > 5 ):
1169 main.log.info( "Please check your PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
1170 #main.cleanup()
1171 #main.exit()
1172 else:
1173 main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
1174
1175 main.step( "Cut links on Core devices using user provided range" )
1176 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1177 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1178 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
1179 for i in range( int( switchLinksToToggle ) ):
1180 main.Mininet1.link(
1181 END1=link1End1,
1182 END2=main.randomLink1[ i ],
1183 OPTION="down" )
1184 time.sleep( link_sleep )
1185 main.Mininet1.link(
1186 END1=link2End1,
1187 END2=main.randomLink2[ i ],
1188 OPTION="down" )
1189 time.sleep( link_sleep )
1190 main.Mininet1.link(
1191 END1=link3End1,
1192 END2=main.randomLink3[ i ],
1193 OPTION="down" )
1194 time.sleep( link_sleep )
1195
Hari Krishna6185fc12015-07-13 15:42:31 -07001196 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001197 linkDown = main.ONOSbench.checkStatus(
1198 topology_output, main.numMNswitches, str(
1199 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
1200 utilities.assert_equals(
1201 expect=main.TRUE,
1202 actual=linkDown,
1203 onpass="Link Down discovered properly",
1204 onfail="Link down was not discovered in " +
1205 str( link_sleep ) +
1206 " seconds" )
1207
1208 main.step( "Verify Ping across all hosts" )
1209 pingResultLinkDown = main.FALSE
1210 time1 = time.time()
1211 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
1212 time2 = time.time()
1213 timeDiff = round( ( time2 - time1 ), 2 )
1214 main.log.report(
1215 "Time taken for Ping All: " +
1216 str( timeDiff ) +
1217 " seconds" )
1218 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1219 onpass="PING ALL PASS",
1220 onfail="PING ALL FAIL" )
1221
1222 caseResult71 = linkDown and pingResultLinkDown
1223 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
1224 onpass="Random Link cut Test PASS",
1225 onfail="Random Link cut Test FAIL" )
1226
1227 def CASE81( self, main ):
1228 """
1229 Bring the core links up that are down and verify ping all ( Point Intents-Att Topo )
1230 """
1231 import random
1232 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1233 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1234 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1235 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1236 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
1237
1238 main.log.report(
1239 "Bring the core links up that are down and verify ping all ( Point Intents-Att Topo" )
1240 main.log.report(
1241 "__________________________________________________________________" )
1242 main.case(
1243 "Point intents - Bring the core links up that are down and verify ping all" )
1244 main.step( "Bring randomly cut links on Core devices up" )
1245 for i in range( int( switchLinksToToggle ) ):
1246 main.Mininet1.link(
1247 END1=link1End1,
1248 END2=main.randomLink1[ i ],
1249 OPTION="up" )
1250 time.sleep( link_sleep )
1251 main.Mininet1.link(
1252 END1=link2End1,
1253 END2=main.randomLink2[ i ],
1254 OPTION="up" )
1255 time.sleep( link_sleep )
1256 main.Mininet1.link(
1257 END1=link3End1,
1258 END2=main.randomLink3[ i ],
1259 OPTION="up" )
1260 time.sleep( link_sleep )
1261
Hari Krishna6185fc12015-07-13 15:42:31 -07001262 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001263 linkUp = main.ONOSbench.checkStatus(
1264 topology_output,
1265 main.numMNswitches,
1266 str( main.numMNlinks ) )
1267 utilities.assert_equals(
1268 expect=main.TRUE,
1269 actual=linkUp,
1270 onpass="Link up discovered properly",
1271 onfail="Link up was not discovered in " +
1272 str( link_sleep ) +
1273 " seconds" )
1274
1275 main.step( "Verify Ping across all hosts" )
1276 pingResultLinkUp = main.FALSE
1277 time1 = time.time()
1278 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout )
1279 time2 = time.time()
1280 timeDiff = round( ( time2 - time1 ), 2 )
1281 main.log.report(
1282 "Time taken for Ping All: " +
1283 str( timeDiff ) +
1284 " seconds" )
1285 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1286 onpass="PING ALL PASS",
1287 onfail="PING ALL FAIL" )
1288
1289 caseResult81 = linkUp and pingResultLinkUp
1290 utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
1291 onpass="Link Up Test PASS",
1292 onfail="Link Up Test FAIL" )
1293
1294 def CASE72( self, main ):
1295 """
1296 Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
1297 """
1298 import random
Jon Hall4ba53f02015-07-29 13:07:41 -07001299 import itertools
Hari Krishnac195f3b2015-07-08 20:02:24 -07001300 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Jon Hall4ba53f02015-07-29 13:07:41 -07001301
Hari Krishnac195f3b2015-07-08 20:02:24 -07001302 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
1303 main.log.report( "___________________________________________________________________________" )
1304 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1305 switches = []
1306 switchesComb = []
1307 for i in range( main.numMNswitches ):
1308 switches.append('s%d'%(i+1))
1309 switchesLinksComb = list(itertools.combinations(switches,2))
1310 main.randomLinks = random.sample(switchesLinksComb, 5 )
1311 print main.randomLinks
1312 main.step( "Cut links on random devices" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001313
Hari Krishnac195f3b2015-07-08 20:02:24 -07001314 for switch in main.randomLinks:
1315 main.Mininet1.link(
1316 END1=switch[0],
1317 END2=switch[1],
1318 OPTION="down")
1319 time.sleep( link_sleep )
1320
Hari Krishna6185fc12015-07-13 15:42:31 -07001321 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001322 linkDown = main.ONOSbench.checkStatus(
1323 topology_output, main.numMNswitches, str(
1324 int( main.numMNlinks ) - 5 * 2 ) )
1325 utilities.assert_equals(
1326 expect=main.TRUE,
1327 actual=linkDown,
1328 onpass="Link Down discovered properly",
1329 onfail="Link down was not discovered in " +
1330 str( link_sleep ) +
1331 " seconds" )
1332
1333 main.step( "Verify Ping across all hosts" )
1334 pingResultLinkDown = main.FALSE
1335 time1 = time.time()
1336 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1337 time2 = time.time()
1338 timeDiff = round( ( time2 - time1 ), 2 )
1339 main.log.report(
1340 "Time taken for Ping All: " +
1341 str( timeDiff ) +
1342 " seconds" )
1343 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1344 onpass="PING ALL PASS",
1345 onfail="PING ALL FAIL" )
1346
1347 caseResult71 = pingResultLinkDown
1348 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
1349 onpass="Random Link cut Test PASS",
1350 onfail="Random Link cut Test FAIL" )
1351
1352 def CASE82( self, main ):
1353 """
1354 Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
1355 """
1356 import random
1357 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Jon Hall4ba53f02015-07-29 13:07:41 -07001358
Hari Krishnac195f3b2015-07-08 20:02:24 -07001359 main.log.report(
1360 "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
1361 main.log.report(
1362 "__________________________________________________________________" )
1363 main.case(
1364 "Host intents - Bring the core links up that are down and verify ping all" )
1365 main.step( "Bring randomly cut links on devices up" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001366
Hari Krishnac195f3b2015-07-08 20:02:24 -07001367 for switch in main.randomLinks:
1368 main.Mininet1.link(
1369 END1=switch[0],
1370 END2=switch[1],
1371 OPTION="up")
1372 time.sleep( link_sleep )
1373
Hari Krishna6185fc12015-07-13 15:42:31 -07001374 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001375 linkUp = main.ONOSbench.checkStatus(
1376 topology_output,
1377 main.numMNswitches,
1378 str( main.numMNlinks ) )
1379 utilities.assert_equals(
1380 expect=main.TRUE,
1381 actual=linkUp,
1382 onpass="Link up discovered properly",
1383 onfail="Link up was not discovered in " +
1384 str( link_sleep ) +
1385 " seconds" )
1386
1387 main.step( "Verify Ping across all hosts" )
1388 pingResultLinkUp = main.FALSE
1389 time1 = time.time()
1390 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1391 time2 = time.time()
1392 timeDiff = round( ( time2 - time1 ), 2 )
1393 main.log.report(
1394 "Time taken for Ping All: " +
1395 str( timeDiff ) +
1396 " seconds" )
1397 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1398 onpass="PING ALL PASS",
1399 onfail="PING ALL FAIL" )
1400
1401 caseResult82 = linkUp and pingResultLinkUp
1402 utilities.assert_equals( expect=main.TRUE, actual=caseResult82,
1403 onpass="Link Up Test PASS",
1404 onfail="Link Up Test FAIL" )
1405
1406 def CASE73( self, main ):
1407 """
1408 Randomly bring some links down and verify ping all ( Point Intents-Chordal Topo)
1409 """
1410 import random
Jon Hall4ba53f02015-07-29 13:07:41 -07001411 import itertools
Hari Krishnac195f3b2015-07-08 20:02:24 -07001412 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Jon Hall4ba53f02015-07-29 13:07:41 -07001413
Hari Krishnac195f3b2015-07-08 20:02:24 -07001414 main.log.report( "Randomly bring some core links down and verify ping all ( Point Intents-Chordal Topo)" )
1415 main.log.report( "___________________________________________________________________________" )
1416 main.case( "Point intents - Randomly bring some core links down and verify ping all" )
1417 switches = []
1418 switchesComb = []
1419 for i in range( main.numMNswitches ):
1420 switches.append('s%d'%(i+1))
1421 switchesLinksComb = list(itertools.combinations(switches,2))
1422 main.randomLinks = random.sample(switchesLinksComb, 5 )
1423 print main.randomLinks
1424 main.step( "Cut links on random devices" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001425
Hari Krishnac195f3b2015-07-08 20:02:24 -07001426 for switch in main.randomLinks:
1427 main.Mininet1.link(
1428 END1=switch[0],
1429 END2=switch[1],
1430 OPTION="down")
1431 time.sleep( link_sleep )
1432
Hari Krishna6185fc12015-07-13 15:42:31 -07001433 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001434 linkDown = main.ONOSbench.checkStatus(
1435 topology_output, main.numMNswitches, str(
1436 int( main.numMNlinks ) - 5 * 2 ) )
1437 utilities.assert_equals(
1438 expect=main.TRUE,
1439 actual=linkDown,
1440 onpass="Link Down discovered properly",
1441 onfail="Link down was not discovered in " +
1442 str( link_sleep ) +
1443 " seconds" )
1444
1445 main.step( "Verify Ping across all hosts" )
1446 pingResultLinkDown = main.FALSE
1447 time1 = time.time()
1448 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1449 time2 = time.time()
1450 timeDiff = round( ( time2 - time1 ), 2 )
1451 main.log.report(
1452 "Time taken for Ping All: " +
1453 str( timeDiff ) +
1454 " seconds" )
1455 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1456 onpass="PING ALL PASS",
1457 onfail="PING ALL FAIL" )
1458
1459 caseResult73 = pingResultLinkDown
1460 utilities.assert_equals( expect=main.TRUE, actual=caseResult73,
1461 onpass="Random Link cut Test PASS",
1462 onfail="Random Link cut Test FAIL" )
1463
1464 def CASE83( self, main ):
1465 """
1466 Bring the core links up that are down and verify ping all ( Point Intents Chordal Topo )
1467 """
1468 import random
1469 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Jon Hall4ba53f02015-07-29 13:07:41 -07001470
Hari Krishnac195f3b2015-07-08 20:02:24 -07001471 main.log.report(
1472 "Bring the core links up that are down and verify ping all ( Point Intents-Chordal Topo" )
1473 main.log.report(
1474 "__________________________________________________________________" )
1475 main.case(
1476 "Point intents - Bring the core links up that are down and verify ping all" )
1477 main.step( "Bring randomly cut links on devices up" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001478
Hari Krishnac195f3b2015-07-08 20:02:24 -07001479 for switch in main.randomLinks:
1480 main.Mininet1.link(
1481 END1=switch[0],
1482 END2=switch[1],
1483 OPTION="up")
1484 time.sleep( link_sleep )
1485
Hari Krishna6185fc12015-07-13 15:42:31 -07001486 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001487 linkUp = main.ONOSbench.checkStatus(
1488 topology_output,
1489 main.numMNswitches,
1490 str( main.numMNlinks ) )
1491 utilities.assert_equals(
1492 expect=main.TRUE,
1493 actual=linkUp,
1494 onpass="Link up discovered properly",
1495 onfail="Link up was not discovered in " +
1496 str( link_sleep ) +
1497 " seconds" )
1498
1499 main.step( "Verify Ping across all hosts" )
1500 pingResultLinkUp = main.FALSE
1501 time1 = time.time()
1502 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1503 time2 = time.time()
1504 timeDiff = round( ( time2 - time1 ), 2 )
1505 main.log.report(
1506 "Time taken for Ping All: " +
1507 str( timeDiff ) +
1508 " seconds" )
1509 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1510 onpass="PING ALL PASS",
1511 onfail="PING ALL FAIL" )
1512
1513 caseResult83 = linkUp and pingResultLinkUp
1514 utilities.assert_equals( expect=main.TRUE, actual=caseResult83,
1515 onpass="Link Up Test PASS",
1516 onfail="Link Up Test FAIL" )
1517
1518 def CASE74( self, main ):
1519 """
1520 Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo)
1521 """
1522 import random
1523 main.randomLink1 = []
1524 main.randomLink2 = []
1525 main.randomLink3 = []
1526 main.randomLink4 = []
1527 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1528 link1End2top = main.params[ 'SPINECORELINKS' ][ 'linkS9top' ].split( ',' )
1529 link1End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS9bot' ].split( ',' )
1530 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1531 link2End2top = main.params[ 'SPINECORELINKS' ][ 'linkS10top' ].split( ',' )
1532 link2End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS10bot' ].split( ',' )
1533 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1534 main.pingTimeout = 400
Jon Hall4ba53f02015-07-29 13:07:41 -07001535
Hari Krishnac195f3b2015-07-08 20:02:24 -07001536 main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" )
1537 main.log.report( "___________________________________________________________________________" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001538
Hari Krishnac195f3b2015-07-08 20:02:24 -07001539 linkIndex = range(4)
Hari Krishna6185fc12015-07-13 15:42:31 -07001540 linkIndexS9 = random.sample(linkIndex,1)[0]
Hari Krishnac195f3b2015-07-08 20:02:24 -07001541 linkIndex.remove(linkIndexS9)
1542 linkIndexS10 = random.sample(linkIndex,1)[0]
1543 main.randomLink1 = link1End2top[linkIndexS9]
1544 main.randomLink2 = link2End2top[linkIndexS10]
1545 main.randomLink3 = random.sample(link1End2bot,1)[0]
1546 main.randomLink4 = random.sample(link2End2bot,1)[0]
Hari Krishna6185fc12015-07-13 15:42:31 -07001547
1548 # Work around for link state propagation delay. Added some sleep time.
Hari Krishnac195f3b2015-07-08 20:02:24 -07001549 # main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="down" )
1550 # main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="down" )
1551 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="down" )
1552 time.sleep( link_sleep )
1553 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="down" )
1554 time.sleep( link_sleep )
1555
Hari Krishna6185fc12015-07-13 15:42:31 -07001556 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001557 linkDown = main.ONOSbench.checkStatus(
1558 topology_output, main.numMNswitches, str(
1559 int( main.numMNlinks ) - 8 ))
1560 utilities.assert_equals(
1561 expect=main.TRUE,
1562 actual=linkDown,
1563 onpass="Link Down discovered properly",
1564 onfail="Link down was not discovered in " +
1565 str( link_sleep ) +
1566 " seconds" )
1567
1568 main.step( "Verify Ping across all hosts" )
1569 pingResultLinkDown = main.FALSE
1570 time1 = time.time()
1571 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1572 time2 = time.time()
1573 timeDiff = round( ( time2 - time1 ), 2 )
1574 main.log.report(
1575 "Time taken for Ping All: " +
1576 str( timeDiff ) +
1577 " seconds" )
1578 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1579 onpass="PING ALL PASS",
1580 onfail="PING ALL FAIL" )
1581
1582 caseResult74 = linkDown and pingResultLinkDown
1583 utilities.assert_equals( expect=main.TRUE, actual=caseResult74,
1584 onpass="Random Link cut Test PASS",
1585 onfail="Random Link cut Test FAIL" )
1586
1587 def CASE84( self, main ):
1588 """
1589 Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo )
1590 """
1591 import random
1592 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1593 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1594 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1595 main.log.report(
1596 "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" )
1597 main.log.report(
1598 "__________________________________________________________________" )
1599 main.case(
1600 "Host intents - Bring the core links up that are down and verify ping all" )
Hari Krishna6185fc12015-07-13 15:42:31 -07001601
1602 # Work around for link state propagation delay. Added some sleep time.
1603 # main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="up" )
1604 # main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="up" )
Hari Krishnac195f3b2015-07-08 20:02:24 -07001605 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="up" )
1606 time.sleep( link_sleep )
1607 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="up" )
1608 time.sleep( link_sleep )
1609
Hari Krishna6185fc12015-07-13 15:42:31 -07001610 topology_output = main.ONOScli1.topology()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001611 linkUp = main.ONOSbench.checkStatus(
1612 topology_output,
1613 main.numMNswitches,
1614 str( main.numMNlinks ) )
1615 utilities.assert_equals(
1616 expect=main.TRUE,
1617 actual=linkUp,
1618 onpass="Link up discovered properly",
1619 onfail="Link up was not discovered in " +
1620 str( link_sleep ) +
1621 " seconds" )
1622
1623 main.step( "Verify Ping across all hosts" )
1624 pingResultLinkUp = main.FALSE
1625 time1 = time.time()
1626 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1627 time2 = time.time()
1628 timeDiff = round( ( time2 - time1 ), 2 )
1629 main.log.report(
1630 "Time taken for Ping All: " +
1631 str( timeDiff ) +
1632 " seconds" )
1633 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1634 onpass="PING ALL PASS",
1635 onfail="PING ALL FAIL" )
1636
1637 caseResult84 = linkUp and pingResultLinkUp
1638 utilities.assert_equals( expect=main.TRUE, actual=caseResult84,
1639 onpass="Link Up Test PASS",
1640 onfail="Link Up Test FAIL" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001641
Hari Krishnac195f3b2015-07-08 20:02:24 -07001642 def CASE90( self ):
1643 """
1644 Install 600 point intents and verify ping all (Att Topology)
1645 """
1646 main.log.report( "Add 600 point intents and verify pingall (Att Topology)" )
1647 main.log.report( "_______________________________________" )
1648 import itertools
1649 import time
1650 main.case( "Install 600 point intents" )
1651 main.step( "Add point Intents" )
1652 intentResult = main.TRUE
Jon Hall4ba53f02015-07-29 13:07:41 -07001653 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1654
Hari Krishnac195f3b2015-07-08 20:02:24 -07001655 intentIdList = []
1656 time1 = time.time()
1657 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1658 pool = []
1659 for cli in main.CLIs:
1660 if i >= len( deviceCombos ):
1661 break
1662 t = main.Thread( target=cli.addPointIntent,
1663 threadID=main.threadID,
1664 name="addPointIntent",
1665 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4",main.MACsDict.get(deviceCombos[i][0]),main.MACsDict.get(deviceCombos[i][1])])
1666 pool.append(t)
Hari Krishnac195f3b2015-07-08 20:02:24 -07001667 t.start()
1668 i = i + 1
1669 main.threadID = main.threadID + 1
1670 for thread in pool:
1671 thread.join()
1672 intentIdList.append(thread.result)
1673 time2 = time.time()
Hari Krishna6185fc12015-07-13 15:42:31 -07001674 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
Hari Krishnac195f3b2015-07-08 20:02:24 -07001675 intentResult = main.TRUE
Hari Krishna6185fc12015-07-13 15:42:31 -07001676 intentsJson = main.ONOScli1.intents()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001677 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1678 intentsJson = intentsJson)
1679 print getIntentStateResult
1680 # Takes awhile for all the onos to get the intents
1681 time.sleep(60)
1682 main.step( "Verify Ping across all hosts" )
1683 pingResult = main.FALSE
1684 time1 = time.time()
1685 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1686 time2 = time.time()
1687 timeDiff = round( ( time2 - time1 ), 2 )
1688 main.log.report(
1689 "Time taken for Ping All: " +
1690 str( timeDiff ) +
1691 " seconds" )
1692 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1693 onpass="PING tALL PASS",
1694 onfail="PING ALL FAIL" )
1695
1696 case90Result = ( intentResult and pingResult )
Jon Hall4ba53f02015-07-29 13:07:41 -07001697
Hari Krishnac195f3b2015-07-08 20:02:24 -07001698 utilities.assert_equals(
1699 expect=main.TRUE,
1700 actual=case90Result,
1701 onpass="Install 600 point Intents and Ping All test PASS",
1702 onfail="Install 600 point Intents and Ping All test FAIL" )
1703
1704 def CASE91( self ):
1705 """
1706 Install 600 point intents and verify ping all (Chordal Topology)
1707 """
1708 main.log.report( "Add 600 point intents and verify pingall (Chordal Topology)" )
1709 main.log.report( "_______________________________________" )
1710 import itertools
1711 import time
1712 main.case( "Install 600 point intents" )
1713 main.step( "Add point Intents" )
1714 intentResult = main.TRUE
Jon Hall4ba53f02015-07-29 13:07:41 -07001715 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1716
Hari Krishnac195f3b2015-07-08 20:02:24 -07001717 intentIdList = []
1718 time1 = time.time()
1719 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1720 pool = []
1721 for cli in main.CLIs:
1722 if i >= len( deviceCombos ):
1723 break
1724 t = main.Thread( target=cli.addPointIntent,
1725 threadID=main.threadID,
1726 name="addPointIntent",
1727 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1728 pool.append(t)
1729 #time.sleep(1)
1730 t.start()
1731 i = i + 1
1732 main.threadID = main.threadID + 1
1733 for thread in pool:
1734 thread.join()
1735 intentIdList.append(thread.result)
1736 time2 = time.time()
Hari Krishna6185fc12015-07-13 15:42:31 -07001737 main.log.info( "Time for adding point intents: %2f seconds" %(time2-time1) )
Hari Krishnac195f3b2015-07-08 20:02:24 -07001738 intentResult = main.TRUE
Hari Krishna6185fc12015-07-13 15:42:31 -07001739 intentsJson = main.ONOScli1.intents()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001740 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1741 intentsJson = intentsJson)
1742 print getIntentStateResult
1743 # Takes awhile for all the onos to get the intents
1744 time.sleep(30)
1745 main.step( "Verify Ping across all hosts" )
1746 pingResult = main.FALSE
1747 time1 = time.time()
1748 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1749 time2 = time.time()
1750 timeDiff = round( ( time2 - time1 ), 2 )
1751 main.log.report(
1752 "Time taken for Ping All: " +
1753 str( timeDiff ) +
1754 " seconds" )
1755 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1756 onpass="PING ALL PASS",
1757 onfail="PING ALL FAIL" )
1758
1759 case91Result = ( intentResult and pingResult )
Jon Hall4ba53f02015-07-29 13:07:41 -07001760
Hari Krishnac195f3b2015-07-08 20:02:24 -07001761 utilities.assert_equals(
1762 expect=main.TRUE,
1763 actual=case91Result,
1764 onpass="Install 600 point Intents and Ping All test PASS",
1765 onfail="Install 600 point Intents and Ping All test FAIL" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001766
Hari Krishnac195f3b2015-07-08 20:02:24 -07001767 def CASE92( self ):
1768 """
1769 Install 4556 point intents and verify ping all (Spine Topology)
1770 """
1771 main.log.report( "Add 4556 point intents and verify pingall (Spine Topology)" )
1772 main.log.report( "_______________________________________" )
1773 import itertools
1774 import time
1775 main.case( "Install 4556 point intents" )
1776 main.step( "Add point Intents" )
1777 intentResult = main.TRUE
1778 main.pingTimeout = 600
1779 for i in range(len(main.hostMACs)):
1780 main.MACsDict[main.deviceDPIDs[i+10]] = main.hostMACs[i].split('/')[0]
1781 print main.MACsDict
1782 deviceCombos = list( itertools.permutations( main.deviceDPIDs[10:], 2 ) )
1783 intentIdList = []
1784 time1 = time.time()
1785 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1786 pool = []
1787 for cli in main.CLIs:
1788 if i >= len( deviceCombos ):
1789 break
1790 t = main.Thread( target=cli.addPointIntent,
1791 threadID=main.threadID,
1792 name="addPointIntent",
1793 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1794 pool.append(t)
1795 #time.sleep(1)
1796 t.start()
1797 i = i + 1
1798 main.threadID = main.threadID + 1
1799 for thread in pool:
1800 thread.join()
1801 intentIdList.append(thread.result)
1802 time2 = time.time()
Hari Krishna6185fc12015-07-13 15:42:31 -07001803 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
Hari Krishnac195f3b2015-07-08 20:02:24 -07001804 intentResult = main.TRUE
Hari Krishna6185fc12015-07-13 15:42:31 -07001805 intentsJson = main.ONOScli1.intents()
Hari Krishnac195f3b2015-07-08 20:02:24 -07001806 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1807 intentsJson = intentsJson)
1808 #print getIntentStateResult
1809 # Takes awhile for all the onos to get the intents
1810 time.sleep(60)
1811 main.step( "Verify Ping across all hosts" )
1812 pingResult = main.FALSE
1813 time1 = time.time()
1814 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1815 time2 = time.time()
1816 timeDiff = round( ( time2 - time1 ), 2 )
1817 main.log.report(
1818 "Time taken for Ping All: " +
1819 str( timeDiff ) +
1820 " seconds" )
1821 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1822 onpass="PING ALL PASS",
1823 onfail="PING ALL FAIL" )
1824
1825 case92Result = ( intentResult and pingResult )
Jon Hall4ba53f02015-07-29 13:07:41 -07001826
Hari Krishnac195f3b2015-07-08 20:02:24 -07001827 utilities.assert_equals(
1828 expect=main.TRUE,
1829 actual=case92Result,
1830 onpass="Install 4556 point Intents and Ping All test PASS",
1831 onfail="Install 4556 point Intents and Ping All test FAIL" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001832
Hari Krishnac195f3b2015-07-08 20:02:24 -07001833 def CASE93( self ):
1834 """
1835 Install multi-single point intents and verify Ping all works
1836 for att topology
1837 """
1838 import copy
1839 import time
1840 main.log.report( "Install multi-single point intents and verify Ping all" )
1841 main.log.report( "___________________________________________" )
1842 main.case( "Install multi-single point intents and Ping all" )
1843 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1844 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1845 intentIdList = []
1846 print "MACsDict", main.MACsDict
1847 time1 = time.time()
1848 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1849 pool = []
1850 for cli in main.CLIs:
1851 egressDevice = deviceDPIDsCopy[i]
1852 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1853 ingressDeviceList.remove(egressDevice)
1854 if i >= len( deviceDPIDsCopy ):
1855 break
1856 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1857 threadID=main.threadID,
1858 name="addMultipointToSinglepointIntent",
1859 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1860 pool.append(t)
1861 #time.sleep(1)
1862 t.start()
1863 i = i + 1
1864 main.threadID = main.threadID + 1
1865 for thread in pool:
1866 thread.join()
1867 intentIdList.append(thread.result)
1868 time2 = time.time()
1869 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1870 time.sleep(30)
1871 print "getting all intents ID"
1872 intentIdTemp = main.ONOScli1.getAllIntentsId()
1873 print intentIdTemp
1874 print len(intentIdList)
1875 print intentIdList
1876 checkIntentStateResult = main.TRUE
1877 print "Checking intents state"
1878 checkIntentStateResult = main.ONOScli1.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1879 checkIntentStateResult = main.ONOScli2.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1880 checkIntentStateResult = main.ONOScli3.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1881 checkIntentStateResult = main.ONOScli4.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1882 checkIntentStateResult = main.ONOScli5.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
Jon Hall4ba53f02015-07-29 13:07:41 -07001883
Hari Krishnac195f3b2015-07-08 20:02:24 -07001884 if checkIntentStateResult:
1885 main.log.info( "All intents are installed correctly " )
1886
1887 print "Checking flows state "
1888 checkFlowsState = main.ONOScli1.checkFlowsState()
1889 time.sleep(50)
1890 main.step( "Verify Ping across all hosts" )
1891 pingResult = main.FALSE
1892 time1 = time.time()
1893 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1894 time2 = time.time()
1895 timeDiff = round( ( time2 - time1 ), 2 )
1896 main.log.report(
1897 "Time taken for Ping All: " +
1898 str( timeDiff ) +
1899 " seconds" )
1900 checkFlowsState = main.ONOScli1.checkFlowsState()
1901 case93Result = pingResult
1902 utilities.assert_equals(
1903 expect=main.TRUE,
1904 actual=case93Result,
1905 onpass="Install 25 multi to single point Intents and Ping All test PASS",
1906 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001907
Hari Krishnac195f3b2015-07-08 20:02:24 -07001908 def CASE94( self ):
1909 """
1910 Install multi-single point intents and verify Ping all works
1911 for Chordal topology
1912 """
1913 import copy
1914 import time
1915 main.log.report( "Install multi-single point intents and verify Ping all" )
1916 main.log.report( "___________________________________________" )
1917 main.case( "Install multi-single point intents and Ping all" )
1918 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1919 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1920 intentIdList = []
1921 print "MACsDict", main.MACsDict
1922 time1 = time.time()
1923 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1924 pool = []
1925 for cli in main.CLIs:
1926 egressDevice = deviceDPIDsCopy[i]
1927 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1928 ingressDeviceList.remove(egressDevice)
1929 if i >= len( deviceDPIDsCopy ):
1930 break
1931 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1932 threadID=main.threadID,
1933 name="addMultipointToSinglepointIntent",
1934 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1935 pool.append(t)
1936 #time.sleep(1)
1937 t.start()
1938 i = i + 1
1939 main.threadID = main.threadID + 1
1940 for thread in pool:
1941 thread.join()
1942 intentIdList.append(thread.result)
1943 time2 = time.time()
Jon Hall4ba53f02015-07-29 13:07:41 -07001944 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
Hari Krishnac195f3b2015-07-08 20:02:24 -07001945 time.sleep(5)
1946 main.step( "Verify Ping across all hosts" )
1947 pingResult = main.FALSE
1948 time1 = time.time()
1949 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1950 time2 = time.time()
1951 timeDiff = round( ( time2 - time1 ), 2 )
1952 main.log.report(
1953 "Time taken for Ping All: " +
1954 str( timeDiff ) +
1955 " seconds" )
1956
1957 case94Result = pingResult
1958 utilities.assert_equals(
1959 expect=main.TRUE,
1960 actual=case94Result,
1961 onpass="Install 25 multi to single point Intents and Ping All test PASS",
1962 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
Jon Hall4ba53f02015-07-29 13:07:41 -07001963
Hari Krishnac195f3b2015-07-08 20:02:24 -07001964 #def CASE95 multi-single point intent for Spine
1965
1966 def CASE96( self ):
1967 """
1968 Install single-multi point intents and verify Ping all works
1969 for att topology
1970 """
1971 import copy
1972 main.log.report( "Install single-multi point intents and verify Ping all" )
1973 main.log.report( "___________________________________________" )
1974 main.case( "Install single-multi point intents and Ping all" )
1975 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1976 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
1977 intentIdList = []
1978 print "MACsDict", main.MACsDict
1979 time1 = time.time()
1980 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1981 pool = []
1982 for cli in main.CLIs:
1983 ingressDevice = deviceDPIDsCopy[i]
1984 egressDeviceList = copy.copy(deviceDPIDsCopy)
1985 egressDeviceList.remove(ingressDevice)
1986 if i >= len( deviceDPIDsCopy ):
1987 break
1988 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
1989 threadID=main.threadID,
1990 name="addSinglepointToMultipointIntent",
1991 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice)])
1992 pool.append(t)
1993 #time.sleep(1)
1994 t.start()
1995 i = i + 1
1996 main.threadID = main.threadID + 1
1997 for thread in pool:
1998 thread.join()
1999 intentIdList.append(thread.result)
2000 time2 = time.time()
Jon Hall4ba53f02015-07-29 13:07:41 -07002001 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
Hari Krishnac195f3b2015-07-08 20:02:24 -07002002 time.sleep(5)
2003 main.step( "Verify Ping across all hosts" )
2004 pingResult = main.FALSE
2005 time1 = time.time()
2006 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
2007 time2 = time.time()
2008 timeDiff = round( ( time2 - time1 ), 2 )
2009 main.log.report(
2010 "Time taken for Ping All: " +
2011 str( timeDiff ) +
2012 " seconds" )
2013
2014 case96Result = pingResult
2015 utilities.assert_equals(
2016 expect=main.TRUE,
2017 actual=case96Result,
2018 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2019 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
2020
2021 def CASE97( self ):
2022 """
2023 Install single-multi point intents and verify Ping all works
2024 for Chordal topology
2025 """
2026 import copy
2027 main.log.report( "Install single-multi point intents and verify Ping all" )
2028 main.log.report( "___________________________________________" )
2029 main.case( "Install single-multi point intents and Ping all" )
2030 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
2031 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
2032 intentIdList = []
2033 print "MACsDict", main.MACsDict
2034 time1 = time.time()
2035 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2036 pool = []
2037 for cli in main.CLIs:
2038 ingressDevice = deviceDPIDsCopy[i]
2039 egressDeviceList = copy.copy(deviceDPIDsCopy)
2040 egressDeviceList.remove(ingressDevice)
2041 if i >= len( deviceDPIDsCopy ):
2042 break
2043 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2044 threadID=main.threadID,
2045 name="addSinglepointToMultipointIntent",
2046 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice),''])
2047 pool.append(t)
2048 #time.sleep(1)
2049 t.start()
2050 i = i + 1
2051 main.threadID = main.threadID + 1
2052 for thread in pool:
2053 thread.join()
2054 intentIdList.append(thread.result)
2055 time2 = time.time()
Jon Hall4ba53f02015-07-29 13:07:41 -07002056 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
Hari Krishnac195f3b2015-07-08 20:02:24 -07002057 time.sleep(5)
2058 main.step( "Verify Ping across all hosts" )
2059 pingResult = main.FALSE
2060 time1 = time.time()
2061 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
2062 time2 = time.time()
2063 timeDiff = round( ( time2 - time1 ), 2 )
2064 main.log.report(
2065 "Time taken for Ping All: " +
2066 str( timeDiff ) +
2067 " seconds" )
2068
2069 case97Result = pingResult
2070 utilities.assert_equals(
2071 expect=main.TRUE,
2072 actual=case97Result,
2073 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2074 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
2075
2076 def CASE98( self ):
2077 """
2078 Install single-multi point intents and verify Ping all works
2079 for Spine topology
2080 """
2081 import copy
2082 main.log.report( "Install single-multi point intents and verify Ping all" )
2083 main.log.report( "___________________________________________" )
2084 main.case( "Install single-multi point intents and Ping all" )
2085 deviceDPIDsCopy = copy.copy( main.deviceDPIDs )
2086 deviceDPIDsCopy = deviceDPIDsCopy[ 10: ]
2087 portEgressList = [ '1' ]*(len(deviceDPIDsCopy) - 1)
2088 intentIdList = []
2089 MACsDictCopy = {}
2090 for i in range( len( deviceDPIDsCopy ) ):
2091 MACsDictCopy[ deviceDPIDsCopy[ i ] ] = main.hostMACs[i].split( '/' )[ 0 ]
2092
2093 print "deviceDPIDsCopy", deviceDPIDsCopy
2094 print ""
2095 print "MACsDictCopy", MACsDictCopy
2096 time1 = time.time()
2097 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2098 pool = []
2099 for cli in main.CLIs:
2100 if i >= len( deviceDPIDsCopy ):
2101 break
2102 ingressDevice = deviceDPIDsCopy[i]
2103 egressDeviceList = copy.copy(deviceDPIDsCopy)
2104 egressDeviceList.remove(ingressDevice)
2105 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2106 threadID=main.threadID,
2107 name="addSinglepointToMultipointIntent",
2108 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',MACsDictCopy.get(ingressDevice),''])
2109 pool.append(t)
2110 #time.sleep(1)
2111 t.start()
2112 i = i + 1
2113 main.threadID = main.threadID + 1
2114 for thread in pool:
2115 thread.join()
2116 intentIdList.append(thread.result)
2117 time2 = time.time()
Jon Hall4ba53f02015-07-29 13:07:41 -07002118 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
Hari Krishnac195f3b2015-07-08 20:02:24 -07002119 time.sleep(5)
2120 main.step( "Verify Ping across all hosts" )
2121 pingResult = main.FALSE
2122 time1 = time.time()
2123 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
2124 time2 = time.time()
2125 timeDiff = round( ( time2 - time1 ), 2 )
2126 main.log.report(
2127 "Time taken for Ping All: " +
2128 str( timeDiff ) +
2129 " seconds" )
2130
2131 case98Result = pingResult
2132 utilities.assert_equals(
2133 expect=main.TRUE,
2134 actual=case98Result,
2135 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2136 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
2137
2138 def CASE10( self ):
2139 import time
GlennRCc6cd2a62015-08-10 16:08:22 -07002140 import re
Hari Krishnac195f3b2015-07-08 20:02:24 -07002141 """
2142 Remove all Intents
2143 """
2144 main.log.report( "Remove all intents that were installed previously" )
2145 main.log.report( "______________________________________________" )
2146 main.log.info( "Remove all intents" )
2147 main.case( "Removing intents" )
2148 main.step( "Obtain the intent id's first" )
2149 intentsList = main.ONOScli1.getAllIntentIds()
2150 ansi_escape = re.compile( r'\x1b[^m]*m' )
2151 intentsList = ansi_escape.sub( '', intentsList )
2152 intentsList = intentsList.replace(
2153 " onos:intents | grep id=",
2154 "" ).replace(
2155 "id=",
2156 "" ).replace(
2157 "\r\r",
2158 "" )
2159 intentsList = intentsList.splitlines()
Hari Krishnac195f3b2015-07-08 20:02:24 -07002160 intentIdList = []
2161 step1Result = main.TRUE
2162 moreIntents = main.TRUE
2163 removeIntentCount = 0
2164 intentsCount = len(intentsList)
2165 main.log.info ( "Current number of intents: " + str(intentsCount) )
2166 if ( len( intentsList ) > 1 ):
2167 results = main.TRUE
2168 main.log.info("Removing intent...")
2169 while moreIntents:
Hari Krishna6185fc12015-07-13 15:42:31 -07002170 # This is a work around only: cycle through intents removal for up to 5 times.
Hari Krishnac195f3b2015-07-08 20:02:24 -07002171 if removeIntentCount == 5:
2172 break
2173 removeIntentCount = removeIntentCount + 1
2174 intentsList1 = main.ONOScli1.getAllIntentIds()
2175 if len( intentsList1 ) == 0:
2176 break
2177 ansi_escape = re.compile( r'\x1b[^m]*m' )
2178 intentsList1 = ansi_escape.sub( '', intentsList1 )
2179 intentsList1 = intentsList1.replace(
2180 " onos:intents | grep id=",
2181 "" ).replace(
2182 " state=",
2183 "" ).replace(
2184 "\r\r",
2185 "" )
2186 intentsList1 = intentsList1.splitlines()
Hari Krishnac195f3b2015-07-08 20:02:24 -07002187 main.log.info ( "Round %d intents to remove: " %(removeIntentCount) )
2188 print intentsList1
2189 intentIdList1 = []
2190 if ( len( intentsList1 ) > 0 ):
2191 moreIntents = main.TRUE
2192 for i in range( len( intentsList1 ) ):
2193 intentsTemp1 = intentsList1[ i ].split( ',' )
2194 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
2195 main.log.info ( "Leftover Intent IDs: " + str(intentIdList1) )
2196 main.log.info ( "Length of Leftover Intents list: " + str(len(intentIdList1)) )
2197 time1 = time.time()
2198 for i in xrange( 0, len( intentIdList1 ), int(main.numCtrls) ):
2199 pool = []
2200 for cli in main.CLIs:
2201 if i >= len( intentIdList1 ):
2202 break
2203 t = main.Thread( target=cli.removeIntent,
2204 threadID=main.threadID,
2205 name="removeIntent",
2206 args=[intentIdList1[i],'org.onosproject.cli',False,False])
2207 pool.append(t)
2208 t.start()
2209 i = i + 1
2210 main.threadID = main.threadID + 1
2211 for thread in pool:
2212 thread.join()
2213 intentIdList.append(thread.result)
2214 #time.sleep(2)
2215 time2 = time.time()
2216 main.log.info("Time for removing host intents: %2f seconds" %(time2-time1))
2217 time.sleep(10)
2218 main.log.info("Purging WITHDRAWN Intents")
Hari Krishna6185fc12015-07-13 15:42:31 -07002219 purgeResult = main.ONOScli1.purgeWithdrawnIntents()
Hari Krishnac195f3b2015-07-08 20:02:24 -07002220 else:
2221 time.sleep(10)
2222 if len( main.ONOScli1.intents()):
2223 continue
2224 break
2225 time.sleep(10)
2226 else:
2227 print "Removed %d intents" %(intentsCount)
2228 step1Result = main.TRUE
2229 else:
2230 print "No Intent IDs found in Intents list: ", intentsList
2231 step1Result = main.FALSE
2232
2233 print main.ONOScli1.intents()
2234 caseResult10 = step1Result
2235 utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
2236 onpass="Intent removal test successful",
2237 onfail="Intent removal test failed" )
2238
2239 def CASE12( self, main ):
2240 """
2241 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
2242 """
2243 import re
2244 import copy
2245 import time
2246
Hari Krishnac195f3b2015-07-08 20:02:24 -07002247 threadID = 0
2248
2249 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
2250 main.log.report( "_____________________________________________________" )
2251 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
2252 main.step( "Enable intent based Reactive forwarding" )
2253 installResult = main.FALSE
2254 feature = "onos-app-ifwd"
Hari Krishna6185fc12015-07-13 15:42:31 -07002255
Hari Krishnac195f3b2015-07-08 20:02:24 -07002256 pool = []
2257 time1 = time.time()
2258 for cli,feature in main.CLIs:
2259 t = main.Thread(target=cli,threadID=threadID,
2260 name="featureInstall",args=[feature])
2261 pool.append(t)
2262 t.start()
2263 threadID = threadID + 1
Jon Hall4ba53f02015-07-29 13:07:41 -07002264
Hari Krishnac195f3b2015-07-08 20:02:24 -07002265 results = []
2266 for thread in pool:
2267 thread.join()
2268 results.append(thread.result)
2269 time2 = time.time()
Jon Hall4ba53f02015-07-29 13:07:41 -07002270
Hari Krishnac195f3b2015-07-08 20:02:24 -07002271 if( all(result == main.TRUE for result in results) == False):
2272 main.log.info("Did not install onos-app-ifwd feature properly")
2273 #main.cleanup()
2274 #main.exit()
2275 else:
2276 main.log.info("Successful feature:install onos-app-ifwd")
2277 installResult = main.TRUE
2278 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
Jon Hall4ba53f02015-07-29 13:07:41 -07002279
Hari Krishnac195f3b2015-07-08 20:02:24 -07002280 main.step( "Verify Pingall" )
2281 ping_result = main.FALSE
2282 time1 = time.time()
2283 ping_result = main.Mininet1.pingall(timeout=600)
2284 time2 = time.time()
2285 timeDiff = round( ( time2 - time1 ), 2 )
2286 main.log.report(
2287 "Time taken for Ping All: " +
2288 str( timeDiff ) +
2289 " seconds" )
Jon Hall4ba53f02015-07-29 13:07:41 -07002290
Hari Krishnac195f3b2015-07-08 20:02:24 -07002291 if ping_result == main.TRUE:
2292 main.log.report( "Pingall Test in Reactive mode successful" )
2293 else:
2294 main.log.report( "Pingall Test in Reactive mode failed" )
2295
2296 main.step( "Disable Intent based Reactive forwarding" )
2297 uninstallResult = main.FALSE
Jon Hall4ba53f02015-07-29 13:07:41 -07002298
Hari Krishnac195f3b2015-07-08 20:02:24 -07002299 pool = []
2300 time1 = time.time()
2301 for cli,feature in main.CLIs:
2302 t = main.Thread(target=cli,threadID=threadID,
2303 name="featureUninstall",args=[feature])
2304 pool.append(t)
2305 t.start()
2306 threadID = threadID + 1
Jon Hall4ba53f02015-07-29 13:07:41 -07002307
Hari Krishnac195f3b2015-07-08 20:02:24 -07002308 results = []
2309 for thread in pool:
2310 thread.join()
2311 results.append(thread.result)
2312 time2 = time.time()
Jon Hall4ba53f02015-07-29 13:07:41 -07002313
Hari Krishnac195f3b2015-07-08 20:02:24 -07002314 if( all(result == main.TRUE for result in results) == False):
2315 main.log.info("Did not uninstall onos-app-ifwd feature properly")
2316 uninstallResult = main.FALSE
2317 #main.cleanup()
2318 #main.exit()
2319 else:
2320 main.log.info("Successful feature:uninstall onos-app-ifwd")
2321 uninstallResult = main.TRUE
2322 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
2323
2324 # Waiting for reative flows to be cleared.
2325 time.sleep( 10 )
2326
2327 case11Result = installResult and ping_result and uninstallResult
2328 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
2329 onpass="Intent based Reactive forwarding Pingall test PASS",
2330 onfail="Intent based Reactive forwarding Pingall test FAIL" )