2013-10-12 08:28:27 +00:00
|
|
|
"""
|
|
|
|
Rados modle-based integration tests
|
|
|
|
"""
|
2011-06-10 17:22:01 +00:00
|
|
|
import contextlib
|
|
|
|
import logging
|
2013-03-08 01:47:25 +00:00
|
|
|
import gevent
|
|
|
|
from teuthology import misc as teuthology
|
2011-06-10 17:22:01 +00:00
|
|
|
|
2014-08-07 14:24:59 +00:00
|
|
|
from teuthology.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
|
2014-02-18 20:03:44 +00:00
|
|
|
ec_pool: use an ec pool
|
2014-06-10 15:17:26 +00:00
|
|
|
erasure_code_profile: profile to use with the erasure coded pool
|
2014-05-03 00:30:36 +00:00
|
|
|
pool_snaps: use pool snapshots instead of selfmanaged snapshots
|
2015-01-14 03:36:25 +00:00
|
|
|
write_fadvise_dontneed: write behavior like with LIBRADOS_OP_FLAG_FADVISE_DONTNEED.
|
|
|
|
This mean data don't access in the near future.
|
|
|
|
Let osd backend don't keep data in cache.
|
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
|
2014-06-10 15:17:26 +00:00
|
|
|
ec_pool: create an ec pool, defaults to False
|
2017-02-14 08:04:12 +00:00
|
|
|
erasure_code_use_overwrites: test overwrites, default false
|
2014-06-10 15:17:26 +00:00
|
|
|
erasure_code_profile:
|
|
|
|
name: teuthologyprofile
|
|
|
|
k: 2
|
|
|
|
m: 1
|
|
|
|
ruleset-failure-domain: osd
|
2014-05-03 00:30:36 +00:00
|
|
|
pool_snaps: true
|
2015-01-14 03:36:25 +00:00
|
|
|
write_fadvise_dontneed: true
|
2013-03-08 01:47:25 +00:00
|
|
|
runs: 10
|
2011-12-30 20:50:59 +00:00
|
|
|
- interactive:
|
2013-12-10 00:02:13 +00:00
|
|
|
|
|
|
|
Optionally, you can provide the pool name to run against:
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- exec:
|
|
|
|
client.0:
|
|
|
|
- ceph osd pool create foo
|
|
|
|
- rados:
|
|
|
|
clients: [client.0]
|
|
|
|
pools: [foo]
|
|
|
|
...
|
|
|
|
|
|
|
|
Alternatively, you can provide a pool prefix:
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- exec:
|
|
|
|
client.0:
|
|
|
|
- ceph osd pool create foo.client.0
|
|
|
|
- rados:
|
|
|
|
clients: [client.0]
|
|
|
|
pool_prefix: foo
|
|
|
|
...
|
|
|
|
|
2015-03-27 06:19:23 +00:00
|
|
|
The tests are run asynchronously, they are not complete when the task
|
|
|
|
returns. For instance:
|
|
|
|
|
|
|
|
- rados:
|
|
|
|
clients: [client.0]
|
|
|
|
pools: [ecbase]
|
|
|
|
ops: 4000
|
|
|
|
objects: 500
|
|
|
|
op_weights:
|
|
|
|
read: 100
|
|
|
|
write: 100
|
|
|
|
delete: 50
|
|
|
|
copy_from: 50
|
|
|
|
- print: "**** done rados ec-cache-agent (part 2)"
|
|
|
|
|
|
|
|
will run the print task immediately after the rados tasks begins but
|
|
|
|
not after it completes. To make the rados task a blocking / sequential
|
|
|
|
task, use:
|
|
|
|
|
|
|
|
- sequential:
|
|
|
|
- rados:
|
|
|
|
clients: [client.0]
|
|
|
|
pools: [ecbase]
|
|
|
|
ops: 4000
|
|
|
|
objects: 500
|
|
|
|
op_weights:
|
|
|
|
read: 100
|
|
|
|
write: 100
|
|
|
|
delete: 50
|
|
|
|
copy_from: 50
|
|
|
|
- print: "**** done rados ec-cache-agent (part 2)"
|
|
|
|
|
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-09-06 20:08:01 +00:00
|
|
|
'adjust-ulimits',
|
2013-02-06 19:16:52 +00:00
|
|
|
'ceph-coverage',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
2014-02-18 20:03:44 +00:00
|
|
|
'ceph_test_rados']
|
|
|
|
if config.get('ec_pool', False):
|
2016-10-25 16:55:46 +00:00
|
|
|
args.extend(['--no-omap'])
|
2017-02-15 01:03:19 +00:00
|
|
|
if not config.get('erasure_code_use_overwrites', False):
|
2016-10-25 16:55:46 +00:00
|
|
|
args.extend(['--ec-pool'])
|
2015-01-14 03:36:25 +00:00
|
|
|
if config.get('write_fadvise_dontneed', False):
|
|
|
|
args.extend(['--write-fadvise-dontneed'])
|
2014-05-03 00:30:36 +00:00
|
|
|
if config.get('pool_snaps', False):
|
|
|
|
args.extend(['--pool-snaps'])
|
2014-02-18 20:03:44 +00:00
|
|
|
args.extend([
|
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))
|
2014-02-18 20:03:44 +00:00
|
|
|
])
|
2015-05-27 21:28:51 +00:00
|
|
|
|
|
|
|
weights = {}
|
|
|
|
weights['read'] = 100
|
|
|
|
weights['write'] = 100
|
|
|
|
weights['delete'] = 10
|
2014-06-06 01:26:47 +00:00
|
|
|
# Parallel of the op_types in test/osd/TestRados.cc
|
2013-12-18 19:41:58 +00:00
|
|
|
for field in [
|
2014-06-06 01:26:47 +00:00
|
|
|
# read handled above
|
|
|
|
# write handled above
|
|
|
|
# delete handled above
|
|
|
|
"snap_create",
|
|
|
|
"snap_remove",
|
|
|
|
"rollback",
|
|
|
|
"setattr",
|
|
|
|
"rmattr",
|
|
|
|
"watch",
|
|
|
|
"copy_from",
|
|
|
|
"hit_set_list",
|
|
|
|
"is_dirty",
|
|
|
|
"undirty",
|
|
|
|
"cache_flush",
|
|
|
|
"cache_try_flush",
|
|
|
|
"cache_evict",
|
|
|
|
"append",
|
2015-05-27 21:28:51 +00:00
|
|
|
"write",
|
|
|
|
"read",
|
|
|
|
"delete"
|
2013-12-18 19:41:58 +00:00
|
|
|
]:
|
|
|
|
if field in op_weights:
|
2015-05-27 21:28:51 +00:00
|
|
|
weights[field] = op_weights[field]
|
|
|
|
|
2015-06-14 01:22:34 +00:00
|
|
|
if config.get('write_append_excl', True):
|
|
|
|
if 'write' in weights:
|
|
|
|
weights['write'] = weights['write'] / 2
|
|
|
|
weights['write_excl'] = weights['write']
|
|
|
|
|
|
|
|
if 'append' in weights:
|
|
|
|
weights['append'] = weights['append'] / 2
|
|
|
|
weights['append_excl'] = weights['append']
|
2015-05-27 21:28:51 +00:00
|
|
|
|
|
|
|
for op, weight in weights.iteritems():
|
|
|
|
args.extend([
|
|
|
|
'--op', op, str(weight)
|
|
|
|
])
|
|
|
|
|
2011-12-30 21:48:58 +00:00
|
|
|
|
2013-03-08 01:47:25 +00:00
|
|
|
def thread():
|
2013-10-12 08:28:27 +00:00
|
|
|
"""Thread spawned by gevent"""
|
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)
|
2016-03-25 01:01:37 +00:00
|
|
|
manager = ctx.managers['ceph']
|
2014-06-10 15:17:26 +00:00
|
|
|
if config.get('ec_pool', False):
|
|
|
|
profile = config.get('erasure_code_profile', {})
|
|
|
|
profile_name = profile.get('name', 'teuthologyprofile')
|
2016-03-25 01:01:37 +00:00
|
|
|
manager.create_erasure_code_profile(profile_name, profile)
|
2014-06-10 15:17:26 +00:00
|
|
|
else:
|
|
|
|
profile_name = None
|
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-12-10 00:02:13 +00:00
|
|
|
existing_pools = config.get('pools', [])
|
|
|
|
created_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-12-10 00:02:13 +00:00
|
|
|
|
|
|
|
pool = config.get('pool', None)
|
|
|
|
if not pool and existing_pools:
|
|
|
|
pool = existing_pools.pop()
|
|
|
|
else:
|
2016-10-25 16:55:46 +00:00
|
|
|
pool = manager.create_pool_with_unique_name(
|
|
|
|
erasure_code_profile_name=profile_name,
|
2017-02-14 08:04:12 +00:00
|
|
|
erasure_code_use_overwrites=
|
|
|
|
config.get('erasure_code_use_overwrites', False)
|
2016-10-25 16:55:46 +00:00
|
|
|
)
|
2013-12-10 00:02:13 +00:00
|
|
|
created_pools.append(pool)
|
2015-11-19 22:44:45 +00:00
|
|
|
if config.get('fast_read', False):
|
2016-03-25 01:01:37 +00:00
|
|
|
manager.raw_cluster_cmd(
|
2015-11-19 22:44:45 +00:00
|
|
|
'osd', 'pool', 'set', pool, 'fast_read', 'true')
|
2013-12-10 00:02:13 +00:00
|
|
|
|
2014-03-27 16:35:28 +00:00
|
|
|
(remote,) = ctx.cluster.only(role).remotes.iterkeys()
|
2013-03-08 01:47:25 +00:00
|
|
|
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-12-10 00:02:13 +00:00
|
|
|
|
|
|
|
for pool in created_pools:
|
2017-01-26 23:41:21 +00:00
|
|
|
manager.wait_snap_trimming_complete(pool);
|
2016-03-25 01:01:37 +00:00
|
|
|
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()
|