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:
parent
09b500e184
commit
7bc8518476
@ -1635,6 +1635,38 @@ class TestPortsV2(NsxVPluginV2TestCase,
|
|||||||
self.assertEqual('direct',
|
self.assertEqual('direct',
|
||||||
res['port']['binding:vnic_type'])
|
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,
|
class TestSubnetsV2(NsxVPluginV2TestCase,
|
||||||
test_plugin.TestSubnetsV2):
|
test_plugin.TestSubnetsV2):
|
||||||
|
@ -151,7 +151,6 @@ class TestQosNsxVNotification(test_plugin.NsxVPluginV2TestCase,
|
|||||||
self.ctxt, **self.policy_data['policy'])
|
self.ctxt, **self.policy_data['policy'])
|
||||||
|
|
||||||
# set the rule in the policy data
|
# 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.'
|
with mock.patch('neutron.services.qos.qos_plugin.QoSPlugin.'
|
||||||
@ -218,7 +217,6 @@ class TestQosNsxVNotification(test_plugin.NsxVPluginV2TestCase,
|
|||||||
self.ctxt, **self.policy_data['policy'])
|
self.ctxt, **self.policy_data['policy'])
|
||||||
|
|
||||||
# set the rule in the policy data
|
# 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
|
plugin = self.qos_plugin
|
||||||
with mock.patch('neutron.services.qos.qos_plugin.QoSPlugin.'
|
with mock.patch('neutron.services.qos.qos_plugin.QoSPlugin.'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user