2 Run an autotest test on the ceph cluster.
8 from teuthology import misc as teuthology
9 from teuthology.parallel import parallel
10 from teuthology.orchestra import run
12 log = logging.getLogger(__name__)
14 def task(ctx, config):
16 Run an autotest test on the ceph cluster.
18 Only autotest client tests are supported.
20 The config is a mapping from role name to list of tests to run on
27 - ceph-fuse: [client.0, client.1]
32 You can also specify a list of tests to run on all clients::
40 assert isinstance(config, dict)
41 config = teuthology.replace_all_with_clients(ctx.cluster, config)
42 log.info('Setting up autotest...')
43 testdir = teuthology.get_testdir(ctx)
45 for role in config.iterkeys():
46 (remote,) = ctx.cluster.only(role).remotes.keys()
47 p.spawn(_download, testdir, remote)
49 log.info('Making a separate scratch dir for every client...')
50 for role in config.iterkeys():
51 assert isinstance(role, basestring)
53 assert role.startswith(PREFIX)
54 id_ = role[len(PREFIX):]
55 (remote,) = ctx.cluster.only(role).remotes.iterkeys()
56 mnt = os.path.join(testdir, 'mnt.{id}'.format(id=id_))
57 scratch = os.path.join(mnt, 'client.{id}'.format(id=id_))
64 '--owner={user}'.format(user='ubuntu'), #TODO
71 for role, tests in config.iteritems():
72 (remote,) = ctx.cluster.only(role).remotes.keys()
73 p.spawn(_run_tests, testdir, remote, role, tests)
75 def _download(testdir, remote):
77 Download. Does not explicitly support muliple tasks in a single run.
81 # explicitly does not support multiple autotest tasks
82 # in a single run; the result archival would conflict
83 'mkdir', '{tdir}/archive/autotest'.format(tdir=testdir),
85 'mkdir', '{tdir}/autotest'.format(tdir=testdir),
89 '--no-check-certificate',
90 'https://github.com/ceph/autotest/tarball/ceph',
94 '-C', '{tdir}/autotest'.format(tdir=testdir),
98 '--strip-components=1',
102 def _run_tests(testdir, remote, role, tests):
104 Spawned to run test on remote site
106 assert isinstance(role, basestring)
108 assert role.startswith(PREFIX)
109 id_ = role[len(PREFIX):]
110 mnt = os.path.join(testdir, 'mnt.{id}'.format(id=id_))
111 scratch = os.path.join(mnt, 'client.{id}'.format(id=id_))
113 assert isinstance(tests, list)
114 for idx, testname in enumerate(tests):
115 log.info('Running autotest client test #%d: %s...', idx, testname)
117 tag = 'client.{id}.num{idx}.{testname}'.format(
122 control = '{tdir}/control.{tag}'.format(tdir=testdir, tag=tag)
123 teuthology.write_file(
126 data='import json; data=json.loads({data!r}); job.run_test(**data)'.format(
127 data=json.dumps(dict(
131 # results will be in {testdir}/autotest/client/results/dbench
132 # or {testdir}/autotest/client/results/dbench.{tag}
138 '{tdir}/autotest/client/bin/autotest'.format(tdir=testdir),
141 '--tag={tag}'.format(tag=tag),
149 'rm', '-rf', '--', control,
157 '{tdir}/autotest/client/results/{tag}'.format(tdir=testdir, tag=tag),
158 '{tdir}/archive/autotest/{tag}'.format(tdir=testdir, tag=tag),
164 'rm', '-rf', '--', '{tdir}/autotest'.format(tdir=testdir),