diff --git a/ovsdbapp/tests/functional/schema/hardware_vtep/test_impl_idl.py b/ovsdbapp/tests/functional/schema/hardware_vtep/test_impl_idl.py index 5bf2580e..9917b65a 100644 --- a/ovsdbapp/tests/functional/schema/hardware_vtep/test_impl_idl.py +++ b/ovsdbapp/tests/functional/schema/hardware_vtep/test_impl_idl.py @@ -13,6 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. +import time + from ovsdbapp.backend.ovs_idl import idlutils from ovsdbapp.schema.hardware_vtep.commands import get_global_record from ovsdbapp.tests.functional import base @@ -352,6 +354,16 @@ class TestMacBindingsOps(HardwareVtepTest): ]: self.addCleanup(self.ovsvenv.call, args) + def _wait_db_rows(self, table): + """Wait for rows in specified table. Raises RuntimeError otherwise.""" + + for _ in range(4): + if table.rows: + return + time.sleep(0.5) + + raise RuntimeError("Table '%s' is empty" % table.name) + def test_list_local_macs(self): local_macs = self.api.list_local_macs( self.ls.name).execute(check_error=True) @@ -370,6 +382,7 @@ class TestMacBindingsOps(HardwareVtepTest): ucast_table = self.api.tables['Ucast_Macs_Local'] mcast_table = self.api.tables['Mcast_Macs_Local'] for table in [ucast_table, mcast_table]: + self._wait_db_rows(table) self.assertEqual(len(table.rows), 1) self.api.clear_local_macs(self.ls.name).execute(check_error=True) @@ -380,6 +393,7 @@ class TestMacBindingsOps(HardwareVtepTest): ucast_table = self.api.tables['Ucast_Macs_Remote'] mcast_table = self.api.tables['Mcast_Macs_Remote'] for table in [ucast_table, mcast_table]: + self._wait_db_rows(table) self.assertEqual(len(table.rows), 1) self.api.clear_remote_macs(self.ls.name).execute(check_error=True) diff --git a/ovsdbapp/venv.py b/ovsdbapp/venv.py index df001afd..ed365fad 100644 --- a/ovsdbapp/venv.py +++ b/ovsdbapp/venv.py @@ -282,10 +282,12 @@ class OvsOvnIcVenvFixture(OvsOvnVenvFixture): class OvsVtepVenvFixture(OvsOvnVenvFixture): VTEP_SCHEMA = 'vtep.ovsschema' - def __init__(self, venv, vtepdir=None, **kwargs): + def __init__(self, venv, **kwargs): + vtepdir = os.getenv('VTEP_SRCDIR') if vtepdir and os.path.isdir(vtepdir): self.PATH_VAR_TEMPLATE += ":{0}".format(vtepdir) - self.vtepdir = self._share_path(self.OVS_PATHS, vtepdir) + self.vtepdir = self._share_path(self.OVS_PATHS, vtepdir, + [self.VTEP_SCHEMA]) super().__init__(venv, **kwargs) def _setUp(self): diff --git a/tox.ini b/tox.ini index 91e9909d..05a96301 100644 --- a/tox.ini +++ b/tox.ini @@ -65,7 +65,7 @@ setenv = {[testenv]setenv} OS_TEST_PATH=./ovsdbapp/tests/functional OVN_SRCDIR={envdir}/src/ovn OVS_SRCDIR={envdir}/src/ovn/ovs - VTEP_SRCDIR={envdir}src/ovn/ovs/vtep + VTEP_SRCDIR={envdir}/src/ovn/ovs/vtep OVN_BRANCH={env:OVN_BRANCH:} passenv = KEEP_VENV commands =