6 from teuthology.orchestra import run
7 from teuthology import misc as teuthology
9 log = logging.getLogger(__name__)
11 def task(ctx, config):
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.
17 The config is a list of two clients to run the locktest on. The
18 first client will be the host.
23 - ceph-fuse: [client.0, client.1]
27 This task does not yield; there would be little point.
30 :param config: Configuration
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)
44 for client_name in config:
45 log.info('building on {client_}'.format(client_=client_name))
46 ctx.cluster.only(client_name).run(
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),
52 'mkdir', '{tdir}/locktest'.format(tdir=testdir),
56 'https://raw.github.com/gregsfortytwo/xfstests-ceph/master/src/locktest.c',
57 '-O', '{tdir}/locktest/locktest.c'.format(tdir=testdir),
59 'g++', '{tdir}/locktest/locktest.c'.format(tdir=testdir),
60 '-o', '{tdir}/locktest/locktest'.format(tdir=testdir)
62 logger=log.getChild('locktest_client.{id}'.format(id=client_name)),
65 log.info('built locktest on each client')
67 host.run(args=['sudo', 'touch',
68 '{mnt}/locktestfile'.format(mnt=hostmnt),
70 'sudo', 'chown', 'ubuntu.ubuntu',
71 '{mnt}/locktestfile'.format(mnt=hostmnt)
75 log.info('starting on host')
78 '{tdir}/locktest/locktest'.format(tdir=testdir),
81 '{mnt}/locktestfile'.format(mnt=hostmnt),
84 logger=log.getChild('locktest.host'),
86 log.info('starting on client')
87 (_,_,hostaddr) = host.name.partition('@')
88 clientproc = client.run(
90 '{tdir}/locktest/locktest'.format(tdir=testdir),
94 '{mnt}/locktestfile'.format(mnt=clientmnt),
96 logger=log.getChild('locktest.client'),
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))
108 log.info('cleaning up host dir')
111 'mkdir', '-p', '{tdir}/locktest'.format(tdir=testdir),
113 'rm', '-f', '{tdir}/locktest/locktest.c'.format(tdir=testdir),
115 'rm', '-f', '{tdir}/locktest/locktest'.format(tdir=testdir),
117 'rmdir', '{tdir}/locktest'
119 logger=log.getChild('.{id}'.format(id=config[0])),
121 log.info('cleaning up client dir')
124 'mkdir', '-p', '{tdir}/locktest'.format(tdir=testdir),
126 'rm', '-f', '{tdir}/locktest/locktest.c'.format(tdir=testdir),
128 'rm', '-f', '{tdir}/locktest/locktest'.format(tdir=testdir),
130 'rmdir', '{tdir}/locktest'.format(tdir=testdir)
132 logger=log.getChild('.{id}'.format(\