blob: 82a46164899f99e16b3a2a505ecdade5e2bf1b67 [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 Hall39570262020-11-17 12:18:19 -080023import tests.USECASE.SegmentRouting.dependencies.cfgtranslator as translator
Devin Lim57221b02018-02-14 15:45:36 -080024
25class SRSwitchFailureFuncs():
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 Hall39570262020-11-17 12:18:19 -080033 main.switchType = "ovs"
Devin Lim57221b02018-02-14 15:45:36 -080034
35 def runTest( self, main, caseNum, numNodes, Topo, minFlow ):
Jon Hall9b0de1f2020-08-24 15:38:04 -070036 try:
Jon Hall9b0de1f2020-08-24 15:38:04 -070037 description = "Switch Failure test with " + self.topo[ Topo ][ 3 ] + " and {} Onos".format( numNodes )
38 main.case( description )
Jon Hall39570262020-11-17 12:18:19 -080039 if not hasattr( main, 'apps' ):
40 run.initTest( main )
Jon Hall9b0de1f2020-08-24 15:38:04 -070041 main.cfgName = Topo
42 main.Cluster.setRunningNode( numNodes )
43 run.installOnos( main )
Jon Hall39570262020-11-17 12:18:19 -080044 suf = main.params.get( 'jsonFileSuffix', '')
45 xconnectFile = "%s%s-xconnects.json%s" % ( main.configPath + main.forJson,
46 main.cfgName, suf )
47 if main.useBmv2:
48 switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', "bmv2" )
49 # Translate configuration file from OVS-OFDPA to BMv2 driver
50 translator.bmv2ToOfdpa( main ) # Try to cleanup if switching between switch types
51 translator.ofdpaToBmv2( main, switchPrefix=switchPrefix )
52 # translate xconnects
53 translator.bmv2ToOfdpa( main, cfgFile=xconnectFile )
54 translator.ofdpaToBmv2( main, cfgFile=xconnectFile, switchPrefix=switchPrefix )
55 else:
56 translator.bmv2ToOfdpa( main )
57 translator.bmv2ToOfdpa( main, cfgFile=xconnectFile )
Jon Hall06fd0df2021-01-25 15:50:06 -080058 if not main.persistentSetup:
59 if suf:
60 run.loadJson( main, suffix=suf )
61 else:
62 run.loadJson( main )
Jon Hall9b0de1f2020-08-24 15:38:04 -070063 run.loadChart( main )
Jon Hall39570262020-11-17 12:18:19 -080064 if hasattr( main, 'Mininet1' ):
65 run.mnDockerSetup( main ) # optionally create and setup docker image
66
67 # Run the test with Mininet
68 mininet_args = self.topo[ Topo ][ 2 ]
69 if main.useBmv2:
70 mininet_args += ' --switch %s' % main.switchType
71 main.log.info( "Using %s switch" % main.switchType )
72
73 run.startMininet( main, 'cord_fabric.py', args=mininet_args )
74 else:
75 # Run the test with physical devices
76 # TODO: connect TestON to the physical network
77 pass
78 # xconnects need to be loaded after topology
79 run.loadXconnects( main )
80 # switch failure
Jon Hall9b0de1f2020-08-24 15:38:04 -070081 switch = main.params[ 'kill' ][ 'switch' ]
82 switchNum = self.topo[ Topo ][ 0 ] + self.topo[ Topo ][ 1 ]
83 linkNum = ( self.topo[ Topo ][ 0 ] + self.topo[ Topo ][ 1 ] ) * self.topo[ Topo ][ 0 ]
Jon Hall39570262020-11-17 12:18:19 -080084 # pre-configured routing and bridging test
85 run.checkFlows( main, minFlowCount=minFlow )
86 run.pingAll( main )
Jon Hall9b0de1f2020-08-24 15:38:04 -070087 run.killSwitch( main, switch, switches='{}'.format( switchNum - 1 ), links='{}'.format( linkNum - switchNum ) )
88 run.pingAll( main, "CASE{}_Failure".format( caseNum ) )
89 run.recoverSwitch( main, switch, switches='{}'.format( switchNum ), links='{}'.format( linkNum ) )
90 run.checkFlows( main, minFlowCount=minFlow, tag="CASE{}_Recovery".format( caseNum ) )
91 run.pingAll( main, "CASE{}_Recovery".format( caseNum ) )
92 # TODO Dynamic config of hosts in subnet
93 # TODO Dynamic config of host not in subnet
94 # TODO Dynamic config of vlan xconnect
95 # TODO Vrouter integration
96 # TODO Mcast integration
Jon Hallf69e3162020-09-01 09:08:44 -070097 except Exception as e:
98 main.log.exception( "Error in runTest" )
99 main.skipCase( result="FAIL", msg=e )
100 finally:
Jon Hall9b0de1f2020-08-24 15:38:04 -0700101 if hasattr( main, 'Mininet1' ):
102 run.cleanup( main )
103 else:
104 # TODO: disconnect TestON from the physical network
105 pass