blob: 908c359972b6e16c743e4c064f63995520c0286e [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
23
24class SRSwitchFailureFuncs():
25
26 def __init__( self ):
27 self.default = ''
28 self.topo = dict()
29 self.topo[ '0x1' ] = ( 0, 1, '--leaf=1 --spine=0', 'single switch' )
30 self.topo[ '2x2' ] = ( 2, 2, '', '2x2 Leaf-spine' )
31 self.topo[ '4x4' ] = ( 4, 4, '--leaf=4 --spine=4', '4x4 Leaf-spine' )
32
33 def runTest( self, main, caseNum, numNodes, Topo, minFlow ):
Jon Hall9b0de1f2020-08-24 15:38:04 -070034 try:
35 if not hasattr( main, 'apps' ):
36 run.initTest( main )
Devin Lim57221b02018-02-14 15:45:36 -080037
Jon Hall9b0de1f2020-08-24 15:38:04 -070038 description = "Switch Failure test with " + self.topo[ Topo ][ 3 ] + " and {} Onos".format( numNodes )
39 main.case( description )
Devin Lim57221b02018-02-14 15:45:36 -080040
Jon Hall9b0de1f2020-08-24 15:38:04 -070041 main.cfgName = Topo
42 main.Cluster.setRunningNode( numNodes )
43 run.installOnos( main )
44 run.loadJson( main )
45 run.loadChart( main )
46 run.startMininet( main, 'cord_fabric.py', args=self.topo[ Topo ][ 2 ] )
47 # pre-configured routing and bridging test
48 run.checkFlows( main, minFlowCount=minFlow )
49 run.pingAll( main )
50 # switch failure\
51 switch = main.params[ 'kill' ][ 'switch' ]
52 switchNum = self.topo[ Topo ][ 0 ] + self.topo[ Topo ][ 1 ]
53 linkNum = ( self.topo[ Topo ][ 0 ] + self.topo[ Topo ][ 1 ] ) * self.topo[ Topo ][ 0 ]
54 run.killSwitch( main, switch, switches='{}'.format( switchNum - 1 ), links='{}'.format( linkNum - switchNum ) )
55 run.pingAll( main, "CASE{}_Failure".format( caseNum ) )
56 run.recoverSwitch( main, switch, switches='{}'.format( switchNum ), links='{}'.format( linkNum ) )
57 run.checkFlows( main, minFlowCount=minFlow, tag="CASE{}_Recovery".format( caseNum ) )
58 run.pingAll( main, "CASE{}_Recovery".format( caseNum ) )
59 # TODO Dynamic config of hosts in subnet
60 # TODO Dynamic config of host not in subnet
61 # TODO Dynamic config of vlan xconnect
62 # TODO Vrouter integration
63 # TODO Mcast integration
Jon Hallf69e3162020-09-01 09:08:44 -070064 except Exception as e:
65 main.log.exception( "Error in runTest" )
66 main.skipCase( result="FAIL", msg=e )
67 finally:
Jon Hall9b0de1f2020-08-24 15:38:04 -070068 if hasattr( main, 'Mininet1' ):
69 run.cleanup( main )
70 else:
71 # TODO: disconnect TestON from the physical network
72 pass