blob: 42e646a839becaa9d7841c52bca686ab5304bc1f [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 Wangece951a2018-04-16 13:34:43 -070041 main.case( '%s, ONOS cluster size: %s' % ( description, onosNodes ) )
42
You Wange24d6272018-03-27 21:18:50 -070043 main.resultFileName = 'CASE%03d' % test_idx
Pier6a0c4de2018-03-18 16:01:30 -070044 main.Cluster.setRunningNode( onosNodes )
45 run.installOnos( main, skipPackage=skipPackage, cliSleep=5 )
You Wange24d6272018-03-27 21:18:50 -070046 # Load configuration files
47 main.step("Load configurations")
48 main.cfgName = 'TEST_CONFIG_ipv4=1_ipv6=1_dhcp=1_routers=1'
49 run.loadJson( main )
50 main.cfgName = 'CASE%03d' % test_idx
51 run.loadMulticastConfig( main )
52 if linkFailure:
53 run.loadLinkFailureChart( main )
54 if switchFailure:
55 run.loadSwitchFailureChart( main )
56 time.sleep( float( main.params[ 'timers' ][ 'loadNetcfgSleep' ] ) )
57
Pier6a0c4de2018-03-18 16:01:30 -070058 if hasattr( main, 'Mininet1' ):
You Wange24d6272018-03-27 21:18:50 -070059 # Run the test with Mininet
60 mininet_args = ' --dhcp=1 --routers=1 --ipv6=1 --ipv4=1'
61 run.startMininet( main, main.params['DEPENDENCY']['topology'], args=mininet_args )
62 time.sleep( float( main.params[ 'timers' ][ 'startMininetSleep' ] ) )
Pier6a0c4de2018-03-18 16:01:30 -070063 else:
64 # Run the test with physical devices
You Wange24d6272018-03-27 21:18:50 -070065 run.connectToPhysicalNetwork( main, self.switchNames )
66 # Check if the devices are up
67 run.checkDevices( main, switches=len( self.switchNames ) )
68
69 # Create scapy components
70 run.startScapyHosts( main )
71
72 for entry in main.multicastConfig:
73 main.step("Verify adding multicast route with group IP {}".format(entry["group"]))
74 # Create a multicast route
75 main.Cluster.active( 0 ).CLI.mcastHostJoin( entry["sIP"], entry["group"], entry["sPorts"], entry["dHosts"] )
76 time.sleep( float( main.params[ 'timers' ][ 'mcastSleep' ] ) )
77 # Check the flows against the devices
78 # run.checkFlows( main, minFlowCount=2, sleep=5 )
79 # Verify multicast traffic
80 run.verifyMulticastTraffic( main, entry, True, skipOnFail=True )
81
82 # Test switch failures
83 if switchFailure:
84 for switch, expected in main.switchFailureChart.items():
85 run.killSwitch( main, switch, expected['switches_after_failure'], expected['links_after_failure'] )
86 run.verifyMulticastTraffic( main, entry, True, skipOnFail=True )
87
88 run.recoverSwitch( main, switch, expected['switches_before_failure'], expected['links_before_failure'] )
89 run.verifyMulticastTraffic( main, entry, True, skipOnFail=True )
90
91 # Test link failures
92 if linkFailure:
93 for link_batch_name, info in main.linkFailureChart.items():
94 linksToRemove = info['links'].values()
95 linksBefore = info['links_before']
96 linksAfter = info['links_after']
97
98 run.killLinkBatch( main, linksToRemove, linksAfter, switches=10 )
99 run.verifyMulticastTraffic( main, entry, True, skipOnFail=True )
100
101 run.restoreLinkBatch( main, linksToRemove, linksBefore, switches=10 )
102 run.verifyMulticastTraffic( main, entry, True, skipOnFail=True )
103
104 if removeRoute:
105 main.step("Verify deleting multicast route with group IP {}".format(entry["group"]))
106 # delete a multicast route
107 main.Cluster.active( 0 ).CLI.mcastHostDelete( entry["sIP"], entry["group"] )
108 time.sleep( float( main.params[ 'timers' ][ 'mcastSleep' ] ) )
109 # Check the flows against the devices
110 # run.checkFlows( main, minFlowCount=2, sleep=5 )
111 # Verify multicast traffic (traffic check is expected to fail)
112 run.verifyMulticastTraffic( main, entry, False, skipOnFail=True )
113
Pier6a0c4de2018-03-18 16:01:30 -0700114 # Clean up the environment
You Wange24d6272018-03-27 21:18:50 -0700115 run.cleanup( main, copyKarafLog=False )