Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 1 | """ |
| 2 | Copyright 2017 Open Networking Foundation ( ONF ) |
| 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or 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 Wang | ac02b14 | 2018-01-26 14:57:28 -0800 | [diff] [blame] | 22 | from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run |
You Wang | 68568b1 | 2019-03-04 11:49:57 -0800 | [diff] [blame] | 23 | import tests.USECASE.SegmentRouting.dependencies.cfgtranslator as translator |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 24 | |
| 25 | class SRBridgingTest (): |
| 26 | |
| 27 | def __init__( self ): |
| 28 | self.default = '' |
Siddesh | 167bc88 | 2021-03-23 21:03:43 +0000 | [diff] [blame] | 29 | self.topo = run.getTopo() |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 30 | # TODO: Implement 2x3 topology |
Jonghwan Hyun | 98fb40a | 2018-01-04 16:16:28 -0800 | [diff] [blame] | 31 | # topo[ '2x3' ] = ( 2, 3, True, '2x3 leaf-spine topology with dual ToR and single ToR', 28 ) |
Devin Lim | 57221b0 | 2018-02-14 15:45:36 -0800 | [diff] [blame] | 32 | self.switchNames = {} |
Jon Hall | 43060f6 | 2020-06-23 13:13:33 -0700 | [diff] [blame] | 33 | self.switchNames[ '0x1' ] = [ "leaf1" ] |
Devin Lim | 57221b0 | 2018-02-14 15:45:36 -0800 | [diff] [blame] | 34 | self.switchNames[ '2x2' ] = [ "leaf1", "leaf2", "spine101", "spine102" ] |
Jon Hall | 43060f6 | 2020-06-23 13:13:33 -0700 | [diff] [blame] | 35 | main.switchType = "ovs" |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 36 | |
Devin Lim | 57221b0 | 2018-02-14 15:45:36 -0800 | [diff] [blame] | 37 | def runTest( self, main, test_idx, topology, onosNodes, description, vlan = [] ): |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 38 | try: |
| 39 | skipPackage = False |
| 40 | init = False |
| 41 | if not hasattr( main, 'apps' ): |
| 42 | init = True |
| 43 | run.initTest( main ) |
Jon Hall | 214f88b | 2020-09-21 10:21:42 -0700 | [diff] [blame] | 44 | # Skip onos packaging if the cluster size stays the same |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 45 | if not init and onosNodes == main.Cluster.numCtrls: |
| 46 | skipPackage = True |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 47 | |
Siddesh | 167bc88 | 2021-03-23 21:03:43 +0000 | [diff] [blame] | 48 | 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 '' ) ) |
| 49 | spines = self.topo[ topology ][ 'spines' ] |
| 50 | leaves = self.topo[ topology ][ 'leaves' ] |
Jon Hall | 3957026 | 2020-11-17 12:18:19 -0800 | [diff] [blame] | 51 | switches = spines + leaves |
| 52 | links = ( spines * leaves ) * 2 |
Siddesh | 167bc88 | 2021-03-23 21:03:43 +0000 | [diff] [blame] | 53 | if self.topo[ topology ][ 'dual-linked' ]: |
Jon Hall | 3957026 | 2020-11-17 12:18:19 -0800 | [diff] [blame] | 54 | links += links |
Siddesh | 167bc88 | 2021-03-23 21:03:43 +0000 | [diff] [blame] | 55 | if self.topo[ topology ][ 'dual-homed' ]: |
Jon Hall | 3957026 | 2020-11-17 12:18:19 -0800 | [diff] [blame] | 56 | links += ( leaves - 1 ) * 2 |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 57 | |
Siddesh | a19e3c8 | 2021-06-09 22:45:27 +0000 | [diff] [blame] | 58 | main.cfgName = 'CASE%01d%01d' % ( test_idx / 10, test_idx % 10 ) |
| 59 | print (main.cfgName, "Testcase : CASE 09") |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 60 | main.Cluster.setRunningNode( onosNodes ) |
| 61 | run.installOnos( main, skipPackage=skipPackage, cliSleep=5 ) |
Siddesh | de1d169 | 2021-09-15 18:12:57 +0000 | [diff] [blame] | 62 | suf = main.params.get( 'jsonFileSuffix', None) |
Jon Hall | 06fd0df | 2021-01-25 15:50:06 -0800 | [diff] [blame] | 63 | if not main.persistentSetup: |
Siddesh | a19e3c8 | 2021-06-09 22:45:27 +0000 | [diff] [blame] | 64 | 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 Hall | 06fd0df | 2021-01-25 15:50:06 -0800 | [diff] [blame] | 73 | if suf: |
| 74 | run.loadJson( main, suffix=suf ) |
| 75 | else: |
| 76 | run.loadJson( main ) |
| 77 | run.loadChart( main ) # stores hosts to ping and expected results |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 78 | if hasattr( main, 'Mininet1' ): |
| 79 | run.mnDockerSetup( main ) # optionally create and setup docker image |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 80 | |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 81 | # Run the test with Mininet |
Siddesh | 167bc88 | 2021-03-23 21:03:43 +0000 | [diff] [blame] | 82 | mininet_args = ' --spine=%d --leaf=%d' % ( self.topo[ topology ][ 'spines' ], self.topo[ topology ][ 'leaves' ] ) |
| 83 | if self.topo[ topology ][ 'dual-homed' ]: |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 84 | mininet_args += ' --dual-homed' |
| 85 | if len( vlan ) > 0 : |
| 86 | mininet_args += ' --vlan=%s' % ( ','.join( ['%d' % vlanId for vlanId in vlan ] ) ) |
| 87 | if main.useBmv2: |
| 88 | mininet_args += ' --switch %s' % main.switchType |
| 89 | main.log.info( "Using %s switch" % main.switchType ) |
Jon Hall | dac3eae | 2020-06-05 12:04:06 -0700 | [diff] [blame] | 90 | |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 91 | run.startMininet( main, 'trellis_fabric.py', args=mininet_args ) |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 92 | else: |
| 93 | # Run the test with physical devices |
Jon Hall | 06fd0df | 2021-01-25 15:50:06 -0800 | [diff] [blame] | 94 | run.connectToPhysicalNetwork( main, hostDiscovery=False ) # We don't want to do host discovery in the pod |
Siddesh | 606bd87 | 2021-06-29 23:42:36 +0000 | [diff] [blame] | 95 | if main.cfgName: |
Siddesh | de1d169 | 2021-09-15 18:12:57 +0000 | [diff] [blame] | 96 | returnValue = run.loadNewJson( main, suffix=suf ) |
Siddesh | 606bd87 | 2021-06-29 23:42:36 +0000 | [diff] [blame] | 97 | utilities.assert_equals( expect=main.TRUE, |
| 98 | actual=returnValue, |
| 99 | onpass="Successfully changed network config", |
| 100 | onfail="Failed to changed network config" ) |
Siddesh | 167bc88 | 2021-03-23 21:03:43 +0000 | [diff] [blame] | 101 | run.checkFlows( main, minFlowCount=self.topo[ topology ][ 'minFlow-Stratum' if main.useBmv2 else 'minFlow-OvS' ] * self.topo[ topology ][ 'leaves' ], sleep=5 ) |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 102 | if main.useBmv2: |
Jon Hall | 06fd0df | 2021-01-25 15:50:06 -0800 | [diff] [blame] | 103 | switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', '' ) |
Jon Hall | be3a2ac | 2021-03-15 12:28:06 -0700 | [diff] [blame] | 104 | if switchPrefix is None or "None": |
| 105 | switchPrefix = '' |
Jon Hall | 06fd0df | 2021-01-25 15:50:06 -0800 | [diff] [blame] | 106 | if switchPrefix is not '' and switchPrefix is not None: |
| 107 | switchPrefix += ':' |
Siddesh | 167bc88 | 2021-03-23 21:03:43 +0000 | [diff] [blame] | 108 | leaf_dpid = [ "device:%sleaf%d" % ( switchPrefix, ls + 1 ) for ls in range( self.topo[ topology ][ 'leaves' ]) ] |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 109 | else: |
Siddesh | 167bc88 | 2021-03-23 21:03:43 +0000 | [diff] [blame] | 110 | leaf_dpid = [ "of:%016d" % ( ls + 1 ) for ls in range( self.topo[ topology ][ 'leaves' ] ) ] |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 111 | for dpid in leaf_dpid: |
Siddesh | 167bc88 | 2021-03-23 21:03:43 +0000 | [diff] [blame] | 112 | run.checkFlowsByDpid( main, dpid, self.topo[ topology ][ 'minFlow-Stratum' if main.useBmv2 else 'minFlow-OvS' ], sleep=5 ) |
Siddesh | d984084 | 2021-08-06 19:26:05 +0000 | [diff] [blame] | 113 | run.populateHostsVlan( main, main.Network.hosts.keys() ) |
Jon Hall | 3957026 | 2020-11-17 12:18:19 -0800 | [diff] [blame] | 114 | run.verifyTopology( main, switches, links, onosNodes ) |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 115 | run.pingAll( main ) |
| 116 | except Exception as e: |
| 117 | main.log.exception( "Error in runTest" ) |
| 118 | main.skipCase( result="FAIL", msg=e ) |
Jon Hall | f69e316 | 2020-09-01 09:08:44 -0700 | [diff] [blame] | 119 | finally: |
| 120 | run.cleanup( main ) |