2011-05-31 20:51:48 +00:00
|
|
|
from cStringIO import StringIO
|
|
|
|
|
2011-06-03 21:47:44 +00:00
|
|
|
import contextlib
|
2011-07-13 19:07:36 +00:00
|
|
|
import errno
|
2011-05-31 20:51:48 +00:00
|
|
|
import logging
|
|
|
|
import os
|
2011-07-13 18:32:28 +00:00
|
|
|
import shutil
|
2011-07-13 19:07:36 +00:00
|
|
|
import subprocess
|
2011-07-13 17:58:01 +00:00
|
|
|
import tempfile
|
2011-05-31 20:51:48 +00:00
|
|
|
|
2011-06-03 21:47:44 +00:00
|
|
|
from teuthology import misc as teuthology
|
2011-06-15 21:57:02 +00:00
|
|
|
from teuthology import contextutil
|
2011-07-14 20:57:07 +00:00
|
|
|
from teuthology.parallel import parallel
|
2011-09-13 21:53:02 +00:00
|
|
|
from ..orchestra import run
|
2011-05-31 20:51:48 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2011-09-14 23:31:58 +00:00
|
|
|
class DaemonState(object):
|
|
|
|
def __init__(self, remote, role, id_, *command_args, **command_kwargs):
|
|
|
|
self.remote = remote
|
|
|
|
self.command_args = command_args
|
|
|
|
self.command_kwargs = command_kwargs
|
|
|
|
self.role = role
|
|
|
|
self.id_ = id_
|
|
|
|
self.logger = command_kwargs.get("logger", None)
|
|
|
|
self.proc = None
|
|
|
|
|
|
|
|
def log(self, msg):
|
|
|
|
if self.logger is not None:
|
|
|
|
self.logger.info("%s.%s: %s"%(self.role, self.id_, msg))
|
|
|
|
|
|
|
|
def stop(self):
|
|
|
|
if self.proc is not None:
|
|
|
|
self.proc.stdin.close()
|
|
|
|
run.wait([self.proc])
|
|
|
|
self.proc = None;
|
|
|
|
self.log("Stopped")
|
|
|
|
|
|
|
|
def restart(self):
|
|
|
|
self.log("Restarting")
|
|
|
|
self.stop()
|
|
|
|
self.proc = self.remote.run(*self.command_args, **self.command_kwargs)
|
|
|
|
self.log("Started")
|
|
|
|
|
|
|
|
def running(self):
|
|
|
|
return self.proc is not None
|
|
|
|
|
|
|
|
|
|
|
|
class CephState(object):
|
|
|
|
def __init__(self):
|
|
|
|
self.daemons = {}
|
|
|
|
|
|
|
|
def add_daemon(self, remote, role, id_, *args, **kwargs):
|
|
|
|
if role not in self.daemons:
|
|
|
|
self.daemons[role] = {}
|
|
|
|
if id_ in self.daemons[role]:
|
|
|
|
self.daemons[role][id_].stop()
|
|
|
|
self.daemons[role][id_] = None
|
|
|
|
self.daemons[role][id_] = DaemonState(remote, role, id_, *args, **kwargs)
|
|
|
|
self.daemons[role][id_].restart()
|
|
|
|
|
|
|
|
def get_daemon(self, role, id_):
|
|
|
|
if role not in self.daemons:
|
|
|
|
return None
|
|
|
|
return self.daemons[role].get(str(id_), None)
|
|
|
|
|
|
|
|
def iter_daemons_of_role(self, role):
|
|
|
|
return self.daemons.get(role, {}).values()
|
2011-06-15 21:57:02 +00:00
|
|
|
|
2011-06-16 20:13:32 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def ceph_log(ctx, config):
|
|
|
|
log.info('Creating log directories...')
|
|
|
|
run.wait(
|
|
|
|
ctx.cluster.run(
|
|
|
|
args=[
|
|
|
|
'install', '-d', '-m0755', '--',
|
|
|
|
'/tmp/cephtest/archive/log',
|
|
|
|
'/tmp/cephtest/archive/profiling-logger',
|
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
|
|
|
|
if ctx.archive is not None:
|
|
|
|
log.info('Compressing logs...')
|
|
|
|
run.wait(
|
|
|
|
ctx.cluster.run(
|
|
|
|
args=[
|
|
|
|
'find',
|
|
|
|
'/tmp/cephtest/archive/log',
|
|
|
|
'-name',
|
|
|
|
'*.log',
|
|
|
|
'-print0',
|
|
|
|
run.Raw('|'),
|
|
|
|
'xargs',
|
|
|
|
'-0',
|
|
|
|
'--no-run-if-empty',
|
|
|
|
'--',
|
2011-07-29 17:35:02 +00:00
|
|
|
'gzip',
|
2011-06-16 20:13:32 +00:00
|
|
|
'--',
|
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
# log file transfer is done by the generic archive data
|
|
|
|
# handling
|
|
|
|
|
2011-06-15 21:57:02 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def ship_utilities(ctx, config):
|
|
|
|
assert config is None
|
2011-06-17 23:00:39 +00:00
|
|
|
FILES = ['daemon-helper', 'enable-coredump']
|
2011-06-15 21:57:02 +00:00
|
|
|
for filename in FILES:
|
|
|
|
log.info('Shipping %r...', filename)
|
|
|
|
src = os.path.join(os.path.dirname(__file__), filename)
|
|
|
|
dst = os.path.join('/tmp/cephtest', filename)
|
|
|
|
with file(src, 'rb') as f:
|
|
|
|
for rem in ctx.cluster.remotes.iterkeys():
|
|
|
|
teuthology.write_file(
|
|
|
|
remote=rem,
|
|
|
|
path=dst,
|
|
|
|
data=f,
|
|
|
|
)
|
|
|
|
f.seek(0)
|
|
|
|
rem.run(
|
|
|
|
args=[
|
|
|
|
'chmod',
|
|
|
|
'a=rx',
|
|
|
|
'--',
|
|
|
|
dst,
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
log.info('Removing shipped files: %s...', ' '.join(FILES))
|
|
|
|
filenames = (
|
|
|
|
os.path.join('/tmp/cephtest', filename)
|
|
|
|
for filename in FILES
|
|
|
|
)
|
|
|
|
run.wait(
|
|
|
|
ctx.cluster.run(
|
|
|
|
args=[
|
|
|
|
'rm',
|
|
|
|
'-rf',
|
|
|
|
'--',
|
|
|
|
] + list(filenames),
|
|
|
|
wait=False,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2011-06-22 17:57:16 +00:00
|
|
|
def _download_binaries(remote, ceph_bindir_url):
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'install', '-d', '-m0755', '--', '/tmp/cephtest/binary',
|
|
|
|
run.Raw('&&'),
|
|
|
|
'uname', '-m',
|
|
|
|
run.Raw('|'),
|
|
|
|
'sed', '-e', 's/^/ceph./; s/$/.tgz/',
|
|
|
|
run.Raw('|'),
|
|
|
|
'wget',
|
|
|
|
'-nv',
|
|
|
|
'-O-',
|
|
|
|
'--base={url}'.format(url=ceph_bindir_url),
|
|
|
|
# need to use --input-file to make wget respect --base
|
|
|
|
'--input-file=-',
|
|
|
|
run.Raw('|'),
|
|
|
|
'tar', '-xzf', '-', '-C', '/tmp/cephtest/binary',
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2011-06-15 21:57:02 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def binaries(ctx, config):
|
2011-07-13 17:17:04 +00:00
|
|
|
path = config.get('path')
|
2011-06-30 21:49:42 +00:00
|
|
|
tmpdir = None
|
|
|
|
|
2011-07-13 17:17:04 +00:00
|
|
|
if path is None:
|
2011-06-30 21:49:42 +00:00
|
|
|
# fetch from gitbuilder gitbuilder
|
|
|
|
log.info('Fetching and unpacking ceph binaries from gitbuilder...')
|
|
|
|
sha1, ceph_bindir_url = teuthology.get_ceph_binary_url(
|
|
|
|
branch=config.get('branch'),
|
|
|
|
tag=config.get('tag'),
|
|
|
|
sha1=config.get('sha1'),
|
|
|
|
flavor=config.get('flavor'),
|
|
|
|
)
|
2011-07-13 19:38:12 +00:00
|
|
|
ctx.summary['ceph-sha1'] = sha1
|
2011-06-30 21:49:42 +00:00
|
|
|
if ctx.archive is not None:
|
|
|
|
with file(os.path.join(ctx.archive, 'ceph-sha1'), 'w') as f:
|
|
|
|
f.write(sha1 + '\n')
|
2011-06-22 17:57:16 +00:00
|
|
|
|
2011-07-14 20:57:07 +00:00
|
|
|
with parallel() as p:
|
|
|
|
for remote in ctx.cluster.remotes.iterkeys():
|
|
|
|
p.spawn(_download_binaries, remote, ceph_bindir_url)
|
2011-06-30 21:49:42 +00:00
|
|
|
else:
|
2011-07-13 19:18:55 +00:00
|
|
|
with tempfile.TemporaryFile(prefix='teuthology-tarball-', suffix='.tgz') as tar_fp:
|
|
|
|
tmpdir = tempfile.mkdtemp(prefix='teuthology-tarball-')
|
2011-07-13 19:07:36 +00:00
|
|
|
try:
|
2011-07-13 19:18:55 +00:00
|
|
|
log.info('Installing %s to %s...' % (path, tmpdir))
|
|
|
|
subprocess.check_call(
|
|
|
|
args=[
|
|
|
|
'make',
|
|
|
|
'install',
|
|
|
|
'DESTDIR={tmpdir}'.format(tmpdir=tmpdir),
|
|
|
|
],
|
|
|
|
cwd=path,
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
os.symlink('.', os.path.join(tmpdir, 'usr', 'local'))
|
|
|
|
except OSError as e:
|
|
|
|
if e.errno == errno.EEXIST:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
raise
|
|
|
|
log.info('Building ceph binary tarball from %s...', tmpdir)
|
|
|
|
subprocess.check_call(
|
|
|
|
args=[
|
|
|
|
'tar',
|
|
|
|
'cz',
|
|
|
|
'.',
|
|
|
|
],
|
|
|
|
cwd=tmpdir,
|
|
|
|
stdout=tar_fp,
|
|
|
|
)
|
|
|
|
finally:
|
|
|
|
shutil.rmtree(tmpdir, ignore_errors=True)
|
|
|
|
log.info('Pushing tarball...')
|
2011-07-13 19:34:39 +00:00
|
|
|
tar_fp.seek(0)
|
|
|
|
writes = ctx.cluster.run(
|
|
|
|
args=[
|
|
|
|
'install', '-d', '-m0755', '--', '/tmp/cephtest/binary',
|
|
|
|
run.Raw('&&'),
|
|
|
|
'tar', '-xzf', '-', '-C', '/tmp/cephtest/binary'
|
|
|
|
],
|
|
|
|
stdin=run.PIPE,
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
teuthology.feed_many_stdins_and_close(tar_fp, writes)
|
|
|
|
run.wait(writes)
|
2011-06-30 21:49:42 +00:00
|
|
|
|
2011-06-15 21:57:02 +00:00
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
log.info('Removing ceph binaries...')
|
|
|
|
run.wait(
|
|
|
|
ctx.cluster.run(
|
|
|
|
args=[
|
|
|
|
'rm',
|
|
|
|
'-rf',
|
|
|
|
'--',
|
|
|
|
'/tmp/cephtest/binary',
|
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2011-10-03 21:03:36 +00:00
|
|
|
|
|
|
|
def assign_devs(roles, devs):
|
|
|
|
return dict(zip(roles, devs))
|
|
|
|
|
2011-08-29 20:58:09 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def valgrind_post(ctx, config):
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
2011-09-02 18:07:10 +00:00
|
|
|
if config.get('valgrind'):
|
|
|
|
lookup_procs = list()
|
|
|
|
val_path = '/tmp/cephtest/archive/log/{val_dir}/*'.format(
|
|
|
|
val_dir=config.get('valgrind').get('logs', "valgrind"))
|
|
|
|
for remote in ctx.cluster.remotes.iterkeys():
|
|
|
|
#look at valgrind logs for each node
|
|
|
|
proc = remote.run(
|
|
|
|
args=[
|
|
|
|
'grep', "<kind>", run.Raw(val_path), run.Raw('|'),
|
|
|
|
'grep', '-v', '-q', "PossiblyLost"],
|
|
|
|
wait = False,
|
|
|
|
check_status=False
|
|
|
|
)
|
|
|
|
lookup_procs.append((proc, remote))
|
|
|
|
|
|
|
|
valgrind_exception = None
|
|
|
|
for (proc, remote) in lookup_procs:
|
|
|
|
result = proc.exitstatus.get()
|
|
|
|
if result is not 1:
|
|
|
|
valgrind_exception = Exception("saw valgrind issues in {node}".format(node=remote.name))
|
|
|
|
|
|
|
|
if valgrind_exception is not None:
|
|
|
|
raise valgrind_exception
|
2011-08-29 20:58:09 +00:00
|
|
|
|
|
|
|
|
2011-06-16 17:36:15 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def cluster(ctx, config):
|
|
|
|
log.info('Creating ceph cluster...')
|
2011-06-16 21:05:13 +00:00
|
|
|
run.wait(
|
|
|
|
ctx.cluster.run(
|
|
|
|
args=[
|
|
|
|
'install', '-d', '-m0755', '--',
|
|
|
|
'/tmp/cephtest/data',
|
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
)
|
2011-06-16 17:36:15 +00:00
|
|
|
|
2011-07-05 23:45:32 +00:00
|
|
|
log.info('Generating config...')
|
2011-06-16 17:36:15 +00:00
|
|
|
remotes_and_roles = ctx.cluster.remotes.items()
|
|
|
|
roles = [roles for (remote, roles) in remotes_and_roles]
|
|
|
|
ips = [host for (host, port) in (remote.ssh.get_transport().getpeername() for (remote, roles) in remotes_and_roles)]
|
|
|
|
conf = teuthology.skeleton_config(roles=roles, ips=ips)
|
2011-07-05 23:45:32 +00:00
|
|
|
for section, keys in config['conf'].iteritems():
|
|
|
|
for key, value in keys.iteritems():
|
|
|
|
log.info("[%s] %s = %s" % (section, key, value))
|
|
|
|
if section not in conf:
|
|
|
|
conf[section] = {}
|
|
|
|
conf[section][key] = value
|
2011-07-12 01:00:03 +00:00
|
|
|
|
2011-11-09 06:00:32 +00:00
|
|
|
import argparse
|
|
|
|
ctx.ceph = argparse.Namespace();
|
|
|
|
ctx.ceph.conf = conf;
|
|
|
|
|
2011-07-05 23:45:32 +00:00
|
|
|
log.info('Writing configs...')
|
2011-06-16 17:36:15 +00:00
|
|
|
conf_fp = StringIO()
|
|
|
|
conf.write(conf_fp)
|
|
|
|
conf_fp.seek(0)
|
|
|
|
writes = ctx.cluster.run(
|
|
|
|
args=[
|
|
|
|
'python',
|
|
|
|
'-c',
|
|
|
|
'import shutil, sys; shutil.copyfileobj(sys.stdin, file(sys.argv[1], "wb"))',
|
|
|
|
'/tmp/cephtest/ceph.conf',
|
|
|
|
],
|
|
|
|
stdin=run.PIPE,
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
teuthology.feed_many_stdins_and_close(conf_fp, writes)
|
|
|
|
run.wait(writes)
|
|
|
|
|
|
|
|
coverage_dir = '/tmp/cephtest/archive/coverage'
|
|
|
|
|
2011-08-31 20:56:42 +00:00
|
|
|
firstmon = teuthology.get_first_mon(ctx, config)
|
2011-07-27 04:46:47 +00:00
|
|
|
|
|
|
|
log.info('Setting up %s...' % firstmon)
|
|
|
|
ctx.cluster.only(firstmon).run(
|
2011-06-16 17:36:15 +00:00
|
|
|
args=[
|
2011-06-17 23:00:39 +00:00
|
|
|
'/tmp/cephtest/enable-coredump',
|
2011-06-16 17:36:15 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-09-23 15:57:18 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-authtool',
|
2011-06-16 17:36:15 +00:00
|
|
|
'--create-keyring',
|
|
|
|
'/tmp/cephtest/ceph.keyring',
|
|
|
|
],
|
|
|
|
)
|
2011-07-27 04:46:47 +00:00
|
|
|
ctx.cluster.only(firstmon).run(
|
2011-06-16 17:36:15 +00:00
|
|
|
args=[
|
2011-06-17 23:00:39 +00:00
|
|
|
'/tmp/cephtest/enable-coredump',
|
2011-06-16 17:36:15 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-09-23 15:57:18 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-authtool',
|
2011-06-16 17:36:15 +00:00
|
|
|
'--gen-key',
|
|
|
|
'--name=mon.',
|
|
|
|
'/tmp/cephtest/ceph.keyring',
|
|
|
|
],
|
|
|
|
)
|
2011-07-27 04:46:47 +00:00
|
|
|
(mon0_remote,) = ctx.cluster.only(firstmon).remotes.keys()
|
2011-06-16 17:36:15 +00:00
|
|
|
teuthology.create_simple_monmap(
|
|
|
|
remote=mon0_remote,
|
|
|
|
conf=conf,
|
|
|
|
)
|
|
|
|
|
2011-07-27 04:46:47 +00:00
|
|
|
log.info('Creating admin key on %s...' % firstmon)
|
|
|
|
ctx.cluster.only(firstmon).run(
|
2011-06-16 17:36:15 +00:00
|
|
|
args=[
|
2011-06-17 23:00:39 +00:00
|
|
|
'/tmp/cephtest/enable-coredump',
|
2011-06-16 17:36:15 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-09-23 15:57:18 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-authtool',
|
2011-06-16 17:36:15 +00:00
|
|
|
'--gen-key',
|
|
|
|
'--name=client.admin',
|
|
|
|
'--set-uid=0',
|
|
|
|
'--cap', 'mon', 'allow *',
|
|
|
|
'--cap', 'osd', 'allow *',
|
|
|
|
'--cap', 'mds', 'allow',
|
|
|
|
'/tmp/cephtest/ceph.keyring',
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2011-07-07 22:40:37 +00:00
|
|
|
log.info('Copying monmap to all nodes...')
|
2011-06-16 17:36:15 +00:00
|
|
|
keyring = teuthology.get_file(
|
|
|
|
remote=mon0_remote,
|
|
|
|
path='/tmp/cephtest/ceph.keyring',
|
|
|
|
)
|
|
|
|
monmap = teuthology.get_file(
|
|
|
|
remote=mon0_remote,
|
|
|
|
path='/tmp/cephtest/monmap',
|
|
|
|
)
|
|
|
|
|
2011-07-07 22:40:37 +00:00
|
|
|
for rem in ctx.cluster.remotes.iterkeys():
|
2011-06-16 17:36:15 +00:00
|
|
|
# copy mon key and initial monmap
|
2011-07-07 22:40:37 +00:00
|
|
|
log.info('Sending monmap to node {remote}'.format(remote=rem))
|
2011-06-16 17:36:15 +00:00
|
|
|
teuthology.write_file(
|
|
|
|
remote=rem,
|
|
|
|
path='/tmp/cephtest/ceph.keyring',
|
|
|
|
data=keyring,
|
|
|
|
)
|
|
|
|
teuthology.write_file(
|
|
|
|
remote=rem,
|
|
|
|
path='/tmp/cephtest/monmap',
|
|
|
|
data=monmap,
|
|
|
|
)
|
|
|
|
|
|
|
|
log.info('Setting up mon nodes...')
|
2011-07-07 22:40:37 +00:00
|
|
|
mons = ctx.cluster.only(teuthology.is_type('mon'))
|
2011-06-16 17:36:15 +00:00
|
|
|
run.wait(
|
|
|
|
mons.run(
|
|
|
|
args=[
|
2011-06-17 23:00:39 +00:00
|
|
|
'/tmp/cephtest/enable-coredump',
|
2011-06-16 17:36:15 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
|
|
|
'/tmp/cephtest/binary/usr/local/bin/osdmaptool',
|
|
|
|
'--clobber',
|
|
|
|
'--createsimple', '{num:d}'.format(
|
|
|
|
num=teuthology.num_instances_of_type(ctx.cluster, 'osd'),
|
|
|
|
),
|
|
|
|
'/tmp/cephtest/osdmap',
|
|
|
|
'--pg_bits', '2',
|
|
|
|
'--pgp_bits', '4',
|
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
log.info('Setting up osd nodes...')
|
|
|
|
osds = ctx.cluster.only(teuthology.is_type('osd'))
|
|
|
|
for remote, roles_for_host in osds.remotes.iteritems():
|
|
|
|
for id_ in teuthology.roles_of_type(roles_for_host, 'osd'):
|
|
|
|
remote.run(
|
|
|
|
args=[
|
2011-06-17 23:00:39 +00:00
|
|
|
'/tmp/cephtest/enable-coredump',
|
2011-06-16 17:36:15 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-09-23 15:57:18 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-authtool',
|
2011-06-16 17:36:15 +00:00
|
|
|
'--create-keyring',
|
|
|
|
'--gen-key',
|
|
|
|
'--name=osd.{id}'.format(id=id_),
|
|
|
|
'/tmp/cephtest/data/osd.{id}.keyring'.format(id=id_),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
log.info('Setting up mds nodes...')
|
|
|
|
mdss = ctx.cluster.only(teuthology.is_type('mds'))
|
|
|
|
for remote, roles_for_host in mdss.remotes.iteritems():
|
|
|
|
for id_ in teuthology.roles_of_type(roles_for_host, 'mds'):
|
|
|
|
remote.run(
|
|
|
|
args=[
|
2011-06-17 23:00:39 +00:00
|
|
|
'/tmp/cephtest/enable-coredump',
|
2011-06-16 17:36:15 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-09-23 15:57:18 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-authtool',
|
2011-06-16 17:36:15 +00:00
|
|
|
'--create-keyring',
|
|
|
|
'--gen-key',
|
|
|
|
'--name=mds.{id}'.format(id=id_),
|
|
|
|
'/tmp/cephtest/data/mds.{id}.keyring'.format(id=id_),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
log.info('Setting up client nodes...')
|
|
|
|
clients = ctx.cluster.only(teuthology.is_type('client'))
|
|
|
|
for remote, roles_for_host in clients.remotes.iteritems():
|
|
|
|
for id_ in teuthology.roles_of_type(roles_for_host, 'client'):
|
|
|
|
remote.run(
|
|
|
|
args=[
|
2011-06-17 23:00:39 +00:00
|
|
|
'/tmp/cephtest/enable-coredump',
|
2011-06-16 17:36:15 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-09-23 15:57:18 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-authtool',
|
2011-06-16 17:36:15 +00:00
|
|
|
'--create-keyring',
|
|
|
|
'--gen-key',
|
|
|
|
# TODO this --name= is not really obeyed, all unknown "types" are munged to "client"
|
|
|
|
'--name=client.{id}'.format(id=id_),
|
|
|
|
'/tmp/cephtest/data/client.{id}.keyring'.format(id=id_),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
log.info('Reading keys from all nodes...')
|
|
|
|
keys_fp = StringIO()
|
|
|
|
keys = []
|
|
|
|
for remote, roles_for_host in ctx.cluster.remotes.iteritems():
|
2011-07-12 01:00:03 +00:00
|
|
|
for type_ in ['osd', 'mds', 'client']:
|
2011-06-16 17:36:15 +00:00
|
|
|
for id_ in teuthology.roles_of_type(roles_for_host, type_):
|
|
|
|
data = teuthology.get_file(
|
|
|
|
remote=remote,
|
|
|
|
path='/tmp/cephtest/data/{type}.{id}.keyring'.format(
|
|
|
|
type=type_,
|
|
|
|
id=id_,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
keys.append((type_, id_, data))
|
|
|
|
keys_fp.write(data)
|
|
|
|
|
|
|
|
log.info('Adding keys to all mons...')
|
|
|
|
writes = mons.run(
|
|
|
|
args=[
|
|
|
|
'cat',
|
|
|
|
run.Raw('>>'),
|
|
|
|
'/tmp/cephtest/ceph.keyring',
|
|
|
|
],
|
|
|
|
stdin=run.PIPE,
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
keys_fp.seek(0)
|
|
|
|
teuthology.feed_many_stdins_and_close(keys_fp, writes)
|
|
|
|
run.wait(writes)
|
|
|
|
for type_, id_, data in keys:
|
|
|
|
run.wait(
|
|
|
|
mons.run(
|
|
|
|
args=[
|
2011-06-17 23:00:39 +00:00
|
|
|
'/tmp/cephtest/enable-coredump',
|
2011-06-16 17:36:15 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-09-23 15:57:18 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-authtool',
|
2011-06-16 17:36:15 +00:00
|
|
|
'/tmp/cephtest/ceph.keyring',
|
|
|
|
'--name={type}.{id}'.format(
|
|
|
|
type=type_,
|
|
|
|
id=id_,
|
|
|
|
),
|
|
|
|
] + list(teuthology.generate_caps(type_)),
|
|
|
|
wait=False,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
log.info('Running mkfs on mon nodes...')
|
|
|
|
for remote, roles_for_host in mons.remotes.iteritems():
|
|
|
|
for id_ in teuthology.roles_of_type(roles_for_host, 'mon'):
|
|
|
|
remote.run(
|
|
|
|
args=[
|
2011-06-17 23:00:39 +00:00
|
|
|
'/tmp/cephtest/enable-coredump',
|
2011-06-16 17:36:15 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-09-23 15:57:18 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-mon',
|
2011-06-16 17:36:15 +00:00
|
|
|
'--mkfs',
|
|
|
|
'-i', id_,
|
|
|
|
'-c', '/tmp/cephtest/ceph.conf',
|
|
|
|
'--monmap=/tmp/cephtest/monmap',
|
|
|
|
'--osdmap=/tmp/cephtest/osdmap',
|
|
|
|
'--keyring=/tmp/cephtest/ceph.keyring',
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
log.info('Running mkfs on osd nodes...')
|
2011-10-03 21:03:36 +00:00
|
|
|
devs_to_clean = {}
|
2011-06-16 17:36:15 +00:00
|
|
|
for remote, roles_for_host in osds.remotes.iteritems():
|
2011-10-03 21:03:36 +00:00
|
|
|
roles_to_devs = {}
|
|
|
|
if config.get('btrfs'):
|
|
|
|
log.info('btrfs option selected, checkin for scrach devs')
|
|
|
|
devs = teuthology.get_scratch_devices(remote)
|
|
|
|
log.info('found devs: %s' % (str(devs),))
|
|
|
|
roles_to_devs = assign_devs(
|
|
|
|
teuthology.roles_of_type(roles_for_host, 'osd'), devs
|
|
|
|
)
|
|
|
|
log.info('dev map: %s' % (str(roles_to_devs),))
|
|
|
|
devs_to_clean[remote] = []
|
|
|
|
|
2011-06-16 17:36:15 +00:00
|
|
|
for id_ in teuthology.roles_of_type(roles_for_host, 'osd'):
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'mkdir',
|
|
|
|
os.path.join('/tmp/cephtest/data', 'osd.{id}.data'.format(id=id_)),
|
|
|
|
],
|
|
|
|
)
|
2011-10-03 21:03:36 +00:00
|
|
|
if roles_to_devs.get(id_):
|
|
|
|
dev = roles_to_devs[id_]
|
|
|
|
log.info('mkfs.btrfs on %s on %s' % (dev, remote))
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'sudo',
|
|
|
|
'apt-get', 'install', '-y', 'btrfs-tools'
|
|
|
|
]
|
|
|
|
)
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'sudo',
|
|
|
|
'mkfs.btrfs',
|
|
|
|
dev
|
|
|
|
]
|
|
|
|
)
|
|
|
|
log.info('mount %s on %s' % (dev, remote))
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'sudo',
|
|
|
|
'mount',
|
|
|
|
dev,
|
|
|
|
os.path.join('/tmp/cephtest/data', 'osd.{id}.data'.format(id=id_)),
|
|
|
|
]
|
|
|
|
)
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'sudo', 'chown', '-R', 'ubuntu.ubuntu',
|
|
|
|
os.path.join('/tmp/cephtest/data', 'osd.{id}.data'.format(id=id_))
|
|
|
|
]
|
|
|
|
)
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'sudo', 'chmod', '-R', '755',
|
|
|
|
os.path.join('/tmp/cephtest/data', 'osd.{id}.data'.format(id=id_))
|
|
|
|
]
|
|
|
|
)
|
|
|
|
devs_to_clean[remote].append(
|
|
|
|
os.path.join(
|
|
|
|
'/tmp/cephtest/data', 'osd.{id}.data'.format(id=id_)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
for id_ in teuthology.roles_of_type(roles_for_host, 'osd'):
|
2011-06-16 17:36:15 +00:00
|
|
|
remote.run(
|
|
|
|
args=[
|
2011-06-17 23:00:39 +00:00
|
|
|
'/tmp/cephtest/enable-coredump',
|
2011-06-16 17:36:15 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-09-23 15:57:18 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-osd',
|
2011-06-16 17:36:15 +00:00
|
|
|
'--mkfs',
|
|
|
|
'-i', id_,
|
|
|
|
'-c', '/tmp/cephtest/ceph.conf',
|
|
|
|
'--monmap', '/tmp/cephtest/monmap',
|
|
|
|
],
|
|
|
|
)
|
|
|
|
run.wait(
|
|
|
|
mons.run(
|
|
|
|
args=[
|
|
|
|
'rm',
|
|
|
|
'--',
|
|
|
|
'/tmp/cephtest/monmap',
|
|
|
|
'/tmp/cephtest/osdmap',
|
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
2011-08-24 04:00:26 +00:00
|
|
|
(mon0_remote,) = ctx.cluster.only(firstmon).remotes.keys()
|
2011-08-23 05:04:57 +00:00
|
|
|
if ctx.archive is not None:
|
2011-08-24 04:00:26 +00:00
|
|
|
log.info('Grabbing cluster log from %s %s...' % (mon0_remote,
|
|
|
|
firstmon))
|
2011-08-23 05:04:57 +00:00
|
|
|
dest = os.path.join(ctx.archive, 'ceph.log')
|
2011-08-31 21:36:01 +00:00
|
|
|
mon0_remote.run(
|
2011-08-23 05:04:57 +00:00
|
|
|
args = [
|
|
|
|
'cat',
|
|
|
|
'--',
|
|
|
|
'/tmp/cephtest/data/%s/log' % firstmon
|
|
|
|
],
|
|
|
|
stdout=file(dest, 'wb'),
|
|
|
|
)
|
|
|
|
|
2011-08-24 04:00:26 +00:00
|
|
|
log.info('Checking cluster ceph.log for badness...')
|
2011-10-17 21:42:03 +00:00
|
|
|
def first_in_ceph_log(pattern, excludes):
|
|
|
|
args = [
|
|
|
|
'egrep', pattern,
|
|
|
|
'/tmp/cephtest/data/%s/log' % firstmon,
|
|
|
|
]
|
|
|
|
for exclude in excludes:
|
|
|
|
args.extend([run.Raw('|'), 'egrep', '-v', exclude])
|
|
|
|
args.extend([
|
|
|
|
run.Raw('|'), 'head', '-n', '1',
|
|
|
|
])
|
2011-10-03 23:08:49 +00:00
|
|
|
r = mon0_remote.run(
|
2011-08-24 04:00:26 +00:00
|
|
|
stdout=StringIO(),
|
2011-10-17 21:42:03 +00:00
|
|
|
args=args,
|
2011-08-24 04:00:26 +00:00
|
|
|
)
|
2011-10-03 23:08:49 +00:00
|
|
|
stdout = r.stdout.getvalue()
|
2011-10-17 21:42:03 +00:00
|
|
|
if stdout != '':
|
2011-10-03 23:08:49 +00:00
|
|
|
return stdout
|
|
|
|
return None
|
|
|
|
|
2011-10-17 21:42:03 +00:00
|
|
|
if first_in_ceph_log('\[ERR\]|\[WRN\]|\[SEC\]',
|
|
|
|
config['log_whitelist']) is not None:
|
2011-08-24 04:00:26 +00:00
|
|
|
log.warning('Found errors (ERR|WRN|SEC) in cluster log')
|
|
|
|
ctx.summary['success'] = False
|
2011-10-03 23:08:49 +00:00
|
|
|
# use the most severe problem as the failure reason
|
|
|
|
if 'failure_reason' not in ctx.summary:
|
|
|
|
for pattern in ['\[SEC\]', '\[ERR\]', '\[WRN\]']:
|
2011-10-17 21:42:03 +00:00
|
|
|
match = first_in_ceph_log(pattern, config['log_whitelist'])
|
2011-10-03 23:08:49 +00:00
|
|
|
if match is not None:
|
|
|
|
ctx.summary['failure_reason'] = \
|
|
|
|
'"{match}" in cluster log'.format(
|
|
|
|
match=match.rstrip('\n'),
|
|
|
|
)
|
|
|
|
break
|
2011-08-24 04:00:26 +00:00
|
|
|
|
2011-10-03 21:03:36 +00:00
|
|
|
for remote, dirs in devs_to_clean.iteritems():
|
|
|
|
for dir_ in dirs:
|
|
|
|
log.info('Unmounting %s on %s' % (dir_, remote))
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
"sudo",
|
|
|
|
"umount",
|
|
|
|
"-f",
|
|
|
|
dir_
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2011-06-16 17:36:15 +00:00
|
|
|
log.info('Cleaning ceph cluster...')
|
|
|
|
run.wait(
|
|
|
|
ctx.cluster.run(
|
|
|
|
args=[
|
|
|
|
'rm',
|
|
|
|
'-rf',
|
|
|
|
'--',
|
|
|
|
'/tmp/cephtest/ceph.conf',
|
|
|
|
'/tmp/cephtest/ceph.keyring',
|
|
|
|
'/tmp/cephtest/data',
|
2011-07-07 22:40:37 +00:00
|
|
|
'/tmp/cephtest/monmap',
|
2011-07-27 04:52:39 +00:00
|
|
|
run.Raw('/tmp/cephtest/asok.*')
|
2011-06-16 17:36:15 +00:00
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2011-06-16 18:30:33 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def mon(ctx, config):
|
|
|
|
log.info('Starting mon daemons...')
|
|
|
|
mons = ctx.cluster.only(teuthology.is_type('mon'))
|
|
|
|
coverage_dir = '/tmp/cephtest/archive/coverage'
|
|
|
|
|
|
|
|
daemon_signal = 'kill'
|
|
|
|
if config.get('coverage'):
|
|
|
|
log.info('Recording coverage for this run.')
|
|
|
|
daemon_signal = 'term'
|
|
|
|
|
|
|
|
for remote, roles_for_host in mons.remotes.iteritems():
|
|
|
|
for id_ in teuthology.roles_of_type(roles_for_host, 'mon'):
|
2011-08-17 17:05:13 +00:00
|
|
|
proc_signal = daemon_signal
|
2011-08-15 22:35:42 +00:00
|
|
|
run_cmd = ['/tmp/cephtest/enable-coredump',
|
2011-06-16 18:30:33 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-08-17 17:05:13 +00:00
|
|
|
'/tmp/cephtest/daemon-helper'
|
|
|
|
]
|
|
|
|
|
2011-09-23 15:57:18 +00:00
|
|
|
run_cmd_tail = ['/tmp/cephtest/binary/usr/local/bin/ceph-mon',
|
2011-06-16 18:30:33 +00:00
|
|
|
'-f',
|
|
|
|
'-i', id_,
|
2011-08-15 22:35:42 +00:00
|
|
|
'-c', '/tmp/cephtest/ceph.conf']
|
|
|
|
|
2011-08-17 17:05:13 +00:00
|
|
|
extra_args = None
|
|
|
|
|
2011-08-15 22:35:42 +00:00
|
|
|
if config.get('valgrind') and (config.get('valgrind').get('mon.{id}'.format(id=id_), None) is not None):
|
2011-08-29 19:39:38 +00:00
|
|
|
valgrind_args = config.get('valgrind').get('mon.{id}'.format(id=id_))
|
2011-08-15 22:35:42 +00:00
|
|
|
log.debug('running mon.{id} under valgrind'.format(id=id_))
|
2011-08-17 17:04:31 +00:00
|
|
|
val_path = '/tmp/cephtest/archive/log/{val_dir}'.format(val_dir=config.get('valgrind').get('logs', "valgrind"))
|
2011-08-17 17:05:13 +00:00
|
|
|
proc_signal = 'term'
|
2011-08-29 19:39:38 +00:00
|
|
|
if 'memcheck' in valgrind_args or \
|
|
|
|
'helgrind' in valgrind_args:
|
|
|
|
extra_args = ['valgrind', '--xml=yes', '--xml-file={vdir}/mon.{id}.log'.format(vdir=val_path, id=id_), valgrind_args]
|
|
|
|
else:
|
|
|
|
extra_args = extra_args = ['valgrind', '--log-file={vdir}/mon.{id}.log'.format(vdir=val_path, id=id_), valgrind_args]
|
2011-08-15 22:35:42 +00:00
|
|
|
|
2011-08-17 17:05:13 +00:00
|
|
|
run_cmd.append(proc_signal)
|
|
|
|
if extra_args is not None:
|
|
|
|
run_cmd.extend(extra_args)
|
2011-08-15 22:35:42 +00:00
|
|
|
run_cmd.extend(run_cmd_tail)
|
2011-09-14 23:31:58 +00:00
|
|
|
ctx.daemons.add_daemon(remote, 'mon', id_,
|
2011-08-15 22:35:42 +00:00
|
|
|
args=run_cmd,
|
2011-06-16 18:30:33 +00:00
|
|
|
logger=log.getChild('mon.{id}'.format(id=id_)),
|
|
|
|
stdin=run.PIPE,
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
log.info('Shutting down mon daemons...')
|
2011-09-14 23:31:58 +00:00
|
|
|
[i.stop() for i in ctx.daemons.iter_daemons_of_role('mon')]
|
2011-06-16 18:30:33 +00:00
|
|
|
|
|
|
|
|
2011-06-16 18:33:43 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def osd(ctx, config):
|
|
|
|
log.info('Starting osd daemons...')
|
|
|
|
osds = ctx.cluster.only(teuthology.is_type('osd'))
|
|
|
|
coverage_dir = '/tmp/cephtest/archive/coverage'
|
|
|
|
|
|
|
|
daemon_signal = 'kill'
|
|
|
|
if config.get('coverage'):
|
|
|
|
log.info('Recording coverage for this run.')
|
|
|
|
daemon_signal = 'term'
|
|
|
|
|
|
|
|
for remote, roles_for_host in osds.remotes.iteritems():
|
|
|
|
for id_ in teuthology.roles_of_type(roles_for_host, 'osd'):
|
2011-08-15 22:35:42 +00:00
|
|
|
run_cmd = ['/tmp/cephtest/enable-coredump',
|
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-08-17 17:05:13 +00:00
|
|
|
'/tmp/cephtest/daemon-helper'
|
2011-08-15 22:35:42 +00:00
|
|
|
]
|
2011-08-17 17:05:13 +00:00
|
|
|
proc_signal = daemon_signal
|
2011-09-23 15:57:18 +00:00
|
|
|
run_cmd_tail = [ '/tmp/cephtest/binary/usr/local/bin/ceph-osd',
|
2011-08-15 22:35:42 +00:00
|
|
|
'-f',
|
|
|
|
'-i', id_,
|
|
|
|
'-c', '/tmp/cephtest/ceph.conf',
|
|
|
|
]
|
2011-08-17 17:05:13 +00:00
|
|
|
|
|
|
|
extra_args = None
|
2011-08-15 22:35:42 +00:00
|
|
|
|
2011-08-29 19:39:38 +00:00
|
|
|
if config.get('valgrind') and config.get('valgrind').get('osd.{id}'.format(id=id_), None) is not None:
|
|
|
|
valgrind_args = config.get('valgrind').get('osd.{id}'.format(id=id_))
|
2011-08-15 22:35:42 +00:00
|
|
|
log.debug('running osd.{id} under valgrind'.format(id=id_))
|
2011-08-17 17:04:31 +00:00
|
|
|
val_path = '/tmp/cephtest/archive/log/{val_dir}'.format(val_dir=config.get('valgrind').get('logs', "valgrind"))
|
2011-08-17 17:05:13 +00:00
|
|
|
proc_signal = 'term'
|
2011-08-29 19:39:38 +00:00
|
|
|
if 'memcheck' in valgrind_args or \
|
|
|
|
'helgrind' in valgrind_args:
|
|
|
|
extra_args = ['valgrind', '--xml=yes', '--xml-file={vdir}/osd.{id}.log'.format(vdir=val_path, id=id_), valgrind_args]
|
|
|
|
else:
|
|
|
|
extra_args = extra_args = ['valgrind', '--log-file={vdir}/osd.{id}.log'.format(vdir=val_path, id=id_), valgrind_args]
|
2011-08-15 22:35:42 +00:00
|
|
|
|
2011-08-17 17:05:13 +00:00
|
|
|
run_cmd.append(proc_signal)
|
|
|
|
if extra_args is not None:
|
|
|
|
run_cmd.extend(extra_args)
|
2011-08-15 22:35:42 +00:00
|
|
|
run_cmd.extend(run_cmd_tail)
|
2011-09-14 23:31:58 +00:00
|
|
|
ctx.daemons.add_daemon(remote, 'osd', id_,
|
2011-08-15 22:35:42 +00:00
|
|
|
args=run_cmd,
|
2011-06-16 18:33:43 +00:00
|
|
|
logger=log.getChild('osd.{id}'.format(id=id_)),
|
|
|
|
stdin=run.PIPE,
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
log.info('Shutting down osd daemons...')
|
2011-09-14 23:31:58 +00:00
|
|
|
[i.stop() for i in ctx.daemons.iter_daemons_of_role('osd')]
|
2011-06-16 18:33:43 +00:00
|
|
|
|
2011-06-16 18:37:51 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def mds(ctx, config):
|
|
|
|
log.info('Starting mds daemons...')
|
2011-08-31 20:56:42 +00:00
|
|
|
firstmon = teuthology.get_first_mon(ctx, config)
|
2011-06-16 18:37:51 +00:00
|
|
|
mdss = ctx.cluster.only(teuthology.is_type('mds'))
|
|
|
|
coverage_dir = '/tmp/cephtest/archive/coverage'
|
|
|
|
|
|
|
|
daemon_signal = 'kill'
|
|
|
|
if config.get('coverage'):
|
|
|
|
log.info('Recording coverage for this run.')
|
|
|
|
daemon_signal = 'term'
|
|
|
|
|
2011-08-10 19:47:20 +00:00
|
|
|
num_active = 0
|
2011-06-16 18:37:51 +00:00
|
|
|
for remote, roles_for_host in mdss.remotes.iteritems():
|
|
|
|
for id_ in teuthology.roles_of_type(roles_for_host, 'mds'):
|
2011-07-28 17:25:30 +00:00
|
|
|
if not id_.endswith('-s'):
|
|
|
|
num_active += 1
|
2011-08-15 22:35:42 +00:00
|
|
|
run_cmd = ['/tmp/cephtest/enable-coredump',
|
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-08-17 17:05:13 +00:00
|
|
|
'/tmp/cephtest/daemon-helper'
|
2011-08-15 22:35:42 +00:00
|
|
|
]
|
2011-08-17 17:05:13 +00:00
|
|
|
proc_signal = daemon_signal
|
2011-09-23 15:57:18 +00:00
|
|
|
run_cmd_tail = ['/tmp/cephtest/binary/usr/local/bin/ceph-mds',
|
2011-08-15 22:35:42 +00:00
|
|
|
'-f',
|
|
|
|
'-i', id_,
|
|
|
|
'-c', '/tmp/cephtest/ceph.conf',
|
|
|
|
]
|
|
|
|
|
2011-08-17 17:05:13 +00:00
|
|
|
extra_args = None
|
|
|
|
|
|
|
|
if config.get('valgrind') and (config.get('valgrind').get('mds.{id}'.format(id=id_), None) is not None):
|
2011-08-29 19:39:38 +00:00
|
|
|
valgrind_args = config.get('valgrind').get('mds.{id}'.format(id=id_))
|
2011-08-15 22:35:42 +00:00
|
|
|
log.debug('running mds.{id} under valgrind'.format(id=id_))
|
2011-08-17 17:04:31 +00:00
|
|
|
val_path = '/tmp/cephtest/archive/log/{val_dir}'.format(val_dir=config.get('valgrind').get('logs', "valgrind"))
|
2011-08-17 17:05:13 +00:00
|
|
|
proc_signal = 'term'
|
2011-08-29 19:39:38 +00:00
|
|
|
if 'memcheck' in valgrind_args or \
|
|
|
|
'helgrind' in valgrind_args:
|
|
|
|
extra_args = ['valgrind', '--xml=yes', '--xml-file={vdir}/mds.{id}.log'.format(vdir=val_path, id=id_), valgrind_args]
|
|
|
|
else:
|
|
|
|
extra_args = extra_args = ['valgrind', '--log-file={vdir}/mds.{id}.log'.format(vdir=val_path, id=id_), valgrind_args]
|
2011-08-15 22:35:42 +00:00
|
|
|
|
2011-08-17 17:05:13 +00:00
|
|
|
run_cmd.append(proc_signal)
|
|
|
|
if extra_args is not None:
|
|
|
|
run_cmd.extend(extra_args)
|
2011-08-15 22:35:42 +00:00
|
|
|
run_cmd.extend(run_cmd_tail)
|
2011-09-14 23:31:58 +00:00
|
|
|
ctx.daemons.add_daemon(remote, 'mds', id_,
|
2011-08-15 22:35:42 +00:00
|
|
|
args=run_cmd,
|
2011-06-16 18:37:51 +00:00
|
|
|
logger=log.getChild('mds.{id}'.format(id=id_)),
|
|
|
|
stdin=run.PIPE,
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
|
2011-07-27 04:46:47 +00:00
|
|
|
(mon0_remote,) = ctx.cluster.only(firstmon).remotes.keys()
|
2011-07-06 23:44:46 +00:00
|
|
|
mon0_remote.run(args=[
|
|
|
|
'/tmp/cephtest/enable-coredump',
|
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
2011-07-28 17:28:57 +00:00
|
|
|
coverage_dir,
|
2011-07-06 23:44:46 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph',
|
|
|
|
'-c', '/tmp/cephtest/ceph.conf',
|
2011-07-28 17:25:30 +00:00
|
|
|
'mds', 'set_max_mds', str(num_active)])
|
2011-07-06 23:44:46 +00:00
|
|
|
|
2011-06-16 18:37:51 +00:00
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
log.info('Shutting down mds daemons...')
|
2011-09-14 23:31:58 +00:00
|
|
|
[i.stop() for i in ctx.daemons.iter_daemons_of_role('mds')]
|
2011-06-16 18:37:51 +00:00
|
|
|
|
2011-06-16 19:18:58 +00:00
|
|
|
def healthy(ctx, config):
|
|
|
|
log.info('Waiting until ceph is healthy...')
|
2011-08-31 20:56:42 +00:00
|
|
|
firstmon = teuthology.get_first_mon(ctx, config)
|
2011-07-27 04:46:47 +00:00
|
|
|
(mon0_remote,) = ctx.cluster.only(firstmon).remotes.keys()
|
2011-06-16 19:18:58 +00:00
|
|
|
teuthology.wait_until_healthy(
|
|
|
|
remote=mon0_remote,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2011-06-03 21:47:44 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def task(ctx, config):
|
2011-06-06 21:22:49 +00:00
|
|
|
"""
|
|
|
|
Set up and tear down a Ceph cluster.
|
|
|
|
|
|
|
|
For example::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- interactive:
|
2011-06-09 21:08:45 +00:00
|
|
|
|
|
|
|
You can also specify what branch to run::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
branch: foo
|
|
|
|
|
|
|
|
Or a tag::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
tag: v0.42.13
|
|
|
|
|
2011-06-10 00:05:55 +00:00
|
|
|
Or a sha1::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
sha1: 1376a5ab0c89780eab39ffbbe436f6a6092314ed
|
|
|
|
|
2011-06-30 21:49:42 +00:00
|
|
|
Or a local source dir::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
path: /home/sage/ceph
|
|
|
|
|
2011-06-09 22:43:43 +00:00
|
|
|
To capture code coverage data, use::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
coverage: true
|
|
|
|
|
2011-10-03 21:03:36 +00:00
|
|
|
To use btrfs on the osds, use::
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
btrfs: true
|
|
|
|
Note, this will cause the task to check the /scratch_devs file on each node
|
|
|
|
for available devices. If no such file is found, /dev/sdb will be used.
|
|
|
|
|
2011-08-17 17:35:37 +00:00
|
|
|
To run some daemons under valgrind, include their names
|
|
|
|
and the tool to use in a valgrind section::
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
valgrind:
|
|
|
|
mds.1: --tool=memcheck
|
|
|
|
osd.1: --tool=memcheck
|
2011-08-29 20:58:09 +00:00
|
|
|
Those nodes which are using memcheck or helgrind will get
|
|
|
|
checked for bad results.
|
2011-08-17 17:35:37 +00:00
|
|
|
|
2011-07-05 23:45:32 +00:00
|
|
|
To adjust or modify config options, use::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
conf:
|
|
|
|
section:
|
|
|
|
key: value
|
|
|
|
|
|
|
|
For example::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
conf:
|
|
|
|
mds.0:
|
|
|
|
some option: value
|
|
|
|
other key: other value
|
|
|
|
client.0:
|
|
|
|
debug client: 10
|
|
|
|
debug ms: 1
|
|
|
|
|
2011-10-17 21:42:03 +00:00
|
|
|
By default, the cluster log is checked for errors and warnings,
|
|
|
|
and the run marked failed if any appear. You can ignore log
|
|
|
|
entries by giving a list of egrep compatible regexes, i.e.:
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
log-whitelist: ['foo.*bar', 'bad message']
|
|
|
|
|
2011-06-06 21:22:49 +00:00
|
|
|
"""
|
2011-06-09 21:08:45 +00:00
|
|
|
if config is None:
|
|
|
|
config = {}
|
2011-06-07 18:45:29 +00:00
|
|
|
assert isinstance(config, dict), \
|
|
|
|
"task ceph only supports a dictionary for configuration"
|
2011-06-03 16:48:22 +00:00
|
|
|
|
2011-07-16 00:15:09 +00:00
|
|
|
overrides = ctx.config.get('overrides', {})
|
|
|
|
config.update(overrides.get('ceph', {}))
|
|
|
|
|
2011-09-14 23:31:58 +00:00
|
|
|
ctx.daemons = CephState()
|
2011-06-09 22:43:43 +00:00
|
|
|
flavor = None
|
2011-07-05 22:14:42 +00:00
|
|
|
if config.get('path'):
|
|
|
|
# local dir precludes any other flavors
|
|
|
|
flavor = 'local'
|
|
|
|
else:
|
|
|
|
if config.get('coverage'):
|
|
|
|
log.info('Recording coverage for this run.')
|
|
|
|
flavor = 'gcov'
|
2011-08-15 22:32:23 +00:00
|
|
|
else:
|
|
|
|
if config.get('valgrind'):
|
|
|
|
log.info('Using notcmalloc flavor and running some daemons under valgrind')
|
|
|
|
flavor = 'notcmalloc'
|
2011-07-05 22:14:42 +00:00
|
|
|
ctx.summary['flavor'] = flavor or 'default'
|
2011-06-09 22:43:43 +00:00
|
|
|
|
2011-08-24 23:48:14 +00:00
|
|
|
if config.get('coverage'):
|
|
|
|
coverage_dir = '/tmp/cephtest/archive/coverage'
|
|
|
|
log.info('Creating coverage directory...')
|
|
|
|
run.wait(
|
|
|
|
ctx.cluster.run(
|
|
|
|
args=[
|
|
|
|
'install', '-d', '-m0755', '--',
|
|
|
|
coverage_dir,
|
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
)
|
2011-05-31 20:51:48 +00:00
|
|
|
)
|
|
|
|
|
2011-08-15 22:32:23 +00:00
|
|
|
if config.get('valgrind'):
|
2011-08-17 17:04:31 +00:00
|
|
|
val_path = '/tmp/cephtest/archive/log/{val_dir}'.format(val_dir=config.get('valgrind').get('logs', "valgrind"))
|
2011-08-15 22:32:23 +00:00
|
|
|
run.wait(
|
|
|
|
ctx.cluster.run(
|
|
|
|
args=[
|
|
|
|
'mkdir', '-p', val_path
|
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2011-06-15 21:57:02 +00:00
|
|
|
with contextutil.nested(
|
2011-06-16 20:13:32 +00:00
|
|
|
lambda: ceph_log(ctx=ctx, config=None),
|
2011-06-15 21:57:02 +00:00
|
|
|
lambda: ship_utilities(ctx=ctx, config=None),
|
|
|
|
lambda: binaries(ctx=ctx, config=dict(
|
|
|
|
branch=config.get('branch'),
|
|
|
|
tag=config.get('tag'),
|
|
|
|
sha1=config.get('sha1'),
|
2011-06-30 21:49:42 +00:00
|
|
|
path=config.get('path'),
|
2011-06-15 21:57:02 +00:00
|
|
|
flavor=flavor,
|
|
|
|
)),
|
2011-08-29 20:58:09 +00:00
|
|
|
lambda: valgrind_post(ctx=ctx, config=config),
|
2011-07-05 23:45:32 +00:00
|
|
|
lambda: cluster(ctx=ctx, config=dict(
|
2011-10-03 21:03:36 +00:00
|
|
|
conf=config.get('conf', {}),
|
2011-10-17 21:42:03 +00:00
|
|
|
btrfs=config.get('btrfs', False),
|
|
|
|
log_whitelist=config.get('log-whitelist', []),
|
2011-07-05 23:45:32 +00:00
|
|
|
)),
|
2011-08-15 22:31:18 +00:00
|
|
|
lambda: mon(ctx=ctx, config=config),
|
|
|
|
lambda: osd(ctx=ctx, config=config),
|
|
|
|
lambda: mds(ctx=ctx, config=config),
|
2011-06-15 21:57:02 +00:00
|
|
|
):
|
2011-06-16 19:18:58 +00:00
|
|
|
healthy(ctx=ctx, config=None)
|
2011-06-16 18:37:51 +00:00
|
|
|
yield
|