2011-06-10 17:22:01 +00:00
|
|
|
import contextlib
|
|
|
|
import logging
|
2013-03-08 01:47:25 +00:00
|
|
|
import gevent
|
|
|
|
from ceph_manager import CephManager
|
|
|
|
from teuthology import misc as teuthology
|
2011-06-10 17:22:01 +00:00
|
|
|
|
2011-09-13 21:53:02 +00:00
|
|
|
from ..orchestra import run
|
2011-06-10 17:22:01 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
@contextlib.contextmanager
|
|
|
|
def task(ctx, config):
|
|
|
|
"""
|
2011-12-30 20:50:59 +00:00
|
|
|
Run RadosModel-based integration tests.
|
|
|
|
|
|
|
|
The config should be as follows::
|
|
|
|
|
2011-12-30 20:54:55 +00:00
|
|
|
rados:
|
2011-12-30 20:50:59 +00:00
|
|
|
clients: [client list]
|
|
|
|
ops: <number of ops>
|
|
|
|
objects: <number of objects to use>
|
2011-12-31 03:27:27 +00:00
|
|
|
max_in_flight: <max number of operations in flight>
|
|
|
|
object_size: <size of objects in bytes>
|
|
|
|
min_stride_size: <minimum write stride size in bytes>
|
|
|
|
max_stride_size: <maximum write stride size in bytes>
|
|
|
|
op_weights: <dictionary mapping operation type to integer weight>
|
2013-03-08 01:47:25 +00:00
|
|
|
runs: <number of times to run> - the pool is remade between runs
|
2011-12-30 20:50:59 +00:00
|
|
|
|
|
|
|
For example::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
2011-12-30 20:54:55 +00:00
|
|
|
- rados:
|
2011-12-30 20:50:59 +00:00
|
|
|
clients: [client.0]
|
|
|
|
ops: 1000
|
2012-01-17 00:53:55 +00:00
|
|
|
max_seconds: 0 # 0 for no limit
|
2011-12-30 20:50:59 +00:00
|
|
|
objects: 25
|
2011-12-31 03:27:27 +00:00
|
|
|
max_in_flight: 16
|
|
|
|
object_size: 4000000
|
|
|
|
min_stride_size: 1024
|
|
|
|
max_stride_size: 4096
|
|
|
|
op_weights:
|
|
|
|
read: 20
|
|
|
|
write: 10
|
|
|
|
delete: 2
|
|
|
|
snap_create: 3
|
|
|
|
rollback: 2
|
2012-01-03 22:07:45 +00:00
|
|
|
snap_remove: 0
|
2013-03-08 01:47:25 +00:00
|
|
|
runs: 10
|
2011-12-30 20:50:59 +00:00
|
|
|
- interactive:
|
2011-06-10 17:22:01 +00:00
|
|
|
"""
|
2011-12-30 20:54:55 +00:00
|
|
|
log.info('Beginning rados...')
|
2011-06-10 17:22:01 +00:00
|
|
|
assert isinstance(config, dict), \
|
|
|
|
"please list clients to run on"
|
|
|
|
|
2011-12-31 03:27:27 +00:00
|
|
|
object_size = int(config.get('object_size', 4000000))
|
|
|
|
op_weights = config.get('op_weights', {})
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
2011-12-30 21:48:58 +00:00
|
|
|
args = [
|
2013-06-23 16:15:28 +00:00
|
|
|
'{tdir}/adjust-ulimits'.format(tdir=testdir),
|
2013-02-06 19:16:52 +00:00
|
|
|
'ceph-coverage',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
2013-02-18 21:39:20 +00:00
|
|
|
'ceph_test_rados',
|
2012-01-17 00:53:55 +00:00
|
|
|
'--op', 'read', str(op_weights.get('read', 100)),
|
|
|
|
'--op', 'write', str(op_weights.get('write', 100)),
|
|
|
|
'--op', 'delete', str(op_weights.get('delete', 10)),
|
|
|
|
'--op', 'snap_create', str(op_weights.get('snap_create', 0)),
|
|
|
|
'--op', 'snap_remove', str(op_weights.get('snap_remove', 0)),
|
|
|
|
'--op', 'rollback', str(op_weights.get('rollback', 0)),
|
2012-02-17 00:10:45 +00:00
|
|
|
'--op', 'setattr', str(op_weights.get('setattr', 0)),
|
|
|
|
'--op', 'rmattr', str(op_weights.get('rmattr', 0)),
|
2012-03-21 01:56:20 +00:00
|
|
|
'--op', 'watch', str(op_weights.get('watch', 0)),
|
2012-01-17 00:53:55 +00:00
|
|
|
'--max-ops', str(config.get('ops', 10000)),
|
|
|
|
'--objects', str(config.get('objects', 500)),
|
|
|
|
'--max-in-flight', str(config.get('max_in_flight', 16)),
|
|
|
|
'--size', str(object_size),
|
|
|
|
'--min-stride-size', str(config.get('min_stride_size', object_size / 10)),
|
|
|
|
'--max-stride-size', str(config.get('max_stride_size', object_size / 5)),
|
|
|
|
'--max-seconds', str(config.get('max_seconds', 0))
|
2011-12-30 21:48:58 +00:00
|
|
|
]
|
|
|
|
|
2013-03-08 01:47:25 +00:00
|
|
|
def thread():
|
|
|
|
if not hasattr(ctx, 'manager'):
|
|
|
|
first_mon = teuthology.get_first_mon(ctx, config)
|
|
|
|
(mon,) = ctx.cluster.only(first_mon).remotes.iterkeys()
|
|
|
|
ctx.manager = CephManager(
|
|
|
|
mon,
|
|
|
|
ctx=ctx,
|
|
|
|
logger=log.getChild('ceph_manager'),
|
|
|
|
)
|
|
|
|
|
2013-06-14 05:27:50 +00:00
|
|
|
clients = ['client.{id}'.format(id=id_) for id_ in teuthology.all_roles_of_type(ctx.cluster, 'client')]
|
|
|
|
log.info('clients are %s' % clients)
|
2013-03-08 01:47:25 +00:00
|
|
|
for i in range(int(config.get('runs', '1'))):
|
|
|
|
log.info("starting run %s out of %s", str(i), config.get('runs', '1'))
|
|
|
|
tests = {}
|
2013-06-24 03:44:38 +00:00
|
|
|
pools = []
|
2013-06-14 05:27:50 +00:00
|
|
|
for role in config.get('clients', clients):
|
2013-03-08 01:47:25 +00:00
|
|
|
assert isinstance(role, basestring)
|
|
|
|
PREFIX = 'client.'
|
|
|
|
assert role.startswith(PREFIX)
|
|
|
|
id_ = role[len(PREFIX):]
|
2013-06-24 03:44:38 +00:00
|
|
|
pool = 'radosmodel-%s' % id_
|
|
|
|
pools.append(pool)
|
|
|
|
ctx.manager.create_pool(pool)
|
2013-03-08 01:47:25 +00:00
|
|
|
(remote,) = ctx.cluster.only(role).remotes.iterkeys()
|
|
|
|
proc = remote.run(
|
2013-06-14 05:27:50 +00:00
|
|
|
args=["CEPH_CLIENT_ID={id_}".format(id_=id_)] + args +
|
|
|
|
["--pool", pool],
|
2013-03-08 01:47:25 +00:00
|
|
|
logger=log.getChild("rados.{id}".format(id=id_)),
|
|
|
|
stdin=run.PIPE,
|
|
|
|
wait=False
|
|
|
|
)
|
|
|
|
tests[id_] = proc
|
|
|
|
run.wait(tests.itervalues())
|
2013-06-24 03:44:38 +00:00
|
|
|
for pool in pools:
|
|
|
|
ctx.manager.remove_pool(pool)
|
2013-03-08 01:47:25 +00:00
|
|
|
|
|
|
|
running = gevent.spawn(thread)
|
2011-06-10 17:22:01 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
2011-12-30 20:54:55 +00:00
|
|
|
log.info('joining rados')
|
2013-03-08 01:47:25 +00:00
|
|
|
running.get()
|