NSX|V: Fix broken unit tests

Commit I54ebf2be14e82f288a9bf177967f1136b72b289e added a unit test
that should be modified a little to match the plugin code.

In addition, commit Ib748947bcd85253aa22e370a56870afbfbafa19b
broke some QoS unit tests.

Change-Id: Iab0202a28bfa525c4cd91e776ac2bdba56a807f6
This commit is contained in:
Adit Sarfaty 2017-05-17 10:14:10 +03:00
parent 09b500e184
commit 7bc8518476
2 changed files with 34 additions and 4 deletions

View File

@ -1635,6 +1635,38 @@ class TestPortsV2(NsxVPluginV2TestCase,
self.assertEqual('direct',
res['port']['binding:vnic_type'])
def test_delete_network_port_exists_owned_by_network_port_not_found(self):
"""Tests that we continue to gracefully delete the network even if
a neutron:dhcp-owned port was deleted concurrently.
"""
res = self._create_network(fmt=self.fmt, name='net',
admin_state_up=True)
network = self.deserialize(self.fmt, res)
network_id = network['network']['id']
self._create_port(self.fmt, network_id,
device_owner=constants.DEVICE_OWNER_DHCP)
# Raise PortNotFound when trying to delete the port to simulate a
# concurrent delete race; note that we actually have to delete the port
# "out of band" otherwise deleting the network will fail because of
# constraints in the data model.
plugin = directory.get_plugin()
orig_delete = plugin.delete_port
def fake_delete_port(context, id, force_delete_dhcp=False):
# Delete the port for real from the database and then raise
# PortNotFound to simulate the race.
self.assertIsNone(orig_delete(
context, id,
force_delete_dhcp=force_delete_dhcp))
raise n_exc.PortNotFound(port_id=id)
p = mock.patch.object(plugin, 'delete_port')
mock_del_port = p.start()
mock_del_port.side_effect = fake_delete_port
req = self.new_delete_request('networks', network_id)
res = req.get_response(self.api)
self.assertEqual(webob.exc.HTTPNoContent.code, res.status_int)
class TestSubnetsV2(NsxVPluginV2TestCase,
test_plugin.TestSubnetsV2):

View File

@ -151,8 +151,7 @@ class TestQosNsxVNotification(test_plugin.NsxVPluginV2TestCase,
self.ctxt, **self.policy_data['policy'])
# set the rule in the policy data
if action != 'create':
setattr(_policy, "rules", [self.rule])
setattr(_policy, "rules", [self.rule])
with mock.patch('neutron.services.qos.qos_plugin.QoSPlugin.'
'get_policy',
@ -218,8 +217,7 @@ class TestQosNsxVNotification(test_plugin.NsxVPluginV2TestCase,
self.ctxt, **self.policy_data['policy'])
# set the rule in the policy data
if action != 'create':
setattr(_policy, "rules", [self.dscp_rule])
setattr(_policy, "rules", [self.dscp_rule])
plugin = self.qos_plugin
with mock.patch('neutron.services.qos.qos_plugin.QoSPlugin.'
'get_policy',