blob: a2ceb25d0ec4984cb333ff6c023a638e2da43199 [file] [log] [blame]
You Wang53dba1e2018-02-02 17:45:44 -08001"""
2Copyright 2017 Open Networking Foundation ( ONF )
3
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or 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
22from tests.USECASE.SegmentRouting.dependencies.Testcaselib import Testcaselib as run
You Wang68568b12019-03-04 11:49:57 -080023import tests.USECASE.SegmentRouting.dependencies.cfgtranslator as translator
You Wang53dba1e2018-02-02 17:45:44 -080024
25class 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 Wang53dba1e2018-02-02 17:45:44 -080045 main.resultFileName = 'CASE%02d' % testIndex
46 main.Cluster.setRunningNode( onosNodes )
47 run.installOnos( main, skipPackage=skipPackage, cliSleep=5 )
You Wang68568b12019-03-04 11:49:57 -080048 if main.useBmv2:
49 # Translate configuration file from OVS-OFDPA to BMv2 driver
Jon Hall43060f62020-06-23 13:13:33 -070050 translator.bmv2ToOfdpa( main ) # Try to cleanup if switching between switch types
51 switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', "bmv2" )
52 translator.ofdpaToBmv2( main, switchPrefix=switchPrefix )
You Wang68568b12019-03-04 11:49:57 -080053 else:
54 translator.bmv2ToOfdpa( main )
Devin Lim57221b02018-02-14 15:45:36 -080055 run.loadJson( main )
56 run.loadHost( main )
You Wang53dba1e2018-02-02 17:45:44 -080057 if hasattr( main, 'Mininet1' ):
Jon Hall43060f62020-06-23 13:13:33 -070058 run.mnDockerSetup( main )
You Wang53dba1e2018-02-02 17:45:44 -080059 # Run the test with Mininet
60 if dualHomed:
61 mininet_args = ' --spine=2 --leaf=4 --dual-homed'
62 else:
63 mininet_args = ' --spine=2 --leaf=2'
64 mininet_args += ' --dhcp-client'
65 if dhcpRelay:
66 mininet_args += ' --dhcp-relay'
67 if multipleServer:
68 mininet_args += ' --multiple-dhcp-server'
69 if remoteServer:
70 mininet_args += ' --remote-dhcp-server'
71 if ipv6:
72 mininet_args += ' --ipv6'
73 if len( vlan ) > 0 :
74 mininet_args += ' --vlan=%s' % ( ','.join( ['%d' % vlanId for vlanId in vlan ] ) )
You Wang68568b12019-03-04 11:49:57 -080075 if main.useBmv2:
Jon Hall43060f62020-06-23 13:13:33 -070076 mininet_args += ' --switch %s' % main.switchType
77 main.log.info( "Using %s switch" % main.switchType )
You Wang53dba1e2018-02-02 17:45:44 -080078
79 run.startMininet( main, 'trellis_fabric.py', args=mininet_args )
80 else:
81 # Run the test with physical devices
82 # TODO: connect TestON to the physical network
83 pass
84 run.verifyOnosHostIp( main )
85 run.verifyNetworkHostIp( main )
86
You Wang5df1c6d2018-04-06 18:02:02 -070087 run.cleanup( main )