]> git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/rbd_fsx.py
import ceph quincy 17.2.4
[ceph.git] / ceph / qa / tasks / rbd_fsx.py
1 """
2 Run fsx on an rbd image
3 """
4 import contextlib
5 import logging
6
7 from teuthology.exceptions import ConfigError
8 from teuthology.parallel import parallel
9 from teuthology import misc as teuthology
10 from tasks.ceph_manager import get_valgrind_args
11
12 log = logging.getLogger(__name__)
13
14 @contextlib.contextmanager
15 def task(ctx, config):
16 """
17 Run fsx on an rbd image.
18
19 Currently this requires running as client.admin
20 to create a pool.
21
22 Specify which clients to run on as a list::
23
24 tasks:
25 ceph:
26 rbd_fsx:
27 clients: [client.0, client.1]
28
29 You can optionally change some properties of fsx:
30
31 tasks:
32 ceph:
33 rbd_fsx:
34 clients: <list of clients>
35 seed: <random seed number, or 0 to use the time>
36 ops: <number of operations to do>
37 size: <maximum image size in bytes>
38 valgrind: [--tool=<valgrind tool>]
39 """
40 log.info('starting rbd_fsx...')
41 with parallel() as p:
42 for role in config['clients']:
43 p.spawn(_run_one_client, ctx, config, role)
44 yield
45
46 def _run_one_client(ctx, config, role):
47 """Spawned task that runs the client"""
48 krbd = config.get('krbd', False)
49 nbd = config.get('nbd', False)
50 testdir = teuthology.get_testdir(ctx)
51 (remote,) = ctx.cluster.only(role).remotes.keys()
52
53 args = []
54 if krbd or nbd:
55 args.append('sudo') # rbd(-nbd) map/unmap need privileges
56 args.extend([
57 'adjust-ulimits',
58 'ceph-coverage',
59 '{tdir}/archive/coverage'.format(tdir=testdir)
60 ])
61
62 overrides = ctx.config.get('overrides', {})
63 teuthology.deep_merge(config, overrides.get('rbd_fsx', {}))
64
65 if config.get('valgrind'):
66 args = get_valgrind_args(
67 testdir,
68 'fsx_{id}'.format(id=role),
69 args,
70 config.get('valgrind')
71 )
72
73 cluster_name, type_, client_id = teuthology.split_role(role)
74 if type_ != 'client':
75 msg = 'client role ({0}) must be a client'.format(role)
76 raise ConfigError(msg)
77
78 args.extend([
79 'ceph_test_librbd_fsx',
80 '--cluster', cluster_name,
81 '--id', client_id,
82 '-d', # debug output for all operations
83 '-W', '-R', # mmap doesn't work with rbd
84 '-p', str(config.get('progress_interval', 100)), # show progress
85 '-P', '{tdir}/archive'.format(tdir=testdir),
86 '-r', str(config.get('readbdy',1)),
87 '-w', str(config.get('writebdy',1)),
88 '-t', str(config.get('truncbdy',1)),
89 '-h', str(config.get('holebdy',1)),
90 '-l', str(config.get('size', 250000000)),
91 '-S', str(config.get('seed', 0)),
92 '-N', str(config.get('ops', 1000)),
93 ])
94 if krbd:
95 args.append('-K') # -K enables krbd mode
96 if nbd:
97 args.append('-M') # -M enables nbd mode
98 if config.get('direct_io', False):
99 args.append('-Z') # -Z use direct IO
100 if not config.get('randomized_striping', True):
101 args.append('-U') # -U disables randomized striping
102 if not config.get('punch_holes', True):
103 args.append('-H') # -H disables discard ops
104 if config.get('deep_copy', False):
105 args.append('-g') # -g deep copy instead of clone
106 if config.get('journal_replay', False):
107 args.append('-j') # -j replay all IO events from journal
108 if config.get('keep_images', False):
109 args.append('-k') # -k keep images on success
110 args.extend([
111 config.get('pool_name', 'pool_{pool}'.format(pool=role)),
112 'image_{image}'.format(image=role),
113 ])
114
115 remote.run(args=args)