Clean up existing instances when not using tenant isolation
The test_list_servers_negative tests require that there are no existing instances in the database when they run and will fail if any are found under the primary/alternate user/tenant. When running tempest with allow_tenant_isolation=false on a slower system, there is a race where instances from previous tests are still cleaning up in the background and cause test_list_servers_negative to fail in setup. This patch makes test_list_servers_negative block while the deleted instances are being cleaned up in the background if running without tenant isolation. Closes-Bug: #1234370 Change-Id: I8519cba1fcf6ff39d69839783d07359544509db5
This commit is contained in:
@@ -27,6 +27,26 @@ from tempest.test import attr
|
|||||||
class ListServersNegativeTestJSON(base.BaseComputeTest):
|
class ListServersNegativeTestJSON(base.BaseComputeTest):
|
||||||
_interface = 'json'
|
_interface = 'json'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _ensure_no_servers(cls, servers, username, tenant_name):
|
||||||
|
"""
|
||||||
|
If there are servers and there is tenant isolation then a
|
||||||
|
skipException is raised to skip the test since it requires no servers
|
||||||
|
to already exist for the given user/tenant.
|
||||||
|
If there are servers and there is not tenant isolation then the test
|
||||||
|
blocks while the servers are being deleted.
|
||||||
|
"""
|
||||||
|
if len(servers):
|
||||||
|
if not compute.MULTI_USER:
|
||||||
|
for srv in servers:
|
||||||
|
cls.client.wait_for_server_termination(srv['id'],
|
||||||
|
ignore_error=True)
|
||||||
|
else:
|
||||||
|
msg = ("User/tenant %(u)s/%(t)s already have "
|
||||||
|
"existing server instances. Skipping test." %
|
||||||
|
{'u': username, 't': tenant_name})
|
||||||
|
raise cls.skipException(msg)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(ListServersNegativeTestJSON, cls).setUpClass()
|
super(ListServersNegativeTestJSON, cls).setUpClass()
|
||||||
@@ -54,26 +74,14 @@ class ListServersNegativeTestJSON(base.BaseComputeTest):
|
|||||||
# start of the test instead of destroying any existing
|
# start of the test instead of destroying any existing
|
||||||
# servers.
|
# servers.
|
||||||
resp, body = cls.client.list_servers()
|
resp, body = cls.client.list_servers()
|
||||||
servers = body['servers']
|
cls._ensure_no_servers(body['servers'],
|
||||||
num_servers = len(servers)
|
cls.os.username,
|
||||||
if num_servers > 0:
|
cls.os.tenant_name)
|
||||||
username = cls.os.username
|
|
||||||
tenant_name = cls.os.tenant_name
|
|
||||||
msg = ("User/tenant %(u)s/%(t)s already have "
|
|
||||||
"existing server instances. Skipping test." %
|
|
||||||
{'u': username, 't': tenant_name})
|
|
||||||
raise cls.skipException(msg)
|
|
||||||
|
|
||||||
resp, body = cls.alt_client.list_servers()
|
resp, body = cls.alt_client.list_servers()
|
||||||
servers = body['servers']
|
cls._ensure_no_servers(body['servers'],
|
||||||
num_servers = len(servers)
|
cls.alt_manager.username,
|
||||||
if num_servers > 0:
|
cls.alt_manager.tenant_name)
|
||||||
username = cls.alt_manager.username
|
|
||||||
tenant_name = cls.alt_manager.tenant_name
|
|
||||||
msg = ("Alt User/tenant %(u)s/%(t)s already have "
|
|
||||||
"existing server instances. Skipping test." %
|
|
||||||
{'u': username, 't': tenant_name})
|
|
||||||
raise cls.skipException(msg)
|
|
||||||
|
|
||||||
# The following servers are created for use
|
# The following servers are created for use
|
||||||
# by the test methods in this class. These
|
# by the test methods in this class. These
|
||||||
|
|||||||
Reference in New Issue
Block a user