blob: 734dc523c07a1671bd2eb767b87c77b8c0b1215e [file] [log] [blame]
Pier6a0c4de2018-03-18 16:01:30 -07001"""
2Copyright 2018 Open Networking Foundation ( ONF )
3
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
11 ( at your option ) any later version.
12
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"""
21
You Wange24d6272018-03-27 21:18:50 -070022import time
Pier6a0c4de2018-03-18 16:01:30 -070023from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
24
25class SRMulticastTest ():
26
27 def __init__( self ):
28 self.default = ''
You Wange24d6272018-03-27 21:18:50 -070029 self.switchNames = [ "leaf205", "leaf206", "spine227", "spine228" ]
Pier6a0c4de2018-03-18 16:01:30 -070030
You Wange24d6272018-03-27 21:18:50 -070031 def runTest( self, main, test_idx, onosNodes, description, removeRoute=False, linkFailure=False, switchFailure=False ):
Pier6a0c4de2018-03-18 16:01:30 -070032 skipPackage = False
33 init = False
34 if not hasattr( main, 'apps' ):
35 init = True
36 run.initTest( main )
37 # Skip onos packaging if the cluster size stays the same
38 if not init and onosNodes == main.Cluster.numCtrls:
39 skipPackage = True
40
You Wange24d6272018-03-27 21:18:50 -070041 main.resultFileName = 'CASE%03d' % test_idx
Pier6a0c4de2018-03-18 16:01:30 -070042 main.Cluster.setRunningNode( onosNodes )
43 run.installOnos( main, skipPackage=skipPackage, cliSleep=5 )
You Wange24d6272018-03-27 21:18:50 -070044 # Load configuration files
45 main.step("Load configurations")
46 main.cfgName = 'TEST_CONFIG_ipv4=1_ipv6=1_dhcp=1_routers=1'
47 run.loadJson( main )
48 main.cfgName = 'CASE%03d' % test_idx
49 run.loadMulticastConfig( main )
50 if linkFailure:
51 run.loadLinkFailureChart( main )
52 if switchFailure:
53 run.loadSwitchFailureChart( main )
54 time.sleep( float( main.params[ 'timers' ][ 'loadNetcfgSleep' ] ) )
55
Pier6a0c4de2018-03-18 16:01:30 -070056 if hasattr( main, 'Mininet1' ):
You Wange24d6272018-03-27 21:18:50 -070057 # Run the test with Mininet
58 mininet_args = ' --dhcp=1 --routers=1 --ipv6=1 --ipv4=1'
59 run.startMininet( main, main.params['DEPENDENCY']['topology'], args=mininet_args )
60 time.sleep( float( main.params[ 'timers' ][ 'startMininetSleep' ] ) )
Pier6a0c4de2018-03-18 16:01:30 -070061 else:
62 # Run the test with physical devices
You Wange24d6272018-03-27 21:18:50 -070063 run.connectToPhysicalNetwork( main, self.switchNames )
64 # Check if the devices are up
65 run.checkDevices( main, switches=len( self.switchNames ) )
66
67 # Create scapy components
68 run.startScapyHosts( main )
69
70 for entry in main.multicastConfig:
71 main.step("Verify adding multicast route with group IP {}".format(entry["group"]))
72 # Create a multicast route
73 main.Cluster.active( 0 ).CLI.mcastHostJoin( entry["sIP"], entry["group"], entry["sPorts"], entry["dHosts"] )
74 time.sleep( float( main.params[ 'timers' ][ 'mcastSleep' ] ) )
75 # Check the flows against the devices
76 # run.checkFlows( main, minFlowCount=2, sleep=5 )
77 # Verify multicast traffic
78 run.verifyMulticastTraffic( main, entry, True, skipOnFail=True )
79
80 # Test switch failures
81 if switchFailure:
82 for switch, expected in main.switchFailureChart.items():
83 run.killSwitch( main, switch, expected['switches_after_failure'], expected['links_after_failure'] )
84 run.verifyMulticastTraffic( main, entry, True, skipOnFail=True )
85
86 run.recoverSwitch( main, switch, expected['switches_before_failure'], expected['links_before_failure'] )
87 run.verifyMulticastTraffic( main, entry, True, skipOnFail=True )
88
89 # Test link failures
90 if linkFailure:
91 for link_batch_name, info in main.linkFailureChart.items():
92 linksToRemove = info['links'].values()
93 linksBefore = info['links_before']
94 linksAfter = info['links_after']
95
96 run.killLinkBatch( main, linksToRemove, linksAfter, switches=10 )
97 run.verifyMulticastTraffic( main, entry, True, skipOnFail=True )
98
99 run.restoreLinkBatch( main, linksToRemove, linksBefore, switches=10 )
100 run.verifyMulticastTraffic( main, entry, True, skipOnFail=True )
101
102 if removeRoute:
103 main.step("Verify deleting multicast route with group IP {}".format(entry["group"]))
104 # delete a multicast route
105 main.Cluster.active( 0 ).CLI.mcastHostDelete( entry["sIP"], entry["group"] )
106 time.sleep( float( main.params[ 'timers' ][ 'mcastSleep' ] ) )
107 # Check the flows against the devices
108 # run.checkFlows( main, minFlowCount=2, sleep=5 )
109 # Verify multicast traffic (traffic check is expected to fail)
110 run.verifyMulticastTraffic( main, entry, False, skipOnFail=True )
111
Pier6a0c4de2018-03-18 16:01:30 -0700112 # Clean up the environment
You Wange24d6272018-03-27 21:18:50 -0700113 run.cleanup( main, copyKarafLog=False )