Prevent stale isolated tenants from blocking test runs
Especially while developing tests, it's easy to kill a test before
it has a chance to clean up the tenants it has created for isolation.
Since the database has a lot of consistency requirements, it's non-
trivial to go clean these up, and (for me) re-running stack.sh is
the quickest path to a running system again (which is annoying).
This patch adds a configuration option that can allow the tenant
creation to avoid the failure by re-using the existing tenant/user
already present. I think it's safe to have this enabled by default
since it only happens if tenant isolation is enabled.
Also, this augments the error message for the condition (in the case
that the configuration option is disabled) to better indicate
what is happening.
Change-Id: I97052b827ca1b2076ac67025539339b39d3260ae
diff --git a/tempest/config.py b/tempest/config.py
index 28a0c5e..003f03e 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -125,6 +125,17 @@
return self.get("allow_tenant_isolation", 'false').lower() != 'false'
@property
+ def allow_tenant_reuse(self):
+ """
+ If allow_tenant_isolation is True and a tenant that would be created
+ for a given test already exists (such as from a previously-failed run),
+ re-use that tenant instead of failing because of the conflict. Note
+ that this would result in the tenant being deleted at the end of a
+ subsequent successful run.
+ """
+ return self.get("allow_tenant_reuse", 'true').lower() != 'false'
+
+ @property
def username(self):
"""Username to use for Nova API requests."""
return self.get("username", "demo")