]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | """ |
2 | Run fsx on an rbd image | |
3 | """ | |
4 | import contextlib | |
5 | import logging | |
6 | ||
9f95a23c | 7 | from teuthology.exceptions import ConfigError |
7c673cae FG |
8 | from teuthology.parallel import parallel |
9 | from teuthology import misc as teuthology | |
f67539c2 | 10 | from tasks.ceph_manager import get_valgrind_args |
7c673cae FG |
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) | |
9f95a23c | 51 | (remote,) = ctx.cluster.only(role).remotes.keys() |
7c673cae FG |
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'): | |
f67539c2 | 66 | args = get_valgrind_args( |
7c673cae FG |
67 | testdir, |
68 | 'fsx_{id}'.format(id=role), | |
69 | args, | |
70 | config.get('valgrind') | |
71 | ) | |
72 | ||
11fdf7f2 TL |
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 | ||
7c673cae FG |
78 | args.extend([ |
79 | 'ceph_test_librbd_fsx', | |
11fdf7f2 TL |
80 | '--cluster', cluster_name, |
81 | '--id', client_id, | |
7c673cae FG |
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 | |
11fdf7f2 TL |
104 | if config.get('deep_copy', False): |
105 | args.append('-g') # -g deep copy instead of clone | |
7c673cae FG |
106 | if config.get('journal_replay', False): |
107 | args.append('-j') # -j replay all IO events from journal | |
11fdf7f2 TL |
108 | if config.get('keep_images', False): |
109 | args.append('-k') # -k keep images on success | |
7c673cae | 110 | args.extend([ |
11fdf7f2 | 111 | config.get('pool_name', 'pool_{pool}'.format(pool=role)), |
7c673cae FG |
112 | 'image_{image}'.format(image=role), |
113 | ]) | |
114 | ||
115 | remote.run(args=args) |