2011-05-31 20:51:48 +00:00
|
|
|
from cStringIO import StringIO
|
|
|
|
|
2011-06-03 21:47:44 +00:00
|
|
|
import contextlib
|
2011-05-31 20:51:48 +00:00
|
|
|
import logging
|
|
|
|
import os
|
2011-06-03 21:47:44 +00:00
|
|
|
import gevent
|
2011-06-07 21:47:30 +00:00
|
|
|
import tarfile
|
2011-06-15 18:49:04 +00:00
|
|
|
import yaml
|
2011-05-31 20:51:48 +00:00
|
|
|
|
2011-06-03 21:47:44 +00:00
|
|
|
from teuthology import misc as teuthology
|
2011-06-07 21:47:30 +00:00
|
|
|
from teuthology import safepath
|
2011-06-03 21:47:44 +00:00
|
|
|
from orchestra import run
|
2011-05-31 20:51:48 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
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-09 22:43:43 +00:00
|
|
|
To capture code coverage data, use::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
coverage: true
|
|
|
|
|
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-06-09 22:43:43 +00:00
|
|
|
flavor = None
|
2011-06-10 18:18:13 +00:00
|
|
|
daemon_signal = 'kill'
|
2011-06-09 22:43:43 +00:00
|
|
|
if config.get('coverage'):
|
|
|
|
log.info('Recording coverage for this run.')
|
|
|
|
flavor = 'gcov'
|
2011-06-10 18:18:13 +00:00
|
|
|
daemon_signal = 'term'
|
2011-06-09 22:43:43 +00:00
|
|
|
|
2011-05-31 20:51:48 +00:00
|
|
|
log.info('Checking for old test directory...')
|
2011-06-03 21:47:44 +00:00
|
|
|
processes = ctx.cluster.run(
|
2011-06-01 23:04:52 +00:00
|
|
|
args=[
|
|
|
|
'test', '!', '-e', '/tmp/cephtest',
|
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
)
|
2011-06-03 21:47:44 +00:00
|
|
|
failed = False
|
|
|
|
for proc in processes:
|
|
|
|
assert isinstance(proc.exitstatus, gevent.event.AsyncResult)
|
|
|
|
try:
|
|
|
|
proc.exitstatus.get()
|
|
|
|
except run.CommandFailedError:
|
|
|
|
log.error('Host %s has stale cephtest directory, check your lock and reboot to clean up.', proc.remote.shortname)
|
|
|
|
failed = True
|
|
|
|
if failed:
|
|
|
|
raise RuntimeError('Stale jobs detected, aborting.')
|
2011-05-31 20:51:48 +00:00
|
|
|
|
2011-06-07 18:45:29 +00:00
|
|
|
coverage_dir = '/tmp/cephtest/archive/coverage'
|
2011-05-31 20:51:48 +00:00
|
|
|
log.info('Creating directories...')
|
|
|
|
run.wait(
|
2011-06-03 21:47:44 +00:00
|
|
|
ctx.cluster.run(
|
2011-05-31 20:51:48 +00:00
|
|
|
args=[
|
|
|
|
'install', '-d', '-m0755', '--',
|
|
|
|
'/tmp/cephtest/binary',
|
2011-06-09 19:58:51 +00:00
|
|
|
'/tmp/cephtest/archive',
|
|
|
|
'/tmp/cephtest/archive/log',
|
|
|
|
'/tmp/cephtest/archive/profiling-logger',
|
2011-05-31 20:51:48 +00:00
|
|
|
'/tmp/cephtest/data',
|
2011-06-07 18:45:29 +00:00
|
|
|
coverage_dir,
|
2011-05-31 20:51:48 +00:00
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
for filename in ['daemon-helper']:
|
|
|
|
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:
|
2011-06-03 21:47:44 +00:00
|
|
|
for rem in ctx.cluster.remotes.iterkeys():
|
2011-05-31 20:51:48 +00:00
|
|
|
teuthology.write_file(
|
2011-06-01 23:04:52 +00:00
|
|
|
remote=rem,
|
2011-05-31 20:51:48 +00:00
|
|
|
path=dst,
|
|
|
|
data=f,
|
|
|
|
)
|
|
|
|
f.seek(0)
|
2011-06-01 23:04:52 +00:00
|
|
|
rem.run(
|
2011-05-31 20:51:48 +00:00
|
|
|
args=[
|
|
|
|
'chmod',
|
|
|
|
'a=rx',
|
|
|
|
'--',
|
|
|
|
dst,
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
log.info('Untarring ceph binaries...')
|
2011-06-09 21:02:44 +00:00
|
|
|
sha1, ceph_bindir_url = teuthology.get_ceph_binary_url(
|
2011-06-09 21:08:45 +00:00
|
|
|
branch=config.get('branch'),
|
|
|
|
tag=config.get('tag'),
|
2011-06-10 00:05:55 +00:00
|
|
|
sha1=config.get('sha1'),
|
2011-06-09 22:43:43 +00:00
|
|
|
flavor=flavor,
|
2011-06-09 21:08:45 +00:00
|
|
|
)
|
2011-06-03 21:47:44 +00:00
|
|
|
ctx.cluster.run(
|
2011-06-02 16:09:08 +00:00
|
|
|
args=[
|
|
|
|
'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-05-31 20:51:48 +00:00
|
|
|
|
|
|
|
log.info('Writing configs...')
|
2011-06-03 21:47:44 +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-05-31 20:51:48 +00:00
|
|
|
conf_fp = StringIO()
|
|
|
|
conf.write(conf_fp)
|
|
|
|
conf_fp.seek(0)
|
2011-06-03 21:47:44 +00:00
|
|
|
writes = ctx.cluster.run(
|
2011-06-01 23:04:52 +00:00
|
|
|
args=[
|
|
|
|
'python',
|
|
|
|
'-c',
|
|
|
|
'import shutil, sys; shutil.copyfileobj(sys.stdin, file(sys.argv[1], "wb"))',
|
|
|
|
'/tmp/cephtest/ceph.conf',
|
|
|
|
],
|
|
|
|
stdin=run.PIPE,
|
|
|
|
wait=False,
|
|
|
|
)
|
2011-05-31 20:51:48 +00:00
|
|
|
teuthology.feed_many_stdins_and_close(conf_fp, writes)
|
|
|
|
run.wait(writes)
|
|
|
|
|
|
|
|
log.info('Setting up mon.0...')
|
2011-06-03 21:47:44 +00:00
|
|
|
ctx.cluster.only('mon.0').run(
|
2011-05-31 20:51:48 +00:00
|
|
|
args=[
|
2011-06-07 18:45:29 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-05-31 20:51:48 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/cauthtool',
|
|
|
|
'--create-keyring',
|
|
|
|
'/tmp/cephtest/ceph.keyring',
|
|
|
|
],
|
|
|
|
)
|
2011-06-03 21:47:44 +00:00
|
|
|
ctx.cluster.only('mon.0').run(
|
2011-05-31 20:51:48 +00:00
|
|
|
args=[
|
2011-06-07 18:45:29 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-05-31 20:51:48 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/cauthtool',
|
|
|
|
'--gen-key',
|
|
|
|
'--name=mon.',
|
|
|
|
'/tmp/cephtest/ceph.keyring',
|
|
|
|
],
|
|
|
|
)
|
2011-06-03 21:47:44 +00:00
|
|
|
(mon0_remote,) = ctx.cluster.only('mon.0').remotes.keys()
|
2011-05-31 20:51:48 +00:00
|
|
|
teuthology.create_simple_monmap(
|
2011-06-01 23:04:52 +00:00
|
|
|
remote=mon0_remote,
|
2011-05-31 20:51:48 +00:00
|
|
|
conf=conf,
|
|
|
|
)
|
|
|
|
|
|
|
|
log.info('Creating admin key on mon.0...')
|
2011-06-03 21:47:44 +00:00
|
|
|
ctx.cluster.only('mon.0').run(
|
2011-05-31 20:51:48 +00:00
|
|
|
args=[
|
2011-06-07 18:45:29 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-05-31 20:51:48 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/cauthtool',
|
|
|
|
'--gen-key',
|
|
|
|
'--name=client.admin',
|
|
|
|
'--set-uid=0',
|
|
|
|
'--cap', 'mon', 'allow *',
|
|
|
|
'--cap', 'osd', 'allow *',
|
|
|
|
'--cap', 'mds', 'allow',
|
|
|
|
'/tmp/cephtest/ceph.keyring',
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
log.info('Copying mon.0 info to all monitors...')
|
|
|
|
keyring = teuthology.get_file(
|
2011-06-01 23:04:52 +00:00
|
|
|
remote=mon0_remote,
|
2011-05-31 20:51:48 +00:00
|
|
|
path='/tmp/cephtest/ceph.keyring',
|
|
|
|
)
|
|
|
|
monmap = teuthology.get_file(
|
2011-06-01 23:04:52 +00:00
|
|
|
remote=mon0_remote,
|
2011-05-31 20:51:48 +00:00
|
|
|
path='/tmp/cephtest/monmap',
|
|
|
|
)
|
2011-06-03 21:47:44 +00:00
|
|
|
mons = ctx.cluster.only(teuthology.is_type('mon'))
|
2011-06-01 23:04:52 +00:00
|
|
|
mons_no_0 = mons.exclude('mon.0')
|
2011-05-31 20:51:48 +00:00
|
|
|
|
2011-06-01 23:04:52 +00:00
|
|
|
for rem in mons_no_0.remotes.iterkeys():
|
|
|
|
# copy mon key and initial monmap
|
|
|
|
log.info('Sending mon0 info to node {remote}'.format(remote=rem))
|
|
|
|
teuthology.write_file(
|
|
|
|
remote=rem,
|
|
|
|
path='/tmp/cephtest/ceph.keyring',
|
|
|
|
data=keyring,
|
|
|
|
)
|
|
|
|
teuthology.write_file(
|
|
|
|
remote=rem,
|
|
|
|
path='/tmp/cephtest/monmap',
|
|
|
|
data=monmap,
|
|
|
|
)
|
2011-05-31 20:51:48 +00:00
|
|
|
|
|
|
|
log.info('Setting up mon nodes...')
|
2011-06-01 23:04:52 +00:00
|
|
|
run.wait(
|
|
|
|
mons.run(
|
|
|
|
args=[
|
2011-06-07 18:45:29 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-06-01 23:04:52 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/osdmaptool',
|
|
|
|
'--clobber',
|
|
|
|
'--createsimple', '{num:d}'.format(
|
2011-06-03 21:47:44 +00:00
|
|
|
num=teuthology.num_instances_of_type(ctx.cluster, 'osd'),
|
2011-06-01 23:04:52 +00:00
|
|
|
),
|
|
|
|
'/tmp/cephtest/osdmap',
|
|
|
|
'--pg_bits', '2',
|
|
|
|
'--pgp_bits', '4',
|
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2011-06-03 21:47:44 +00:00
|
|
|
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-07 18:45:29 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-06-03 21:47:44 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/cmon',
|
|
|
|
'--mkfs',
|
|
|
|
'-i', id_,
|
|
|
|
'-c', '/tmp/cephtest/ceph.conf',
|
|
|
|
'--monmap=/tmp/cephtest/monmap',
|
|
|
|
'--osdmap=/tmp/cephtest/osdmap',
|
|
|
|
'--keyring=/tmp/cephtest/ceph.keyring',
|
|
|
|
],
|
|
|
|
)
|
2011-06-01 23:04:52 +00:00
|
|
|
|
|
|
|
run.wait(
|
|
|
|
mons.run(
|
|
|
|
args=[
|
|
|
|
'rm',
|
|
|
|
'--',
|
|
|
|
'/tmp/cephtest/monmap',
|
|
|
|
'/tmp/cephtest/osdmap',
|
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
),
|
|
|
|
)
|
2011-05-31 20:51:48 +00:00
|
|
|
|
|
|
|
mon_daemons = {}
|
|
|
|
log.info('Starting mon daemons...')
|
2011-06-03 21:47:44 +00:00
|
|
|
for remote, roles_for_host in mons.remotes.iteritems():
|
2011-05-31 20:51:48 +00:00
|
|
|
for id_ in teuthology.roles_of_type(roles_for_host, 'mon'):
|
2011-06-03 21:47:44 +00:00
|
|
|
proc = remote.run(
|
2011-05-31 20:51:48 +00:00
|
|
|
args=[
|
2011-06-07 18:45:29 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-05-31 20:51:48 +00:00
|
|
|
'/tmp/cephtest/daemon-helper',
|
2011-06-10 18:18:13 +00:00
|
|
|
daemon_signal,
|
2011-05-31 20:51:48 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/cmon',
|
|
|
|
'-f',
|
|
|
|
'-i', id_,
|
|
|
|
'-c', '/tmp/cephtest/ceph.conf',
|
|
|
|
],
|
|
|
|
logger=log.getChild('mon.{id}'.format(id=id_)),
|
|
|
|
stdin=run.PIPE,
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
mon_daemons[id_] = proc
|
|
|
|
|
|
|
|
log.info('Setting up osd nodes...')
|
2011-06-03 21:47:44 +00:00
|
|
|
osds = ctx.cluster.only(teuthology.is_type('osd'))
|
|
|
|
for remote, roles_for_host in osds.remotes.iteritems():
|
2011-05-31 20:51:48 +00:00
|
|
|
for id_ in teuthology.roles_of_type(roles_for_host, 'osd'):
|
2011-06-03 21:47:44 +00:00
|
|
|
remote.run(
|
2011-05-31 20:51:48 +00:00
|
|
|
args=[
|
2011-06-07 18:45:29 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-05-31 20:51:48 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/cauthtool',
|
|
|
|
'--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...')
|
2011-06-03 21:47:44 +00:00
|
|
|
mdss = ctx.cluster.only(teuthology.is_type('mds'))
|
|
|
|
for remote, roles_for_host in mdss.remotes.iteritems():
|
2011-05-31 20:51:48 +00:00
|
|
|
for id_ in teuthology.roles_of_type(roles_for_host, 'mds'):
|
2011-06-03 21:47:44 +00:00
|
|
|
remote.run(
|
2011-05-31 20:51:48 +00:00
|
|
|
args=[
|
2011-06-07 18:45:29 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-05-31 20:51:48 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/cauthtool',
|
|
|
|
'--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...')
|
2011-06-03 21:47:44 +00:00
|
|
|
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-07 18:45:29 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-06-03 21:47:44 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/cauthtool',
|
|
|
|
'--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_),
|
|
|
|
],
|
|
|
|
)
|
2011-05-31 20:51:48 +00:00
|
|
|
|
|
|
|
log.info('Reading keys from all nodes...')
|
|
|
|
keys = []
|
2011-06-03 21:47:44 +00:00
|
|
|
for remote, roles_for_host in ctx.cluster.remotes.iteritems():
|
2011-05-31 20:51:48 +00:00
|
|
|
for type_ in ['osd','mds','client']:
|
|
|
|
for id_ in teuthology.roles_of_type(roles_for_host, type_):
|
|
|
|
data = teuthology.get_file(
|
2011-06-03 21:47:44 +00:00
|
|
|
remote=remote,
|
2011-05-31 20:51:48 +00:00
|
|
|
path='/tmp/cephtest/data/{type}.{id}.keyring'.format(
|
|
|
|
type=type_,
|
|
|
|
id=id_,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
keys.append((type_, id_, data))
|
|
|
|
|
|
|
|
log.info('Adding keys to mon.0...')
|
|
|
|
for type_, id_, data in keys:
|
|
|
|
teuthology.write_file(
|
2011-06-01 23:04:52 +00:00
|
|
|
remote=mon0_remote,
|
2011-05-31 20:51:48 +00:00
|
|
|
path='/tmp/cephtest/temp.keyring',
|
|
|
|
data=data,
|
|
|
|
)
|
2011-06-01 23:04:52 +00:00
|
|
|
mon0_remote.run(
|
2011-05-31 20:51:48 +00:00
|
|
|
args=[
|
2011-06-07 18:45:29 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-05-31 20:51:48 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/cauthtool',
|
|
|
|
'/tmp/cephtest/temp.keyring',
|
|
|
|
'--name={type}.{id}'.format(
|
|
|
|
type=type_,
|
|
|
|
id=id_,
|
|
|
|
),
|
|
|
|
] + list(teuthology.generate_caps(type_)),
|
|
|
|
)
|
2011-06-01 23:04:52 +00:00
|
|
|
mon0_remote.run(
|
2011-05-31 20:51:48 +00:00
|
|
|
args=[
|
2011-06-07 18:45:29 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-05-31 20:51:48 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph',
|
|
|
|
'-c', '/tmp/cephtest/ceph.conf',
|
|
|
|
'-k', '/tmp/cephtest/ceph.keyring',
|
|
|
|
'-i', '/tmp/cephtest/temp.keyring',
|
|
|
|
'auth',
|
|
|
|
'add',
|
|
|
|
'{type}.{id}'.format(
|
|
|
|
type=type_,
|
|
|
|
id=id_,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
log.info('Setting max_mds...')
|
|
|
|
# TODO where does this belong?
|
2011-06-01 23:04:52 +00:00
|
|
|
mon0_remote.run(
|
2011-05-31 20:51:48 +00:00
|
|
|
args=[
|
2011-06-07 18:45:29 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-05-31 20:51:48 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph',
|
|
|
|
'-c', '/tmp/cephtest/ceph.conf',
|
|
|
|
'-k', '/tmp/cephtest/ceph.keyring',
|
|
|
|
'mds',
|
|
|
|
'set_max_mds',
|
|
|
|
'{num_mds:d}'.format(
|
2011-06-03 21:47:44 +00:00
|
|
|
num_mds=teuthology.num_instances_of_type(ctx.cluster, 'mds'),
|
2011-05-31 20:51:48 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
log.info('Running mkfs on osd nodes...')
|
2011-06-03 21:47:44 +00:00
|
|
|
for remote, roles_for_host in osds.remotes.iteritems():
|
|
|
|
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_)),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
remote.run(
|
|
|
|
args=[
|
2011-06-07 18:45:29 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-06-03 21:47:44 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/cosd',
|
|
|
|
'--mkfs',
|
|
|
|
'-i', id_,
|
2011-06-07 19:58:48 +00:00
|
|
|
'-c', '/tmp/cephtest/ceph.conf',
|
2011-06-03 21:47:44 +00:00
|
|
|
],
|
|
|
|
)
|
2011-05-31 20:51:48 +00:00
|
|
|
|
|
|
|
osd_daemons = {}
|
|
|
|
log.info('Starting osd daemons...')
|
2011-06-03 21:47:44 +00:00
|
|
|
for remote, roles_for_host in osds.remotes.iteritems():
|
2011-05-31 20:51:48 +00:00
|
|
|
for id_ in teuthology.roles_of_type(roles_for_host, 'osd'):
|
2011-06-03 21:47:44 +00:00
|
|
|
proc = remote.run(
|
2011-05-31 20:51:48 +00:00
|
|
|
args=[
|
2011-06-07 18:45:29 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-05-31 20:51:48 +00:00
|
|
|
'/tmp/cephtest/daemon-helper',
|
2011-06-10 18:18:13 +00:00
|
|
|
daemon_signal,
|
2011-05-31 20:51:48 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/cosd',
|
|
|
|
'-f',
|
|
|
|
'-i', id_,
|
2011-06-07 19:58:48 +00:00
|
|
|
'-c', '/tmp/cephtest/ceph.conf',
|
2011-05-31 20:51:48 +00:00
|
|
|
],
|
|
|
|
logger=log.getChild('osd.{id}'.format(id=id_)),
|
|
|
|
stdin=run.PIPE,
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
osd_daemons[id_] = proc
|
|
|
|
|
|
|
|
mds_daemons = {}
|
|
|
|
log.info('Starting mds daemons...')
|
2011-06-03 21:47:44 +00:00
|
|
|
for remote, roles_for_host in mdss.remotes.iteritems():
|
2011-05-31 20:51:48 +00:00
|
|
|
for id_ in teuthology.roles_of_type(roles_for_host, 'mds'):
|
2011-06-03 21:47:44 +00:00
|
|
|
proc = remote.run(
|
2011-05-31 20:51:48 +00:00
|
|
|
args=[
|
2011-06-07 18:45:29 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/ceph-coverage',
|
|
|
|
coverage_dir,
|
2011-05-31 20:51:48 +00:00
|
|
|
'/tmp/cephtest/daemon-helper',
|
2011-06-10 18:18:13 +00:00
|
|
|
daemon_signal,
|
2011-05-31 20:51:48 +00:00
|
|
|
'/tmp/cephtest/binary/usr/local/bin/cmds',
|
|
|
|
'-f',
|
|
|
|
'-i', id_,
|
2011-06-07 19:58:48 +00:00
|
|
|
'-c', '/tmp/cephtest/ceph.conf',
|
2011-05-31 20:51:48 +00:00
|
|
|
],
|
|
|
|
logger=log.getChild('mds.{id}'.format(id=id_)),
|
|
|
|
stdin=run.PIPE,
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
mds_daemons[id_] = proc
|
|
|
|
|
|
|
|
|
|
|
|
log.info('Waiting until ceph is healthy...')
|
|
|
|
teuthology.wait_until_healthy(
|
2011-06-01 23:04:52 +00:00
|
|
|
remote=mon0_remote,
|
2011-05-31 20:51:48 +00:00
|
|
|
)
|
|
|
|
|
2011-06-03 21:47:44 +00:00
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
2011-06-10 18:18:13 +00:00
|
|
|
log.info('Shutting down mds daemons...')
|
|
|
|
for id_, proc in mds_daemons.iteritems():
|
|
|
|
proc.stdin.close()
|
|
|
|
|
|
|
|
log.info('Shutting down osd daemons...')
|
|
|
|
for id_, proc in osd_daemons.iteritems():
|
|
|
|
proc.stdin.close()
|
|
|
|
|
|
|
|
log.info('Shutting down mon daemons...')
|
|
|
|
for id_, proc in mon_daemons.iteritems():
|
|
|
|
proc.stdin.close()
|
2011-06-09 23:05:08 +00:00
|
|
|
|
|
|
|
run.wait(mds_daemons.itervalues())
|
|
|
|
run.wait(osd_daemons.itervalues())
|
|
|
|
run.wait(mon_daemons.itervalues())
|
2011-06-07 21:47:30 +00:00
|
|
|
|
|
|
|
log.info('Removing uninteresting files...')
|
|
|
|
run.wait(
|
|
|
|
ctx.cluster.run(
|
|
|
|
args=[
|
|
|
|
'rm',
|
|
|
|
'-rf',
|
|
|
|
'--',
|
|
|
|
'/tmp/cephtest/binary',
|
|
|
|
'/tmp/cephtest/daemon-helper',
|
|
|
|
'/tmp/cephtest/ceph.conf',
|
|
|
|
'/tmp/cephtest/ceph.keyring',
|
|
|
|
'/tmp/cephtest/temp.keyring',
|
|
|
|
'/tmp/cephtest/data',
|
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
if ctx.archive is not None:
|
|
|
|
os.mkdir(ctx.archive)
|
|
|
|
|
2011-06-09 23:39:20 +00:00
|
|
|
with file(os.path.join(ctx.archive, 'ceph-sha1'), 'w') as f:
|
|
|
|
f.write(sha1 + '\n')
|
|
|
|
|
2011-06-15 00:52:43 +00:00
|
|
|
with file(os.path.join(ctx.archive, 'config.yaml'), 'w') as f:
|
2011-06-15 18:50:32 +00:00
|
|
|
yaml.safe_dump(ctx.config, f, default_flow_style=False)
|
2011-06-15 00:52:43 +00:00
|
|
|
|
2011-06-07 21:47:30 +00:00
|
|
|
log.info('Compressing logs...')
|
|
|
|
run.wait(
|
|
|
|
ctx.cluster.run(
|
|
|
|
args=[
|
|
|
|
'find',
|
2011-06-09 19:58:51 +00:00
|
|
|
'/tmp/cephtest/archive/log',
|
2011-06-07 21:47:30 +00:00
|
|
|
'-name',
|
|
|
|
'*.log',
|
|
|
|
'-print0',
|
|
|
|
run.Raw('|'),
|
|
|
|
'xargs',
|
|
|
|
'-0',
|
|
|
|
'--no-run-if-empty',
|
|
|
|
'--',
|
|
|
|
'bzip2',
|
|
|
|
'-9',
|
|
|
|
'--',
|
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2011-06-09 19:58:51 +00:00
|
|
|
log.info('Transferring archived files...')
|
|
|
|
logdir = os.path.join(ctx.archive, 'remote')
|
|
|
|
os.mkdir(logdir)
|
|
|
|
for remote in ctx.cluster.remotes.iterkeys():
|
|
|
|
path = os.path.join(logdir, remote.shortname)
|
|
|
|
os.mkdir(path)
|
|
|
|
log.debug('Transferring archived files from %s to %s', remote.shortname, path)
|
|
|
|
proc = remote.run(
|
|
|
|
args=[
|
|
|
|
'tar',
|
|
|
|
'c',
|
|
|
|
'-f', '-',
|
|
|
|
'-C', '/tmp/cephtest/archive',
|
|
|
|
'--',
|
|
|
|
'.',
|
|
|
|
],
|
|
|
|
stdout=run.PIPE,
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
tar = tarfile.open(mode='r|', fileobj=proc.stdout)
|
|
|
|
while True:
|
|
|
|
ti = tar.next()
|
|
|
|
if ti is None:
|
|
|
|
break
|
|
|
|
|
|
|
|
if ti.isdir():
|
|
|
|
# ignore silently; easier to just create leading dirs below
|
|
|
|
pass
|
|
|
|
elif ti.isfile():
|
|
|
|
sub = safepath.munge(ti.name)
|
|
|
|
safepath.makedirs(root=path, path=os.path.dirname(sub))
|
|
|
|
tar.makefile(ti, targetpath=os.path.join(path, sub))
|
|
|
|
else:
|
|
|
|
if ti.isdev():
|
|
|
|
type_ = 'device'
|
|
|
|
elif ti.issym():
|
|
|
|
type_ = 'symlink'
|
|
|
|
elif ti.islnk():
|
|
|
|
type_ = 'hard link'
|
2011-06-07 21:47:30 +00:00
|
|
|
else:
|
2011-06-09 19:58:51 +00:00
|
|
|
type_ = 'unknown'
|
|
|
|
log.info('Ignoring tar entry: %r type %r', ti.name, type_)
|
|
|
|
continue
|
|
|
|
proc.exitstatus.get()
|
|
|
|
|
|
|
|
log.info('Removing archived files...')
|
2011-06-07 21:47:30 +00:00
|
|
|
run.wait(
|
|
|
|
ctx.cluster.run(
|
|
|
|
args=[
|
|
|
|
'rm',
|
|
|
|
'-rf',
|
|
|
|
'--',
|
2011-06-09 19:58:51 +00:00
|
|
|
'/tmp/cephtest/archive',
|
2011-06-07 21:47:30 +00:00
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
log.info('Tidying up after the test...')
|
|
|
|
# if this fails, one of the above cleanups is flawed; don't
|
|
|
|
# just cram an rm -rf here
|
|
|
|
run.wait(
|
|
|
|
ctx.cluster.run(
|
|
|
|
args=[
|
|
|
|
'rmdir',
|
|
|
|
'--',
|
|
|
|
'/tmp/cephtest',
|
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
),
|
|
|
|
)
|