blob: c3d93be704bacc57075ad7dc880a4f085e6cf021 [file] [log] [blame]
Jonghwan Hyun3731d6a2017-10-19 11:59:31 -07001"""
2Copyright 2017 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 Wangac02b142018-01-26 14:57:28 -080022from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
You Wang68568b12019-03-04 11:49:57 -080023import tests.USECASE.SegmentRouting.dependencies.cfgtranslator as translator
Jonghwan Hyun3731d6a2017-10-19 11:59:31 -070024
25class SRBridgingTest ():
26
27 def __init__( self ):
28 self.default = ''
Devin Lim57221b02018-02-14 15:45:36 -080029 self.topo = dict()
You Wang68568b12019-03-04 11:49:57 -080030 # TODO: Check minFlowCount of leaf for BMv2 switch
31 # (number of spine switch, number of leaf switch, dual-homed, description, minFlowCount - leaf (OvS), minFlowCount - leaf (BMv2))
32 self.topo[ '0x1' ] = ( 0, 1, False, 'single ToR', 28, 28 )
33 self.topo[ '0x2' ] = ( 0, 2, True, 'dual-homed ToR', 37, 37 )
34 self.topo[ '2x2' ] = ( 2, 2, False, '2x2 leaf-spine topology', 37, 32 )
Jonghwan Hyun3731d6a2017-10-19 11:59:31 -070035 # TODO: Implement 2x3 topology
Jonghwan Hyun98fb40a2018-01-04 16:16:28 -080036 # topo[ '2x3' ] = ( 2, 3, True, '2x3 leaf-spine topology with dual ToR and single ToR', 28 )
You Wang68568b12019-03-04 11:49:57 -080037 self.topo[ '2x4' ] = ( 2, 4, True, '2x4 dual-homed leaf-spine topology', 53, 53 )
Devin Lim57221b02018-02-14 15:45:36 -080038 self.switchNames = {}
Jon Hall43060f62020-06-23 13:13:33 -070039 self.switchNames[ '0x1' ] = [ "leaf1" ]
Devin Lim57221b02018-02-14 15:45:36 -080040 self.switchNames[ '2x2' ] = [ "leaf1", "leaf2", "spine101", "spine102" ]
Jon Hall43060f62020-06-23 13:13:33 -070041 main.switchType = "ovs"
Jonghwan Hyun3731d6a2017-10-19 11:59:31 -070042
Devin Lim57221b02018-02-14 15:45:36 -080043 def runTest( self, main, test_idx, topology, onosNodes, description, vlan = [] ):
Jon Hall9b0de1f2020-08-24 15:38:04 -070044 try:
45 skipPackage = False
46 init = False
47 if not hasattr( main, 'apps' ):
48 init = True
49 run.initTest( main )
50 # Skip onos packaging if the clusrer size stays the same
51 if not init and onosNodes == main.Cluster.numCtrls:
52 skipPackage = True
Jonghwan Hyun3731d6a2017-10-19 11:59:31 -070053
Jon Hall9b0de1f2020-08-24 15:38:04 -070054 main.case( '%s, with %s, %s switches and %d ONOS instance%s' %
55 ( description, self.topo[ topology ][ 3 ], main.switchType, onosNodes, 's' if onosNodes > 1 else '' ) )
Jonghwan Hyun3731d6a2017-10-19 11:59:31 -070056
Jon Hall9b0de1f2020-08-24 15:38:04 -070057 main.cfgName = 'CASE%01d%01d' % ( test_idx / 10, ( ( test_idx - 1 ) % 10 ) % 4 + 1 )
58 main.Cluster.setRunningNode( onosNodes )
59 run.installOnos( main, skipPackage=skipPackage, cliSleep=5 )
You Wang68568b12019-03-04 11:49:57 -080060 if main.useBmv2:
Jon Hall9b0de1f2020-08-24 15:38:04 -070061 switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', "bmv2" )
62 # Translate configuration file from OVS-OFDPA to BMv2 driver
63 translator.bmv2ToOfdpa( main ) # Try to cleanup if switching between switch types
64 translator.ofdpaToBmv2( main, switchPrefix=switchPrefix )
65 else:
66 translator.bmv2ToOfdpa( main )
67 suf = main.params.get( 'jsonFileSuffix', None)
68 if suf:
69 run.loadJson( main, suffix=suf )
70 else:
71 run.loadJson( main )
72 run.loadChart( main )
73 if hasattr( main, 'Mininet1' ):
74 run.mnDockerSetup( main ) # optionally create and setup docker image
Jonghwan Hyun3731d6a2017-10-19 11:59:31 -070075
Jon Hall9b0de1f2020-08-24 15:38:04 -070076 # Run the test with Mininet
77 mininet_args = ' --spine=%d --leaf=%d' % ( self.topo[ topology ][ 0 ], self.topo[ topology ][ 1 ] )
78 if self.topo[ topology ][ 2 ]:
79 mininet_args += ' --dual-homed'
80 if len( vlan ) > 0 :
81 mininet_args += ' --vlan=%s' % ( ','.join( ['%d' % vlanId for vlanId in vlan ] ) )
82 if main.useBmv2:
83 mininet_args += ' --switch %s' % main.switchType
84 main.log.info( "Using %s switch" % main.switchType )
Jon Halldac3eae2020-06-05 12:04:06 -070085
Jon Hall9b0de1f2020-08-24 15:38:04 -070086 run.startMininet( main, 'trellis_fabric.py', args=mininet_args )
You Wangd5873482018-01-24 12:30:00 -080087
Jon Hall9b0de1f2020-08-24 15:38:04 -070088 else:
89 # Run the test with physical devices
90 run.connectToPhysicalNetwork( main )
91
92 run.checkFlows( main, minFlowCount=self.topo[ topology ][ 5 if main.useBmv2 else 4 ] * self.topo[ topology ][ 1 ], sleep=5 )
93 if main.useBmv2:
94 leaf_dpid = [ "device:bmv2:leaf%d" % ( ls + 1 ) for ls in range( self.topo[ topology ][ 1 ]) ]
95 else:
96 leaf_dpid = [ "of:%016d" % ( ls + 1 ) for ls in range( self.topo[ topology ][ 1 ] ) ]
97 for dpid in leaf_dpid:
98 run.checkFlowsByDpid( main, dpid, self.topo[ topology ][ 5 if main.useBmv2 else 4 ], sleep=5 )
99 run.pingAll( main )
100 except Exception as e:
101 main.log.exception( "Error in runTest" )
102 main.skipCase( result="FAIL", msg=e )
Jon Hallf69e3162020-09-01 09:08:44 -0700103 finally:
104 run.cleanup( main )