]> git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/radosbench.py
3db57af83f819017758ad64f553fef36d13d55db
[ceph.git] / ceph / qa / tasks / radosbench.py
1 """
2 Rados benchmarking
3 """
4 import contextlib
5 import logging
6
7 from teuthology.orchestra import run
8 from teuthology import misc as teuthology
9
10 log = logging.getLogger(__name__)
11
12 @contextlib.contextmanager
13 def task(ctx, config):
14 """
15 Run radosbench
16
17 The config should be as follows:
18
19 radosbench:
20 clients: [client list]
21 time: <seconds to run>
22 pool: <pool to use>
23 size: write size to use
24 unique_pool: use a unique pool, defaults to False
25 ec_pool: create an ec pool, defaults to False
26 create_pool: create pool, defaults to False
27 erasure_code_profile:
28 name: teuthologyprofile
29 k: 2
30 m: 1
31 ruleset-failure-domain: osd
32 cleanup: false (defaults to true)
33 example:
34
35 tasks:
36 - ceph:
37 - radosbench:
38 clients: [client.0]
39 time: 360
40 - interactive:
41 """
42 log.info('Beginning radosbench...')
43 assert isinstance(config, dict), \
44 "please list clients to run on"
45 radosbench = {}
46
47 testdir = teuthology.get_testdir(ctx)
48 manager = ctx.managers['ceph']
49
50 create_pool = config.get('create_pool', True)
51 for role in config.get('clients', ['client.0']):
52 assert isinstance(role, basestring)
53 PREFIX = 'client.'
54 assert role.startswith(PREFIX)
55 id_ = role[len(PREFIX):]
56 (remote,) = ctx.cluster.only(role).remotes.iterkeys()
57
58 if config.get('ec_pool', False):
59 profile = config.get('erasure_code_profile', {})
60 profile_name = profile.get('name', 'teuthologyprofile')
61 manager.create_erasure_code_profile(profile_name, profile)
62 else:
63 profile_name = None
64
65 cleanup = []
66 if not config.get('cleanup', True):
67 cleanup = ['--no-cleanup']
68
69 pool = config.get('pool', 'data')
70 if create_pool:
71 if pool != 'data':
72 manager.create_pool(pool, erasure_code_profile_name=profile_name)
73 else:
74 pool = manager.create_pool_with_unique_name(erasure_code_profile_name=profile_name)
75
76 proc = remote.run(
77 args=[
78 "/bin/sh", "-c",
79 " ".join(['adjust-ulimits',
80 'ceph-coverage',
81 '{tdir}/archive/coverage',
82 'rados',
83 '--no-log-to-stderr',
84 '--name', role,
85 '-b', str(config.get('size', 4<<20)),
86 '-p' , pool,
87 'bench', str(config.get('time', 360)), 'write',
88 ] + cleanup).format(tdir=testdir),
89 ],
90 logger=log.getChild('radosbench.{id}'.format(id=id_)),
91 stdin=run.PIPE,
92 wait=False
93 )
94 radosbench[id_] = proc
95
96 try:
97 yield
98 finally:
99 timeout = config.get('time', 360) * 5 + 180
100 log.info('joining radosbench (timing out after %ss)', timeout)
101 run.wait(radosbench.itervalues(), timeout=timeout)
102
103 if pool is not 'data' and create_pool:
104 manager.remove_pool(pool)