blob: d5230a04f07a3bdb4abee7da8518e1296a21c59c [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 = ''
Siddesh167bc882021-03-23 21:03:43 +000029 self.topo = run.getTopo()
You Wang53dba1e2018-02-02 17:45:44 -080030
31 @staticmethod
32 def runTest( main, testIndex, onosNodes, description, dhcpRelay=False, remoteServer=False, multipleServer=False, ipv6=False, vlan=[], dualHomed=False ):
Jon Hall9b0de1f2020-08-24 15:38:04 -070033 try:
34 skipPackage = False
35 init = False
36 if not hasattr( main, 'apps' ):
37 init = True
38 run.initTest( main )
39 # Skip onos packaging if the clusrer size stays the same
40 if not init and onosNodes == main.Cluster.numCtrls:
41 skipPackage = True
You Wang53dba1e2018-02-02 17:45:44 -080042
Jon Hall9b0de1f2020-08-24 15:38:04 -070043 main.case( '%s, with %d ONOS instance%s' %
44 ( description, onosNodes, 's' if onosNodes > 1 else '' ) )
You Wang53dba1e2018-02-02 17:45:44 -080045
Jon Hall9b0de1f2020-08-24 15:38:04 -070046 main.cfgName = 'CASE%02d' % testIndex
47 main.resultFileName = 'CASE%02d' % testIndex
48 main.Cluster.setRunningNode( onosNodes )
49 run.installOnos( main, skipPackage=skipPackage, cliSleep=5 )
You Wang68568b12019-03-04 11:49:57 -080050 if main.useBmv2:
Jon Hall9b0de1f2020-08-24 15:38:04 -070051 # Translate configuration file from OVS-OFDPA to BMv2 driver
52 translator.bmv2ToOfdpa( main ) # Try to cleanup if switching between switch types
Jon Hall06fd0df2021-01-25 15:50:06 -080053 switchPrefix = main.params[ 'DEPENDENCY' ].get( 'switchPrefix', '' )
54 if switchPrefix is None:
55 switchPrefix = ''
Jon Hall9b0de1f2020-08-24 15:38:04 -070056 translator.ofdpaToBmv2( main, switchPrefix=switchPrefix )
57 else:
58 translator.bmv2ToOfdpa( main )
Jon Hall06fd0df2021-01-25 15:50:06 -080059 if not main.persistentSetup:
60 run.loadJson( main )
Jon Hall9b0de1f2020-08-24 15:38:04 -070061 run.loadHost( main )
62 if hasattr( main, 'Mininet1' ):
63 run.mnDockerSetup( main )
64 # Run the test with Mininet
65 if dualHomed:
66 mininet_args = ' --spine=2 --leaf=4 --dual-homed'
67 else:
68 mininet_args = ' --spine=2 --leaf=2'
69 mininet_args += ' --dhcp-client'
70 if dhcpRelay:
71 mininet_args += ' --dhcp-relay'
72 if multipleServer:
73 mininet_args += ' --multiple-dhcp-server'
74 if remoteServer:
75 mininet_args += ' --remote-dhcp-server'
76 if ipv6:
77 mininet_args += ' --ipv6'
78 if len( vlan ) > 0 :
79 mininet_args += ' --vlan=%s' % ( ','.join( ['%d' % vlanId for vlanId in vlan ] ) )
80 if main.useBmv2:
81 mininet_args += ' --switch %s' % main.switchType
82 main.log.info( "Using %s switch" % main.switchType )
You Wang53dba1e2018-02-02 17:45:44 -080083
Jon Hall9b0de1f2020-08-24 15:38:04 -070084 run.startMininet( main, 'trellis_fabric.py', args=mininet_args )
85 else:
86 # Run the test with physical devices
87 # TODO: connect TestON to the physical network
88 pass
89 run.verifyOnosHostIp( main, skipOnFail=False )
90 run.verifyNetworkHostIp( main )
91 except Exception as e:
92 main.log.exception( "Error in runTest" )
93 main.skipCase( result="FAIL", msg=e )
Jon Hallf69e3162020-09-01 09:08:44 -070094 finally:
95 run.cleanup( main )