blob: 0a0ef5a84c182cfdd28b71fc6e208f8022a0503a [file] [log] [blame]
Devin Lim57221b02018-02-14 15:45:36 -08001"""
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
22from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
Jon Hall214f88b2020-09-21 10:21:42 -070023import tests.USECASE.SegmentRouting.dependencies.cfgtranslator as translator
Devin Lim57221b02018-02-14 15:45:36 -080024
25class SRLinkFailFuncs():
26
27 def __init__( self ):
28 self.default = ''
29 self.topo = dict()
30 self.topo[ '0x1' ] = ( 0, 1, '--leaf=1 --spine=0', 'single switch' )
31 self.topo[ '2x2' ] = ( 2, 2, '', '2x2 Leaf-spine' )
32 self.topo[ '4x4' ] = ( 4, 4, '--leaf=4 --spine=4', '4x4 Leaf-spine' )
Jon Hall214f88b2020-09-21 10:21:42 -070033 main.switchType = "ovs"
Devin Lim57221b02018-02-14 15:45:36 -080034 self.switchOne = 'spine101'
35 self.switchTwo = 'leaf2'
36 self.dpidOne = 'of:0000000000000101'
37 self.dpidTwo = 'of:0000000000000002'
38 self.portOne = '2'
39 self.portTwo = '3'
40
41 def runTest( self, main, caseNum, numNodes, Topo, minFlow ):
Jon Hall9b0de1f2020-08-24 15:38:04 -070042 try:
Jon Hall9b0de1f2020-08-24 15:38:04 -070043 description = "Bridging and Routing Link Failure test with " + self.topo[ Topo ][ 3 ] + " and {} Onos".format( numNodes )
44 main.case( description )
Jon Hall214f88b2020-09-21 10:21:42 -070045 if not hasattr( main, 'apps' ):
46 run.initTest( main )
Jon Hall9b0de1f2020-08-24 15:38:04 -070047 main.cfgName = Topo
48 main.Cluster.setRunningNode( numNodes )
49 run.installOnos( main )
Jon Hall214f88b2020-09-21 10:21:42 -070050 suf = main.params.get( 'jsonFileSuffix', '')
51 xconnectFile = "%s%s-xconnects.json%s" % ( main.configPath + main.forJson,
52 main.cfgName, suf )
53 if main.useBmv2:
54 switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', "bmv2" )
55 # Translate configuration file from OVS-OFDPA to BMv2 driver
56 translator.bmv2ToOfdpa( main ) # Try to cleanup if switching between switch types
57 translator.ofdpaToBmv2( main, switchPrefix=switchPrefix )
58 # translate xconnects
59 translator.bmv2ToOfdpa( main, cfgFile=xconnectFile )
60 translator.ofdpaToBmv2( main, cfgFile=xconnectFile, switchPrefix=switchPrefix )
61 else:
62 translator.bmv2ToOfdpa( main )
63 translator.bmv2ToOfdpa( main, cfgFile=xconnectFile )
64 if suf:
65 run.loadJson( main, suffix=suf )
66 else:
67 run.loadJson( main )
Jon Hall9b0de1f2020-08-24 15:38:04 -070068 run.loadChart( main )
Jon Hall214f88b2020-09-21 10:21:42 -070069 if hasattr( main, 'Mininet1' ):
70 run.mnDockerSetup( main ) # optionally create and setup docker image
71
72 # Run the test with Mininet
73 mininet_args = self.topo[ Topo ][ 2 ]
74 if main.useBmv2:
75 mininet_args += ' --switch %s' % main.switchType
76 main.log.info( "Using %s switch" % main.switchType )
77
78 run.startMininet( main, 'cord_fabric.py', args=mininet_args )
79 else:
80 # Run the test with physical devices
81 # TODO: connect TestON to the physical network
82 pass
Jon Hall10e2ab82020-09-15 17:14:54 -070083 # xconnects need to be loaded after topology
84 run.loadXconnects( main )
Jon Hall9b0de1f2020-08-24 15:38:04 -070085 # pre-configured routing and bridging test
86 run.checkFlows( main, minFlowCount=minFlow )
87 run.pingAll( main )
88 switch = self.topo[ Topo ][ 0 ] + self.topo[ Topo ][ 1 ]
89 link = ( self.topo[ Topo ][ 0 ] + self.topo[ Topo ][ 1 ] ) * self.topo[ Topo ][ 0 ]
90 # link failure
91 run.killLink( main, self.switchOne, self.switchTwo, switches='{}'.format( switch ), links='{}'.format( link - 2 ) )
92 run.pingAll( main, "CASE{}_Failure".format( caseNum ) )
93 run.restoreLink( main, self.switchOne, self.switchTwo, '{}'.format( switch ), '{}'.format( link ),
94 True, self.dpidOne, self.dpidTwo, self.portOne, self.portTwo )
95 run.pingAll( main, "CASE{}_Recovery".format( caseNum ) )
96 # TODO Dynamic config of hosts in subnet
97 # TODO Dynamic config of host not in subnet
98 # TODO Dynamic config of vlan xconnect
99 # TODO Vrouter integration
100 # TODO Mcast integration
Jon Hall9b0de1f2020-08-24 15:38:04 -0700101 except Exception as e:
102 main.log.exception( "Error in runTest" )
103 main.skipCase( result="FAIL", msg=e )
Jon Hallf69e3162020-09-01 09:08:44 -0700104 finally:
105 run.cleanup( main )