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