@@ -1157,14 +1157,14 @@ def test_set_port_status_concurrent_delete(self):
11571157 side_effect = exc ) as apc , \
11581158 mock .patch .object (self .mech_driver ,
11591159 '_update_dnat_entry_if_needed' ) as ude :
1160- self .mech_driver .set_port_status_down (port1 ['port' ]['id' ], False )
1160+ self .mech_driver .set_port_status_down (port1 ['port' ]['id' ])
11611161 apc .assert_called_once_with (
11621162 mock .ANY ,
11631163 port1 ['port' ]['id' ],
11641164 resources .PORT ,
11651165 provisioning_blocks .L2_AGENT_ENTITY
11661166 )
1167- ude .assert_called_once_with (port1 ['port' ]['id' ])
1167+ ude .assert_called_once_with (port1 ['port' ]['id' ], False )
11681168
11691169 def test_bind_port_unsupported_vnic_type (self ):
11701170 fake_port = fakes .FakePort .create_one_port (
@@ -2358,33 +2358,49 @@ def test_agent_with_nb_cfg_timestamp_not_timeout(self):
23582358 self .assertTrue (agent .alive , "Agent of type %s alive=%s" % (
23592359 agent .agent_type , agent .alive ))
23602360
2361- def _test__update_dnat_entry_if_needed (self , up = True ):
2362- ovn_conf .cfg .CONF .set_override (
2363- 'enable_distributed_floating_ip' , True , group = 'ovn' )
2361+ def _test__update_dnat_entry_if_needed (self , up = True , dvr = True ):
2362+ if dvr :
2363+ ovn_conf .cfg .CONF .set_override (
2364+ 'enable_distributed_floating_ip' , True , group = 'ovn' )
23642365 port_id = 'fake-port-id'
23652366 fake_ext_mac_key = 'fake-ext-mac-key'
23662367 fake_nat_uuid = uuidutils .generate_uuid ()
23672368 nat_row = fakes .FakeOvsdbRow .create_one_ovsdb_row (
23682369 attrs = {'_uuid' : fake_nat_uuid , 'external_ids' : {
23692370 ovn_const .OVN_FIP_EXT_MAC_KEY : fake_ext_mac_key },
23702371 'external_mac' : 'aa:aa:aa:aa:aa:aa' })
2372+
23712373 fake_db_find = mock .Mock ()
23722374 fake_db_find .execute .return_value = [nat_row ]
23732375 self .nb_ovn .db_find .return_value = fake_db_find
2376+
23742377 self .mech_driver ._update_dnat_entry_if_needed (port_id , up = up )
2375- if up :
2378+
2379+ if up and dvr :
23762380 # Assert that we are setting the external_mac in the NAT table
23772381 self .nb_ovn .db_set .assert_called_once_with (
23782382 'NAT' , fake_nat_uuid , ('external_mac' , fake_ext_mac_key ))
23792383 else :
2380- # Assert that we are cleaning the external_mac from the NAT table
2381- self .nb_ovn .db_clear .assert_called_once_with (
2382- 'NAT' , fake_nat_uuid , 'external_mac' )
2383- def test__update_dnat_entry_if_needed_up (self ):
2384+ if dvr :
2385+ self .nb_ovn .db_set .assert_not_called ()
2386+ else :
2387+ # Assert that we are cleaning the external_mac from the NAT
2388+ # table
2389+ self .nb_ovn .db_clear .assert_called_once_with (
2390+ 'NAT' , fake_nat_uuid , 'external_mac' )
2391+
2392+ def test__update_dnat_entry_if_needed_up_dvr (self ):
23842393 self ._test__update_dnat_entry_if_needed ()
2385- def test__update_dnat_entry_if_needed_down (self ):
2394+
2395+ def test__update_dnat_entry_if_needed_up_no_dvr (self ):
2396+ self ._test__update_dnat_entry_if_needed (dvr = False )
2397+
2398+ def test__update_dnat_entry_if_needed_down_dvr (self ):
23862399 self ._test__update_dnat_entry_if_needed (up = False )
23872400
2401+ def test__update_dnat_entry_if_needed_down_no_dvr (self ):
2402+ self ._test__update_dnat_entry_if_needed (up = False , dvr = False )
2403+
23882404 @mock .patch ('neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb.'
23892405 'ovn_client.OVNClient._get_router_ports' )
23902406 def _test_update_network_fragmentation (self , new_mtu , expected_opts , grps ):
0 commit comments