Enable passive deletes on trunk deletion
Add missing sqlalchemy cascade="all, delete-orphan" on the
trunk-subports relationship to disable child object loading
on a trunk delete operation, otherwise sqlalchemy would
attempt to update the children with a NULL key, and cause
an integrity violation.
Deleting a trunk with subports is allowed, and a test is
added to cover that.
Partially-implements: blueprint vlan-aware-vms
Change-Id: I143c436ce6d2d3a441c26a4b08730981f1ec2973
diff --git a/neutron/tests/tempest/api/test_trunk.py b/neutron/tests/tempest/api/test_trunk.py
index 05e1430..c22c334 100644
--- a/neutron/tests/tempest/api/test_trunk.py
+++ b/neutron/tests/tempest/api/test_trunk.py
@@ -21,6 +21,9 @@
def trunks_cleanup(client, trunks):
for trunk in trunks:
+ # NOTE(armax): deleting a trunk with subports is permitted, however
+ # for testing purposes it is safer to be explicit and clean all the
+ # resources associated with the trunk beforehand.
subports = test_utils.call_and_ignore_notfound_exc(
client.get_subports, trunk['id'])
if subports:
@@ -129,6 +132,16 @@
created_subport = observed_subports[0]
self.assertEqual(subports[0], created_subport)
+ @test.idempotent_id('ee5fcead-1abf-483a-bce6-43d1e06d6aa0')
+ def test_delete_trunk_with_subport_is_allowed(self):
+ network = self.create_network()
+ port = self.create_port(network)
+ subports = [{'port_id': port['id'],
+ 'segmentation_type': 'vlan',
+ 'segmentation_id': 2}]
+ trunk = self._create_trunk_with_network_and_parent(subports)
+ self.client.delete_trunk(trunk['trunk']['id'])
+
@test.idempotent_id('96eea398-a03c-4c3e-a99e-864392c2ca53')
def test_remove_subport(self):
subport_parent1 = self.create_port(self.create_network())