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
|
||||
# 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)
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user