kill orphans during probe test setup

orphans processes sometimes cause probe test failures so
get rid of them before each test.

Change-Id: I4ba6748d30fbb28371f13aa95387c49bc8223402
This commit is contained in:
Alistair Coles 2018-02-08 12:59:36 +00:00 committed by Tim Burke
parent 6b9098eead
commit 1f4ebbc990

View File

@ -266,18 +266,26 @@ def get_policy(**kwargs):
raise unittest.SkipTest('No policy matching %s' % kwargs)
def resetswift():
p = Popen("resetswift 2>&1", shell=True, stdout=PIPE)
def run_cleanup(cmd):
p = Popen(cmd + " 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))
'Cleanup with %r failed: stdout: %s, stderr: %s'
% (cmd, stdout, _stderr))
print(stdout)
Manager(['all']).stop()
def resetswift():
run_cleanup("resetswift")
def kill_orphans():
run_cleanup("swift-orphans -a 0 -k 9")
class Body(object):
def __init__(self, total=3.5 * 2 ** 20):
@ -328,6 +336,7 @@ class ProbeTest(unittest.TestCase):
def setUp(self):
resetswift()
kill_orphans()
try:
self.ipport2server = {}
self.configs = defaultdict(dict)