2011-06-02 22:04:01 +00:00
|
|
|
import contextlib
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
|
|
|
from teuthology import misc as teuthology
|
2011-09-13 21:53:02 +00:00
|
|
|
from ..orchestra import run
|
2011-06-02 22:04:01 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
@contextlib.contextmanager
|
|
|
|
def task(ctx, config):
|
2011-06-06 21:22:49 +00:00
|
|
|
"""
|
|
|
|
Mount/unmount a ``cfuse`` client.
|
|
|
|
|
2011-06-16 23:07:59 +00:00
|
|
|
The config is optional and defaults to mounting on all clients. If
|
|
|
|
a config is given, it is expected to be a list of clients to do
|
|
|
|
this operation on. This lets you e.g. set up one client with
|
|
|
|
``cfuse`` and another with ``kclient``.
|
|
|
|
|
|
|
|
Example that mounts all clients::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- cfuse:
|
|
|
|
- interactive:
|
|
|
|
|
|
|
|
Example that uses both ``kclient` and ``cfuse``::
|
2011-06-06 21:22:49 +00:00
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- cfuse: [client.0]
|
2011-06-16 23:07:59 +00:00
|
|
|
- kclient: [client.1]
|
2011-06-06 21:22:49 +00:00
|
|
|
- interactive:
|
2011-08-24 21:07:11 +00:00
|
|
|
|
|
|
|
Example that enables valgrind:
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- cfuse:
|
|
|
|
client.0:
|
|
|
|
valgrind: --tool=memcheck
|
|
|
|
- interactive:
|
|
|
|
|
2011-06-06 21:22:49 +00:00
|
|
|
"""
|
2011-06-02 22:04:01 +00:00
|
|
|
log.info('Mounting cfuse clients...')
|
|
|
|
cfuse_daemons = {}
|
|
|
|
|
2011-06-16 23:07:59 +00:00
|
|
|
if config is None:
|
2011-08-24 21:07:11 +00:00
|
|
|
config = dict(('client.{id}'.format(id=id_), None)
|
|
|
|
for id_ in teuthology.all_roles_of_type(ctx.cluster, 'client'))
|
|
|
|
elif isinstance(config, list):
|
|
|
|
config = dict((name, None) for name in config)
|
|
|
|
|
|
|
|
clients = list(teuthology.get_clients(ctx=ctx, roles=config.keys()))
|
2011-06-16 23:07:59 +00:00
|
|
|
|
|
|
|
for id_, remote in clients:
|
2011-06-02 22:04:01 +00:00
|
|
|
mnt = os.path.join('/tmp/cephtest', 'mnt.{id}'.format(id=id_))
|
2011-08-04 22:03:05 +00:00
|
|
|
log.info('Mounting cfuse client.{id} at {remote} {mnt}...'.format(
|
|
|
|
id=id_, remote=remote,mnt=mnt))
|
|
|
|
|
2011-08-24 21:07:11 +00:00
|
|
|
client_config = config.get("client.%s" % id_)
|
|
|
|
if client_config is None:
|
|
|
|
client_config = {}
|
|
|
|
log.info("Client client.%s config is %s" % (id_, client_config))
|
|
|
|
|
|
|
|
daemon_signal = 'kill'
|
|
|
|
if client_config.get('coverage'):
|
|
|
|
log.info('Recording coverage for this run.')
|
|
|
|
daemon_signal = 'term'
|
|
|
|
|
2011-06-02 22:04:01 +00:00
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'mkdir',
|
|
|
|
'--',
|
|
|
|
mnt,
|
|
|
|
],
|
|
|
|
)
|
2011-08-24 21:07:11 +00:00
|
|
|
|
|
|
|
run_cmd=[
|
|
|
|
'/tmp/cephtest/enable-coredump',
|
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
'/tmp/cephtest/archive/coverage',
|
|
|
|
'/tmp/cephtest/daemon-helper',
|
|
|
|
]
|
|
|
|
run_cmd_tail=[
|
|
|
|
'/tmp/cephtest/binary/usr/local/bin/cfuse',
|
|
|
|
'-f',
|
|
|
|
'--name', 'client.{id}'.format(id=id_),
|
|
|
|
'-c', '/tmp/cephtest/ceph.conf',
|
|
|
|
# TODO cfuse doesn't understand dash dash '--',
|
|
|
|
mnt,
|
|
|
|
]
|
|
|
|
|
|
|
|
extra_args = None
|
|
|
|
if client_config.get('valgrind') is not None:
|
|
|
|
log.debug('Running client.{id} under valgrind'.format(id=id_))
|
|
|
|
val_path = '/tmp/cephtest/archive/log/valgrind'
|
|
|
|
daemon_signal = 'term'
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'mkdir', '-p', '--', val_path,
|
|
|
|
],
|
|
|
|
wait=True,
|
|
|
|
)
|
|
|
|
extra_args = [
|
|
|
|
'valgrind',
|
|
|
|
'--log-file={vdir}/client.{id}.log'.format(vdir=val_path,
|
|
|
|
id=id_),
|
|
|
|
client_config.get('valgrind')
|
|
|
|
]
|
|
|
|
|
|
|
|
run_cmd.append(daemon_signal)
|
|
|
|
if extra_args is not None:
|
|
|
|
run_cmd.extend(extra_args)
|
|
|
|
run_cmd.extend(run_cmd_tail)
|
|
|
|
|
2011-06-02 22:04:01 +00:00
|
|
|
proc = remote.run(
|
2011-08-24 21:07:11 +00:00
|
|
|
args=run_cmd,
|
2011-06-02 22:04:01 +00:00
|
|
|
logger=log.getChild('cfuse.{id}'.format(id=id_)),
|
|
|
|
stdin=run.PIPE,
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
cfuse_daemons[id_] = proc
|
|
|
|
|
2011-06-16 23:07:59 +00:00
|
|
|
for id_, remote in clients:
|
2011-06-02 22:04:01 +00:00
|
|
|
mnt = os.path.join('/tmp/cephtest', 'mnt.{id}'.format(id=id_))
|
|
|
|
teuthology.wait_until_fuse_mounted(
|
|
|
|
remote=remote,
|
|
|
|
fuse=cfuse_daemons[id_],
|
|
|
|
mountpoint=mnt,
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
log.info('Unmounting cfuse clients...')
|
2011-06-16 23:07:59 +00:00
|
|
|
for id_, remote in clients:
|
2011-06-02 22:04:01 +00:00
|
|
|
mnt = os.path.join('/tmp/cephtest', 'mnt.{id}'.format(id=id_))
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'fusermount',
|
|
|
|
'-u',
|
|
|
|
mnt,
|
|
|
|
],
|
|
|
|
)
|
|
|
|
run.wait(cfuse_daemons.itervalues())
|
2011-06-06 22:38:20 +00:00
|
|
|
|
2011-06-16 23:07:59 +00:00
|
|
|
for id_, remote in clients:
|
2011-06-06 22:38:20 +00:00
|
|
|
mnt = os.path.join('/tmp/cephtest', 'mnt.{id}'.format(id=id_))
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'rmdir',
|
|
|
|
'--',
|
|
|
|
mnt,
|
|
|
|
],
|
|
|
|
)
|