32
32
33
33
34
34
class TestRouter (base .TestOVNFunctionalBase ):
35
- def setUp (self ):
36
- super (TestRouter , self ).setUp ()
35
+ def setUp (self , ** kwargs ):
36
+ super ().setUp (** kwargs )
37
37
self .chassis1 = self .add_fake_chassis (
38
- 'ovs-host1' , physical_nets = ['physnet1' , 'physnet3' ])
38
+ 'ovs-host1' , physical_nets = ['physnet1' , 'physnet3' ],
39
+ enable_chassis_as_gw = True , azs = [])
39
40
self .chassis2 = self .add_fake_chassis (
40
- 'ovs-host2' , physical_nets = ['physnet2' , 'physnet3' ])
41
+ 'ovs-host2' , physical_nets = ['physnet2' , 'physnet3' ],
42
+ enable_chassis_as_gw = True , azs = [])
41
43
self .cr_lrp_pb_event = events .WaitForCrLrpPortBindingEvent ()
42
44
self .sb_api .idl .notify_handler .watch_event (self .cr_lrp_pb_event )
43
45
@@ -95,12 +97,14 @@ def test_gateway_chassis_on_router_gateway_port(self):
95
97
self .assertIn (rc , expected )
96
98
97
99
def _check_gateway_chassis_candidates (self , candidates ,
98
- router_az_hints = None ):
100
+ router_az_hints = None ,
101
+ physnet = 'physnet1' ):
99
102
# In this test, fake_select() is called once from _create_router()
100
103
# and later from schedule_unhosted_gateways()
101
104
ovn_client = self .l3_plugin ._ovn_client
105
+ net_type = 'vlan' if physnet else 'geneve'
102
106
ext1 = self ._create_ext_network (
103
- 'ext1' , 'vlan' , 'physnet1' , 1 , "10.0.0.1" , "10.0.0.0/24" )
107
+ 'ext1' , net_type , physnet , 1 , "10.0.0.1" , "10.0.0.0/24" )
104
108
# mock select function and check if it is called with expected
105
109
# candidates.
106
110
@@ -131,12 +135,11 @@ def fake_select(*args, **kwargs):
131
135
132
136
def test_gateway_chassis_with_cms_and_bridge_mappings (self ):
133
137
# Both chassis1 and chassis3 are having proper bridge mappings,
134
- # but only chassis3 is having enable-chassis-as-gw.
135
- # Test if chassis3 is selected as candidate or not.
138
+ # but only chassis1 is having enable-chassis-as-gw.
139
+ # Test if chassis1 is selected as candidate or not.
136
140
self .chassis3 = self .add_fake_chassis (
137
- 'ovs-host3' , physical_nets = ['physnet1' ],
138
- other_config = {'ovn-cms-options' : 'enable-chassis-as-gw' })
139
- self ._check_gateway_chassis_candidates ([self .chassis3 ])
141
+ 'ovs-host3' , physical_nets = ['physnet1' ], azs = [])
142
+ self ._check_gateway_chassis_candidates ([self .chassis1 ])
140
143
141
144
def test_gateway_chassis_with_cms_and_no_bridge_mappings (self ):
142
145
# chassis1 is having proper bridge mappings.
@@ -170,12 +173,10 @@ def test_gateway_chassis_with_cms_and_azs(self):
170
173
# Test if chassis3 is selected as candidate or not.
171
174
self .chassis3 = self .add_fake_chassis (
172
175
'ovs-host3' , physical_nets = ['physnet1' ],
173
- other_config = {'ovn-cms-options' : 'enable-chassis-as-gw' },
174
- azs = ['ovn' ])
176
+ azs = ['ovn' ], enable_chassis_as_gw = True )
175
177
self .chassis4 = self .add_fake_chassis (
176
178
'ovs-host4' , physical_nets = ['physnet1' ],
177
- other_config = {'ovn-cms-options' : 'enable-chassis-as-gw' },
178
- azs = ['ovn2' ])
179
+ azs = ['ovn2' ], enable_chassis_as_gw = True )
179
180
self ._check_gateway_chassis_candidates ([self .chassis3 ],
180
181
router_az_hints = ['ovn' ])
181
182
@@ -185,11 +186,9 @@ def test_gateway_chassis_with_cms_and_not_match_azs(self):
185
186
# AvailabilityZoneNotFound. after create will delete if.
186
187
# add chassis4 is having azs [ovn2], not match routers az_hints [ovn]
187
188
self .chassis3 = self .add_fake_chassis (
188
- 'ovs-host3' , physical_nets = ['physnet1' ],
189
- other_config = {'ovn-cms-options' : 'enable-chassis-as-gw' })
189
+ 'ovs-host3' , physical_nets = ['physnet1' ], enable_chassis_as_gw = True )
190
190
self .chassis4 = self .add_fake_chassis (
191
- 'ovs-host4' , physical_nets = ['physnet1' ],
192
- other_config = {'ovn-cms-options' : 'enable-chassis-as-gw' },
191
+ 'ovs-host4' , physical_nets = ['physnet1' ], enable_chassis_as_gw = True ,
193
192
azs = ['ovn2' ])
194
193
ovn_client = self .l3_plugin ._ovn_client
195
194
ext1 = self ._create_ext_network (
@@ -217,6 +216,11 @@ def test_gateway_chassis_with_bridge_mappings_and_no_cms(self):
217
216
# Test if chassis1 is selected as candidate or not.
218
217
self ._check_gateway_chassis_candidates ([self .chassis1 ])
219
218
219
+ def test_gateway_chassis_no_physnet_tunnelled_network (self ):
220
+ # The GW network is tunnelled, no physnet defined --> no possible
221
+ # candidates.
222
+ self ._check_gateway_chassis_candidates ([], physnet = None )
223
+
220
224
def _l3_ha_supported (self ):
221
225
# If the Gateway_Chassis table exists in SB database, then it
222
226
# means that L3 HA is supported.
0 commit comments