Devin Lim | 57221b0 | 2018-02-14 15:45:36 -0800 | [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 | |
| 22 | from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run |
Jon Hall | 214f88b | 2020-09-21 10:21:42 -0700 | [diff] [blame] | 23 | import tests.USECASE.SegmentRouting.dependencies.cfgtranslator as translator |
Devin Lim | 57221b0 | 2018-02-14 15:45:36 -0800 | [diff] [blame] | 24 | |
| 25 | class SRLinkFailFuncs(): |
| 26 | |
| 27 | def __init__( self ): |
| 28 | self.default = '' |
Siddesh | 167bc88 | 2021-03-23 21:03:43 +0000 | [diff] [blame] | 29 | self.topo = run.getTopo() |
Jon Hall | 214f88b | 2020-09-21 10:21:42 -0700 | [diff] [blame] | 30 | main.switchType = "ovs" |
Devin Lim | 57221b0 | 2018-02-14 15:45:36 -0800 | [diff] [blame] | 31 | self.switchOne = 'spine101' |
| 32 | self.switchTwo = 'leaf2' |
| 33 | self.dpidOne = 'of:0000000000000101' |
| 34 | self.dpidTwo = 'of:0000000000000002' |
| 35 | self.portOne = '2' |
| 36 | self.portTwo = '3' |
| 37 | |
Siddesh | 167bc88 | 2021-03-23 21:03:43 +0000 | [diff] [blame] | 38 | def runTest( self, main, caseNum, numNodes, topology, minFlow ): |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 39 | try: |
Siddesh | 167bc88 | 2021-03-23 21:03:43 +0000 | [diff] [blame] | 40 | description = "Bridging and Routing Link Failure test with " + self.topo[ topology ][ 'description' ] + " and {} Onos".format( numNodes ) |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 41 | main.case( description ) |
Jon Hall | 214f88b | 2020-09-21 10:21:42 -0700 | [diff] [blame] | 42 | if not hasattr( main, 'apps' ): |
| 43 | run.initTest( main ) |
Siddesh | 167bc88 | 2021-03-23 21:03:43 +0000 | [diff] [blame] | 44 | main.cfgName = topology |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 45 | main.Cluster.setRunningNode( numNodes ) |
| 46 | run.installOnos( main ) |
Jon Hall | 214f88b | 2020-09-21 10:21:42 -0700 | [diff] [blame] | 47 | suf = main.params.get( 'jsonFileSuffix', '') |
| 48 | xconnectFile = "%s%s-xconnects.json%s" % ( main.configPath + main.forJson, |
| 49 | main.cfgName, suf ) |
| 50 | if main.useBmv2: |
| 51 | switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', "bmv2" ) |
| 52 | # Translate configuration file from OVS-OFDPA to BMv2 driver |
| 53 | translator.bmv2ToOfdpa( main ) # Try to cleanup if switching between switch types |
| 54 | translator.ofdpaToBmv2( main, switchPrefix=switchPrefix ) |
| 55 | # translate xconnects |
| 56 | translator.bmv2ToOfdpa( main, cfgFile=xconnectFile ) |
| 57 | translator.ofdpaToBmv2( main, cfgFile=xconnectFile, switchPrefix=switchPrefix ) |
| 58 | else: |
| 59 | translator.bmv2ToOfdpa( main ) |
| 60 | translator.bmv2ToOfdpa( main, cfgFile=xconnectFile ) |
Jon Hall | 06fd0df | 2021-01-25 15:50:06 -0800 | [diff] [blame] | 61 | if not main.persistentSetup: |
| 62 | if suf: |
| 63 | run.loadJson( main, suffix=suf ) |
| 64 | else: |
| 65 | run.loadJson( main ) |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 66 | run.loadChart( main ) |
Jon Hall | 214f88b | 2020-09-21 10:21:42 -0700 | [diff] [blame] | 67 | if hasattr( main, 'Mininet1' ): |
| 68 | run.mnDockerSetup( main ) # optionally create and setup docker image |
| 69 | |
| 70 | # Run the test with Mininet |
Siddesh | 167bc88 | 2021-03-23 21:03:43 +0000 | [diff] [blame] | 71 | mininet_args = self.topo[ topology ][ 'mininetArgs' ] |
Jon Hall | 214f88b | 2020-09-21 10:21:42 -0700 | [diff] [blame] | 72 | if main.useBmv2: |
| 73 | mininet_args += ' --switch %s' % main.switchType |
| 74 | main.log.info( "Using %s switch" % main.switchType ) |
| 75 | |
| 76 | run.startMininet( main, 'cord_fabric.py', args=mininet_args ) |
| 77 | else: |
| 78 | # Run the test with physical devices |
| 79 | # TODO: connect TestON to the physical network |
| 80 | pass |
Jon Hall | 10e2ab8 | 2020-09-15 17:14:54 -0700 | [diff] [blame] | 81 | # xconnects need to be loaded after topology |
| 82 | run.loadXconnects( main ) |
Siddesh | 167bc88 | 2021-03-23 21:03:43 +0000 | [diff] [blame] | 83 | switches = self.topo[ topology ][ 'spines' ] + self.topo[ topology ][ 'leaves' ] |
| 84 | links = ( self.topo[ topology ][ 'spines' ] * self.topo[ topology ][ 'leaves' ] ) * 2 |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 85 | # pre-configured routing and bridging test |
Jon Hall | 3957026 | 2020-11-17 12:18:19 -0800 | [diff] [blame] | 86 | run.verifyTopology( main, switches, links, numNodes ) |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 87 | run.checkFlows( main, minFlowCount=minFlow ) |
Jon Hall | 3957026 | 2020-11-17 12:18:19 -0800 | [diff] [blame] | 88 | run.pingAll( main, 'CASE{}'.format( caseNum ) ) |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 89 | # link failure |
Jon Hall | 3957026 | 2020-11-17 12:18:19 -0800 | [diff] [blame] | 90 | run.killLink( main, self.switchOne, self.switchTwo, switches='{}'.format( switches ), links='{}'.format( links - 2 ) ) |
| 91 | run.pingAll( main, 'CASE{}_Failure'.format( caseNum ) ) |
| 92 | run.restoreLink( main, self.switchOne, self.switchTwo, '{}'.format( switches ), '{}'.format( links ), |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 93 | True, self.dpidOne, self.dpidTwo, self.portOne, self.portTwo ) |
Jon Hall | 3957026 | 2020-11-17 12:18:19 -0800 | [diff] [blame] | 94 | run.checkFlows( main, minFlowCount=minFlow, tag='CASE{}_Recovery'.format( caseNum ) ) |
| 95 | run.pingAll( main, 'CASE{}_Recovery'.format( caseNum ) ) |
| 96 | run.verifyTopology( main, switches, links, numNodes ) |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 97 | # TODO Dynamic config of hosts in subnet |
| 98 | # TODO Dynamic config of host not in subnet |
| 99 | # TODO Dynamic config of vlan xconnect |
| 100 | # TODO Vrouter integration |
| 101 | # TODO Mcast integration |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 102 | except Exception as e: |
| 103 | main.log.exception( "Error in runTest" ) |
| 104 | main.skipCase( result="FAIL", msg=e ) |
Jon Hall | f69e316 | 2020-09-01 09:08:44 -0700 | [diff] [blame] | 105 | finally: |
| 106 | run.cleanup( main ) |