summaryrefslogtreecommitdiff
path: root/neutron/tests/unit/ml2
diff options
context:
space:
mode:
Diffstat (limited to 'neutron/tests/unit/ml2')
-rw-r--r--neutron/tests/unit/ml2/_test_mech_agent.py15
-rw-r--r--neutron/tests/unit/ml2/drivers/test_l2population.py16
-rw-r--r--neutron/tests/unit/ml2/drivers/test_ofagent_mech.py25
-rw-r--r--neutron/tests/unit/ml2/test_mech_openvswitch.py23
4 files changed, 73 insertions, 6 deletions
diff --git a/neutron/tests/unit/ml2/_test_mech_agent.py b/neutron/tests/unit/ml2/_test_mech_agent.py
index a42eca0c2a..71aeecf13c 100644
--- a/neutron/tests/unit/ml2/_test_mech_agent.py
+++ b/neutron/tests/unit/ml2/_test_mech_agent.py
@@ -120,7 +120,7 @@ class AgentMechanismBaseTestCase(base.BaseTestCase):
# The following must be overridden for the specific mechanism
# driver being tested:
VIF_TYPE = None
- CAP_PORT_FILTER = None
+ VIF_DETAILS = None
AGENT_TYPE = None
AGENTS = None
AGENTS_DEAD = None
@@ -136,8 +136,17 @@ class AgentMechanismBaseTestCase(base.BaseTestCase):
self.assertEqual(context._bound_vif_type, self.VIF_TYPE)
vif_details = context._bound_vif_details
self.assertIsNotNone(vif_details)
- self.assertEqual(vif_details[portbindings.CAP_PORT_FILTER],
- self.CAP_PORT_FILTER)
+ # NOTE(r-mibu): The following five lines are just for backward
+ # compatibility. In this class, HAS_PORT_FILTER has been replaced
+ # by VIF_DETAILS which can be set expected vif_details to check,
+ # but all replacement of HAS_PORT_FILTER in successor has not been
+ # completed.
+ if self.VIF_DETAILS is None:
+ expected = getattr(self, 'CAP_PORT_FILTER', None)
+ port_filter = vif_details[portbindings.CAP_PORT_FILTER]
+ self.assertEqual(expected, port_filter)
+ return
+ self.assertEqual(self.VIF_DETAILS, vif_details)
class AgentMechanismGenericTestCase(AgentMechanismBaseTestCase):
diff --git a/neutron/tests/unit/ml2/drivers/test_l2population.py b/neutron/tests/unit/ml2/drivers/test_l2population.py
index cfe76d3a57..85d8b37a73 100644
--- a/neutron/tests/unit/ml2/drivers/test_l2population.py
+++ b/neutron/tests/unit/ml2/drivers/test_l2population.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import contextlib
import mock
from neutron.common import constants
@@ -24,6 +25,7 @@ from neutron.extensions import providernet as pnet
from neutron import manager
from neutron.openstack.common import timeutils
from neutron.plugins.ml2 import config as config
+from neutron.plugins.ml2.drivers.l2pop import mech_driver as l2pop_mech_driver
from neutron.plugins.ml2 import managers
from neutron.plugins.ml2 import rpc
from neutron.tests.unit import test_db_plugin as test_plugin
@@ -794,3 +796,17 @@ class TestL2PopulationRpcTestCase(test_plugin.NeutronDbPluginV2TestCase):
self.mock_fanout.assert_called_with(
mock.ANY, expected, topic=self.fanout_topic)
+
+ def test_delete_port_invokes_update_device_down(self):
+ l2pop_mech = l2pop_mech_driver.L2populationMechanismDriver()
+ l2pop_mech.L2PopulationAgentNotify = mock.Mock()
+ l2pop_mech.rpc_ctx = mock.Mock()
+ with contextlib.nested(
+ mock.patch.object(l2pop_mech,
+ '_update_port_down',
+ return_value=None),
+ mock.patch.object(l2pop_mech.L2PopulationAgentNotify,
+ 'remove_fdb_entries')) as (upd_port_down,
+ rem_fdb_entries):
+ l2pop_mech.delete_port_postcommit(mock.Mock())
+ self.assertTrue(upd_port_down.called) \ No newline at end of file
diff --git a/neutron/tests/unit/ml2/drivers/test_ofagent_mech.py b/neutron/tests/unit/ml2/drivers/test_ofagent_mech.py
index 3187f296b4..8c62e1e79f 100644
--- a/neutron/tests/unit/ml2/drivers/test_ofagent_mech.py
+++ b/neutron/tests/unit/ml2/drivers/test_ofagent_mech.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
+
from neutron.common import constants
from neutron.extensions import portbindings
from neutron.plugins.ml2.drivers import mech_ofagent
@@ -21,7 +23,8 @@ from neutron.tests.unit.ml2 import _test_mech_agent as base
class OfagentMechanismBaseTestCase(base.AgentMechanismBaseTestCase):
VIF_TYPE = portbindings.VIF_TYPE_OVS
- CAP_PORT_FILTER = True
+ VIF_DETAILS = {portbindings.CAP_PORT_FILTER: True,
+ portbindings.OVS_HYBRID_PLUG: True}
AGENT_TYPE = constants.AGENT_TYPE_OFA
GOOD_MAPPINGS = {'fake_physical_network': 'fake_interface'}
@@ -49,6 +52,17 @@ class OfagentMechanismBaseTestCase(base.AgentMechanismBaseTestCase):
self.driver.initialize()
+class OfagentMechanismSGDisabledBaseTestCase(OfagentMechanismBaseTestCase):
+ VIF_DETAILS = {portbindings.CAP_PORT_FILTER: False,
+ portbindings.OVS_HYBRID_PLUG: False}
+
+ def setUp(self):
+ cfg.CONF.set_override('enable_security_group',
+ False,
+ group='SECURITYGROUP')
+ super(OfagentMechanismSGDisabledBaseTestCase, self).setUp()
+
+
class OfagentMechanismGenericTestCase(OfagentMechanismBaseTestCase,
base.AgentMechanismGenericTestCase):
pass
@@ -74,12 +88,19 @@ class OfagentMechanismGreTestCase(OfagentMechanismBaseTestCase,
pass
+class OfagentMechanismSGDisabledLocalTestCase(
+ OfagentMechanismSGDisabledBaseTestCase,
+ base.AgentMechanismLocalTestCase):
+ pass
+
+
# The following tests are for deprecated "bridge_mappings".
# TODO(yamamoto): Remove them.
class OfagentMechanismPhysBridgeTestCase(base.AgentMechanismBaseTestCase):
VIF_TYPE = portbindings.VIF_TYPE_OVS
- CAP_PORT_FILTER = True
+ VIF_DETAILS = {portbindings.CAP_PORT_FILTER: True,
+ portbindings.OVS_HYBRID_PLUG: True}
AGENT_TYPE = constants.AGENT_TYPE_OFA
GOOD_MAPPINGS = {'fake_physical_network': 'fake_bridge'}
diff --git a/neutron/tests/unit/ml2/test_mech_openvswitch.py b/neutron/tests/unit/ml2/test_mech_openvswitch.py
index b1af1b7fae..456d6f02cc 100644
--- a/neutron/tests/unit/ml2/test_mech_openvswitch.py
+++ b/neutron/tests/unit/ml2/test_mech_openvswitch.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.config import cfg
+
from neutron.common import constants
from neutron.extensions import portbindings
from neutron.plugins.ml2.drivers import mech_openvswitch
@@ -21,7 +23,8 @@ from neutron.tests.unit.ml2 import _test_mech_agent as base
class OpenvswitchMechanismBaseTestCase(base.AgentMechanismBaseTestCase):
VIF_TYPE = portbindings.VIF_TYPE_OVS
- CAP_PORT_FILTER = True
+ VIF_DETAILS = {portbindings.CAP_PORT_FILTER: True,
+ portbindings.OVS_HYBRID_PLUG: True}
AGENT_TYPE = constants.AGENT_TYPE_OVS
GOOD_MAPPINGS = {'fake_physical_network': 'fake_bridge'}
@@ -49,6 +52,18 @@ class OpenvswitchMechanismBaseTestCase(base.AgentMechanismBaseTestCase):
self.driver.initialize()
+class OpenvswitchMechanismSGDisabledBaseTestCase(
+ OpenvswitchMechanismBaseTestCase):
+ VIF_DETAILS = {portbindings.CAP_PORT_FILTER: False,
+ portbindings.OVS_HYBRID_PLUG: False}
+
+ def setUp(self):
+ cfg.CONF.set_override('enable_security_group',
+ False,
+ group='SECURITYGROUP')
+ super(OpenvswitchMechanismSGDisabledBaseTestCase, self).setUp()
+
+
class OpenvswitchMechanismGenericTestCase(OpenvswitchMechanismBaseTestCase,
base.AgentMechanismGenericTestCase):
pass
@@ -72,3 +87,9 @@ class OpenvswitchMechanismVlanTestCase(OpenvswitchMechanismBaseTestCase,
class OpenvswitchMechanismGreTestCase(OpenvswitchMechanismBaseTestCase,
base.AgentMechanismGreTestCase):
pass
+
+
+class OpenvswitchMechanismSGDisabledLocalTestCase(
+ OpenvswitchMechanismSGDisabledBaseTestCase,
+ base.AgentMechanismLocalTestCase):
+ pass