@@ -1175,14 +1175,14 @@ def test_set_port_status_concurrent_delete(self):
11751175 side_effect = exc ) as apc , \
11761176 mock .patch .object (self .mech_driver ,
11771177 '_update_dnat_entry_if_needed' ) as ude :
1178- self .mech_driver .set_port_status_down (port1 ['port' ]['id' ], False )
1178+ self .mech_driver .set_port_status_down (port1 ['port' ]['id' ])
11791179 apc .assert_called_once_with (
11801180 mock .ANY ,
11811181 port1 ['port' ]['id' ],
11821182 resources .PORT ,
11831183 provisioning_blocks .L2_AGENT_ENTITY
11841184 )
1185- ude .assert_called_once_with (port1 ['port' ]['id' ])
1185+ ude .assert_called_once_with (port1 ['port' ]['id' ], False )
11861186
11871187 def test_bind_port_unsupported_vnic_type (self ):
11881188 fake_port = fakes .FakePort .create_one_port (
@@ -2376,33 +2376,49 @@ def test_agent_with_nb_cfg_timestamp_not_timeout(self):
23762376 self .assertTrue (agent .alive , "Agent of type %s alive=%s" % (
23772377 agent .agent_type , agent .alive ))
23782378
2379- def _test__update_dnat_entry_if_needed (self , up = True ):
2380- ovn_conf .cfg .CONF .set_override (
2381- 'enable_distributed_floating_ip' , True , group = 'ovn' )
2379+ def _test__update_dnat_entry_if_needed (self , up = True , dvr = True ):
2380+ if dvr :
2381+ ovn_conf .cfg .CONF .set_override (
2382+ 'enable_distributed_floating_ip' , True , group = 'ovn' )
23822383 port_id = 'fake-port-id'
23832384 fake_ext_mac_key = 'fake-ext-mac-key'
23842385 fake_nat_uuid = uuidutils .generate_uuid ()
23852386 nat_row = fakes .FakeOvsdbRow .create_one_ovsdb_row (
23862387 attrs = {'_uuid' : fake_nat_uuid , 'external_ids' : {
23872388 ovn_const .OVN_FIP_EXT_MAC_KEY : fake_ext_mac_key },
23882389 'external_mac' : 'aa:aa:aa:aa:aa:aa' })
2390+
23892391 fake_db_find = mock .Mock ()
23902392 fake_db_find .execute .return_value = [nat_row ]
23912393 self .nb_ovn .db_find .return_value = fake_db_find
2394+
23922395 self .mech_driver ._update_dnat_entry_if_needed (port_id , up = up )
2393- if up :
2396+
2397+ if up and dvr :
23942398 # Assert that we are setting the external_mac in the NAT table
23952399 self .nb_ovn .db_set .assert_called_once_with (
23962400 'NAT' , fake_nat_uuid , ('external_mac' , fake_ext_mac_key ))
23972401 else :
2398- # Assert that we are cleaning the external_mac from the NAT table
2399- self .nb_ovn .db_clear .assert_called_once_with (
2400- 'NAT' , fake_nat_uuid , 'external_mac' )
2401- def test__update_dnat_entry_if_needed_up (self ):
2402+ if dvr :
2403+ self .nb_ovn .db_set .assert_not_called ()
2404+ else :
2405+ # Assert that we are cleaning the external_mac from the NAT
2406+ # table
2407+ self .nb_ovn .db_clear .assert_called_once_with (
2408+ 'NAT' , fake_nat_uuid , 'external_mac' )
2409+
2410+ def test__update_dnat_entry_if_needed_up_dvr (self ):
24022411 self ._test__update_dnat_entry_if_needed ()
2403- def test__update_dnat_entry_if_needed_down (self ):
2412+
2413+ def test__update_dnat_entry_if_needed_up_no_dvr (self ):
2414+ self ._test__update_dnat_entry_if_needed (dvr = False )
2415+
2416+ def test__update_dnat_entry_if_needed_down_dvr (self ):
24042417 self ._test__update_dnat_entry_if_needed (up = False )
24052418
2419+ def test__update_dnat_entry_if_needed_down_no_dvr (self ):
2420+ self ._test__update_dnat_entry_if_needed (up = False , dvr = False )
2421+
24062422 @mock .patch ('neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb.'
24072423 'ovn_client.OVNClient._get_router_ports' )
24082424 def _test_update_network_fragmentation (self , new_mtu , expected_opts , grps ):
0 commit comments