~corey.bryant/ubuntu/trusty/neutron/lp1318721

« back to all changes in this revision

Viewing changes to neutron/tests/unit/vmware/test_nsx_plugin.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Corey Bryant
  • Date: 2014-10-06 09:15:06 UTC
  • mfrom: (28.1.4 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20141006091506-cesvev43moce4y74
Tags: 1:2014.1.3-0ubuntu1
[ Corey Bryant ]
* Resynchronize with stable/icehouse (4a0210e) (LP: #1377136):
  - [3a30d19] Deletes floating ip related connection states
  - [dd4b77f] Forbid regular users to reset admin-only attrs to default values
  - [dc2c893] Add delete operations for the ODL MechanismDriver
  - [b51e2c7] Add missing ml2 plugin to migration 1fcfc149aca4
  - [a17a500] Don't convert numeric protocol values to int
  - [3a85946] NSX: Optionally not enforce nat rule match length check
  - [645f984] Don't spawn metadata-proxy for non-isolated nets
  - [b464d89] Big Switch: Check for 'id' in port before lookup
  - [3116ffa] use TRUE in SQL for boolean var
  - [3520e66] call security_groups_member_updated in port_update
  - [50e1534] Don't allow user to set firewall rule with port and no protocol
  - [0061533] BSN: Add context to backend request for debugging
  - [6de6d61] Improve ODL ML2 Exception Handling
  - [2a4153d] Send network name and uuid to subnet create
  - [b5e3c9a] BSN: Allow concurrent reads to consistency DB
  - [b201432] Big Switch: Retry on 503 errors from backend
  - [f6c47ee] NSX: log request body to NSX as debug
  - [97d622a] Fix metadata agent's auth info caching
  - [255df45] NSX: Correct allowed_address_pair return value on create_port
  - [5bea041] Neutron should not use the neutronclient utils module for import_class
  - [d5314e2] Cisco N1kv plugin to send subtype on network profile creation
  - [f32d1ce] Pass object to policy when finding fields to strip
  - [8b5f6be] Call policy.init() once per API request
  - [9a6d811] Perform policy checks only once on list responses
  - [c48db90] Datacenter moid should not be tuple
  - [161d465] Allow unsharing a network used as gateway/floatingip
  - [9574a2f] Add support for router scheduling in Cisco N1kv Plugin
  - [6f54565] Fix func job hook script permission problems
  - [ea43103] Add hook scripts for the functional infra job
  - [8161cb7] Fixes Hyper-V agent issue on Hyper-V 2008 R2
  - [8e99cfd] Fixes Hyper-V issue due to ML2 RPC versioning
  - [69f9121] Ensure ip6tables are used only if ipv6 is enabled in kernel
  - [399b809] Remove explicit dependency on amqplib
  - [a872143] Clear entries in Cisco N1KV specific tables on rollback
  - [ad82fad] Verify ML2 type driver exists before calling del
  - [af2cc98] Big Switch: Only update hash header on success
  - [b1e5eec] Ignore variable column widths in ovsdb functional tests
  - [4a0210e] VMWare: don't notify on disassociate_floatingips()

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# limitations under the License.
15
15
 
16
16
import contextlib
 
17
import uuid
17
18
 
18
19
import mock
19
20
import netaddr
943
944
        with self.port() as p:
944
945
            private_sub = {'subnet': {'id':
945
946
                                      p['port']['fixed_ips'][0]['subnet_id']}}
946
 
            with self.floatingip_no_assoc(private_sub) as fip:
947
 
                port_id = p['port']['id']
948
 
                body = self._update('floatingips', fip['floatingip']['id'],
949
 
                                    {'floatingip': {'port_id': port_id}})
950
 
                self.assertEqual(body['floatingip']['port_id'], port_id)
951
 
                # Disassociate
952
 
                body = self._update('floatingips', fip['floatingip']['id'],
953
 
                                    {'floatingip': {'port_id': None}})
954
 
                body = self._show('floatingips', fip['floatingip']['id'])
955
 
                self.assertIsNone(body['floatingip']['port_id'])
956
 
                self.assertIsNone(body['floatingip']['fixed_ip_address'])
 
947
            plugin = manager.NeutronManager.get_plugin()
 
948
            with mock.patch.object(plugin, 'notify_routers_updated') as notify:
 
949
                with self.floatingip_no_assoc(private_sub) as fip:
 
950
                    port_id = p['port']['id']
 
951
                    body = self._update('floatingips', fip['floatingip']['id'],
 
952
                                        {'floatingip': {'port_id': port_id}})
 
953
                    self.assertEqual(body['floatingip']['port_id'], port_id)
 
954
                    # Disassociate
 
955
                    body = self._update('floatingips', fip['floatingip']['id'],
 
956
                                        {'floatingip': {'port_id': None}})
 
957
                    body = self._show('floatingips', fip['floatingip']['id'])
 
958
                    self.assertIsNone(body['floatingip']['port_id'])
 
959
                    self.assertIsNone(body['floatingip']['fixed_ip_address'])
 
960
 
 
961
                # check that notification was not requested
 
962
                self.assertFalse(notify.called)
957
963
 
958
964
    def test_create_router_maintenance_returns_503(self):
959
965
        with self._create_l3_ext_network() as net:
1145
1151
        res = req.get_response(self.ext_api)
1146
1152
        self.assertEqual(res.status_int, 200)
1147
1153
 
 
1154
    def _test_remove_router_interface_nsx_out_of_sync(self, unsync_action):
 
1155
        # Create external network and subnet
 
1156
        ext_net_id = self._create_network_and_subnet('1.1.1.0/24', True)[0]
 
1157
        # Create internal network and subnet
 
1158
        int_sub_id = self._create_network_and_subnet('10.0.0.0/24')[1]
 
1159
        res = self._create_router('json', 'tenant')
 
1160
        router = self.deserialize('json', res)
 
1161
        # Set gateway and add interface to router (needed to generate NAT rule)
 
1162
        req = self.new_update_request(
 
1163
            'routers',
 
1164
            {'router': {'external_gateway_info':
 
1165
                        {'network_id': ext_net_id}}},
 
1166
            router['router']['id'])
 
1167
        res = req.get_response(self.ext_api)
 
1168
        self.assertEqual(res.status_int, 200)
 
1169
        req = self.new_action_request(
 
1170
            'routers',
 
1171
            {'subnet_id': int_sub_id},
 
1172
            router['router']['id'],
 
1173
            "add_router_interface")
 
1174
        res = req.get_response(self.ext_api)
 
1175
        self.assertEqual(res.status_int, 200)
 
1176
        unsync_action()
 
1177
        req = self.new_action_request(
 
1178
            'routers',
 
1179
            {'subnet_id': int_sub_id},
 
1180
            router['router']['id'],
 
1181
            "remove_router_interface")
 
1182
        res = req.get_response(self.ext_api)
 
1183
        self.assertEqual(res.status_int, 200)
 
1184
 
1148
1185
    def test_remove_router_interface_not_in_nsx(self):
1149
 
        # Create internal network and subnet
1150
 
        int_sub_id = self._create_network_and_subnet('10.0.0.0/24')[1]
1151
 
        res = self._create_router('json', 'tenant')
1152
 
        router = self.deserialize('json', res)
1153
 
        # Add interface to router (needed to generate NAT rule)
1154
 
        req = self.new_action_request(
1155
 
            'routers',
1156
 
            {'subnet_id': int_sub_id},
1157
 
            router['router']['id'],
1158
 
            "add_router_interface")
1159
 
        res = req.get_response(self.ext_api)
1160
 
        self.assertEqual(res.status_int, 200)
1161
 
        self.fc._fake_lrouter_dict.clear()
1162
 
        req = self.new_action_request(
1163
 
            'routers',
1164
 
            {'subnet_id': int_sub_id},
1165
 
            router['router']['id'],
1166
 
            "remove_router_interface")
1167
 
        res = req.get_response(self.ext_api)
1168
 
        self.assertEqual(res.status_int, 200)
 
1186
 
 
1187
        def unsync_action():
 
1188
            self.fc._fake_lrouter_dict.clear()
 
1189
            self.fc._fake_lrouter_nat_dict.clear()
 
1190
 
 
1191
        self._test_remove_router_interface_nsx_out_of_sync(unsync_action)
 
1192
 
 
1193
    def test_remove_router_interface_nat_rule_not_in_nsx(self):
 
1194
        self._test_remove_router_interface_nsx_out_of_sync(
 
1195
            self.fc._fake_lrouter_nat_dict.clear)
 
1196
 
 
1197
    def test_remove_router_interface_duplicate_nat_rules_in_nsx(self):
 
1198
 
 
1199
        def unsync_action():
 
1200
            # duplicate every entry in the nat rule dict
 
1201
            for (_rule_id, rule) in self.fc._fake_lrouter_nat_dict.items():
 
1202
                self.fc._fake_lrouter_nat_dict[uuid.uuid4()] = rule
 
1203
 
 
1204
        self._test_remove_router_interface_nsx_out_of_sync(unsync_action)
1169
1205
 
1170
1206
    def test_update_router_not_in_nsx(self):
1171
1207
        res = self._create_router('json', 'tenant')