ceph/teuthology/task/rados.py
Tommi Virtanen e80c32c442 Rename "testrados" and "testswift" tasks to not begin with "test".
Anything "test*" looks like a unit test, and shouldn't be used for
actual code.
2011-12-05 10:07:25 -08:00

85 lines
2.4 KiB
Python

import contextlib
import logging
from ..orchestra import run
log = logging.getLogger(__name__)
@contextlib.contextmanager
def task(ctx, config):
"""
Run testrados
The config should be as follows:
testrados:
clients: [client list]
ops: <number of ops>
objects: <number of objects to use>
maxinflight: <max number of operations in flight>
snaps: <create/remove/rollback snaps>
example:
tasks:
- ceph:
- testrados:
clients: [client.0]
ops: 1000
objects: 25
maxinflight: 16
snaps: true
- interactive:
"""
log.info('Beginning testrados...')
assert isinstance(config, dict), \
"please list clients to run on"
testrados = {}
(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)
args = []
if not config.get('snaps', False):
args = [
'CEPH_CLIENT_ID={id_}'.format(id_=id_),
'CEPH_CONF=/tmp/cephtest/ceph.conf',
'LD_PRELOAD=/tmp/cephtest/binary/usr/local/lib/librados.so.2',
'/tmp/cephtest/binary/usr/local/bin/testreadwrite',
str(config.get('ops', '10000')),
str(config.get('objects', '500')),
str(50),
str(config.get('maxinflight', '16'))
]
else:
args = [
'CEPH_CLIENT_ID={id_}'.format(id_=id_),
'CEPH_CONF=/tmp/cephtest/ceph.conf',
'LD_PRELOAD=/tmp/cephtest/binary/usr/local/lib/librados.so.2',
'/tmp/cephtest/binary/usr/local/bin/testsnaps',
str(config.get('ops', '10000')),
str(config.get('objects', '500')),
str(config.get('maxinflight', '16'))
]
proc = remote.run(
args=args,
logger=log.getChild('testrados.{id}'.format(id=id_)),
stdin=run.PIPE,
wait=False
)
testrados[id_] = proc
try:
yield
finally:
log.info('joining testrados')
run.wait(testrados.itervalues())