Merge "Add WaitForPortCreateEvent in BaseOVSTestCase" into stable/train
This commit is contained in:
commit
331629ee70
|
@ -19,6 +19,7 @@ import mock
|
||||||
from neutron_lib import constants as p_const
|
from neutron_lib import constants as p_const
|
||||||
from neutron_lib.services.qos import constants as qos_constants
|
from neutron_lib.services.qos import constants as qos_constants
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
from ovsdbapp.backend.ovs_idl import event
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from neutron.agent.common import ovs_lib
|
from neutron.agent.common import ovs_lib
|
||||||
|
@ -38,6 +39,17 @@ OTHER_CONFIG_DEFAULT = {six.u('max-rate'): six.u(str(MAX_RATE_DEFAULT)),
|
||||||
six.u('min-rate'): six.u(str(MIN_RATE_DEFAULT))}
|
six.u('min-rate'): six.u(str(MIN_RATE_DEFAULT))}
|
||||||
|
|
||||||
|
|
||||||
|
class WaitForPortCreateEvent(event.WaitEvent):
|
||||||
|
event_name = 'WaitForPortCreateEvent'
|
||||||
|
|
||||||
|
def __init__(self, port_name):
|
||||||
|
table = 'Port'
|
||||||
|
events = (self.ROW_CREATE,)
|
||||||
|
conditions = (('name', '=', port_name),)
|
||||||
|
super(WaitForPortCreateEvent, self).__init__(
|
||||||
|
events, table, conditions, timeout=5)
|
||||||
|
|
||||||
|
|
||||||
class BaseOVSTestCase(base.BaseSudoTestCase):
|
class BaseOVSTestCase(base.BaseSudoTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -112,8 +124,11 @@ class BaseOVSTestCase(base.BaseSudoTestCase):
|
||||||
self.elements_to_clean['bridges'].append(self.br_name)
|
self.elements_to_clean['bridges'].append(self.br_name)
|
||||||
|
|
||||||
def _create_port(self, port_name):
|
def _create_port(self, port_name):
|
||||||
|
row_event = WaitForPortCreateEvent(port_name)
|
||||||
|
self.ovs.ovsdb.idl.notify_handler.watch_event(row_event)
|
||||||
self.ovs.ovsdb.add_port(self.br_name, port_name).execute(
|
self.ovs.ovsdb.add_port(self.br_name, port_name).execute(
|
||||||
check_error=True)
|
check_error=True)
|
||||||
|
self.assertTrue(row_event.wait())
|
||||||
|
|
||||||
def _find_port_uuid(self, port_name):
|
def _find_port_uuid(self, port_name):
|
||||||
return self.ovs.ovsdb.db_get('Port', port_name, '_uuid').execute()
|
return self.ovs.ovsdb.db_get('Port', port_name, '_uuid').execute()
|
||||||
|
|
Loading…
Reference in New Issue