Fix auto allocate network cleanup
AutoAllocateNetworkTest.resource_cleanup was trying to delete all
networks instead of only networks in its tenant. This leads to
failures if there happens to be another network (created by
something else) in a different tenant, since the context used is
non-admin and therefore lacks policy permission to delete things
in other tenants. The cleanup is herein changed to only cleanup
networks in the relevant tenant.
Change-Id: Ibc00ca976472cac46bf611f626d315d7e644f650
Closes-Bug: #1698382
diff --git a/tempest/api/compute/admin/test_auto_allocate_network.py b/tempest/api/compute/admin/test_auto_allocate_network.py
index ba8a214..83fe215 100644
--- a/tempest/api/compute/admin/test_auto_allocate_network.py
+++ b/tempest/api/compute/admin/test_auto_allocate_network.py
@@ -111,10 +111,12 @@
LOG.info('(%s) Found more than one router for tenant.',
test_utils.find_test_caller())
- # Let's just blindly remove any networks, duplicate or otherwise, that
- # the test might have created even though Neutron will cleanup
- # duplicate resources automatically (so ignore 404s).
- networks = cls.networks_client.list_networks().get('networks', [])
+ # Remove any networks, duplicate or otherwise, that these tests
+ # created. All such networks will be in the current tenant. Neutron
+ # will cleanup duplicate resources automatically, so ignore 404s.
+ search_opts = {'tenant_id': cls.networks_client.tenant_id}
+ networks = cls.networks_client.list_networks(
+ **search_opts).get('networks', [])
for router in routers:
# Disassociate the subnets from the router. Because of the race