From c8ec76eed8edebf6305a37c0f431c7b23267f803 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 --- teuthology/task/s3readwrite.py | 23 ++++++++++++++--------- teuthology/task/s3tests.py | 25 ++++++++++++++++--------- teuthology/task/swift.py | 23 ++++++++++++++--------- 3 files changed, 44 insertions(+), 27 deletions(-) diff --git a/teuthology/task/s3readwrite.py b/teuthology/task/s3readwrite.py index 87992f22c933c..fec46e9b6a947 100644 --- a/teuthology/task/s3readwrite.py +++ b/teuthology/task/s3readwrite.py @@ -31,15 +31,7 @@ def 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=teuthology.get_testdir(ctx)), - ], - ) + cleanup_tests(ctx, config) def _config_user(s3tests_conf, section, user): s3tests_conf[section].setdefault('user_id', user) @@ -149,6 +141,18 @@ def run_tests(ctx, config): yield +@contextlib.contextmanager +def cleanup_tests(ctx, config): + log.info('Removing s3-tests...') + for client in config: + ctx.cluster.only(client).run( + args=[ + 'rm', + '-rf', + '{tdir}/s3-tests'.format(tdir=teuthology.get_testdir(ctx)), + ], + ) + @contextlib.contextmanager def task(ctx, config): """ @@ -250,5 +254,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/teuthology/task/s3tests.py b/teuthology/task/s3tests.py index a52ccc723cb0c..00dc210cfd0fa 100644 --- a/teuthology/task/s3tests.py +++ b/teuthology/task/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/teuthology/task/swift.py b/teuthology/task/swift.py index 076509b2dd08f..f832ca79c1e5e 100644 --- a/teuthology/task/swift.py +++ b/teuthology/task/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