You Wang | 53dba1e | 2018-02-02 17:45:44 -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 |
You Wang | 68568b1 | 2019-03-04 11:49:57 -0800 | [diff] [blame] | 23 | import tests.USECASE.SegmentRouting.dependencies.cfgtranslator as translator |
You Wang | 53dba1e | 2018-02-02 17:45:44 -0800 | [diff] [blame] | 24 | |
| 25 | class SRDhcprelayTest (): |
| 26 | |
| 27 | def __init__( self ): |
| 28 | self.default = '' |
| 29 | |
| 30 | @staticmethod |
| 31 | def runTest( main, testIndex, onosNodes, description, dhcpRelay=False, remoteServer=False, multipleServer=False, ipv6=False, vlan=[], dualHomed=False ): |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 32 | try: |
| 33 | skipPackage = False |
| 34 | init = False |
| 35 | if not hasattr( main, 'apps' ): |
| 36 | init = True |
| 37 | run.initTest( main ) |
| 38 | # Skip onos packaging if the clusrer size stays the same |
| 39 | if not init and onosNodes == main.Cluster.numCtrls: |
| 40 | skipPackage = True |
You Wang | 53dba1e | 2018-02-02 17:45:44 -0800 | [diff] [blame] | 41 | |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 42 | main.case( '%s, with %d ONOS instance%s' % |
| 43 | ( description, onosNodes, 's' if onosNodes > 1 else '' ) ) |
You Wang | 53dba1e | 2018-02-02 17:45:44 -0800 | [diff] [blame] | 44 | |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 45 | main.cfgName = 'CASE%02d' % testIndex |
| 46 | main.resultFileName = 'CASE%02d' % testIndex |
| 47 | main.Cluster.setRunningNode( onosNodes ) |
| 48 | run.installOnos( main, skipPackage=skipPackage, cliSleep=5 ) |
You Wang | 68568b1 | 2019-03-04 11:49:57 -0800 | [diff] [blame] | 49 | if main.useBmv2: |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 50 | # Translate configuration file from OVS-OFDPA to BMv2 driver |
| 51 | translator.bmv2ToOfdpa( main ) # Try to cleanup if switching between switch types |
| 52 | switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', "bmv2" ) |
| 53 | translator.ofdpaToBmv2( main, switchPrefix=switchPrefix ) |
| 54 | else: |
| 55 | translator.bmv2ToOfdpa( main ) |
| 56 | run.loadJson( main ) |
| 57 | run.loadHost( main ) |
| 58 | if hasattr( main, 'Mininet1' ): |
| 59 | run.mnDockerSetup( main ) |
| 60 | # Run the test with Mininet |
| 61 | if dualHomed: |
| 62 | mininet_args = ' --spine=2 --leaf=4 --dual-homed' |
| 63 | else: |
| 64 | mininet_args = ' --spine=2 --leaf=2' |
| 65 | mininet_args += ' --dhcp-client' |
| 66 | if dhcpRelay: |
| 67 | mininet_args += ' --dhcp-relay' |
| 68 | if multipleServer: |
| 69 | mininet_args += ' --multiple-dhcp-server' |
| 70 | if remoteServer: |
| 71 | mininet_args += ' --remote-dhcp-server' |
| 72 | if ipv6: |
| 73 | mininet_args += ' --ipv6' |
| 74 | if len( vlan ) > 0 : |
| 75 | mininet_args += ' --vlan=%s' % ( ','.join( ['%d' % vlanId for vlanId in vlan ] ) ) |
| 76 | if main.useBmv2: |
| 77 | mininet_args += ' --switch %s' % main.switchType |
| 78 | main.log.info( "Using %s switch" % main.switchType ) |
You Wang | 53dba1e | 2018-02-02 17:45:44 -0800 | [diff] [blame] | 79 | |
Jon Hall | 9b0de1f | 2020-08-24 15:38:04 -0700 | [diff] [blame] | 80 | run.startMininet( main, 'trellis_fabric.py', args=mininet_args ) |
| 81 | else: |
| 82 | # Run the test with physical devices |
| 83 | # TODO: connect TestON to the physical network |
| 84 | pass |
| 85 | run.verifyOnosHostIp( main, skipOnFail=False ) |
| 86 | run.verifyNetworkHostIp( main ) |
| 87 | except Exception as e: |
| 88 | main.log.exception( "Error in runTest" ) |
| 89 | main.skipCase( result="FAIL", msg=e ) |
Jon Hall | f69e316 | 2020-09-01 09:08:44 -0700 | [diff] [blame] | 90 | finally: |
| 91 | run.cleanup( main ) |