2 Rados modle-based integration tests
7 from teuthology
import misc
as teuthology
9 from teuthology
.orchestra
import run
11 log
= logging
.getLogger(__name__
)
13 @contextlib.contextmanager
14 def task(ctx
, config
):
16 Run RadosModel-based integration tests.
18 The config should be as follows::
21 clients: [client list]
23 objects: <number of objects to use>
24 max_in_flight: <max number of operations in flight>
25 object_size: <size of objects in bytes>
26 min_stride_size: <minimum write stride size in bytes>
27 max_stride_size: <maximum write stride size in bytes>
28 op_weights: <dictionary mapping operation type to integer weight>
29 runs: <number of times to run> - the pool is remade between runs
30 ec_pool: use an ec pool
31 erasure_code_profile: profile to use with the erasure coded pool
32 fast_read: enable ec_pool's fast_read
33 min_size: set the min_size of created pool
34 pool_snaps: use pool snapshots instead of selfmanaged snapshots
35 write_fadvise_dontneed: write behavior like with LIBRADOS_OP_FLAG_FADVISE_DONTNEED.
36 This mean data don't access in the near future.
37 Let osd backend don't keep data in cache.
46 max_seconds: 0 # 0 for no limit
59 ec_pool: create an ec pool, defaults to False
60 erasure_code_use_overwrites: test overwrites, default false
62 name: teuthologyprofile
65 ruleset-failure-domain: osd
67 write_fadvise_dontneed: true
71 Optionally, you can provide the pool name to run against:
77 - ceph osd pool create foo
83 Alternatively, you can provide a pool prefix:
89 - ceph osd pool create foo.client.0
95 The tests are run asynchronously, they are not complete when the task
96 returns. For instance:
108 - print: "**** done rados ec-cache-agent (part 2)"
110 will run the print task immediately after the rados tasks begins but
111 not after it completes. To make the rados task a blocking / sequential
125 - print: "**** done rados ec-cache-agent (part 2)"
128 log
.info('Beginning rados...')
129 assert isinstance(config
, dict), \
130 "please list clients to run on"
132 object_size
= int(config
.get('object_size', 4000000))
133 op_weights
= config
.get('op_weights', {})
134 testdir
= teuthology
.get_testdir(ctx
)
138 '{tdir}/archive/coverage'.format(tdir
=testdir
),
140 if config
.get('ec_pool', False):
141 args
.extend(['--no-omap'])
142 if not config
.get('erasure_code_use_overwrites', False):
143 args
.extend(['--ec-pool'])
144 if config
.get('write_fadvise_dontneed', False):
145 args
.extend(['--write-fadvise-dontneed'])
146 if config
.get('set_redirect', False):
147 args
.extend(['--set_redirect'])
148 if config
.get('pool_snaps', False):
149 args
.extend(['--pool-snaps'])
151 '--max-ops', str(config
.get('ops', 10000)),
152 '--objects', str(config
.get('objects', 500)),
153 '--max-in-flight', str(config
.get('max_in_flight', 16)),
154 '--size', str(object_size
),
155 '--min-stride-size', str(config
.get('min_stride_size', object_size
/ 10)),
156 '--max-stride-size', str(config
.get('max_stride_size', object_size
/ 5)),
157 '--max-seconds', str(config
.get('max_seconds', 0))
161 weights
['read'] = 100
162 weights
['write'] = 100
163 weights
['delete'] = 10
164 # Parallel of the op_types in test/osd/TestRados.cc
167 # write handled above
168 # delete handled above
187 if field
in op_weights
:
188 weights
[field
] = op_weights
[field
]
190 if config
.get('write_append_excl', True):
191 if 'write' in weights
:
192 weights
['write'] = weights
['write'] / 2
193 weights
['write_excl'] = weights
['write']
195 if 'append' in weights
:
196 weights
['append'] = weights
['append'] / 2
197 weights
['append_excl'] = weights
['append']
199 for op
, weight
in weights
.iteritems():
201 '--op', op
, str(weight
)
206 """Thread spawned by gevent"""
207 clients
= ['client.{id}'.format(id=id_
) for id_
in teuthology
.all_roles_of_type(ctx
.cluster
, 'client')]
208 log
.info('clients are %s' % clients
)
209 manager
= ctx
.managers
['ceph']
210 if config
.get('ec_pool', False):
211 profile
= config
.get('erasure_code_profile', {})
212 profile_name
= profile
.get('name', 'teuthologyprofile')
213 manager
.create_erasure_code_profile(profile_name
, profile
)
216 for i
in range(int(config
.get('runs', '1'))):
217 log
.info("starting run %s out of %s", str(i
), config
.get('runs', '1'))
219 existing_pools
= config
.get('pools', [])
221 for role
in config
.get('clients', clients
):
222 assert isinstance(role
, basestring
)
224 assert role
.startswith(PREFIX
)
225 id_
= role
[len(PREFIX
):]
227 pool
= config
.get('pool', None)
228 if not pool
and existing_pools
:
229 pool
= existing_pools
.pop()
231 pool
= manager
.create_pool_with_unique_name(
232 erasure_code_profile_name
=profile_name
,
233 erasure_code_use_overwrites
=
234 config
.get('erasure_code_use_overwrites', False)
236 created_pools
.append(pool
)
237 if config
.get('fast_read', False):
238 manager
.raw_cluster_cmd(
239 'osd', 'pool', 'set', pool
, 'fast_read', 'true')
240 min_size
= config
.get('min_size', None);
241 if min_size
is not None:
242 manager
.raw_cluster_cmd(
243 'osd', 'pool', 'set', pool
, 'min_size', str(min_size
))
245 (remote
,) = ctx
.cluster
.only(role
).remotes
.iterkeys()
247 args
=["CEPH_CLIENT_ID={id_}".format(id_
=id_
)] + args
+
249 logger
=log
.getChild("rados.{id}".format(id=id_
)),
254 run
.wait(tests
.itervalues())
256 for pool
in created_pools
:
257 manager
.wait_snap_trimming_complete(pool
);
258 manager
.remove_pool(pool
)
260 running
= gevent
.spawn(thread
)
265 log
.info('joining rados')