From 2f678b980cfd9fbd6fdcda18af1a140916630055 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Fri, 19 Jan 2024 11:41:15 +0000 Subject: [PATCH] [OVN][FT] Retry in case of timeout when executing "ovsdb-client". The shell command "ovsdb-client", in the functional tests, is prone to timeouts. This patch adds a tenacity decorator and sets the command timeout to 3 seconds, that should be more than enough to retrieve one single register. Closes-Bug: #1955008 Change-Id: I38626835ca809cc3f2894e5f81fab55cf3f40071 (cherry picked from commit 64fddf4f2d18b134b5cc8348049a3c4f10f69a28) --- .../drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py index e8d6665c2e4..5630a8c50eb 100644 --- a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py +++ b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py @@ -13,6 +13,7 @@ # under the License. import datetime import functools +import subprocess from unittest import mock import fixtures as og_fixtures @@ -26,6 +27,7 @@ from oslo_utils import timeutils from oslo_utils import uuidutils from ovsdbapp.backend.ovs_idl import event from ovsdbapp.backend.ovs_idl import idlutils +import tenacity from neutron.common.ovn import constants as ovn_const from neutron.common import utils as n_utils @@ -144,6 +146,10 @@ class TestNBDbMonitor(base.TestOVNFunctionalBase): 'port_id': port['id']}}) return r1_f2 + @tenacity.retry( + retry=tenacity.retry_if_exception_type(subprocess.TimeoutExpired), + wait=tenacity.wait_exponential(multiplier=0.02, max=1), + reraise=True) def _check_mac_binding_exists(self, macb_id): cmd = ['ovsdb-client', 'transact', self.mech_driver.sb_ovn.connection_string] @@ -156,8 +162,7 @@ class TestNBDbMonitor(base.TestOVNFunctionalBase): cmd += ['["OVN_Southbound", {"op": "select", "table": "MAC_Binding", ' '"where": [["_uuid", "==", ["uuid", "%s"]]]}]' % macb_id] - out, _ = processutils.execute(*cmd, - log_errors=False) + out, _ = processutils.execute(*cmd, log_errors=False, timeout=3) return str(macb_id) in out def test_floatingip_mac_bindings(self):