neutron-lbaas/neutron/tests/unit/midonet/test_midonet_driver.py
Isaku Yamahata 9af846caf7 options: consolidate options definitions
Some config options(interface_driver, use_namespaces) are defined
multiple times in ad-hoc way.  It causes DuplicateOptError exception
when using those module at the same time.  Right now the exception is
avoided in ad-hoc way by each executable.  Those duplicated
definitions should be consolidated and treated in uniformed way.

This is the blocker for blueprint: l3-agent-consolidation

neutron.services.loadbalancer.drivers.haproxy.agent periodic_interval
conflicts with neutron.service one. Since there is no way to fix it
without changing existing behavior/default value, it is untouched for now.

Closes-bug: #1279769
Change-Id: Ifed79b7ee0033644854499416f8a2b22a20416fe
2014-02-24 13:25:11 +09:00

59 lines
2.1 KiB
Python

# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (C) 2012 Midokura Japan K.K.
# Copyright (C) 2013 Midokura PTE LTD
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# @author: Rossella Sblendido, Midokura Japan KK
import mock
import sys
sys.modules["midonetclient"] = mock.Mock()
from neutron.agent.common import config
from neutron.agent.linux import dhcp
from neutron.common import config as base_config
import neutron.plugins.midonet.agent.midonet_driver as driver
from neutron.tests import base
class FakeNetwork:
id = 'aaaabbbb-cccc-dddd-eeee-ffff00001111'
namespace = 'qdhcp-ns'
class TestDhcpNoOpDriver(base.BaseTestCase):
def setUp(self):
super(TestDhcpNoOpDriver, self).setUp()
self.conf = config.setup_conf()
config.register_interface_driver_opts_helper(self.conf)
self.conf.register_opts(base_config.core_opts)
self.conf.register_opts(dhcp.OPTS)
self.conf.enable_isolated_metadata = True
self.conf.use_namespaces = True
instance = mock.patch("neutron.agent.linux.dhcp.DeviceManager")
self.mock_mgr = instance.start()
self.addCleanup(instance.stop)
def test_disable_no_retain_port(self):
dhcp_driver = driver.DhcpNoOpDriver(self.conf, FakeNetwork())
dhcp_driver.disable(retain_port=False)
self.assertTrue(self.mock_mgr.return_value.destroy.called)
def test_disable_retain_port(self):
dhcp_driver = driver.DhcpNoOpDriver(self.conf, FakeNetwork())
dhcp_driver.disable(retain_port=True)
self.assertFalse(self.mock_mgr.return_value.destroy.called)