From 95a5a4a7ec1ec8a48db756121e7b3440f5704536 Mon Sep 17 00:00:00 2001 From: Kota Tsuyuzaki Date: Mon, 15 Aug 2016 18:26:00 -0700 Subject: [PATCH] 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 --- test/probe/common.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/probe/common.py b/test/probe/common.py index 5bb4b5d546..cf1b6936ce 100644 --- a/test/probe/common.py +++ b/test/probe/common.py @@ -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()