Skip to content

Commit 1f5ce18

Browse files
committed
[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 64fddf4)
1 parent 4b47f8d commit 1f5ce18

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovsdb_monitor.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# under the License.
1414
import datetime
1515
import functools
16+
import subprocess
1617
from unittest import mock
1718

1819
import fixtures as og_fixtures
@@ -26,6 +27,7 @@
2627
from oslo_utils import uuidutils
2728
from ovsdbapp.backend.ovs_idl import event
2829
from ovsdbapp.backend.ovs_idl import idlutils
30+
import tenacity
2931

3032
from neutron.common.ovn import constants as ovn_const
3133
from neutron.common import utils as n_utils
@@ -144,6 +146,10 @@ def _create_fip(self, port, fip_address):
144146
'port_id': port['id']}})
145147
return r1_f2
146148

149+
@tenacity.retry(
150+
retry=tenacity.retry_if_exception_type(subprocess.TimeoutExpired),
151+
wait=tenacity.wait_exponential(multiplier=0.02, max=1),
152+
reraise=True)
147153
def _check_mac_binding_exists(self, macb_id):
148154
cmd = ['ovsdb-client', 'transact',
149155
self.mech_driver.sb_ovn.connection_string]
@@ -156,8 +162,7 @@ def _check_mac_binding_exists(self, macb_id):
156162
cmd += ['["OVN_Southbound", {"op": "select", "table": "MAC_Binding", '
157163
'"where": [["_uuid", "==", ["uuid", "%s"]]]}]' % macb_id]
158164

159-
out, _ = processutils.execute(*cmd,
160-
log_errors=False)
165+
out, _ = processutils.execute(*cmd, log_errors=False, timeout=3)
161166
return str(macb_id) in out
162167

163168
def test_floatingip_mac_bindings(self):

0 commit comments

Comments
 (0)