Don't run probe tests if resetswift failed

Probe test is cleaning up the swift environment for each test in setUp
method. However, probe tests will run even if we cannot use the resetswift
script for some reasons (e.g. not permitted, the script not found) and
probably the probe tests will fail after a long time passed for the
execution.

To prevent such an unfortunate situation and also to find the reason
easily, this patch adds the exit code check for "resetswift" and if it
failed, the test will raise AssertionError with the stdout and stderr to
make it easy to find the reason.

Closes-Bug: #1613494

Change-Id: Id80d56ab6b71402ead4fe22c120064d78c1e74ac
This commit is contained in:
Kota Tsuyuzaki 2016-08-15 18:26:00 -07:00
parent 9c859ccfee
commit 95a5a4a7ec

View File

@ -266,6 +266,11 @@ def get_policy(**kwargs):
def resetswift():
p = Popen("resetswift 2>&1", shell=True, stdout=PIPE)
stdout, _stderr = p.communicate()
if p.returncode:
raise AssertionError(
'Cleanup with "resetswift" failed: stdout: %s, stderr: %s'
% (stdout, _stderr))
print(stdout)
Manager(['all']).stop()