~ubuntu-branches/ubuntu/vivid/neutron/vivid-proposed

« back to all changes in this revision

Viewing changes to neutron/tests/unit/scheduler/test_l3_agent_scheduler.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Corey Byrant
  • Date: 2015-10-15 08:56:04 UTC
  • mfrom: (1.1.25)
  • Revision ID: package-import@ubuntu.com-20151015085604-zmf42dhshxz2qjad
Tags: 1:2015.1.2-0ubuntu1
[ Chuck Short ]
* Resynchronize with stable/kilo (7dbaa12) (LP: #1506058):
  - [7dbaa12] Changed filter field to router_id
  - [6c55f58] Do not log an error when deleting a linuxbridge does not exist
  - [118a76f] metadata: don't crash proxy on non-unicode user data
  - [eec8c50] Only get host data for floating ips on DVR routers
  - [9950ce2] Update dhcp host portbinding on failover
  - [1c87d72] func: Don't use private method of AsyncProcess
  - [834279c] Allow setting Agents description to None
  - [2f85b22] Process user iptables rules before INVALID
  - [f232475] Execute ipset command using check_exit_code
  - [d78899d] Don't write DHCP opts for SLAAC entries
  - [cb0554f] Check idl.run() return value before blocking
  - [2224851] Stop sending gratuitous arp when ip version is 6
  - [96276d5] Fix _ensure_default_security_group logic
  - [66a5116] Remove hack for sending gratuitous arp from fip ns
  - [2394418] populate port security default into network
  - [fc1c812] Remove early yields in _iter_hosts in dhcp agent
  - [2ead51a] Enable servicing lbaasV2 vip by DVR
  - [9498ea2] Descheduling DVR routers when ports are unbound from VM
  - [c74b05e] Bug-Fix for unexpected DHCP agent redundant
  - [e6a0e7d] Switch to dictionary for iptables find
  - [c377330] Add configurable options for HA networks
  - [114949b] Fix ipset can't be destroyed when last rule is deleted
  - [aba5e82] Updated NSXv plugin parameter descriptions
  - [d1a48f7] ovs: don't use ARP responder for IPv6 addresses
  - [4d15b6f] Configure gw_iface for RAs only in Master HA Router
  - [6975b2b] Register extraroute extension
  - [19d5ba4] Broadcast service port's arp in DVR
  - [767cea2] Stop device_owner from being set to 'network:*'
  - [2a6b34e] Fix a wrong condition for the _purge_metering_info function
  - [bf28c72] Add ARP spoofing protection for LinuxBridge agent
  - [635d5cf] Correct neutron-ns-metadata-proxy command when watch_log is
              False
  - [cc791b0] Fix usage of netaddr '.broadcast'
  - [f57a90a] Switch to using os-testr's copy of subunit2html
  - [c1201a2] Add optional file permission argument to replace_file()
  - [533900c] Adding loadbalanacerv2 device owner constant to neutron
              constants
  - [2a00016] Don't fatal error during initialization for missing service
              providers
  - [7c2727c] Update port bindings for master router
  - [6298a90] Setup reference service providers for API test runs
  - [6167d44] Move away nested transaction from _ensure_default_security_group
  - [c129bfa] Reject router-interface-add with a port which doesn't have any
              addresses
  - [770a105] SR-IOV: Fix SR-IOV agent to run ip link commands as root
  - [a0632d7] Catch ObjectDeletedError and skip port or subnet removal
  - [c4c8686] Cleanup stale metadata processes on l3 agent sync
  - [0c22d15] Bump stable/kilo next version to 2015.1.2
  - [4f9409d] lb-agent: ensure tap mtu is the same as physical device
  - [5d38dc5] Adds garp_master_repeat and garp_master_refresh to
              keepalived.conf
  - [e759c1c] Lower log level of errors caused by user requests to INFO
  - [1a1cc3d] Fix race condition by using lock on enable_radvd
  - [5827664] Remove bridge cleanup call
  - [23f5134] Added networking-plumgrid in plugin requirements

[ Corey Byrant ]
* d/rules: Prevent dh_python2 from guessing dependencies.

Show diffs side-by-side

added added

removed removed

Lines of Context:
950
950
        self.adminContext = q_context.get_admin_context()
951
951
        self.dut = L3DvrScheduler()
952
952
 
 
953
    def test__notify_l3_agent_update_port_no_removing_routers(self):
 
954
        port_id = 'fake-port'
 
955
        kwargs = {
 
956
            'context': self.adminContext,
 
957
            'port': None,
 
958
            'original_port': {
 
959
                'id': port_id,
 
960
                'binding:host_id': 'vm-host',
 
961
                'device_id': 'vm-id',
 
962
                'device_owner': 'compute:None',
 
963
                'mac_address': '02:04:05:17:18:19'
 
964
            },
 
965
            'mac_address_updated': True
 
966
        }
 
967
 
 
968
        plugin = manager.NeutronManager.get_plugin()
 
969
        l3plugin = mock.Mock()
 
970
        l3plugin.supported_extension_aliases = [
 
971
            'router', constants.L3_AGENT_SCHEDULER_EXT_ALIAS,
 
972
            constants.L3_DISTRIBUTED_EXT_ALIAS
 
973
        ]
 
974
 
 
975
        with mock.patch.object(manager.NeutronManager,
 
976
                               'get_service_plugins',
 
977
                               return_value={'L3_ROUTER_NAT': l3plugin}):
 
978
            l3_dvrscheduler_db._notify_l3_agent_port_update(
 
979
                'port', 'after_update', plugin, **kwargs)
 
980
 
 
981
            self.assertFalse(l3plugin.dvr_vmarp_table_update.called)
 
982
            self.assertFalse(l3plugin.dvr_update_router_addvm.called)
 
983
            self.assertFalse(l3plugin.remove_router_from_l3_agent.called)
 
984
            self.assertFalse(l3plugin.dvr_deletens_if_no_port.called)
 
985
 
 
986
    def test__notify_l3_agent_update_port_removing_routers(self):
 
987
        port_id = 'fake-port'
 
988
        kwargs = {
 
989
            'context': self.adminContext,
 
990
            'port': {
 
991
                'id': port_id,
 
992
                'binding:host_id': None,
 
993
                'device_id': '',
 
994
                'device_owner': ''
 
995
            },
 
996
            'mac_address_updated': False,
 
997
            'original_port': {
 
998
                'id': port_id,
 
999
                'binding:host_id': 'vm-host',
 
1000
                'device_id': 'vm-id',
 
1001
                'device_owner': 'compute:None'
 
1002
            }
 
1003
        }
 
1004
 
 
1005
        plugin = manager.NeutronManager.get_plugin()
 
1006
        l3plugin = mock.Mock()
 
1007
        l3plugin.supported_extension_aliases = [
 
1008
            'router', constants.L3_AGENT_SCHEDULER_EXT_ALIAS,
 
1009
            constants.L3_DISTRIBUTED_EXT_ALIAS
 
1010
        ]
 
1011
        with mock.patch.object(manager.NeutronManager,
 
1012
                               'get_service_plugins',
 
1013
                               return_value={'L3_ROUTER_NAT': l3plugin}),\
 
1014
                mock.patch.object(l3plugin, 'dvr_deletens_if_no_port',
 
1015
                                  return_value=[{'agent_id': 'foo_agent',
 
1016
                                             'router_id': 'foo_id'}]):
 
1017
            l3_dvrscheduler_db._notify_l3_agent_port_update(
 
1018
                'port', 'after_update', plugin, **kwargs)
 
1019
 
 
1020
            self.assertEqual(1, l3plugin.dvr_vmarp_table_update.call_count)
 
1021
            l3plugin.dvr_vmarp_table_update.assert_called_once_with(
 
1022
                self.adminContext, mock.ANY, 'del')
 
1023
 
 
1024
            self.assertFalse(l3plugin.dvr_update_router_addvm.called)
 
1025
            l3plugin.remove_router_from_l3_agent.assert_called_once_with(
 
1026
                self.adminContext, 'foo_agent', 'foo_id')
 
1027
 
953
1028
    def test__notify_port_delete(self):
954
1029
        plugin = manager.NeutronManager.get_plugin()
955
1030
        l3plugin = mock.Mock()
1108
1183
                                                    'my-subnet-id')
1109
1184
            self.assertTrue(result)
1110
1185
 
1111
 
    def test_dvr_serviced_vip_port_exists_on_subnet(self):
 
1186
    def _test_dvr_serviced_vip_port_exists_on_subnet(self, device_owner):
1112
1187
        vip_port = {
1113
1188
                'id': 'lbaas-vip-port1',
1114
1189
                'device_id': 'vip-pool-id',
1115
1190
                'status': 'ACTIVE',
1116
1191
                'binding:host_id': 'thisHost',
1117
 
                'device_owner': constants.DEVICE_OWNER_LOADBALANCER,
 
1192
                'device_owner': device_owner,
1118
1193
                'fixed_ips': [
1119
1194
                    {
1120
1195
                        'subnet_id': 'my-subnet-id',
1124
1199
        }
1125
1200
        self._test_dvr_serviced_port_exists_on_subnet(port=vip_port)
1126
1201
 
 
1202
    def test_dvr_serviced_lbaas_vip_port_exists_on_subnet(self):
 
1203
        self._test_dvr_serviced_vip_port_exists_on_subnet(
 
1204
                        device_owner=constants.DEVICE_OWNER_LOADBALANCER)
 
1205
 
 
1206
    def test_dvr_serviced_lbaasv2_vip_port_exists_on_subnet(self):
 
1207
        self._test_dvr_serviced_vip_port_exists_on_subnet(
 
1208
                        device_owner=constants.DEVICE_OWNER_LOADBALANCERV2)
 
1209
 
1127
1210
    def _create_port(self, port_name, tenant_id, host, subnet_id, ip_address,
1128
1211
                     status='ACTIVE',
1129
1212
                     device_owner='compute:nova'):