]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
9f95a23c TL |
10 | import six |
11 | ||
7c673cae FG |
12 | log = logging.getLogger(__name__) |
13 | ||
14 | @contextlib.contextmanager | |
15 | def task(ctx, config): | |
16 | """ | |
17 | Run radosbench | |
18 | ||
19 | The config should be as follows: | |
20 | ||
21 | radosbench: | |
22 | clients: [client list] | |
23 | time: <seconds to run> | |
24 | pool: <pool to use> | |
25 | size: write size to use | |
224ce89b | 26 | objectsize: object size to use |
7c673cae FG |
27 | unique_pool: use a unique pool, defaults to False |
28 | ec_pool: create an ec pool, defaults to False | |
224ce89b | 29 | create_pool: create pool, defaults to True |
7c673cae FG |
30 | erasure_code_profile: |
31 | name: teuthologyprofile | |
32 | k: 2 | |
33 | m: 1 | |
224ce89b | 34 | crush-failure-domain: osd |
7c673cae | 35 | cleanup: false (defaults to true) |
224ce89b | 36 | type: <write|seq|rand> (defaults to write) |
7c673cae FG |
37 | example: |
38 | ||
39 | tasks: | |
40 | - ceph: | |
41 | - radosbench: | |
42 | clients: [client.0] | |
43 | time: 360 | |
44 | - interactive: | |
45 | """ | |
46 | log.info('Beginning radosbench...') | |
47 | assert isinstance(config, dict), \ | |
48 | "please list clients to run on" | |
49 | radosbench = {} | |
50 | ||
51 | testdir = teuthology.get_testdir(ctx) | |
52 | manager = ctx.managers['ceph'] | |
224ce89b | 53 | runtype = config.get('type', 'write') |
7c673cae FG |
54 | |
55 | create_pool = config.get('create_pool', True) | |
56 | for role in config.get('clients', ['client.0']): | |
9f95a23c | 57 | assert isinstance(role, six.string_types) |
7c673cae FG |
58 | PREFIX = 'client.' |
59 | assert role.startswith(PREFIX) | |
60 | id_ = role[len(PREFIX):] | |
9f95a23c | 61 | (remote,) = ctx.cluster.only(role).remotes.keys() |
7c673cae FG |
62 | |
63 | if config.get('ec_pool', False): | |
64 | profile = config.get('erasure_code_profile', {}) | |
65 | profile_name = profile.get('name', 'teuthologyprofile') | |
66 | manager.create_erasure_code_profile(profile_name, profile) | |
67 | else: | |
68 | profile_name = None | |
69 | ||
70 | cleanup = [] | |
71 | if not config.get('cleanup', True): | |
72 | cleanup = ['--no-cleanup'] | |
9f95a23c TL |
73 | write_to_omap = [] |
74 | if config.get('write-omap', False): | |
75 | write_to_omap = ['--write-omap'] | |
76 | log.info('omap writes') | |
7c673cae FG |
77 | |
78 | pool = config.get('pool', 'data') | |
79 | if create_pool: | |
80 | if pool != 'data': | |
81 | manager.create_pool(pool, erasure_code_profile_name=profile_name) | |
82 | else: | |
83 | pool = manager.create_pool_with_unique_name(erasure_code_profile_name=profile_name) | |
84 | ||
9f95a23c | 85 | size = config.get('size', 65536) |
a8e16298 | 86 | osize = config.get('objectsize', 65536) |
9f95a23c TL |
87 | sizeargs = ['-b', str(size)] |
88 | if osize != 0 and osize != size: | |
89 | # only use -O if this varies from size. kludgey workaround the | |
90 | # fact that -O was -o in older releases. | |
91 | sizeargs.extend(['-O', str(osize)]) | |
92 | ||
224ce89b WB |
93 | # If doing a reading run then populate data |
94 | if runtype != "write": | |
95 | proc = remote.run( | |
96 | args=[ | |
97 | "/bin/sh", "-c", | |
98 | " ".join(['adjust-ulimits', | |
99 | 'ceph-coverage', | |
100 | '{tdir}/archive/coverage', | |
101 | 'rados', | |
102 | '--no-log-to-stderr', | |
103 | '--name', role] | |
9f95a23c | 104 | + sizeargs + |
224ce89b WB |
105 | ['-p' , pool, |
106 | 'bench', str(60), "write", "--no-cleanup" | |
107 | ]).format(tdir=testdir), | |
108 | ], | |
109 | logger=log.getChild('radosbench.{id}'.format(id=id_)), | |
110 | wait=True | |
111 | ) | |
9f95a23c | 112 | sizeargs = [] |
224ce89b | 113 | |
7c673cae FG |
114 | proc = remote.run( |
115 | args=[ | |
116 | "/bin/sh", "-c", | |
117 | " ".join(['adjust-ulimits', | |
118 | 'ceph-coverage', | |
119 | '{tdir}/archive/coverage', | |
120 | 'rados', | |
121 | '--no-log-to-stderr', | |
224ce89b | 122 | '--name', role] |
9f95a23c | 123 | + sizeargs + |
224ce89b WB |
124 | ['-p' , pool, |
125 | 'bench', str(config.get('time', 360)), runtype, | |
9f95a23c | 126 | ] + write_to_omap + cleanup).format(tdir=testdir), |
7c673cae FG |
127 | ], |
128 | logger=log.getChild('radosbench.{id}'.format(id=id_)), | |
129 | stdin=run.PIPE, | |
130 | wait=False | |
131 | ) | |
132 | radosbench[id_] = proc | |
133 | ||
134 | try: | |
135 | yield | |
136 | finally: | |
224ce89b | 137 | timeout = config.get('time', 360) * 30 + 300 |
7c673cae | 138 | log.info('joining radosbench (timing out after %ss)', timeout) |
9f95a23c | 139 | run.wait(radosbench.values(), timeout=timeout) |
7c673cae | 140 | |
9f95a23c | 141 | if pool != 'data' and create_pool: |
7c673cae | 142 | manager.remove_pool(pool) |