]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
added testsnaps
authorSamuel Just <samuel.just@dreamhost.com>
Fri, 10 Jun 2011 17:22:01 +0000 (10:22 -0700)
committerSamuel Just <samuel.just@dreamhost.com>
Fri, 10 Jun 2011 21:42:52 +0000 (14:42 -0700)
Signed-off-by: Samuel Just <samuel.just@dreamhost.com>
teuthology/task/testsnaps.py [new file with mode: 0644]

diff --git a/teuthology/task/testsnaps.py b/teuthology/task/testsnaps.py
new file mode 100644 (file)
index 0000000..024a017
--- /dev/null
@@ -0,0 +1,91 @@
+import contextlib
+import logging
+import os
+
+from teuthology import misc as teuthology
+from orchestra import run
+
+log = logging.getLogger(__name__)
+
+@contextlib.contextmanager
+def task(ctx, config):
+    """
+    Run testsnaps
+
+    The config should be as follows:
+
+    testsnaps:
+        clients: [client list]
+        ops: <number of ops>
+        objects: <number of objects to use>
+        maxinflight: <max number of operations in flight>
+
+    example:
+
+    tasks:
+    - ceph:
+    - testsnaps: 
+        clients: [client.0]
+        ops: 1000
+        objects: 25
+        maxinflight: 16
+    - interactive:
+    """
+    log.info('Beginning testsnaps...')
+    assert isinstance(config, dict), \
+        "please list clients to run on"
+    testsnaps = {}
+
+    (mon,) = ctx.cluster.only('mon.0').remotes.iterkeys()
+    remotes = []
+    for role in config.get('clients', ['client.0']):
+        assert isinstance(role, basestring)
+        PREFIX = 'client.'
+        assert role.startswith(PREFIX)
+        id_ = role[len(PREFIX):]
+        (remote,) = ctx.cluster.only(role).remotes.iterkeys()
+        remotes.append(remote)
+
+        remote.run(
+            args= [
+                'cp',
+                '/tmp/cephtest/ceph.conf',
+                '/tmp/cephtest/data/ceph.conf',
+                ],
+            logger=log.getChild('testsnaps.{id}'.format(id=id_)),
+            wait=True,
+            )
+
+        proc = remote.run(
+            args= [
+                '/bin/sh', '-c',
+                " ".join([
+                    'cd', '/tmp/cephtest/data;',
+                    'export CEPH_CLIENT_ID={id_}; /tmp/cephtest/binary/usr/local/bin/testsnaps'.format(
+                        id_=id_),
+                    str(config.get('ops', '1000')),
+                    str(config.get('objects', '25')),
+                    str(config.get('maxinflight', '16')),
+                    ])
+                ],
+            logger=log.getChild('testsnaps.{id}'.format(id=id_)),
+            stdin=run.PIPE,
+            wait=False
+            )
+        testsnaps[id_] = proc
+
+    try:
+        yield
+    finally:
+        for i in remotes:
+            i.run(
+                args=[
+                    'rm',
+                    '/tmp/cephtest/data/ceph.conf'
+                    ],
+                logger=log.getChild('testsnaps.{id}'.format(id=id_)),
+                wait=True,
+                )
+                
+        log.info('joining testrados')
+        run.wait(testsnaps.itervalues())