3232
3333
3434class TestRouter (base .TestOVNFunctionalBase ):
35- def setUp (self ):
36- super (TestRouter , self ).setUp ()
35+ def setUp (self , ** kwargs ):
36+ super ().setUp (** kwargs )
3737 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 = [])
3940 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 = [])
4143 self .cr_lrp_pb_event = events .WaitForCrLrpPortBindingEvent ()
4244 self .sb_api .idl .notify_handler .watch_event (self .cr_lrp_pb_event )
4345
@@ -95,12 +97,14 @@ def test_gateway_chassis_on_router_gateway_port(self):
9597 self .assertIn (rc , expected )
9698
9799 def _check_gateway_chassis_candidates (self , candidates ,
98- router_az_hints = None ):
100+ router_az_hints = None ,
101+ physnet = 'physnet1' ):
99102 # In this test, fake_select() is called once from _create_router()
100103 # and later from schedule_unhosted_gateways()
101104 ovn_client = self .l3_plugin ._ovn_client
105+ net_type = 'vlan' if physnet else 'geneve'
102106 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" )
104108 # mock select function and check if it is called with expected
105109 # candidates.
106110
@@ -131,12 +135,11 @@ def fake_select(*args, **kwargs):
131135
132136 def test_gateway_chassis_with_cms_and_bridge_mappings (self ):
133137 # 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.
136140 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 ])
140143
141144 def test_gateway_chassis_with_cms_and_no_bridge_mappings (self ):
142145 # chassis1 is having proper bridge mappings.
@@ -170,12 +173,10 @@ def test_gateway_chassis_with_cms_and_azs(self):
170173 # Test if chassis3 is selected as candidate or not.
171174 self .chassis3 = self .add_fake_chassis (
172175 '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 )
175177 self .chassis4 = self .add_fake_chassis (
176178 '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 )
179180 self ._check_gateway_chassis_candidates ([self .chassis3 ],
180181 router_az_hints = ['ovn' ])
181182
@@ -185,11 +186,9 @@ def test_gateway_chassis_with_cms_and_not_match_azs(self):
185186 # AvailabilityZoneNotFound. after create will delete if.
186187 # add chassis4 is having azs [ovn2], not match routers az_hints [ovn]
187188 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 )
190190 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 ,
193192 azs = ['ovn2' ])
194193 ovn_client = self .l3_plugin ._ovn_client
195194 ext1 = self ._create_ext_network (
@@ -217,6 +216,11 @@ def test_gateway_chassis_with_bridge_mappings_and_no_cms(self):
217216 # Test if chassis1 is selected as candidate or not.
218217 self ._check_gateway_chassis_candidates ([self .chassis1 ])
219218
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+
220224 def _l3_ha_supported (self ):
221225 # If the Gateway_Chassis table exists in SB database, then it
222226 # means that L3 HA is supported.
0 commit comments