]> git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/multibench.py
53b1aa5212343df1695ce7b42b9de7263cc11d75
[ceph.git] / ceph / qa / tasks / multibench.py
1 """
2 Multibench testing
3 """
4 import contextlib
5 import logging
6 import radosbench
7 import time
8 import copy
9 import gevent
10
11 log = logging.getLogger(__name__)
12
13 @contextlib.contextmanager
14 def task(ctx, config):
15 """
16 Run multibench
17
18 The config should be as follows:
19
20 multibench:
21 time: <seconds to run total>
22 segments: <number of concurrent benches>
23 radosbench: <config for radosbench>
24
25 example:
26
27 tasks:
28 - ceph:
29 - multibench:
30 clients: [client.0]
31 time: 360
32 - interactive:
33 """
34 log.info('Beginning multibench...')
35 assert isinstance(config, dict), \
36 "please list clients to run on"
37
38 def run_one(num):
39 """Run test spawn from gevent"""
40 start = time.time()
41 if not config.get('radosbench'):
42 benchcontext = {}
43 else:
44 benchcontext = copy.copy(config.get('radosbench'))
45 iterations = 0
46 while time.time() - start < int(config.get('time', 600)):
47 log.info("Starting iteration %s of segment %s"%(iterations, num))
48 benchcontext['pool'] = str(num) + "-" + str(iterations)
49 with radosbench.task(ctx, benchcontext):
50 time.sleep()
51 iterations += 1
52 log.info("Starting %s threads"%(str(config.get('segments', 3)),))
53 segments = [
54 gevent.spawn(run_one, i)
55 for i in range(0, int(config.get('segments', 3)))]
56
57 try:
58 yield
59 finally:
60 [i.get() for i in segments]