2012-06-28 00:38:12 +00:00
|
|
|
import contextlib
|
|
|
|
import logging
|
|
|
|
|
|
|
|
from teuthology import misc as teuthology
|
|
|
|
from teuthology import contextutil
|
|
|
|
from ..orchestra import run
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
blktrace = '/usr/sbin/blktrace'
|
2012-06-29 19:36:30 +00:00
|
|
|
daemon_signal = 'term'
|
2012-06-28 00:38:12 +00:00
|
|
|
|
|
|
|
@contextlib.contextmanager
|
|
|
|
def setup(ctx, config):
|
|
|
|
osds = ctx.cluster.only(teuthology.is_type('osd'))
|
2013-01-23 20:37:39 +00:00
|
|
|
log_dir = '{tdir}/archive/performance/blktrace'.format(tdir=teuthology.get_testdir(ctx))
|
|
|
|
|
2012-06-28 00:38:12 +00:00
|
|
|
for remote, roles_for_host in osds.remotes.iteritems():
|
|
|
|
log.info('Creating %s on %s' % (log_dir,remote.name))
|
2012-09-21 23:44:35 +00:00
|
|
|
remote.run(
|
2012-06-28 00:38:12 +00:00
|
|
|
args=['mkdir', '-p', '-m0755', '--', log_dir],
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
yield
|
|
|
|
|
|
|
|
@contextlib.contextmanager
|
|
|
|
def execute(ctx, config):
|
2012-06-29 19:36:30 +00:00
|
|
|
procs = []
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir=teuthology.get_testdir(ctx)
|
|
|
|
log_dir = '{tdir}/archive/performance/blktrace'.format(tdir=testdir)
|
|
|
|
|
2012-06-28 00:38:12 +00:00
|
|
|
osds = ctx.cluster.only(teuthology.is_type('osd'))
|
|
|
|
for remote, roles_for_host in osds.remotes.iteritems():
|
|
|
|
roles_to_devs = ctx.disk_config.remote_to_roles_to_dev[remote]
|
|
|
|
for id_ in teuthology.roles_of_type(roles_for_host, 'osd'):
|
|
|
|
if roles_to_devs.get(id_):
|
|
|
|
dev = roles_to_devs[id_]
|
|
|
|
log.info("running blktrace on %s: %s" % (remote.name, dev))
|
2012-06-29 19:36:30 +00:00
|
|
|
|
2012-06-28 00:38:12 +00:00
|
|
|
proc = remote.run(
|
|
|
|
args=[
|
|
|
|
'cd',
|
|
|
|
log_dir,
|
|
|
|
run.Raw(';'),
|
2013-09-06 20:08:01 +00:00
|
|
|
'daemon-helper',
|
2012-06-29 19:36:30 +00:00
|
|
|
daemon_signal,
|
2012-06-28 00:38:12 +00:00
|
|
|
'sudo',
|
|
|
|
blktrace,
|
|
|
|
'-o',
|
|
|
|
dev.rsplit("/", 1)[1],
|
|
|
|
'-d',
|
|
|
|
dev,
|
|
|
|
],
|
|
|
|
wait=False,
|
2012-06-29 19:36:30 +00:00
|
|
|
stdin=run.PIPE,
|
2012-06-28 00:38:12 +00:00
|
|
|
)
|
2012-06-29 19:36:30 +00:00
|
|
|
procs.append(proc)
|
2012-06-28 00:38:12 +00:00
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
osds = ctx.cluster.only(teuthology.is_type('osd'))
|
2012-06-29 19:36:30 +00:00
|
|
|
log.info('stopping blktrace processs')
|
|
|
|
for proc in procs:
|
|
|
|
proc.stdin.close()
|
2012-06-28 00:38:12 +00:00
|
|
|
|
|
|
|
@contextlib.contextmanager
|
|
|
|
def task(ctx, config):
|
|
|
|
if config is None:
|
|
|
|
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.fromkeys(config)
|
|
|
|
|
|
|
|
with contextutil.nested(
|
|
|
|
lambda: setup(ctx=ctx, config=config),
|
|
|
|
lambda: execute(ctx=ctx, config=config),
|
|
|
|
):
|
|
|
|
yield
|
|
|
|
|