[ONOS-7524] Mininet based SRMulticast tests
Change-Id: I92f69417f10b24fad386fe348fa4ed148ad173e7
diff --git a/TestON/tests/USECASE/SegmentRouting/SRMulticast/dependencies/SRMulticastTest.py b/TestON/tests/USECASE/SegmentRouting/SRMulticast/dependencies/SRMulticastTest.py
index e822c29..734dc52 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRMulticast/dependencies/SRMulticastTest.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRMulticast/dependencies/SRMulticastTest.py
@@ -19,19 +19,16 @@
along with TestON. If not, see <http://www.gnu.org/licenses/>.
"""
+import time
from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
class SRMulticastTest ():
def __init__( self ):
self.default = ''
- self.topo = dict()
- # (number of spine switch, number of leaf switch, dual-homed, description, minFlowCount - leaf)
- self.topo[ '2x2' ] = ( 2, 2, False, '2x2 leaf-spine topology', 1 )
- self.switchNames = {}
- self.switchNames[ '2x2' ] = [ "leaf205", "leaf206", "spine227", "spine228" ]
+ self.switchNames = [ "leaf205", "leaf206", "spine227", "spine228" ]
- def runTest( self, main, test_idx, topology, onosNodes, description, vlan = [] ):
+ def runTest( self, main, test_idx, onosNodes, description, removeRoute=False, linkFailure=False, switchFailure=False ):
skipPackage = False
init = False
if not hasattr( main, 'apps' ):
@@ -41,21 +38,76 @@
if not init and onosNodes == main.Cluster.numCtrls:
skipPackage = True
- main.case( '%s, with %s and %d ONOS instance%s' %
- ( description, self.topo[ topology ][ 3 ], onosNodes, 's' if onosNodes > 1 else '' ) )
-
- main.cfgName = 'CASE%01d%01d' % ( test_idx / 10, ( ( test_idx - 1 ) % 10 ) % 4 + 1 )
+ main.resultFileName = 'CASE%03d' % test_idx
main.Cluster.setRunningNode( onosNodes )
run.installOnos( main, skipPackage=skipPackage, cliSleep=5 )
+ # Load configuration files
+ main.step("Load configurations")
+ main.cfgName = 'TEST_CONFIG_ipv4=1_ipv6=1_dhcp=1_routers=1'
+ run.loadJson( main )
+ main.cfgName = 'CASE%03d' % test_idx
+ run.loadMulticastConfig( main )
+ if linkFailure:
+ run.loadLinkFailureChart( main )
+ if switchFailure:
+ run.loadSwitchFailureChart( main )
+ time.sleep( float( main.params[ 'timers' ][ 'loadNetcfgSleep' ] ) )
+
if hasattr( main, 'Mininet1' ):
- # TODO Mininet implementation
- pass
+ # Run the test with Mininet
+ mininet_args = ' --dhcp=1 --routers=1 --ipv6=1 --ipv4=1'
+ run.startMininet( main, main.params['DEPENDENCY']['topology'], args=mininet_args )
+ time.sleep( float( main.params[ 'timers' ][ 'startMininetSleep' ] ) )
else:
# Run the test with physical devices
- run.connectToPhysicalNetwork( main, self.switchNames[ topology ] )
- # Check if the devices are up
- run.checkDevices( main, switches=len(self.switchNames[ topology ]))
- # Check the flows against the devices
- run.checkFlows( main, minFlowCount=self.topo[ topology ][ 4 ] * self.topo[ topology ][ 1 ], sleep=5 )
+ run.connectToPhysicalNetwork( main, self.switchNames )
+ # Check if the devices are up
+ run.checkDevices( main, switches=len( self.switchNames ) )
+
+ # Create scapy components
+ run.startScapyHosts( main )
+
+ for entry in main.multicastConfig:
+ main.step("Verify adding multicast route with group IP {}".format(entry["group"]))
+ # Create a multicast route
+ main.Cluster.active( 0 ).CLI.mcastHostJoin( entry["sIP"], entry["group"], entry["sPorts"], entry["dHosts"] )
+ time.sleep( float( main.params[ 'timers' ][ 'mcastSleep' ] ) )
+ # Check the flows against the devices
+ # run.checkFlows( main, minFlowCount=2, sleep=5 )
+ # Verify multicast traffic
+ run.verifyMulticastTraffic( main, entry, True, skipOnFail=True )
+
+ # Test switch failures
+ if switchFailure:
+ for switch, expected in main.switchFailureChart.items():
+ run.killSwitch( main, switch, expected['switches_after_failure'], expected['links_after_failure'] )
+ run.verifyMulticastTraffic( main, entry, True, skipOnFail=True )
+
+ run.recoverSwitch( main, switch, expected['switches_before_failure'], expected['links_before_failure'] )
+ run.verifyMulticastTraffic( main, entry, True, skipOnFail=True )
+
+ # Test link failures
+ if linkFailure:
+ for link_batch_name, info in main.linkFailureChart.items():
+ linksToRemove = info['links'].values()
+ linksBefore = info['links_before']
+ linksAfter = info['links_after']
+
+ run.killLinkBatch( main, linksToRemove, linksAfter, switches=10 )
+ run.verifyMulticastTraffic( main, entry, True, skipOnFail=True )
+
+ run.restoreLinkBatch( main, linksToRemove, linksBefore, switches=10 )
+ run.verifyMulticastTraffic( main, entry, True, skipOnFail=True )
+
+ if removeRoute:
+ main.step("Verify deleting multicast route with group IP {}".format(entry["group"]))
+ # delete a multicast route
+ main.Cluster.active( 0 ).CLI.mcastHostDelete( entry["sIP"], entry["group"] )
+ time.sleep( float( main.params[ 'timers' ][ 'mcastSleep' ] ) )
+ # Check the flows against the devices
+ # run.checkFlows( main, minFlowCount=2, sleep=5 )
+ # Verify multicast traffic (traffic check is expected to fail)
+ run.verifyMulticastTraffic( main, entry, False, skipOnFail=True )
+
# Clean up the environment
- run.cleanup( main, physical=(not hasattr( main, 'Mininet1' )))
+ run.cleanup( main, copyKarafLog=False )