blob: 325af80320eccf9b1c410644780813e3374f0257 [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 ):
Jon Hall9b0de1f2020-08-24 15:38:04 -070032 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 Wang53dba1e2018-02-02 17:45:44 -080041
Jon Hall9b0de1f2020-08-24 15:38:04 -070042 main.case( '%s, with %d ONOS instance%s' %
43 ( description, onosNodes, 's' if onosNodes > 1 else '' ) )
You Wang53dba1e2018-02-02 17:45:44 -080044
Jon Hall9b0de1f2020-08-24 15:38:04 -070045 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 Wang68568b12019-03-04 11:49:57 -080049 if main.useBmv2:
Jon Hall9b0de1f2020-08-24 15:38:04 -070050 # Translate configuration file from OVS-OFDPA to BMv2 driver
51 translator.bmv2ToOfdpa( main ) # Try to cleanup if switching between switch types
Jon Hall06fd0df2021-01-25 15:50:06 -080052 switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', '' )
53 if switchPrefix is None:
54 switchPrefix = ''
Jon Hall9b0de1f2020-08-24 15:38:04 -070055 translator.ofdpaToBmv2( main, switchPrefix=switchPrefix )
56 else:
57 translator.bmv2ToOfdpa( main )
Jon Hall06fd0df2021-01-25 15:50:06 -080058 if not main.persistentSetup:
59 run.loadJson( main )
Jon Hall9b0de1f2020-08-24 15:38:04 -070060 run.loadHost( main )
61 if hasattr( main, 'Mininet1' ):
62 run.mnDockerSetup( main )
63 # Run the test with Mininet
64 if dualHomed:
65 mininet_args = ' --spine=2 --leaf=4 --dual-homed'
66 else:
67 mininet_args = ' --spine=2 --leaf=2'
68 mininet_args += ' --dhcp-client'
69 if dhcpRelay:
70 mininet_args += ' --dhcp-relay'
71 if multipleServer:
72 mininet_args += ' --multiple-dhcp-server'
73 if remoteServer:
74 mininet_args += ' --remote-dhcp-server'
75 if ipv6:
76 mininet_args += ' --ipv6'
77 if len( vlan ) > 0 :
78 mininet_args += ' --vlan=%s' % ( ','.join( ['%d' % vlanId for vlanId in vlan ] ) )
79 if main.useBmv2:
80 mininet_args += ' --switch %s' % main.switchType
81 main.log.info( "Using %s switch" % main.switchType )
You Wang53dba1e2018-02-02 17:45:44 -080082
Jon Hall9b0de1f2020-08-24 15:38:04 -070083 run.startMininet( main, 'trellis_fabric.py', args=mininet_args )
84 else:
85 # Run the test with physical devices
86 # TODO: connect TestON to the physical network
87 pass
88 run.verifyOnosHostIp( main, skipOnFail=False )
89 run.verifyNetworkHostIp( main )
90 except Exception as e:
91 main.log.exception( "Error in runTest" )
92 main.skipCase( result="FAIL", msg=e )
Jon Hallf69e3162020-09-01 09:08:44 -070093 finally:
94 run.cleanup( main )