Skip to content

Commit d7ef3cc

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "ovn: Wait for northd in functional tests" into stable/yoga
2 parents 8272bd4 + 525a9b2 commit d7ef3cc

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

neutron/tests/functional/base.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
from neutron.agent.linux import utils
3535
from neutron.api import extensions as exts
36+
from neutron.common import utils as n_utils
3637
from neutron.conf.agent import common as config
3738
from neutron.conf.agent import ovs_conf
3839
from neutron.conf.plugins.ml2 import config as ml2_config
@@ -276,6 +277,28 @@ def get_ovsdb_server_protocol(self):
276277
def _start_ovn_northd(self):
277278
if not self.ovsdb_server_mgr:
278279
return
280+
281+
def wait_for_northd():
282+
try:
283+
self.nb_api.nb_global
284+
except StopIteration:
285+
LOG.debug("NB_Global is not ready yet")
286+
return False
287+
288+
try:
289+
next(iter(self.sb_api.db_list_rows('SB_Global').execute(
290+
check_error=True)))
291+
except StopIteration:
292+
LOG.debug("SB_Global is not ready yet")
293+
return False
294+
except KeyError:
295+
# Maintenance worker doesn't register SB_Global therefore
296+
# we don't need to wait for it
297+
LOG.debug("SB_Global is not registered in this IDL")
298+
299+
return True
300+
301+
timeout = 20
279302
ovn_nb_db = self.ovsdb_server_mgr.get_ovsdb_connection_path('nb')
280303
ovn_sb_db = self.ovsdb_server_mgr.get_ovsdb_connection_path('sb')
281304
LOG.debug("Starting OVN northd")
@@ -284,6 +307,11 @@ def _start_ovn_northd(self):
284307
ovn_nb_db, ovn_sb_db,
285308
protocol=self._ovsdb_protocol))
286309
LOG.debug("OVN northd started: %r", self.ovn_northd_mgr)
310+
n_utils.wait_until_true(
311+
wait_for_northd, timeout, sleep=1,
312+
exception=Exception(
313+
"ovn-northd didn't initialize OVN DBs in %d"
314+
"seconds" % timeout))
287315

288316
def _start_ovsdb_server(self):
289317
# Start 2 ovsdb-servers one each for OVN NB DB and OVN SB DB

0 commit comments

Comments
 (0)