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 |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 23 | |
| 24 | class SRBridgingTest (): |
| 25 | |
| 26 | def __init__( self ): |
| 27 | self.default = '' |
Devin Lim | 57221b0 | 2018-02-14 15:45:36 -0800 | [diff] [blame] | 28 | self.topo = dict() |
Jonghwan Hyun | 98fb40a | 2018-01-04 16:16:28 -0800 | [diff] [blame] | 29 | # (number of spine switch, number of leaf switch, dual-homed, description, minFlowCount - leaf) |
Devin Lim | 57221b0 | 2018-02-14 15:45:36 -0800 | [diff] [blame] | 30 | self.topo[ '0x1' ] = ( 0, 1, False, 'single ToR', 28 ) |
| 31 | self.topo[ '0x2' ] = ( 0, 2, True, 'dual-homed ToR', 37 ) |
| 32 | self.topo[ '2x2' ] = ( 2, 2, False, '2x2 leaf-spine topology', 37 ) |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 33 | # TODO: Implement 2x3 topology |
Jonghwan Hyun | 98fb40a | 2018-01-04 16:16:28 -0800 | [diff] [blame] | 34 | # 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] | 35 | self.topo[ '2x4' ] = ( 2, 4, True, '2x4 dual-homed leaf-spine topology', 53 ) |
| 36 | self.switchNames = {} |
| 37 | self.switchNames[ '2x2' ] = [ "leaf1", "leaf2", "spine101", "spine102" ] |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 38 | |
Devin Lim | 57221b0 | 2018-02-14 15:45:36 -0800 | [diff] [blame] | 39 | def runTest( self, main, test_idx, topology, onosNodes, description, vlan = [] ): |
You Wang | 1cdc5f5 | 2017-12-19 16:47:51 -0800 | [diff] [blame] | 40 | skipPackage = False |
| 41 | init = False |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 42 | if not hasattr( main, 'apps' ): |
You Wang | 1cdc5f5 | 2017-12-19 16:47:51 -0800 | [diff] [blame] | 43 | init = True |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 44 | run.initTest( main ) |
You Wang | 1cdc5f5 | 2017-12-19 16:47:51 -0800 | [diff] [blame] | 45 | # Skip onos packaging if the clusrer size stays the same |
| 46 | if not init and onosNodes == main.Cluster.numCtrls: |
| 47 | skipPackage = True |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 48 | |
| 49 | main.case( '%s, with %s and %d ONOS instance%s' % |
Devin Lim | 57221b0 | 2018-02-14 15:45:36 -0800 | [diff] [blame] | 50 | ( description, self.topo[ topology ][ 3 ], onosNodes, 's' if onosNodes > 1 else '' ) ) |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 51 | |
| 52 | main.cfgName = 'CASE%01d%01d' % ( test_idx / 10, ( ( test_idx - 1 ) % 10 ) % 4 + 1 ) |
| 53 | main.Cluster.setRunningNode( onosNodes ) |
You Wang | 1cdc5f5 | 2017-12-19 16:47:51 -0800 | [diff] [blame] | 54 | run.installOnos( main, skipPackage=skipPackage, cliSleep=5 ) |
Devin Lim | 57221b0 | 2018-02-14 15:45:36 -0800 | [diff] [blame] | 55 | run.loadJson( main ) |
| 56 | run.loadChart( main ) |
You Wang | d587348 | 2018-01-24 12:30:00 -0800 | [diff] [blame] | 57 | if hasattr( main, 'Mininet1' ): |
| 58 | # Run the test with Mininet |
Devin Lim | 57221b0 | 2018-02-14 15:45:36 -0800 | [diff] [blame] | 59 | mininet_args = ' --spine=%d --leaf=%d' % ( self.topo[ topology ][ 0 ], self.topo[ topology ][ 1 ] ) |
| 60 | if self.topo[ topology ][ 2 ]: |
You Wang | d587348 | 2018-01-24 12:30:00 -0800 | [diff] [blame] | 61 | mininet_args += ' --dual-homed' |
| 62 | if len( vlan ) > 0 : |
| 63 | mininet_args += ' --vlan=%s' % ( ','.join( ['%d' % vlanId for vlanId in vlan ] ) ) |
Jonghwan Hyun | 3731d6a | 2017-10-19 11:59:31 -0700 | [diff] [blame] | 64 | |
You Wang | d587348 | 2018-01-24 12:30:00 -0800 | [diff] [blame] | 65 | run.startMininet( main, 'trellis_fabric.py', args=mininet_args ) |
| 66 | else: |
| 67 | # Run the test with physical devices |
Devin Lim | 57221b0 | 2018-02-14 15:45:36 -0800 | [diff] [blame] | 68 | run.connectToPhysicalNetwork( main, self.switchNames[ topology ] ) |
You Wang | d587348 | 2018-01-24 12:30:00 -0800 | [diff] [blame] | 69 | |
Devin Lim | 57221b0 | 2018-02-14 15:45:36 -0800 | [diff] [blame] | 70 | run.checkFlows( main, minFlowCount=self.topo[ topology ][ 4 ] * self.topo[ topology ][ 1 ], sleep=5 ) |
| 71 | leaf_dpid = [ "of:%016d" % ( ls + 1 ) for ls in range( self.topo[ topology ][ 1 ] ) ] |
Jonghwan Hyun | 98fb40a | 2018-01-04 16:16:28 -0800 | [diff] [blame] | 72 | for dpid in leaf_dpid: |
Devin Lim | 57221b0 | 2018-02-14 15:45:36 -0800 | [diff] [blame] | 73 | run.checkFlowsByDpid( main, dpid, self.topo[ topology ][ 4 ], sleep=5 ) |
Jonghwan Hyun | 76a02b7 | 2018-01-30 16:40:48 +0900 | [diff] [blame] | 74 | run.pingAll( main ) |
You Wang | d587348 | 2018-01-24 12:30:00 -0800 | [diff] [blame] | 75 | |
| 76 | if hasattr( main, 'Mininet1' ): |
| 77 | run.cleanup( main ) |
| 78 | else: |
| 79 | # TODO: disconnect TestON from the physical network |
| 80 | pass |