blob: 55c9e2c636239f91a7df45274c9518061203a551 [file] [log] [blame]
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -07001"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2017 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07003
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070011 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070012
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20"""
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070021"""
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -070022Testing various connectivity failures for VPLS.
23
24CASE1: Startup.
25CASE2: Load VPLS topology and configurations from demo script.
26CASE50: Initial connectivity test.
27CASE100: Bring down 1 host at a time and test connectivity.
28CASE200: Bring down 1 switch at a time and test connectivity.
29CASE300: Stop 1 ONOS node at a time and test connectivity.
30CASE310: Kill 1 ONOS node at a time and test connectivity.
31CASE400: Bring down 1 link at a time and test connectivity.
32"""
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -070033class VPLSfailsafe:
34
35 def __init__( self ):
36 self.default = ''
37
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -070038 def CASE1( self, main ):
39 """
40 CASE1 is to compile ONOS and push it to the test machines
41
42 Startup sequence:
43 cell <name>
44 onos-verify-cell
45 NOTE: temporary - onos-remove-raft-logs
46 onos-uninstall
47 start mininet
48 git pull
49 mvn clean install
50 onos-package
51 onos-install -f
52 onos-wait-for-start
53 start cli sessions
54 start tcpdump
55 """
56 import imp
57 import time
58 import json
Jeremy Ronquillod7791d82017-08-14 16:23:08 +000059 try:
60 from tests.dependencies.ONOSSetup import ONOSSetup
61 main.testSetUp = ONOSSetup()
62 except ImportError:
63 main.log.error( "ONOSSetup not found. exiting the test" )
64 main.cleanAndExit()
65 main.testSetUp.envSetupDescription()
66 stepResult = main.FALSE
67 try:
68 # load some variables from the params file
69 cellName = main.params[ 'ENV' ][ 'cellName' ]
70 main.timeSleep = int( main.params[ 'RETRY' ][ 'sleep' ] )
71 main.numAttempts = int( main.params[ 'RETRY' ][ 'attempts' ] )
72 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -070073
Jeremy Ronquillod7791d82017-08-14 16:23:08 +000074 ofPort = main.params[ 'CTRL' ][ 'port' ]
75 stepResult = main.testSetUp.envSetup()
76 except Exception as e:
77 main.testSetUp.envSetupException( e )
78 main.testSetUp.evnSetupConclusion( stepResult )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -070079
Jeremy Ronquillod7791d82017-08-14 16:23:08 +000080 main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster,
81 cellName=cellName )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -070082
83 main.step( "Starting Mininet" )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -070084 # scp topo file to mininet
85 # TODO: move to params?
86 topoName = "vpls"
Jeremy Ronquillo31caa482017-07-18 15:55:31 -070087 topoFile = "vpls.py"
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -070088 filePath = main.ONOSbench.home + "/tools/test/topos/"
89 main.ONOSbench.scp( main.Mininet1,
90 filePath + topoFile,
91 main.Mininet1.home,
92 direction="to" )
93 topo = " --custom " + main.Mininet1.home + topoFile + " --topo " + topoName
94 args = " --switch ovs,protocols=OpenFlow13"
Jeremy Ronquillod7791d82017-08-14 16:23:08 +000095 for ctrl in main.Cluster.active():
96 args += " --controller=remote,ip=" + ctrl.ipAddress
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -070097 mnCmd = "sudo mn" + topo + args
98 mnResult = main.Mininet1.startNet( mnCmd=mnCmd )
99 utilities.assert_equals( expect=main.TRUE, actual=mnResult,
100 onpass="Mininet Started",
101 onfail="Error starting Mininet" )
102
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700103 main.step( "Activate apps defined in the params file" )
104 # get data from the params
105 apps = main.params.get( 'apps' )
106 if apps:
107 apps = apps.split( ',' )
108 main.log.warn( apps )
109 activateResult = True
110 for app in apps:
Jeremy Ronquillod7791d82017-08-14 16:23:08 +0000111 main.Cluster.active( 0 ).CLI.app( app, "Activate" )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700112 # TODO: check this worked
113 time.sleep( SLEEP ) # wait for apps to activate
114 for app in apps:
Jeremy Ronquillod7791d82017-08-14 16:23:08 +0000115 state = main.Cluster.active( 0 ).CLI.appStatus( app )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700116 if state == "ACTIVE":
117 activateResult = activateResult and True
118 else:
119 main.log.error( "{} is in {} state".format( app, state ) )
120 activateResult = False
121 utilities.assert_equals( expect=True,
122 actual=activateResult,
123 onpass="Successfully activated apps",
124 onfail="Failed to activate apps" )
125 else:
126 main.log.warn( "No apps were specified to be loaded after startup" )
127
128 main.step( "Set ONOS configurations" )
129 config = main.params.get( 'ONOS_Configuration' )
130 if config:
131 main.log.debug( config )
132 checkResult = main.TRUE
133 for component in config:
134 for setting in config[ component ]:
135 value = config[ component ][ setting ]
Jeremy Ronquillod7791d82017-08-14 16:23:08 +0000136 check = main.Cluster.active( 0 ).CLI.setCfg( component, setting, value )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700137 main.log.info( "Value was changed? {}".format( main.TRUE == check ) )
138 checkResult = check and checkResult
139 utilities.assert_equals( expect=main.TRUE,
140 actual=checkResult,
141 onpass="Successfully set config",
142 onfail="Failed to set config" )
143 else:
144 main.log.warn( "No configurations were specified to be changed after startup" )
145
146 main.step( "App Ids check" )
Jeremy Ronquillod7791d82017-08-14 16:23:08 +0000147 appCheck = main.Cluster.command( "appToIDCheck", returnBool=True )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700148 if appCheck is not True:
Jeremy Ronquillod7791d82017-08-14 16:23:08 +0000149 main.log.warn( main.Cluster.active( 0 ).CLI.apps() )
150 main.log.warn( main.Cluster.active( 0 ).CLI.appIDs() )
151 utilities.assert_equals( expect=True, actual=appCheck,
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700152 onpass="App Ids seem to be correct",
153 onfail="Something is wrong with app Ids" )
154
155 def CASE2( self, main ):
156 """
157 Load and test vpls configurations from json configuration file
158 """
159 import os.path
160 from tests.USECASE.VPLS.dependencies import vpls
161
162 main.vpls = vpls
163 pprint = main.ONOSrest1.pprint
164 hosts = int( main.params[ 'vpls' ][ 'hosts' ] )
165 SLEEP = int( main.params[ 'SLEEP' ][ 'netcfg' ] )
166
167 main.step( "Discover hosts using pings" )
168 for i in range( 1, hosts + 1 ):
169 src = "h" + str( i )
170 for j in range( 1, hosts + 1 ):
171 if j == i:
172 continue
173 dst = "h" + str( j )
174 pingResult = main.Mininet1.pingHost( SRC=src, TARGET=dst )
175
176 main.step( "Load VPLS configurations" )
177 fileName = main.params[ 'DEPENDENCY' ][ 'topology' ]
178 app = main.params[ 'vpls' ][ 'name' ]
179
Jeremy Ronquillod7791d82017-08-14 16:23:08 +0000180 loadVPLSResult = main.ONOSbench.onosNetCfg( main.Cluster.active( 0 ).ipAddress, "", fileName )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700181 utilities.assert_equals( expect=main.TRUE,
182 actual=loadVPLSResult,
183 onpass="Loaded vpls configuration.",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700184 onfail="Failed to load vpls configuration." )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700185
186 # Time for netcfg to load data
187 time.sleep( SLEEP )
188
189 main.step( "Check VPLS configurations" )
190 # 'Master' copy of test configuration
191 try:
192 with open( os.path.expanduser( fileName ) ) as dataFile:
193 originalCfg = json.load( dataFile )
194 main.vplsConfig = originalCfg[ 'apps' ].get( app ).get( 'vpls' ).get( 'vplsList' )
195 except Exception as e:
196 main.log.error( "Error loading config file: {}".format( e ) )
197 if main.vplsConfig:
198 result = True
199 else:
200 result = False
201 utilities.assert_equals( expect=True,
202 actual=result,
203 onpass="Check vpls configuration succeeded.",
204 onfail="Check vpls configuration failed." )
205
206 main.step( "Check interface configurations" )
207 result = False
208 getPorts = utilities.retry( f=main.ONOSrest1.getNetCfg,
209 retValue=False,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700210 kwargs={ "subjectClass": "ports" },
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700211 sleep=SLEEP )
212 onosCfg = pprint( getPorts )
213 sentCfg = pprint( originalCfg.get( "ports" ) )
214
215 if onosCfg == sentCfg:
216 main.log.info( "ONOS interfaces NetCfg matches what was sent" )
217 result = True
218 else:
219 main.log.error( "ONOS interfaces NetCfg doesn't match what was sent" )
220 main.log.debug( "ONOS config: {}".format( onosCfg ) )
221 main.log.debug( "Sent config: {}".format( sentCfg ) )
222 utilities.assert_equals( expect=True,
223 actual=result,
224 onpass="Net Cfg added for interfaces",
225 onfail="Net Cfg not added for interfaces" )
226
227 # Run a bunch of checks to verify functionality based on configs
228 vpls.verify( main )
229
230 # This is to avoid a race condition in pushing netcfg's.
231 main.step( "Loading vpls configuration in case any configuration was missed." )
Jeremy Ronquillod7791d82017-08-14 16:23:08 +0000232 loadVPLSResult = main.ONOSbench.onosNetCfg( main.Cluster.active( 0 ).ipAddress, "", fileName )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700233 utilities.assert_equals( expect=main.TRUE,
234 actual=loadVPLSResult,
235 onpass="Loaded vpls configuration.",
236 onfail="Failed to load vpls configuration." )
237
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700238 def CASE50( self, main ):
239 """
240 Initial connectivity check
241 """
242 main.case( "Check connectivity before running all other tests." )
243
244 # Check connectivity before running all other tests
245 connectCheckResult = main.vpls.testConnectivityVpls( main )
246 utilities.assert_equals( expect=main.TRUE, actual=connectCheckResult,
247 onpass="Connectivity is as expected.",
248 onfail="Connectivity is NOT as expected." )
249
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700250 def CASE100( self, main ):
251 """
252 Bring down 1 host at a time and test connectivity
253 """
254 assert vpls, "vpls not defined"
255
256 main.case( "Bring down one host at a time and test connectivity." )
257 result = main.TRUE
258
259 for i in range( 1, hosts + 1 ):
260
261 stri = str( i )
262
263 # Bring host down
264 main.step( "Kill link between s" + stri + " and h" + stri + "." )
265 linkDownResult = main.Mininet1.link( END1="s" + stri, END2="h" + stri, OPTION="down" )
266
267 # Check if link was successfully down'd
268 utilities.assert_equals( expect=main.TRUE, actual=linkDownResult,
269 onpass="Link down successful.",
270 onfail="Failed to bring link down." )
271 result = result and linkDownResult
272
273 # Check connectivity
274 connectivityResult = vpls.testConnectivityVpls( main, blacklist=[ "h" + stri ] )
275 result = result and connectivityResult
276
277 # Bring host up
278 main.step( "Re-adding link between s" + stri + " and h" + stri + "." )
279 linkUpResult = main.Mininet1.link( END1="s" + stri, END2="h" + stri, OPTION="up" )
280
281 # Check if link was successfully re-added
282 utilities.assert_equals( expect=main.TRUE, actual=linkUpResult,
283 onpass="Link up successful.",
284 onfail="Failed to bring link up." )
285 result = result and linkUpResult
286
287 # Discover host using ping
288 main.step( "Discover h" + stri + " using ping." )
289 main.Mininet1.pingHost( SRC="h" + stri, TARGET="h" + str( ( i % hosts ) + 1 ) )
290
291 # Check connectivity
292 connectivityResult = vpls.testConnectivityVpls( main )
293 result = result and connectivityResult
294
295 utilities.assert_equals( expect=main.TRUE, actual=result,
296 onpass="Connectivity is as expected.",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700297 onfail="Connectivity is NOT as expected." )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700298
299 def CASE200( self, main ):
300 """
301 Bring down 1 switch at a time and test connectivity
302 """
303 assert vpls, "vpls not defined"
304
305 main.case( "Bring down one switch at a time and test connectivity." )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700306 links = main.Mininet1.getLinks() # Obtain links here
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700307 result = main.TRUE
308
309 for i in range( 5, hosts + 1 ):
310
311 stri = str( i )
312
313 # Bring switch down
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700314 main.step( "Delete s" + stri + "." )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700315 delSwitchResult = main.Mininet1.delSwitch( sw="s" + stri )
316
317 # Check if switch was deleted
318 utilities.assert_equals( expect=main.TRUE, actual=delSwitchResult,
319 onpass="Successfully deleted switch.",
320 onfail="Failed to delete switch." )
321 result = result and delSwitchResult
322
323 # Check connectivity
324 connectivityResult = vpls.testConnectivityVpls( main, blacklist=[ "h" + stri ] )
325 result = result and connectivityResult
326
327 # Bring switch up
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700328 main.step( "Add s" + stri + "." )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700329 addSwitchResult = main.Mininet1.addSwitch( sw="s" + stri )
330
331 # Check if switch was added
332 utilities.assert_equals( expect=main.TRUE, actual=addSwitchResult,
333 onpass="Successfully added switch.",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700334 onfail="Failed to add switch." )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700335 result = result and addSwitchResult
336
337 # Reconnect links
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700338 main.step( "Reconnecting links on s" + stri + "." )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700339 for j in links:
340 if ( j[ 'node1' ] == "s" + stri and j[ 'node2' ][ 0 ] == "s" ) or \
341 ( j[ 'node2' ] == "s" + stri and j[ 'node1' ][ 0 ] == "s" ):
342 main.Mininet1.addLink( str( j[ 'node1' ] ), str( j[ 'node2' ] ) )
343
344 # Discover host using ping
345 main.Mininet1.pingHost( SRC="h" + stri, TARGET="h" + str( ( i % hosts ) + 1 ) )
346
347 # Check connectivity
348 connectivityResult = vpls.testConnectivityVpls( main )
349 result = result and connectivityResult
350
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700351 utilities.assert_equals( expect=main.TRUE,
352 actual=result,
353 onpass="Connectivity is as expected.",
354 onfail="Connectivity is NOT as expected." )
355
356 def CASE300( self, main ):
357 """
358 Stop 1 ONOS node at a time and test connectivity
359 """
360 from tests.USECASE.VPLS.dependencies import vpls
361 from tests.HA.dependencies.HA import HA
362 assert vpls, "vpls not defined"
363
364 main.HA = HA()
365 main.case( "Stop one ONOS node at a time and test connectivity." )
366
367 result = main.TRUE
368
Jeremy Ronquillod7791d82017-08-14 16:23:08 +0000369 for i in range( 0, main.Cluster.numCtrls ):
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700370
371 stri = str( i )
372
Jeremy Ronquillod7791d82017-08-14 16:23:08 +0000373 ip_address = main.Cluster.active( i ).ipAddress
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700374
375 # Stop an ONOS node: i
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700376 main.step( "Stop ONOS node " + stri + "." )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700377 stopResult = main.ONOSbench.onosStop( ip_address )
Jeremy Ronquillod7791d82017-08-14 16:23:08 +0000378 main.Cluster.runningNodes[ i ].active = False
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700379
380 utilities.assert_equals( expect=main.TRUE, actual=stopResult,
381 onpass="ONOS nodes stopped successfully.",
382 onfail="ONOS nodes NOT successfully stopped." )
383
384 # Check connectivity
385 connectivityResult = vpls.testConnectivityVpls( main, isNodeUp=False )
386 result = result and connectivityResult
387
388 # Restart ONOS node
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700389 main.step( "Restart ONOS node " + stri + " and checking status of restart." )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700390 startResult = main.ONOSbench.onosStart( ip_address )
391
392 utilities.assert_equals( expect=main.TRUE, actual=startResult,
393 onpass="ONOS nodes started successfully.",
394 onfail="ONOS nodes NOT successfully started." )
395 result = result and startResult
396
397 # Check if ONOS is up yet
398 main.log.info( "Checking if ONOS node " + stri + " is up." )
399 upResult = main.ONOSbench.isup( ip_address )
400
401 utilities.assert_equals( expect=main.TRUE, actual=upResult,
402 onpass="ONOS successfully restarted.",
403 onfail="ONOS did NOT successfully restart." )
404
405 # Restart CLI
406 main.log.info( "Restarting ONOS node " + stri + "'s main.CLI." )
Jeremy Ronquillod7791d82017-08-14 16:23:08 +0000407 cliResults = main.Cluster.active( 0 ).CLI.startOnosCli( ip_address )
408 main.Cluster.runningNodes[ i ].active = True
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700409
410 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
411 onpass="ONOS CLI successfully restarted.",
412 onfail="ONOS CLI did NOT successfully restart." )
413
414 # Run some basic checks to see if ONOS node truly has succesfully restarted:
415
416 # Checking if all nodes appear with status READY using 'nodes' command
417 main.step( "Checking ONOS nodes." )
418 nodeResults = utilities.retry( main.HA.nodesCheck,
419 False,
Jeremy Ronquillod7791d82017-08-14 16:23:08 +0000420 args=[ main.Cluster.runningNodes ],
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700421 sleep=main.timeSleep,
422 attempts=main.numAttempts )
423
424 utilities.assert_equals( expect=True, actual=nodeResults,
425 onpass="Nodes check successful.",
426 onfail="Nodes check NOT successful." )
427
428 # All apps that are present are active
429 main.log.info( "Checking if apps are active." )
430 compareAppsResult = vpls.compareApps( main )
431 utilities.assert_equals( expect=main.TRUE,
432 actual=compareAppsResult,
433 onpass="Apps are the same across all nodes.",
434 onfail="Apps are NOT the same across all nodes." )
435 result = result and compareAppsResult
436
437 # Check connectivity
438 connectivityResult = vpls.testConnectivityVpls( main )
439 result = result and connectivityResult
440
441 utilities.assert_equals( expect=main.TRUE,
442 actual=result,
443 onpass="Connectivity is as expected.",
444 onfail="Connectivity is NOT as expected." )
445
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700446 def CASE310( self, main ):
447 """
448 Kill 1 ONOS node at a time and test connectivity
449 """
450 assert vpls, "vpls not defined"
451
452 main.case( "Kill one ONOS node at a time and test connectivity." )
453 killSleep = int( main.params[ 'SLEEP' ][ 'killnode' ] )
454 result = main.TRUE
455
Jeremy Ronquillod7791d82017-08-14 16:23:08 +0000456 for i in range( 0, main.Cluster.numCtrls ):
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700457
458 # Kill an ONOS node
459 main.step( "Killing ONOS node " + str( i + 1 ) + "." )
Jeremy Ronquillod7791d82017-08-14 16:23:08 +0000460 killresult = main.ONOSbench.onosKill( main.Cluster.active( i ).ipAddress )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700461
462 # Check if ONOS node has been successfully killed
463 utilities.assert_equals( expect=main.TRUE, actual=killresult,
464 onpass="ONOS node killed successfully.",
465 onfail="ONOS node NOT successfully killed." )
466
467 main.step( "Waiting for ONOS to restart." )
468 main.log.info( "Sleeping for " + str( killSleep ) + " seconds..." )
469 time.sleep( killSleep )
470
471 # Check connectivity
472 connectivityResult = vpls.testConnectivityVpls( main )
473 result = result and connectivityResult
474
475 utilities.assert_equals( expect=main.TRUE,
476 actual=result,
477 onpass="Connectivity is as expected.",
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700478 onfail="Connectivity is NOT as expected." )
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700479
480 def CASE400( self, main ):
481 """
482 Bring down 1 link at a time and test connectivity
483 """
484 assert vpls, "vpls not defined"
485
Jeremy Ronquillo3008aa32017-07-07 15:38:57 -0700486 main.case( "Bring down one link at a time and test connectivity." )
487
488 result = main.TRUE
489
490 for link in main.Mininet1.getLinks():
491 nodes = [ link[ 'node1' ], link[ 'node2' ] ]
492
493 # Bring down a link
494 main.step( "Bring down link: " + nodes[ 0 ] + " to " + nodes[ 1 ] )
495 delLinkResult = main.Mininet1.link( END1=nodes[ 0 ], END2=nodes[ 1 ], OPTION="down" )
496
497 # Check if the link has successfully been brought down
498 utilities.assert_equals( expect=main.TRUE, actual=delLinkResult,
499 onpass="Successfully deleted link.",
500 onfail="Failed to delete link." )
501 result = result and delLinkResult
502
503 # Add removed host to blacklist if necessary
504 blacklist = []
505 for l in nodes:
506 if l[ 0 ] == 'h':
507 blacklist.append( l )
508
509 # Check intent states, then connectivity
510 connectivityResult = vpls.testConnectivityVpls( main, blacklist )
511 result = result and connectivityResult
512
513 # Re-add the link
514 main.step( "Adding link: " + nodes[ 0 ] + " to " + nodes[ 1 ] + "." )
515 addLinkResult = main.Mininet1.link( END1=nodes[ 0 ], END2=nodes[ 1 ], OPTION="up" )
516
517 # Check if the link has successfully been added
518 utilities.assert_equals( expect=main.TRUE, actual=addLinkResult,
519 onpass="Successfully added link.",
520 onfail="Failed to delete link." )
521 result = result and addLinkResult
522
523 main.log.debug( main.timeSleep )
524 time.sleep( main.timeSleep )
525
526 # Check intent states, then connectivity
527 connectivityResult = vpls.testConnectivityVpls( main )
528 result = result and connectivityResult
529
530 utilities.assert_equals( expect=main.TRUE,
531 actual=result,
532 onpass="Connectivity is as expected.",
533 onfail="Connectivity is NOT as expected." )