]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
s3readwrite.py: enable overrides
authorJoe Buck <jbbuck@gmail.com>
Sun, 4 Aug 2013 19:36:04 +0000 (12:36 -0700)
committerJoe Buck <jbbuck@gmail.com>
Tue, 6 Aug 2013 19:15:37 +0000 (12:15 -0700)
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 <jbbuck@gmail.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
teuthology/task/s3readwrite.py

index 46a258afe28d197d3f8464b2cfa328f1f488137d..fedf7445629264fc79dcac32a4b715e7920b65bb 100644 (file)
@@ -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,