ovn: Wait for northd in functional tests
Each functional test method create new empty NB and SB DBs. Each DB
has its own table NB_Global or SB_Global respectively that contains
exactly one record created by ovn-northd. When functional test spawns
northd, it populates the DBs however it doesn't guarantee the running
test in parallel will not attempt to access the record.
This patch makes sure that northd creates the records before it moves on
and considers northd spawned.
Closes-Bug: #1952004
Conflicts:
neutron/tests/functional/base.py
Signed-off-by: Jakub Libosvar <libosvar@redhat.com>
Change-Id: Ic936864aebcabb811860e17913fbff311c52845f
(cherry picked from commit af03d133f4
)
This commit is contained in:
parent
a146f58aef
commit
80d408cd96
|
@ -33,6 +33,7 @@ from oslo_utils import uuidutils
|
|||
|
||||
from neutron.agent.linux import utils
|
||||
from neutron.api import extensions as exts
|
||||
from neutron.common import utils as n_utils
|
||||
from neutron.conf.agent import common as config
|
||||
from neutron.conf.agent import ovs_conf
|
||||
from neutron.conf.plugins.ml2 import config as ml2_config
|
||||
|
@ -264,12 +265,39 @@ class TestOVNFunctionalBase(test_plugin.Ml2PluginV2TestCase,
|
|||
def _start_ovn_northd(self):
|
||||
if not self.ovsdb_server_mgr:
|
||||
return
|
||||
|
||||
def wait_for_northd():
|
||||
try:
|
||||
self.nb_api.nb_global
|
||||
except StopIteration:
|
||||
LOG.debug("NB_Global is not ready yet")
|
||||
return False
|
||||
|
||||
try:
|
||||
next(iter(self.sb_api.db_list_rows('SB_Global').execute(
|
||||
check_error=True)))
|
||||
except StopIteration:
|
||||
LOG.debug("SB_Global is not ready yet")
|
||||
return False
|
||||
except KeyError:
|
||||
# Maintenance worker doesn't register SB_Global therefore
|
||||
# we don't need to wait for it
|
||||
LOG.debug("SB_Global is not registered in this IDL")
|
||||
|
||||
return True
|
||||
|
||||
timeout = 20
|
||||
ovn_nb_db = self.ovsdb_server_mgr.get_ovsdb_connection_path('nb')
|
||||
ovn_sb_db = self.ovsdb_server_mgr.get_ovsdb_connection_path('sb')
|
||||
self.ovn_northd_mgr = self.useFixture(
|
||||
process.OvnNorthd(self.temp_dir,
|
||||
ovn_nb_db, ovn_sb_db,
|
||||
protocol=self._ovsdb_protocol))
|
||||
n_utils.wait_until_true(
|
||||
wait_for_northd, timeout, sleep=1,
|
||||
exception=Exception(
|
||||
"ovn-northd didn't initialize OVN DBs in %d"
|
||||
"seconds" % timeout))
|
||||
|
||||
def _start_ovsdb_server(self):
|
||||
# Start 2 ovsdb-servers one each for OVN NB DB and OVN SB DB
|
||||
|
|
Loading…
Reference in New Issue