]> git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/locktest.py
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / qa / tasks / locktest.py
1 """
2 locktests
3 """
4 import logging
5
6 from teuthology.orchestra import run
7 from teuthology import misc as teuthology
8
9 log = logging.getLogger(__name__)
10
11 def task(ctx, config):
12 """
13 Run locktests, from the xfstests suite, on the given
14 clients. Whether the clients are ceph-fuse or kernel does not
15 matter, and the two clients can refer to the same mount.
16
17 The config is a list of two clients to run the locktest on. The
18 first client will be the host.
19
20 For example:
21 tasks:
22 - ceph:
23 - ceph-fuse: [client.0, client.1]
24 - locktest:
25 [client.0, client.1]
26
27 This task does not yield; there would be little point.
28
29 :param ctx: Context
30 :param config: Configuration
31 """
32
33 assert isinstance(config, list)
34 log.info('fetching and building locktests...')
35 (host,) = ctx.cluster.only(config[0]).remotes
36 (client,) = ctx.cluster.only(config[1]).remotes
37 ( _, _, host_id) = config[0].partition('.')
38 ( _, _, client_id) = config[1].partition('.')
39 testdir = teuthology.get_testdir(ctx)
40 hostmnt = '{tdir}/mnt.{id}'.format(tdir=testdir, id=host_id)
41 clientmnt = '{tdir}/mnt.{id}'.format(tdir=testdir, id=client_id)
42
43 try:
44 for client_name in config:
45 log.info('building on {client_}'.format(client_=client_name))
46 ctx.cluster.only(client_name).run(
47 args=[
48 # explicitly does not support multiple autotest tasks
49 # in a single run; the result archival would conflict
50 'mkdir', '{tdir}/archive/locktest'.format(tdir=testdir),
51 run.Raw('&&'),
52 'mkdir', '{tdir}/locktest'.format(tdir=testdir),
53 run.Raw('&&'),
54 'wget',
55 '-nv',
56 'https://raw.github.com/gregsfortytwo/xfstests-ceph/master/src/locktest.c',
57 '-O', '{tdir}/locktest/locktest.c'.format(tdir=testdir),
58 run.Raw('&&'),
59 'g++', '{tdir}/locktest/locktest.c'.format(tdir=testdir),
60 '-o', '{tdir}/locktest/locktest'.format(tdir=testdir)
61 ],
62 logger=log.getChild('locktest_client.{id}'.format(id=client_name)),
63 )
64
65 log.info('built locktest on each client')
66
67 host.run(args=['sudo', 'touch',
68 '{mnt}/locktestfile'.format(mnt=hostmnt),
69 run.Raw('&&'),
70 'sudo', 'chown', 'ubuntu.ubuntu',
71 '{mnt}/locktestfile'.format(mnt=hostmnt)
72 ]
73 )
74
75 log.info('starting on host')
76 hostproc = host.run(
77 args=[
78 '{tdir}/locktest/locktest'.format(tdir=testdir),
79 '-p', '6788',
80 '-d',
81 '{mnt}/locktestfile'.format(mnt=hostmnt),
82 ],
83 wait=False,
84 logger=log.getChild('locktest.host'),
85 )
86 log.info('starting on client')
87 (_,_,hostaddr) = host.name.partition('@')
88 clientproc = client.run(
89 args=[
90 '{tdir}/locktest/locktest'.format(tdir=testdir),
91 '-p', '6788',
92 '-d',
93 '-h', hostaddr,
94 '{mnt}/locktestfile'.format(mnt=clientmnt),
95 ],
96 logger=log.getChild('locktest.client'),
97 wait=False
98 )
99
100 hostresult = hostproc.wait()
101 clientresult = clientproc.wait()
102 if (hostresult != 0) or (clientresult != 0):
103 raise Exception("Did not pass locking test!")
104 log.info('finished locktest executable with results {r} and {s}'. \
105 format(r=hostresult, s=clientresult))
106
107 finally:
108 log.info('cleaning up host dir')
109 host.run(
110 args=[
111 'mkdir', '-p', '{tdir}/locktest'.format(tdir=testdir),
112 run.Raw('&&'),
113 'rm', '-f', '{tdir}/locktest/locktest.c'.format(tdir=testdir),
114 run.Raw('&&'),
115 'rm', '-f', '{tdir}/locktest/locktest'.format(tdir=testdir),
116 run.Raw('&&'),
117 'rmdir', '{tdir}/locktest'
118 ],
119 logger=log.getChild('.{id}'.format(id=config[0])),
120 )
121 log.info('cleaning up client dir')
122 client.run(
123 args=[
124 'mkdir', '-p', '{tdir}/locktest'.format(tdir=testdir),
125 run.Raw('&&'),
126 'rm', '-f', '{tdir}/locktest/locktest.c'.format(tdir=testdir),
127 run.Raw('&&'),
128 'rm', '-f', '{tdir}/locktest/locktest'.format(tdir=testdir),
129 run.Raw('&&'),
130 'rmdir', '{tdir}/locktest'.format(tdir=testdir)
131 ],
132 logger=log.getChild('.{id}'.format(\
133 id=config[1])),
134 )