From 70f4eeb970f1f61e8b230233a2e2fbc9c474f76c Mon Sep 17 00:00:00 2001 From: Joe Buck Date: Sun, 4 Aug 2013 12:36:04 -0700 Subject: [PATCH] s3readwrite.py: enable overrides Enable s3readwrite task to have the branch to download specified and for overrides to be incorporated into the config at run-time. Code based on the s3tests.py task. Signed-off-by: Joe Buck Reviewed-by: Josh Durgin --- teuthology/task/s3readwrite.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/teuthology/task/s3readwrite.py b/teuthology/task/s3readwrite.py index 46a258afe2..fedf744562 100644 --- a/teuthology/task/s3readwrite.py +++ b/teuthology/task/s3readwrite.py @@ -17,27 +17,42 @@ log = logging.getLogger(__name__) @contextlib.contextmanager def download(ctx, config): - assert isinstance(config, list) + assert isinstance(config, dict) log.info('Downloading s3-tests...') - for client in config: + testdir = teuthology.get_testdir(ctx) + for (client, cconf) in config.items(): + branch = cconf.get('force-branch', None) + if not branch: + branch = cconf.get('branch', 'master') + sha1 = cconf.get('sha1') ctx.cluster.only(client).run( args=[ 'git', 'clone', + '-b', branch, # 'https://github.com/ceph/s3-tests.git', 'git://ceph.com/git/s3-tests.git', - '{tdir}/s3-tests'.format(tdir=teuthology.get_testdir(ctx)), + '{tdir}/s3-tests'.format(tdir=testdir), ], ) + if sha1 is not None: + ctx.cluster.only(client).run( + args=[ + 'cd', '{tdir}/s3-tests'.format(tdir=testdir), + run.Raw('&&'), + 'git', 'reset', '--hard', sha1, + ], + ) try: yield finally: 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=teuthology.get_testdir(ctx)), + '{tdir}/s3-tests'.format(tdir=testdir), ], ) @@ -241,6 +256,15 @@ def task(ctx, config): config = dict.fromkeys(config) clients = config.keys() + overrides = ctx.config.get('overrides', {}) + # merge each client section, not the top level. + for client in config.iterkeys(): + if not config[client]: + config[client] = {} + teuthology.deep_merge(config[client], overrides.get('s3readwrite', {})) + + log.debug('in s3readwrite, config is %s', config) + s3tests_conf = {} for client in clients: if config[client] is None: @@ -259,7 +283,7 @@ def task(ctx, config): }) with contextutil.nested( - lambda: download(ctx=ctx, config=clients), + lambda: download(ctx=ctx, config=config), lambda: create_users(ctx=ctx, config=dict( clients=clients, s3tests_conf=s3tests_conf, -- 2.39.5