blob: 9da11a59e543dc3452f871467723b2bb352f1d9f [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 SROnosFailureFuncs():
26
27 def __init__( self ):
28 self.default = ''
Siddesh167bc882021-03-23 21:03:43 +000029 self.topo = run.getTopo()
Jon Hall214f88b2020-09-21 10:21:42 -070030 main.switchType = "ovs"
Devin Lim57221b02018-02-14 15:45:36 -080031
Siddesh167bc882021-03-23 21:03:43 +000032 def runTest( self, main, caseNum, numNodes, topology, minFlow, killList=[ 0 ] ):
Jon Hall9b0de1f2020-08-24 15:38:04 -070033 try:
Siddesh167bc882021-03-23 21:03:43 +000034 description = "ONOS Failure test with " + self.topo[ topology ][ 'description' ]
Jon Hall9b0de1f2020-08-24 15:38:04 -070035 main.case( description )
36 if not hasattr( main, 'apps' ):
37 run.initTest( main )
Siddesh167bc882021-03-23 21:03:43 +000038 main.cfgName = topology
Jon Hall9b0de1f2020-08-24 15:38:04 -070039 main.Cluster.setRunningNode( numNodes )
40 run.installOnos( main )
Jon Hall214f88b2020-09-21 10:21:42 -070041 suf = main.params.get( 'jsonFileSuffix', '')
42 xconnectFile = "%s%s-xconnects.json%s" % ( main.configPath + main.forJson,
43 main.cfgName, suf )
44 if main.useBmv2:
45 switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', "bmv2" )
46 # Translate configuration file from OVS-OFDPA to BMv2 driver
47 translator.bmv2ToOfdpa( main ) # Try to cleanup if switching between switch types
48 translator.ofdpaToBmv2( main, switchPrefix=switchPrefix )
49 # translate xconnects
50 translator.bmv2ToOfdpa( main, cfgFile=xconnectFile )
51 translator.ofdpaToBmv2( main, cfgFile=xconnectFile, switchPrefix=switchPrefix )
52 else:
53 translator.bmv2ToOfdpa( main )
54 translator.bmv2ToOfdpa( main, cfgFile=xconnectFile )
Jon Hall06fd0df2021-01-25 15:50:06 -080055 if not main.persistentSetup:
56 if suf:
57 run.loadJson( main, suffix=suf )
58 else:
59 run.loadJson( main )
Jon Hall9b0de1f2020-08-24 15:38:04 -070060 run.loadChart( main )
61 if hasattr( main, 'Mininet1' ):
Jon Hallf69e3162020-09-01 09:08:44 -070062 run.mnDockerSetup( main ) # optionally create and setup docker image
63
64 # Run the test with Mininet
Siddesh167bc882021-03-23 21:03:43 +000065 mininet_args = self.topo[ topology ][ 'mininetArgs' ]
Jon Hallf69e3162020-09-01 09:08:44 -070066 if main.useBmv2:
67 mininet_args += ' --switch %s' % main.switchType
68 main.log.info( "Using %s switch" % main.switchType )
69
70 run.startMininet( main, 'cord_fabric.py', args=mininet_args )
Jon Hall9b0de1f2020-08-24 15:38:04 -070071 else:
72 # Run the test with physical devices
73 # TODO: connect TestON to the physical network
74 pass
Jon Hall06fd0df2021-01-25 15:50:06 -080075 if not main.persistentSetup:
76 # xconnects need to be loaded after topology
77 run.loadXconnects( main )
Siddesh167bc882021-03-23 21:03:43 +000078 switches = self.topo[ topology ][ 'spines' ] + self.topo[ topology ][ 'leaves' ]
79 links = ( self.topo[ topology ][ 'spines' ] * self.topo[ topology ][ 'leaves' ] ) * 2
Jon Hall9b0de1f2020-08-24 15:38:04 -070080 # pre-configured routing and bridging test
Jon Hall39570262020-11-17 12:18:19 -080081 run.verifyTopology( main, switches, links, numNodes )
Jon Hall9b0de1f2020-08-24 15:38:04 -070082 run.checkFlows( main, minFlowCount=minFlow )
83 run.pingAll( main, 'CASE{}'.format( caseNum ) )
Jon Hall39570262020-11-17 12:18:19 -080084 run.killOnos( main, killList, switches, links, '{}'.format( numNodes - 1 ) )
Jon Hall9b0de1f2020-08-24 15:38:04 -070085 run.pingAll( main, 'CASE{}_Failure'.format( caseNum ) )
Jon Hall39570262020-11-17 12:18:19 -080086 run.recoverOnos( main, killList, switches, links, '{}'.format( numNodes ) )
Jon Hall9b0de1f2020-08-24 15:38:04 -070087 run.checkFlows( main, minFlowCount=minFlow, tag='CASE{}_Recovery'.format( caseNum ) )
88 run.pingAll( main, 'CASE{}_Recovery'.format( caseNum ) )
Jon Hall39570262020-11-17 12:18:19 -080089 run.verifyTopology( main, switches, links, numNodes )
Jon Hall9b0de1f2020-08-24 15:38:04 -070090 # TODO Dynamic config of hosts in subnet
91 # TODO Dynamic config of host not in subnet
92 # TODO Dynamic config of vlan xconnect
93 # TODO Vrouter integration
94 # TODO Mcast integration
Jon Hall9b0de1f2020-08-24 15:38:04 -070095 except Exception as e:
96 main.log.exception( "Error in runTest" )
97 main.skipCase( result="FAIL", msg=e )
Jon Hallf69e3162020-09-01 09:08:44 -070098 finally:
99 run.cleanup( main )