blob: 458a4a746e3f59afba25fdc23aec700d3b92b9d9 [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 = ''
Siddesh167bc882021-03-23 21:03:43 +000029 self.topo = run.getTopo()
Jonghwan Hyun3731d6a2017-10-19 11:59:31 -070030 # TODO: Implement 2x3 topology
Jonghwan Hyun98fb40a2018-01-04 16:16:28 -080031 # topo[ '2x3' ] = ( 2, 3, True, '2x3 leaf-spine topology with dual ToR and single ToR', 28 )
Devin Lim57221b02018-02-14 15:45:36 -080032 self.switchNames = {}
Jon Hall43060f62020-06-23 13:13:33 -070033 self.switchNames[ '0x1' ] = [ "leaf1" ]
Devin Lim57221b02018-02-14 15:45:36 -080034 self.switchNames[ '2x2' ] = [ "leaf1", "leaf2", "spine101", "spine102" ]
Jon Hall43060f62020-06-23 13:13:33 -070035 main.switchType = "ovs"
Jonghwan Hyun3731d6a2017-10-19 11:59:31 -070036
Siddesh606bd872021-06-29 23:42:36 +000037
Devin Lim57221b02018-02-14 15:45:36 -080038 def runTest( self, main, test_idx, topology, onosNodes, description, vlan = [] ):
Jon Hall9b0de1f2020-08-24 15:38:04 -070039 try:
40 skipPackage = False
41 init = False
42 if not hasattr( main, 'apps' ):
43 init = True
44 run.initTest( main )
Jon Hall214f88b2020-09-21 10:21:42 -070045 # Skip onos packaging if the cluster size stays the same
Jon Hall9b0de1f2020-08-24 15:38:04 -070046 if not init and onosNodes == main.Cluster.numCtrls:
47 skipPackage = True
Jonghwan Hyun3731d6a2017-10-19 11:59:31 -070048
Siddesh167bc882021-03-23 21:03:43 +000049 main.case( '%s, with %s, %s switches and %d ONOS instance%s' %( description, self.topo[ topology ][ 'description' ], main.switchType, onosNodes, 's' if onosNodes > 1 else '' ) )
50 spines = self.topo[ topology ][ 'spines' ]
51 leaves = self.topo[ topology ][ 'leaves' ]
Jon Hall39570262020-11-17 12:18:19 -080052 switches = spines + leaves
53 links = ( spines * leaves ) * 2
Siddesh167bc882021-03-23 21:03:43 +000054 if self.topo[ topology ][ 'dual-linked' ]:
Jon Hall39570262020-11-17 12:18:19 -080055 links += links
Siddesh167bc882021-03-23 21:03:43 +000056 if self.topo[ topology ][ 'dual-homed' ]:
Jon Hall39570262020-11-17 12:18:19 -080057 links += ( leaves - 1 ) * 2
Jonghwan Hyun3731d6a2017-10-19 11:59:31 -070058
Siddesha19e3c82021-06-09 22:45:27 +000059 main.cfgName = 'CASE%01d%01d' % ( test_idx / 10, test_idx % 10 )
60 print (main.cfgName, "Testcase : CASE 09")
Jon Hall9b0de1f2020-08-24 15:38:04 -070061 main.Cluster.setRunningNode( onosNodes )
62 run.installOnos( main, skipPackage=skipPackage, cliSleep=5 )
Jon Hall06fd0df2021-01-25 15:50:06 -080063 if not main.persistentSetup:
Siddesha19e3c82021-06-09 22:45:27 +000064 if main.useBmv2:
65 switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', '' )
66 if switchPrefix is None or "None":
67 switchPrefix = ''
68 # Translate configuration file from OVS-OFDPA to BMv2 driver
69 translator.bmv2ToOfdpa( main ) # Try to cleanup if switching between switch types
70 translator.ofdpaToBmv2( main, switchPrefix=switchPrefix )
71 else:
72 translator.bmv2ToOfdpa( main )
Jon Hall06fd0df2021-01-25 15:50:06 -080073 suf = main.params.get( 'jsonFileSuffix', None)
74 if suf:
75 run.loadJson( main, suffix=suf )
76 else:
77 run.loadJson( main )
78 run.loadChart( main ) # stores hosts to ping and expected results
Jon Hall9b0de1f2020-08-24 15:38:04 -070079 if hasattr( main, 'Mininet1' ):
80 run.mnDockerSetup( main ) # optionally create and setup docker image
Jonghwan Hyun3731d6a2017-10-19 11:59:31 -070081
Jon Hall9b0de1f2020-08-24 15:38:04 -070082 # Run the test with Mininet
Siddesh167bc882021-03-23 21:03:43 +000083 mininet_args = ' --spine=%d --leaf=%d' % ( self.topo[ topology ][ 'spines' ], self.topo[ topology ][ 'leaves' ] )
84 if self.topo[ topology ][ 'dual-homed' ]:
Jon Hall9b0de1f2020-08-24 15:38:04 -070085 mininet_args += ' --dual-homed'
86 if len( vlan ) > 0 :
87 mininet_args += ' --vlan=%s' % ( ','.join( ['%d' % vlanId for vlanId in vlan ] ) )
88 if main.useBmv2:
89 mininet_args += ' --switch %s' % main.switchType
90 main.log.info( "Using %s switch" % main.switchType )
Jon Halldac3eae2020-06-05 12:04:06 -070091
Jon Hall9b0de1f2020-08-24 15:38:04 -070092 run.startMininet( main, 'trellis_fabric.py', args=mininet_args )
You Wangd5873482018-01-24 12:30:00 -080093
Jon Hall9b0de1f2020-08-24 15:38:04 -070094 else:
95 # Run the test with physical devices
Jon Hall06fd0df2021-01-25 15:50:06 -080096 run.connectToPhysicalNetwork( main, hostDiscovery=False ) # We don't want to do host discovery in the pod
Siddesh606bd872021-06-29 23:42:36 +000097 if main.cfgName:
98 returnValue = run.loadNewJson( main )
99 utilities.assert_equals( expect=main.TRUE,
100 actual=returnValue,
101 onpass="Successfully changed network config",
102 onfail="Failed to changed network config" )
Siddesh167bc882021-03-23 21:03:43 +0000103 run.checkFlows( main, minFlowCount=self.topo[ topology ][ 'minFlow-Stratum' if main.useBmv2 else 'minFlow-OvS' ] * self.topo[ topology ][ 'leaves' ], sleep=5 )
Jon Hall9b0de1f2020-08-24 15:38:04 -0700104 if main.useBmv2:
Jon Hall06fd0df2021-01-25 15:50:06 -0800105 switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', '' )
Jon Hallbe3a2ac2021-03-15 12:28:06 -0700106 if switchPrefix is None or "None":
107 switchPrefix = ''
Jon Hall06fd0df2021-01-25 15:50:06 -0800108 if switchPrefix is not '' and switchPrefix is not None:
109 switchPrefix += ':'
Siddesh167bc882021-03-23 21:03:43 +0000110 leaf_dpid = [ "device:%sleaf%d" % ( switchPrefix, ls + 1 ) for ls in range( self.topo[ topology ][ 'leaves' ]) ]
Jon Hall9b0de1f2020-08-24 15:38:04 -0700111 else:
Siddesh167bc882021-03-23 21:03:43 +0000112 leaf_dpid = [ "of:%016d" % ( ls + 1 ) for ls in range( self.topo[ topology ][ 'leaves' ] ) ]
Jon Hall9b0de1f2020-08-24 15:38:04 -0700113 for dpid in leaf_dpid:
Siddesh167bc882021-03-23 21:03:43 +0000114 run.checkFlowsByDpid( main, dpid, self.topo[ topology ][ 'minFlow-Stratum' if main.useBmv2 else 'minFlow-OvS' ], sleep=5 )
Jon Hall39570262020-11-17 12:18:19 -0800115 run.verifyTopology( main, switches, links, onosNodes )
Jon Hall9b0de1f2020-08-24 15:38:04 -0700116 run.pingAll( main )
117 except Exception as e:
118 main.log.exception( "Error in runTest" )
119 main.skipCase( result="FAIL", msg=e )
Jon Hallf69e3162020-09-01 09:08:44 -0700120 finally:
121 run.cleanup( main )