Update to support the ovdsbapp 0.4.0 API
idl_factory was removed in favor of just passing in an Idl instance as an Idl doesn't start a connection until its .run() is called. The try/excepts will be removed when the ovsdbapp 0.4.0 constraint changes are merged. Change-Id: Id22faa1f6179c2fdf8a136972d65f10749c9fc2e
This commit is contained in:
parent
6d84a8fac5
commit
1eec265ad0
neutron
agent/ovsdb
tests
functional/agent/ovsdb/native
unit
agent
cmd
plugins/ml2/drivers/openvswitch/agent
@ -35,11 +35,20 @@ Transaction = moves.moved_class(transaction.Transaction,
|
||||
'Transaction', __name__)
|
||||
|
||||
ovs_conf.register_ovs_agent_opts()
|
||||
_connection = connection.Connection(idl_factory=connection.idl_factory,
|
||||
timeout=cfg.CONF.ovs_vsctl_timeout)
|
||||
_connection = None
|
||||
|
||||
|
||||
def api_factory(context):
|
||||
global _connection
|
||||
if _connection is None:
|
||||
try:
|
||||
_connection = connection.Connection(
|
||||
idl=connection.idl_factory(),
|
||||
timeout=cfg.CONF.ovs_vsctl_timeout)
|
||||
except TypeError:
|
||||
_connection = connection.Connection(
|
||||
idl_factory=connection.idl_factory,
|
||||
timeout=cfg.CONF.ovs_vsctl_timeout)
|
||||
return NeutronOvsdbIdl(_connection)
|
||||
|
||||
|
||||
|
@ -39,9 +39,15 @@ class OVSDBConnectionTestCase(base.BaseSudoTestCase):
|
||||
helper.register_table(table)
|
||||
return idl.Idl(connection, helper)
|
||||
|
||||
self.connection = connection.Connection(
|
||||
idl_factory=_idl_factory,
|
||||
timeout=cfg.CONF.ovs_vsctl_timeout,
|
||||
)
|
||||
self.connection.start(table_name_list=tables)
|
||||
try:
|
||||
self.connection = connection.Connection(
|
||||
idl=_idl_factory(),
|
||||
timeout=cfg.CONF.ovs_vsctl_timeout,
|
||||
)
|
||||
except TypeError:
|
||||
self.connection = connection.Connection(
|
||||
idl_factory=_idl_factory,
|
||||
timeout=cfg.CONF.ovs_vsctl_timeout,
|
||||
)
|
||||
self.connection.start()
|
||||
self.assertItemsEqual(tables, self.connection.idl.tables.keys())
|
||||
|
@ -138,7 +138,7 @@ class QosExtensionBaseTestCase(base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(QosExtensionBaseTestCase, self).setUp()
|
||||
conn_patcher = mock.patch(
|
||||
'neutron.agent.ovsdb.native.connection.Connection.start')
|
||||
'neutron.agent.ovsdb.impl_idl._connection')
|
||||
conn_patcher.start()
|
||||
self.addCleanup(conn_patcher.stop)
|
||||
self.qos_ext = qos.QosAgentExtension()
|
||||
|
@ -382,8 +382,7 @@ class TestOVSInterfaceDriver(TestBase):
|
||||
internal=True)
|
||||
|
||||
def _test_plug(self, bridge=None, namespace=None):
|
||||
with mock.patch('neutron.agent.ovsdb.native.connection.'
|
||||
'Connection.start'):
|
||||
with mock.patch('neutron.agent.ovsdb.impl_idl._connection'):
|
||||
if not bridge:
|
||||
bridge = 'br-int'
|
||||
|
||||
@ -456,8 +455,7 @@ class TestOVSInterfaceDriverWithVeth(TestOVSInterfaceDriver):
|
||||
|
||||
def _test_plug(self, devname=None, bridge=None, namespace=None,
|
||||
prefix=None):
|
||||
with mock.patch('neutron.agent.ovsdb.native.connection.'
|
||||
'Connection.start'):
|
||||
with mock.patch('neutron.agent.ovsdb.impl_idl._connection'):
|
||||
|
||||
if not devname:
|
||||
devname = 'ns-0'
|
||||
|
@ -37,8 +37,12 @@ class TestOVSNativeConnection(base.BaseTestCase):
|
||||
# raise until 3rd retry attempt
|
||||
mock_get_schema_helper.side_effect = [Exception(), Exception(),
|
||||
mock_helper]
|
||||
conn = connection.Connection(idl_factory=native_conn.idl_factory,
|
||||
timeout=mock.Mock())
|
||||
try:
|
||||
conn = connection.Connection(idl_factory=native_conn.idl_factory,
|
||||
timeout=mock.Mock())
|
||||
except TypeError:
|
||||
conn = connection.Connection(idl=native_conn.idl_factory(),
|
||||
timeout=mock.Mock())
|
||||
conn.start()
|
||||
self.assertEqual(3, len(mock_get_schema_helper.mock_calls))
|
||||
mock_helper.register_all.assert_called_once_with()
|
||||
|
@ -59,7 +59,7 @@ class TestNetnsCleanup(base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(TestNetnsCleanup, self).setUp()
|
||||
conn_patcher = mock.patch(
|
||||
'neutron.agent.ovsdb.native.connection.Connection.start')
|
||||
'neutron.agent.ovsdb.impl_idl._connection')
|
||||
conn_patcher.start()
|
||||
self.addCleanup(conn_patcher.stop)
|
||||
|
||||
|
@ -26,7 +26,7 @@ from neutron.tests import base
|
||||
|
||||
class TestOVSCleanup(base.BaseTestCase):
|
||||
|
||||
@mock.patch('neutron.agent.ovsdb.native.connection.Connection.start')
|
||||
@mock.patch('neutron.agent.ovsdb.impl_idl._connection')
|
||||
@mock.patch('neutron.common.config.setup_logging')
|
||||
@mock.patch('neutron.cmd.ovs_cleanup.setup_conf')
|
||||
@mock.patch('neutron.agent.common.ovs_lib.BaseOVS.get_bridges')
|
||||
|
@ -33,7 +33,7 @@ class QosOVSAgentDriverTestCase(ovs_test_base.OVSAgentConfigTestBase):
|
||||
def setUp(self):
|
||||
super(QosOVSAgentDriverTestCase, self).setUp()
|
||||
conn_patcher = mock.patch(
|
||||
'neutron.agent.ovsdb.native.connection.Connection.start')
|
||||
'neutron.agent.ovsdb.impl_idl._connection')
|
||||
conn_patcher.start()
|
||||
self.addCleanup(conn_patcher.stop)
|
||||
self.context = context.get_admin_context()
|
||||
|
@ -32,7 +32,7 @@ class OVSPhysicalBridgeTest(ovs_bridge_test_base.OVSBridgeTestBase,
|
||||
|
||||
def setUp(self):
|
||||
conn_patcher = mock.patch(
|
||||
'neutron.agent.ovsdb.native.connection.Connection.start')
|
||||
'neutron.agent.ovsdb.impl_idl._connection')
|
||||
conn_patcher.start()
|
||||
super(OVSPhysicalBridgeTest, self).setUp()
|
||||
self.addCleanup(conn_patcher.stop)
|
||||
|
@ -32,7 +32,7 @@ class OVSTunnelBridgeTest(ovs_bridge_test_base.OVSBridgeTestBase,
|
||||
|
||||
def setUp(self):
|
||||
conn_patcher = mock.patch(
|
||||
'neutron.agent.ovsdb.native.connection.Connection.start')
|
||||
'neutron.agent.ovsdb.impl_idl._connection')
|
||||
conn_patcher.start()
|
||||
super(OVSTunnelBridgeTest, self).setUp()
|
||||
# NOTE(ivasilevskaya) The behaviour of oslotest.base.addCleanup()
|
||||
|
@ -26,7 +26,7 @@ class TestBRCookieOpenflow(base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(TestBRCookieOpenflow, self).setUp()
|
||||
conn_patcher = mock.patch(
|
||||
'neutron.agent.ovsdb.native.connection.Connection.start')
|
||||
'neutron.agent.ovsdb.impl_idl._connection')
|
||||
conn_patcher.start()
|
||||
self.addCleanup(conn_patcher.stop)
|
||||
self.br = ovs_bridge.OVSAgentBridge('br-int')
|
||||
|
@ -42,7 +42,7 @@ class OVSAgentTestBase(OVSAgentConfigTestBase):
|
||||
def setUp(self):
|
||||
super(OVSAgentTestBase, self).setUp()
|
||||
conn_patcher = mock.patch(
|
||||
'neutron.agent.ovsdb.native.connection.Connection.start')
|
||||
'neutron.agent.ovsdb.impl_idl._connection')
|
||||
conn_patcher.start()
|
||||
self.addCleanup(conn_patcher.stop)
|
||||
self.br_int_cls = importutils.import_class(self._BR_INT_CLASS)
|
||||
|
@ -123,6 +123,7 @@ class TestOvsNeutronAgent(object):
|
||||
mock.patch('neutron.agent.common.ovs_lib.BaseOVS.config',
|
||||
new_callable=mock.PropertyMock,
|
||||
return_value={}).start()
|
||||
mock.patch('neutron.agent.ovsdb.impl_idl._connection').start()
|
||||
self.agent = self._make_agent()
|
||||
self.agent.sg_agent = mock.Mock()
|
||||
|
||||
@ -2161,7 +2162,7 @@ class AncillaryBridgesTest(object):
|
||||
def setUp(self):
|
||||
super(AncillaryBridgesTest, self).setUp()
|
||||
conn_patcher = mock.patch(
|
||||
'neutron.agent.ovsdb.native.connection.Connection.start')
|
||||
'neutron.agent.ovsdb.impl_idl._connection')
|
||||
conn_patcher.start()
|
||||
self.addCleanup(conn_patcher.stop)
|
||||
notifier_p = mock.patch(NOTIFIER)
|
||||
@ -2294,6 +2295,7 @@ class TestOvsDvrNeutronAgent(object):
|
||||
mock.patch('neutron.agent.common.ovs_lib.BaseOVS.config',
|
||||
new_callable=mock.PropertyMock,
|
||||
return_value={}).start()
|
||||
mock.patch('neutron.agent.ovsdb.impl_idl._connection').start()
|
||||
with mock.patch.object(self.mod_agent.OVSNeutronAgent,
|
||||
'setup_integration_br'),\
|
||||
mock.patch.object(self.mod_agent.OVSNeutronAgent,
|
||||
|
@ -78,7 +78,7 @@ class TunnelTest(object):
|
||||
super(TunnelTest, self).setUp()
|
||||
self.useFixture(test_vlanmanager.LocalVlanManagerFixture())
|
||||
conn_patcher = mock.patch(
|
||||
'neutron.agent.ovsdb.native.connection.Connection.start')
|
||||
'neutron.agent.ovsdb.impl_idl._connection')
|
||||
conn_patcher.start()
|
||||
self.addCleanup(conn_patcher.stop)
|
||||
cfg.CONF.set_default('firewall_driver',
|
||||
@ -110,6 +110,7 @@ class TunnelTest(object):
|
||||
new_callable=mock.PropertyMock,
|
||||
return_value={}).start()
|
||||
|
||||
mock.patch('neutron.agent.ovsdb.impl_idl._connection').start()
|
||||
self.ovs_bridges = {
|
||||
self.INT_BRIDGE: mock.create_autospec(
|
||||
self.br_int_cls('br-int')),
|
||||
|
Loading…
x
Reference in New Issue
Block a user