Merge "venv: unit tests don't work for 'hardware_vtep'"

This commit is contained in:
Zuul 2023-11-17 18:21:38 +00:00 committed by Gerrit Code Review
commit 8e55b0b74c
3 changed files with 19 additions and 3 deletions

View File

@ -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)

View File

@ -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):

View File

@ -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 =