venv: unit tests don't work for 'hardware_vtep'
If OVN and OVS are not installed on the system, but cloned into '.venv', the 'OvsVtepVenvFixture' class is not instantiated correctly and all unit tests fail. Closes-bug: 2037568 Change-Id: Id26004b57cb02900faed5dabeee8956ff9c66b54
This commit is contained in:
parent
a39b4f8e62
commit
dd56fd5bea
@ -13,6 +13,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
from ovsdbapp.backend.ovs_idl import idlutils
|
from ovsdbapp.backend.ovs_idl import idlutils
|
||||||
from ovsdbapp.schema.hardware_vtep.commands import get_global_record
|
from ovsdbapp.schema.hardware_vtep.commands import get_global_record
|
||||||
from ovsdbapp.tests.functional import base
|
from ovsdbapp.tests.functional import base
|
||||||
@ -352,6 +354,16 @@ class TestMacBindingsOps(HardwareVtepTest):
|
|||||||
]:
|
]:
|
||||||
self.addCleanup(self.ovsvenv.call, args)
|
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):
|
def test_list_local_macs(self):
|
||||||
local_macs = self.api.list_local_macs(
|
local_macs = self.api.list_local_macs(
|
||||||
self.ls.name).execute(check_error=True)
|
self.ls.name).execute(check_error=True)
|
||||||
@ -370,6 +382,7 @@ class TestMacBindingsOps(HardwareVtepTest):
|
|||||||
ucast_table = self.api.tables['Ucast_Macs_Local']
|
ucast_table = self.api.tables['Ucast_Macs_Local']
|
||||||
mcast_table = self.api.tables['Mcast_Macs_Local']
|
mcast_table = self.api.tables['Mcast_Macs_Local']
|
||||||
for table in [ucast_table, mcast_table]:
|
for table in [ucast_table, mcast_table]:
|
||||||
|
self._wait_db_rows(table)
|
||||||
self.assertEqual(len(table.rows), 1)
|
self.assertEqual(len(table.rows), 1)
|
||||||
|
|
||||||
self.api.clear_local_macs(self.ls.name).execute(check_error=True)
|
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']
|
ucast_table = self.api.tables['Ucast_Macs_Remote']
|
||||||
mcast_table = self.api.tables['Mcast_Macs_Remote']
|
mcast_table = self.api.tables['Mcast_Macs_Remote']
|
||||||
for table in [ucast_table, mcast_table]:
|
for table in [ucast_table, mcast_table]:
|
||||||
|
self._wait_db_rows(table)
|
||||||
self.assertEqual(len(table.rows), 1)
|
self.assertEqual(len(table.rows), 1)
|
||||||
|
|
||||||
self.api.clear_remote_macs(self.ls.name).execute(check_error=True)
|
self.api.clear_remote_macs(self.ls.name).execute(check_error=True)
|
||||||
|
@ -282,10 +282,12 @@ class OvsOvnIcVenvFixture(OvsOvnVenvFixture):
|
|||||||
class OvsVtepVenvFixture(OvsOvnVenvFixture):
|
class OvsVtepVenvFixture(OvsOvnVenvFixture):
|
||||||
VTEP_SCHEMA = 'vtep.ovsschema'
|
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):
|
if vtepdir and os.path.isdir(vtepdir):
|
||||||
self.PATH_VAR_TEMPLATE += ":{0}".format(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)
|
super().__init__(venv, **kwargs)
|
||||||
|
|
||||||
def _setUp(self):
|
def _setUp(self):
|
||||||
|
2
tox.ini
2
tox.ini
@ -65,7 +65,7 @@ setenv = {[testenv]setenv}
|
|||||||
OS_TEST_PATH=./ovsdbapp/tests/functional
|
OS_TEST_PATH=./ovsdbapp/tests/functional
|
||||||
OVN_SRCDIR={envdir}/src/ovn
|
OVN_SRCDIR={envdir}/src/ovn
|
||||||
OVS_SRCDIR={envdir}/src/ovn/ovs
|
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:}
|
OVN_BRANCH={env:OVN_BRANCH:}
|
||||||
passenv = KEEP_VENV
|
passenv = KEEP_VENV
|
||||||
commands =
|
commands =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user