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 ): |
| 32 | skipPackage = False |
| 33 | init = False |
| 34 | if not hasattr( main, 'apps' ): |
| 35 | init = True |
| 36 | run.initTest( main ) |
| 37 | # Skip onos packaging if the clusrer size stays the same |
| 38 | if not init and onosNodes == main.Cluster.numCtrls: |
| 39 | skipPackage = True |
| 40 | |
| 41 | main.case( '%s, with %d ONOS instance%s' % |
| 42 | ( description, onosNodes, 's' if onosNodes > 1 else '' ) ) |
| 43 | |
| 44 | main.cfgName = 'CASE%02d' % testIndex |
You Wang | 53dba1e | 2018-02-02 17:45:44 -0800 | [diff] [blame] | 45 | main.resultFileName = 'CASE%02d' % testIndex |
| 46 | main.Cluster.setRunningNode( onosNodes ) |
| 47 | run.installOnos( main, skipPackage=skipPackage, cliSleep=5 ) |
You Wang | 68568b1 | 2019-03-04 11:49:57 -0800 | [diff] [blame] | 48 | if main.useBmv2: |
| 49 | # Translate configuration file from OVS-OFDPA to BMv2 driver |
| 50 | translator.ofdpaToBmv2( main ) |
| 51 | else: |
| 52 | translator.bmv2ToOfdpa( main ) |
Devin Lim | 57221b0 | 2018-02-14 15:45:36 -0800 | [diff] [blame] | 53 | run.loadJson( main ) |
| 54 | run.loadHost( main ) |
You Wang | 53dba1e | 2018-02-02 17:45:44 -0800 | [diff] [blame] | 55 | if hasattr( main, 'Mininet1' ): |
| 56 | # Run the test with Mininet |
| 57 | if dualHomed: |
| 58 | mininet_args = ' --spine=2 --leaf=4 --dual-homed' |
| 59 | else: |
| 60 | mininet_args = ' --spine=2 --leaf=2' |
| 61 | mininet_args += ' --dhcp-client' |
| 62 | if dhcpRelay: |
| 63 | mininet_args += ' --dhcp-relay' |
| 64 | if multipleServer: |
| 65 | mininet_args += ' --multiple-dhcp-server' |
| 66 | if remoteServer: |
| 67 | mininet_args += ' --remote-dhcp-server' |
| 68 | if ipv6: |
| 69 | mininet_args += ' --ipv6' |
| 70 | if len( vlan ) > 0 : |
| 71 | mininet_args += ' --vlan=%s' % ( ','.join( ['%d' % vlanId for vlanId in vlan ] ) ) |
You Wang | 68568b1 | 2019-03-04 11:49:57 -0800 | [diff] [blame] | 72 | if main.useBmv2: |
| 73 | mininet_args += ' --switch bmv2' |
| 74 | main.log.info( "Using BMv2 switch" ) |
You Wang | 53dba1e | 2018-02-02 17:45:44 -0800 | [diff] [blame] | 75 | |
| 76 | run.startMininet( main, 'trellis_fabric.py', args=mininet_args ) |
| 77 | else: |
| 78 | # Run the test with physical devices |
| 79 | # TODO: connect TestON to the physical network |
| 80 | pass |
| 81 | run.verifyOnosHostIp( main ) |
| 82 | run.verifyNetworkHostIp( main ) |
| 83 | |
You Wang | 5df1c6d | 2018-04-06 18:02:02 -0700 | [diff] [blame] | 84 | run.cleanup( main ) |