2011-06-22 23:36:58 +00:00
|
|
|
import contextlib
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
|
|
|
from teuthology import misc as teuthology
|
|
|
|
from teuthology import contextutil
|
2011-09-13 21:53:02 +00:00
|
|
|
from ..orchestra import run
|
2011-06-22 23:36:58 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
@contextlib.contextmanager
|
|
|
|
def create_dirs(ctx, config):
|
|
|
|
log.info('Creating apache directories...')
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
2012-02-21 23:47:32 +00:00
|
|
|
for client in config.iterkeys():
|
2011-06-22 23:36:58 +00:00
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
|
|
|
'mkdir',
|
|
|
|
'-p',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/apache/htdocs'.format(tdir=testdir),
|
|
|
|
'{tdir}/apache/tmp'.format(tdir=testdir),
|
2011-06-22 23:36:58 +00:00
|
|
|
run.Raw('&&'),
|
|
|
|
'mkdir',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/archive/apache'.format(tdir=testdir),
|
2011-06-22 23:36:58 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
log.info('Cleaning up apache directories...')
|
2012-02-21 23:47:32 +00:00
|
|
|
for client in config.iterkeys():
|
2011-06-22 23:36:58 +00:00
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
|
|
|
'rm',
|
|
|
|
'-rf',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/apache/tmp'.format(tdir=testdir),
|
2011-06-22 23:36:58 +00:00
|
|
|
run.Raw('&&'),
|
|
|
|
'rmdir',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/apache/htdocs'.format(tdir=testdir),
|
2011-06-22 23:36:58 +00:00
|
|
|
run.Raw('&&'),
|
|
|
|
'rmdir',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/apache'.format(tdir=testdir),
|
2011-06-22 23:36:58 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@contextlib.contextmanager
|
|
|
|
def ship_config(ctx, config):
|
2012-02-21 23:47:32 +00:00
|
|
|
assert isinstance(config, dict)
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
2011-06-22 23:36:58 +00:00
|
|
|
log.info('Shipping apache config and rgw.fcgi...')
|
2013-02-06 17:04:37 +00:00
|
|
|
src = os.path.join(os.path.dirname(__file__)
|
|
|
|
, 'apache.conf.template').format(
|
|
|
|
testdir=testdir
|
|
|
|
)
|
2012-02-21 23:47:32 +00:00
|
|
|
for client in config.iterkeys():
|
2011-06-22 23:36:58 +00:00
|
|
|
(remote,) = ctx.cluster.only(client).remotes.keys()
|
|
|
|
with file(src, 'rb') as f:
|
2013-02-07 06:02:10 +00:00
|
|
|
conf = f.read().format(testdir=testdir)
|
2011-06-22 23:36:58 +00:00
|
|
|
teuthology.write_file(
|
|
|
|
remote=remote,
|
2013-01-23 20:37:39 +00:00
|
|
|
path='{tdir}/apache/apache.conf'.format(tdir=testdir),
|
2013-02-07 06:02:10 +00:00
|
|
|
data=conf,
|
2011-06-22 23:36:58 +00:00
|
|
|
)
|
|
|
|
teuthology.write_file(
|
|
|
|
remote=remote,
|
2013-01-23 20:37:39 +00:00
|
|
|
path='{tdir}/apache/htdocs/rgw.fcgi'.format(tdir=testdir),
|
2011-06-22 23:36:58 +00:00
|
|
|
data="""#!/bin/sh
|
|
|
|
ulimit -c unlimited
|
2013-02-06 19:16:52 +00:00
|
|
|
exec radosgw -f
|
2013-01-23 20:37:39 +00:00
|
|
|
""".format(tdir=testdir)
|
2011-06-22 23:36:58 +00:00
|
|
|
)
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'chmod',
|
|
|
|
'a=rx',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/apache/htdocs/rgw.fcgi'.format(tdir=testdir),
|
2011-06-22 23:36:58 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
log.info('Removing apache config...')
|
2012-02-21 23:47:32 +00:00
|
|
|
for client in config.iterkeys():
|
2011-06-22 23:36:58 +00:00
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
|
|
|
'rm',
|
|
|
|
'-f',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/apache/apache.conf'.format(tdir=testdir),
|
2011-06-22 23:36:58 +00:00
|
|
|
run.Raw('&&'),
|
|
|
|
'rm',
|
|
|
|
'-f',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/apache/htdocs/rgw.fcgi'.format(tdir=testdir),
|
2011-06-22 23:36:58 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2011-09-03 00:58:19 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def start_rgw(ctx, config):
|
|
|
|
log.info('Starting rgw...')
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
2012-02-21 23:47:32 +00:00
|
|
|
for client in config.iterkeys():
|
2011-09-03 00:58:19 +00:00
|
|
|
(remote,) = ctx.cluster.only(client).remotes.iterkeys()
|
2012-02-22 00:08:21 +00:00
|
|
|
|
|
|
|
client_config = config.get(client)
|
|
|
|
if client_config is None:
|
|
|
|
client_config = {}
|
2012-02-24 20:04:58 +00:00
|
|
|
log.info("rgw %s config is %s", client, client_config)
|
2012-02-22 00:08:21 +00:00
|
|
|
|
|
|
|
run_cmd=[
|
2013-02-18 20:14:14 +00:00
|
|
|
'sudo',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/enable-coredump'.format(tdir=testdir),
|
2013-02-06 19:16:52 +00:00
|
|
|
'ceph-coverage',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
|
|
|
'{tdir}/daemon-helper'.format(tdir=testdir),
|
2011-09-03 00:58:19 +00:00
|
|
|
'term',
|
2012-02-22 00:08:21 +00:00
|
|
|
]
|
|
|
|
run_cmd_tail=[
|
2013-02-06 19:16:52 +00:00
|
|
|
'radosgw',
|
2013-02-17 03:37:17 +00:00
|
|
|
# authenticate as client.admin and use system keyring
|
|
|
|
'-k', '/etc/ceph/ceph.keyring',
|
2013-02-18 20:14:12 +00:00
|
|
|
'--log-file', '/var/log/ceph/rgw.log',
|
2013-01-23 20:37:39 +00:00
|
|
|
'--rgw_ops_log_socket_path', '{tdir}/rgw.opslog.sock'.format(tdir=testdir),
|
|
|
|
'{tdir}/apache/apache.conf'.format(tdir=testdir),
|
2011-10-05 22:54:57 +00:00
|
|
|
'--foreground',
|
2013-02-18 20:14:12 +00:00
|
|
|
run.Raw('|'),
|
|
|
|
'sudo',
|
|
|
|
'tee',
|
|
|
|
'/var/log/ceph/rgw.stdout'.format(tdir=testdir),
|
2011-09-03 00:58:19 +00:00
|
|
|
run.Raw('2>&1'),
|
2012-02-22 00:08:21 +00:00
|
|
|
]
|
2012-02-22 17:18:17 +00:00
|
|
|
|
2012-02-24 22:55:23 +00:00
|
|
|
run_cmd.extend(
|
|
|
|
teuthology.get_valgrind_args(
|
2013-02-04 04:08:40 +00:00
|
|
|
testdir,
|
2012-02-24 22:55:23 +00:00
|
|
|
client,
|
|
|
|
client_config.get('valgrind')
|
|
|
|
)
|
|
|
|
)
|
2012-02-22 00:08:21 +00:00
|
|
|
|
|
|
|
run_cmd.extend(run_cmd_tail)
|
|
|
|
|
2013-04-30 23:37:48 +00:00
|
|
|
ctx.daemons.add_daemon(
|
|
|
|
remote, 'rgw', client,
|
2012-02-22 00:08:21 +00:00
|
|
|
args=run_cmd,
|
2011-09-03 00:58:19 +00:00
|
|
|
logger=log.getChild(client),
|
|
|
|
stdin=run.PIPE,
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
2013-04-30 23:37:48 +00:00
|
|
|
teuthology.stop_daemons_of_type(ctx, 'rgw')
|
|
|
|
for client in config.iterkeys():
|
2012-11-20 00:19:06 +00:00
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
|
|
|
'rm',
|
2013-04-30 23:37:48 +00:00
|
|
|
'-f',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/rgw.opslog.sock'.format(tdir=testdir),
|
2013-04-30 23:37:48 +00:00
|
|
|
],
|
|
|
|
)
|
2011-09-03 00:58:19 +00:00
|
|
|
|
|
|
|
|
2011-06-22 23:36:58 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def start_apache(ctx, config):
|
|
|
|
log.info('Starting apache...')
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
2011-06-22 23:36:58 +00:00
|
|
|
apaches = {}
|
2012-02-21 23:47:32 +00:00
|
|
|
for client in config.iterkeys():
|
2011-06-22 23:36:58 +00:00
|
|
|
(remote,) = ctx.cluster.only(client).remotes.keys()
|
|
|
|
proc = remote.run(
|
|
|
|
args=[
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/enable-coredump'.format(tdir=testdir),
|
|
|
|
'{tdir}/daemon-helper'.format(tdir=testdir),
|
|
|
|
'kill'.format(tdir=testdir),
|
|
|
|
'apache2'.format(tdir=testdir),
|
|
|
|
'-X'.format(tdir=testdir),
|
|
|
|
'-f'.format(tdir=testdir),
|
|
|
|
'{tdir}/apache/apache.conf'.format(tdir=testdir),
|
2011-06-22 23:36:58 +00:00
|
|
|
],
|
|
|
|
logger=log.getChild(client),
|
|
|
|
stdin=run.PIPE,
|
|
|
|
wait=False,
|
|
|
|
)
|
|
|
|
apaches[client] = proc
|
|
|
|
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
log.info('Stopping apache...')
|
|
|
|
for client, proc in apaches.iteritems():
|
|
|
|
proc.stdin.close()
|
|
|
|
|
|
|
|
run.wait(apaches.itervalues())
|
|
|
|
|
|
|
|
|
|
|
|
@contextlib.contextmanager
|
|
|
|
def task(ctx, config):
|
|
|
|
"""
|
|
|
|
Spin up apache configured to run a rados gateway.
|
|
|
|
Only one should be run per machine, since it uses a hard-coded port for now.
|
|
|
|
|
|
|
|
For example, to run rgw on all clients::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rgw:
|
|
|
|
|
|
|
|
To only run on certain clients::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rgw: [client.0, client.3]
|
2012-02-22 00:08:21 +00:00
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rgw:
|
|
|
|
client.0:
|
|
|
|
client.3:
|
|
|
|
|
|
|
|
To run radosgw through valgrind:
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rgw:
|
|
|
|
client.0:
|
|
|
|
valgrind: [--tool=memcheck]
|
|
|
|
client.3:
|
|
|
|
valgrind: [--tool=memcheck]
|
2012-02-24 20:04:58 +00:00
|
|
|
|
2011-06-22 23:36:58 +00:00
|
|
|
"""
|
|
|
|
if config is None:
|
2012-02-21 23:47:32 +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)
|
2011-06-22 23:36:58 +00:00
|
|
|
|
|
|
|
for _, roles_for_host in ctx.cluster.remotes.iteritems():
|
|
|
|
running_rgw = False
|
|
|
|
for role in roles_for_host:
|
2012-02-21 23:47:32 +00:00
|
|
|
if role in config.iterkeys():
|
2011-06-22 23:36:58 +00:00
|
|
|
assert not running_rgw, "Only one client per host can run rgw."
|
|
|
|
running_rgw = True
|
|
|
|
|
|
|
|
with contextutil.nested(
|
|
|
|
lambda: create_dirs(ctx=ctx, config=config),
|
|
|
|
lambda: ship_config(ctx=ctx, config=config),
|
2011-09-03 00:58:19 +00:00
|
|
|
lambda: start_rgw(ctx=ctx, config=config),
|
2011-06-22 23:36:58 +00:00
|
|
|
lambda: start_apache(ctx=ctx, config=config),
|
|
|
|
):
|
|
|
|
yield
|