Add cleanup to test_verify_multiple_nics_order
This test doesn't cleanup the networks and subnets that it created. Following
Tempest tests in non-isolated environments are consequently failing because
multiple networks are found. This change deleted those networks and subnets.
Related-Bug: #1329065
Change-Id: Id618aeeb85e3d4767ed07b4d29b908274eba76df
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index 25dc87d..bc452aa 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -132,17 +132,27 @@
# preserved within the server.
name_net1 = data_utils.rand_name(self.__class__.__name__)
_, net1 = self.network_client.create_network(name=name_net1)
+ self.addCleanup(self.network_client.delete_network,
+ net1['network']['id'])
+
name_net2 = data_utils.rand_name(self.__class__.__name__)
_, net2 = self.network_client.create_network(name=name_net2)
+ self.addCleanup(self.network_client.delete_network,
+ net2['network']['id'])
_, subnet1 = self.network_client.create_subnet(
network_id=net1['network']['id'],
cidr='19.80.0.0/24',
ip_version=4)
+ self.addCleanup(self.network_client.delete_subnet,
+ subnet1['subnet']['id'])
+
_, subnet2 = self.network_client.create_subnet(
network_id=net2['network']['id'],
cidr='19.86.0.0/24',
ip_version=4)
+ self.addCleanup(self.network_client.delete_subnet,
+ subnet2['subnet']['id'])
networks = [{'uuid': net1['network']['id']},
{'uuid': net2['network']['id']}]
@@ -150,6 +160,18 @@
_, server_multi_nics = self.create_test_server(
networks=networks, wait_until='ACTIVE')
+ # Cleanup server; this is needed in the test case because with the LIFO
+ # nature of the cleanups, if we don't delete the server first, the port
+ # will still be part of the subnet and we'll get a 409 from Neutron
+ # when trying to delete the subnet. The tear down in the base class
+ # will try to delete the server and get a 404 but it's ignored so
+ # we're OK.
+ def cleanup_server():
+ self.client.delete_server(server_multi_nics['id'])
+ self.client.wait_for_server_termination(server_multi_nics['id'])
+
+ self.addCleanup(cleanup_server)
+
_, addresses = self.client.list_addresses(server_multi_nics['id'])
expected_addr = ['19.80.0.2', '19.86.0.2']