From 595c387efb19744e1c9547b79501e4bb8a94ea0d Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Tue, 14 Feb 2023 04:40:15 +0100 Subject: [PATCH] [UT] Mock the retry decorator when creating duplicated NDPProxy The test ``test_create_ndp_proxy_with_duplicated`` was correctly testing the creation of a duplicated NDPProxy object. However it was taking around 3 minutes because the decorator ``oslo_db_api.wrap_db_retry`` was retrying the object creation several times. This patch mocks the retry decorator; now the test takes around 6 seconds. Closes-Bug: #2007254 Change-Id: I2fcad691df4a7ae112e1d55fefe662016430aa5b --- neutron/tests/unit/extensions/test_l3_ndp_proxy.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/neutron/tests/unit/extensions/test_l3_ndp_proxy.py b/neutron/tests/unit/extensions/test_l3_ndp_proxy.py index 2814c6fee9f..d5ce2d728a3 100644 --- a/neutron/tests/unit/extensions/test_l3_ndp_proxy.py +++ b/neutron/tests/unit/extensions/test_l3_ndp_proxy.py @@ -23,6 +23,7 @@ from neutron_lib.api.definitions import l3 as l3_apidef from neutron_lib.api.definitions import l3_ext_gw_mode from neutron_lib import constants from neutron_lib import context +from neutron_lib import fixture from oslo_config import cfg from oslo_utils import uuidutils from webob import exc @@ -566,6 +567,9 @@ class L3NDPProxyTestCase(test_address_scope.AddressScopeTestCase, def test_create_ndp_proxy_with_duplicated(self): with self.port(self.private_subnet) as port1: self._create_ndp_proxy(self.router1_id, port1['port']['id']) + retry_fixture = fixture.DBRetryErrorsFixture(max_retries=1) + retry_fixture.setUp() self._create_ndp_proxy( self.router1_id, port1['port']['id'], expected_code=exc.HTTPConflict.code) + retry_fixture.cleanUp()