From 820c72b8d0177b01f69887ec64d98702db37077c Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 29 Apr 2013 11:24:04 -0700 Subject: [PATCH] s3tests, s3readwrite, swift: cleanup explicitly Cleaning up test dir explicitly after run, so that consecutive runs don't fail. Signed-off-by: Yehuda Sadeh --- s3tests.py | 25 ++++++++++++++++--------- swift.py | 23 ++++++++++++++--------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/s3tests.py b/s3tests.py index a52ccc723cb..00dc210cfd0 100644 --- a/s3tests.py +++ b/s3tests.py @@ -42,15 +42,7 @@ def do_download(ctx, config): try: yield finally: - log.info('Removing s3-tests...') - for client in config: - ctx.cluster.only(client).run( - args=[ - 'rm', - '-rf', - '{tdir}/s3-tests'.format(tdir=testdir), - ], - ) + cleanup_tests(ctx, config) @contextlib.contextmanager def download(ctx, config): @@ -157,6 +149,20 @@ def run_tests(ctx, config): do_run_tests(ctx, config) yield +@contextlib.contextmanager +def cleanup_tests(ctx, config): + log.info('Removing s3-tests...') + testdir = teuthology.get_testdir(ctx) + for client in config: + ctx.cluster.only(client).run( + args=[ + 'rm', + '-rf', + '{tdir}/s3-tests'.format(tdir=testdir), + ], + ) + yield + @contextlib.contextmanager def task(ctx, config): """ @@ -241,5 +247,6 @@ def task(ctx, config): s3tests_conf=s3tests_conf, )), lambda: run_tests(ctx=ctx, config=config), + lambda: cleanup_tests(ctx=ctx, config=config), ): yield diff --git a/swift.py b/swift.py index 076509b2dd0..f832ca79c1e 100644 --- a/swift.py +++ b/swift.py @@ -29,15 +29,7 @@ def download(ctx, config): try: yield finally: - log.info('Removing swift...') - for client in config: - ctx.cluster.only(client).run( - args=[ - 'rm', - '-rf', - '{tdir}/swift'.format(tdir=testdir), - ], - ) + cleanup_tests(ctx, config) def _config_user(testswift_conf, account, user, suffix): testswift_conf['func_test'].setdefault('account{s}'.format(s=suffix), account); @@ -134,6 +126,18 @@ def run_tests(ctx, config): ) yield +@contextlib.contextmanager +def cleanup_tests(ctx, config): + log.info('Removing swift...') + testdir = teuthology.get_testdir(ctx) + for client in config: + ctx.cluster.only(client).run( + args=[ + 'rm', + '-rf', + '{tdir}/swift'.format(tdir=testdir), + ], + ) @contextlib.contextmanager def task(ctx, config): @@ -212,5 +216,6 @@ def task(ctx, config): testswift_conf=testswift_conf, )), lambda: run_tests(ctx=ctx, config=config), + lambda: cleanup_tests(ctx=ctx, config=config), ): yield -- 2.39.5