1 # Copyright (c) 2013 OpenStack Foundation
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
16 from oslo_config import cfg
18 from neutron.common import constants
19 from neutron.extensions import portbindings
20 from neutron.plugins.ml2.drivers.openvswitch.mech_driver \
21 import mech_openvswitch
22 from neutron.tests.unit.plugins.ml2 import _test_mech_agent as base
25 class OpenvswitchMechanismBaseTestCase(base.AgentMechanismBaseTestCase):
26 VIF_TYPE = portbindings.VIF_TYPE_OVS
27 VIF_DETAILS = {portbindings.CAP_PORT_FILTER: True,
28 portbindings.OVS_HYBRID_PLUG: True}
29 AGENT_TYPE = constants.AGENT_TYPE_OVS
31 GOOD_MAPPINGS = {'fake_physical_network': 'fake_bridge'}
32 GOOD_TUNNEL_TYPES = ['gre', 'vxlan']
33 GOOD_CONFIGS = {'bridge_mappings': GOOD_MAPPINGS,
34 'tunnel_types': GOOD_TUNNEL_TYPES}
36 BAD_MAPPINGS = {'wrong_physical_network': 'wrong_bridge'}
37 BAD_TUNNEL_TYPES = ['bad_tunnel_type']
38 BAD_CONFIGS = {'bridge_mappings': BAD_MAPPINGS,
39 'tunnel_types': BAD_TUNNEL_TYPES}
41 AGENTS = [{'alive': True,
42 'configurations': GOOD_CONFIGS,
44 AGENTS_DEAD = [{'alive': False,
45 'configurations': GOOD_CONFIGS,
47 AGENTS_BAD = [{'alive': False,
48 'configurations': GOOD_CONFIGS,
49 'host': 'bad_host_1'},
51 'configurations': BAD_CONFIGS,
52 'host': 'bad_host_2'}]
55 super(OpenvswitchMechanismBaseTestCase, self).setUp()
56 self.driver = mech_openvswitch.OpenvswitchMechanismDriver()
57 self.driver.initialize()
60 class OpenvswitchMechanismSGDisabledBaseTestCase(
61 OpenvswitchMechanismBaseTestCase):
62 VIF_DETAILS = {portbindings.CAP_PORT_FILTER: False,
63 portbindings.OVS_HYBRID_PLUG: False}
66 cfg.CONF.set_override('enable_security_group',
68 group='SECURITYGROUP')
69 super(OpenvswitchMechanismSGDisabledBaseTestCase, self).setUp()
72 class OpenvswitchMechanismGenericTestCase(OpenvswitchMechanismBaseTestCase,
73 base.AgentMechanismGenericTestCase):
77 class OpenvswitchMechanismLocalTestCase(OpenvswitchMechanismBaseTestCase,
78 base.AgentMechanismLocalTestCase):
82 class OpenvswitchMechanismFlatTestCase(OpenvswitchMechanismBaseTestCase,
83 base.AgentMechanismFlatTestCase):
87 class OpenvswitchMechanismVlanTestCase(OpenvswitchMechanismBaseTestCase,
88 base.AgentMechanismVlanTestCase):
92 class OpenvswitchMechanismGreTestCase(OpenvswitchMechanismBaseTestCase,
93 base.AgentMechanismGreTestCase):
97 class OpenvswitchMechanismSGDisabledLocalTestCase(
98 OpenvswitchMechanismSGDisabledBaseTestCase,
99 base.AgentMechanismLocalTestCase):