~ubuntu-branches/ubuntu/saucy/neutron/saucy-proposed

« back to all changes in this revision

Viewing changes to neutron/tests/unit/test_dhcp_agent.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2014-02-25 09:32:04 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20140225093204-clm31i33q8jfzkbe
Tags: 1:2013.2.2-0ubuntu1
* Resynchronize with stable/havana (3c9fc6f) (LP: #1284643):
  - [3f4c282] reduce severity of network notfound trace when looked up by
    dhcp agent LP: 1251874
  - [7a4842d] Mellanox Neutron Agent is using keystone port LP: 1245885
  - [aa2502b] check_nvp_config.py erroneous config complaint LP: 1265353
  - [94679f1] uncaught portnotfound exception on get_dhcp_port LP: 1252437
  - [5bbc2f0] devstack-exercises floating_ips broken LP: 1262785
  - [3738343] [neutron bandwidth metering] When I delete a label, router's
    tenant_id disappeared. LP: 1249188
  - [e631e89] dhcp dnsmasq lost port in host config file LP: 1192381
  - [5f959d7] tenant does not see network that is routable from tenant-
    visible network until neutron-server is restarted LP: 1254555
  - [c7596bf] Remove and recreate interfacein ovs  if already exists
    LP: 1268762
  - [711106a] Multiple  Neutron operations  using a script fails on Brocade
    Plugin LP: 1223754
  - [927e8a6] Should RPC consume_in_thread() be more fault tolerant?
    LP: 1189711
  - [15a912b] neutron-metadata-agent incorrectly passes keystone token to
    neutronclient LP: 1274487
  - [4265436] Have tox install via setup.py develop
  - [a72ab24] nicira: error occurs when net-gateway-connect with different
    segmentation-type LP: 1270724
  - [3c9fc6f] improve version validation for router operations with the
    nsx/nvp plugin LP: 1274361

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
from neutron.agent.linux import interface
33
33
from neutron.common import constants as const
34
34
from neutron.common import exceptions
 
35
from neutron.openstack.common.rpc import common
35
36
from neutron.tests import base
36
37
 
37
38
 
210
211
                                            mock.ANY,
211
212
                                            mock.ANY)
212
213
 
213
 
    def test_call_driver_failure(self):
 
214
    def _test_call_driver_failure(self, exc=None, trace_level='exception'):
214
215
        network = mock.Mock()
215
216
        network.id = '1'
216
 
        self.driver.return_value.foo.side_effect = Exception
217
 
        with mock.patch.object(dhcp_agent.LOG, 'exception') as log:
 
217
        self.driver.return_value.foo.side_effect = exc or Exception
 
218
        with mock.patch.object(dhcp_agent.LOG, trace_level) as log:
218
219
            dhcp = dhcp_agent.DhcpAgent(HOSTNAME)
219
220
            self.assertIsNone(dhcp.call_driver('foo', network))
220
221
            self.driver.assert_called_once_with(cfg.CONF,
225
226
            self.assertEqual(log.call_count, 1)
226
227
            self.assertTrue(dhcp.needs_resync)
227
228
 
 
229
    def test_call_driver_failure(self):
 
230
        self._test_call_driver_failure()
 
231
 
 
232
    def test_call_driver_remote_error_net_not_found(self):
 
233
        self._test_call_driver_failure(
 
234
            exc=common.RemoteError(exc_type='NetworkNotFound'),
 
235
            trace_level='warning')
 
236
 
 
237
    def test_call_driver_network_not_found(self):
 
238
        self._test_call_driver_failure(
 
239
            exc=exceptions.NetworkNotFound(net_id='1'),
 
240
            trace_level='warning')
 
241
 
228
242
    def _test_sync_state_helper(self, known_networks, active_networks):
229
243
        with mock.patch(DHCP_PLUGIN) as plug:
230
244
            mock_plugin = mock.Mock()
477
491
        self.assertFalse(self.cache.called)
478
492
        self.assertFalse(self.external_process.called)
479
493
 
 
494
    def test_enable_dhcp_helper_network_none(self):
 
495
        self.plugin.get_network_info.return_value = None
 
496
        with mock.patch.object(dhcp_agent.LOG, 'warn') as log:
 
497
            self.dhcp.enable_dhcp_helper('fake_id')
 
498
            self.plugin.assert_has_calls(
 
499
                [mock.call.get_network_info('fake_id')])
 
500
            self.assertFalse(self.call_driver.called)
 
501
            self.assertTrue(log.called)
 
502
            self.assertFalse(self.dhcp.needs_resync)
 
503
 
480
504
    def test_enable_dhcp_helper_exception_during_rpc(self):
481
505
        self.plugin.get_network_info.side_effect = Exception
482
506
        with mock.patch.object(dhcp_agent.LOG, 'exception') as log: