From 6aba6d2cadedd8fdcd8495ca639653ce15f6b2cc Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Tue, 30 Apr 2013 16:47:34 -0700 Subject: [PATCH] rgw tests: clean up immediately after the test There's no need for an explicit cleanup function, so move it back to where it came from (except in s3roundtrip, which did not have it). Instead, since these use a nested contextmanager, pass through and yield to the top-level run_tasks after the nested contextmanager has finished (and thus run all the cleanup steps in the subtasks for this test). Signed-off-by: Josh Durgin --- teuthology/task/s3readwrite.py | 28 ++++++++++++---------------- teuthology/task/s3roundtrip.py | 3 ++- teuthology/task/s3tests.py | 29 ++++++++++++----------------- teuthology/task/swift.py | 26 ++++++++++++-------------- 4 files changed, 38 insertions(+), 48 deletions(-) diff --git a/teuthology/task/s3readwrite.py b/teuthology/task/s3readwrite.py index aa9c41902f..f44c343f7c 100644 --- a/teuthology/task/s3readwrite.py +++ b/teuthology/task/s3readwrite.py @@ -31,7 +31,16 @@ def download(ctx, config): try: yield finally: - 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)), + ], + ) + def _config_user(s3tests_conf, section, user): s3tests_conf[section].setdefault('user_id', user) @@ -141,19 +150,6 @@ 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)), - ], - ) - yield - @contextlib.contextmanager def task(ctx, config): """ @@ -255,6 +251,6 @@ def task(ctx, config): s3tests_conf=s3tests_conf, )), lambda: run_tests(ctx=ctx, config=config), - lambda: cleanup_tests(ctx=ctx, config=config), ): - yield + pass + yield diff --git a/teuthology/task/s3roundtrip.py b/teuthology/task/s3roundtrip.py index 9d375bbab9..64995498d3 100644 --- a/teuthology/task/s3roundtrip.py +++ b/teuthology/task/s3roundtrip.py @@ -253,4 +253,5 @@ def task(ctx, config): )), lambda: run_tests(ctx=ctx, config=config), ): - yield + pass + yield diff --git a/teuthology/task/s3tests.py b/teuthology/task/s3tests.py index 00dc210cfd..3bae160481 100644 --- a/teuthology/task/s3tests.py +++ b/teuthology/task/s3tests.py @@ -42,7 +42,16 @@ def do_download(ctx, config): try: yield finally: - 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), + ], + ) @contextlib.contextmanager def download(ctx, config): @@ -149,20 +158,6 @@ 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): """ @@ -247,6 +242,6 @@ def task(ctx, config): s3tests_conf=s3tests_conf, )), lambda: run_tests(ctx=ctx, config=config), - lambda: cleanup_tests(ctx=ctx, config=config), ): - yield + pass + yield diff --git a/teuthology/task/swift.py b/teuthology/task/swift.py index 7692a5d03c..a799f62470 100644 --- a/teuthology/task/swift.py +++ b/teuthology/task/swift.py @@ -29,7 +29,16 @@ def download(ctx, config): try: yield finally: - 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), + ], + ) def _config_user(testswift_conf, account, user, suffix): testswift_conf['func_test'].setdefault('account{s}'.format(s=suffix), account); @@ -128,17 +137,6 @@ def run_tests(ctx, config): @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), - ], - ) - yield @contextlib.contextmanager def task(ctx, config): @@ -217,6 +215,6 @@ def task(ctx, config): testswift_conf=testswift_conf, )), lambda: run_tests(ctx=ctx, config=config), - lambda: cleanup_tests(ctx=ctx, config=config), ): - yield + pass + yield -- 2.39.5