From 1c50db6a4630d07e72144dafd985c397f8a42dc5 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 19 Nov 2012 16:19:06 -0800 Subject: [PATCH] rgw-logsocket: a task to verify opslog socket works Signed-off-by: Yehuda Sadeh --- teuthology/task/rgw-logsocket.py | 150 +++++++++++++++++++++++++++++++ teuthology/task/rgw.py | 9 ++ teuthology/task/s3tests.py | 27 ++++-- 3 files changed, 177 insertions(+), 9 deletions(-) create mode 100644 teuthology/task/rgw-logsocket.py diff --git a/teuthology/task/rgw-logsocket.py b/teuthology/task/rgw-logsocket.py new file mode 100644 index 0000000000000..daa29c18cb3c0 --- /dev/null +++ b/teuthology/task/rgw-logsocket.py @@ -0,0 +1,150 @@ +from cStringIO import StringIO +from configobj import ConfigObj +import base64 +import contextlib +import logging +import os +import random +import string +import s3tests +import socket + +from teuthology import misc as teuthology +from teuthology import contextutil +from ..orchestra import run +from ..orchestra.connection import split_user + +log = logging.getLogger(__name__) + + +@contextlib.contextmanager +def download(ctx, config): + return s3tests.do_download(ctx, config) + +def _config_user(s3tests_conf, section, user): + return s3tests._config_user(s3tests_conf, section, user) + +@contextlib.contextmanager +def create_users(ctx, config): + return s3tests.do_create_users(ctx, config) + +@contextlib.contextmanager +def configure(ctx, config): + return s3tests.do_configure(ctx, config) + +@contextlib.contextmanager +def run_tests(ctx, config): + assert isinstance(config, dict) + for client, client_config in config.iteritems(): + client_config['extra_args'] = [ + 's3tests.functional.test_s3:test_bucket_list_return_data', + ] + +# args = [ +# 'S3TEST_CONF=/tmp/cephtest/archive/s3-tests.{client}.conf'.format(client=client), +# '/tmp/cephtest/s3-tests/virtualenv/bin/nosetests', +# '-w', +# '/tmp/cephtest/s3-tests', +# '-v', +# 's3tests.functional.test_s3:test_bucket_list_return_data', +# ] +# if client_config is not None and 'extra_args' in client_config: +# args.extend(client_config['extra_args']) +# +# ctx.cluster.only(client).run( +# args=args, +# ) + + s3tests.do_run_tests(ctx, config) + + netcat_out = StringIO() + + for client, client_config in config.iteritems(): + proc = ctx.cluster.only(client).run( + args = [ + 'netcat', + '-w', '5', + '-U', '/tmp/cephtest/rgw.opslog.sock', + ], + stdout = netcat_out, + ) + + out = netcat_out.getvalue() + + assert len(out) > 100 + + print 'Received', out + + yield + + +@contextlib.contextmanager +def task(ctx, config): + """ + Run some s3-tests suite against rgw, verify opslog socket returns data + + Must restrict testing to a particular client:: + + tasks: + - ceph: + - rgw: [client.0] + - s3tests: [client.0] + + To pass extra arguments to nose (e.g. to run a certain test):: + + tasks: + - ceph: + - rgw: [client.0] + - s3tests: + client.0: + extra_args: ['test_s3:test_object_acl_grand_public_read'] + client.1: + extra_args: ['--exclude', 'test_100_continue'] + """ + assert config is None or isinstance(config, list) \ + or isinstance(config, dict), \ + "task s3tests only supports a list or dictionary for configuration" + all_clients = ['client.{id}'.format(id=id_) + for id_ in teuthology.all_roles_of_type(ctx.cluster, 'client')] + if config is None: + config = all_clients + if isinstance(config, list): + config = dict.fromkeys(config) + clients = config.keys() + + overrides = ctx.config.get('overrides', {}) + # merge each client section, not the top level. + for (client, cconf) in config.iteritems(): + teuthology.deep_merge(cconf, overrides.get('rgw-logsocket', {})) + + log.debug('config is %s', config) + + s3tests_conf = {} + for client in clients: + s3tests_conf[client] = ConfigObj( + indent_type='', + infile={ + 'DEFAULT': + { + 'port' : 7280, + 'is_secure' : 'no', + }, + 'fixtures' : {}, + 's3 main' : {}, + 's3 alt' : {}, + } + ) + + with contextutil.nested( + lambda: download(ctx=ctx, config=config), + lambda: create_users(ctx=ctx, config=dict( + clients=clients, + s3tests_conf=s3tests_conf, + )), + lambda: configure(ctx=ctx, config=dict( + clients=config, + s3tests_conf=s3tests_conf, + )), + lambda: run_tests(ctx=ctx, config=config), + ): + yield diff --git a/teuthology/task/rgw.py b/teuthology/task/rgw.py index eebba4f3d17b3..04ed675db5f1a 100644 --- a/teuthology/task/rgw.py +++ b/teuthology/task/rgw.py @@ -115,6 +115,7 @@ def start_rgw(ctx, config): '/tmp/cephtest/binary/usr/local/bin/radosgw', '-c', '/tmp/cephtest/ceph.conf', '--log-file', '/tmp/cephtest/archive/log/rgw.log', + '--rgw_ops_log_socket_path', '/tmp/cephtest/rgw.opslog.sock', '/tmp/cephtest/apache/apache.conf', '--foreground', run.Raw('>'), @@ -146,6 +147,14 @@ def start_rgw(ctx, config): for client, proc in rgws.iteritems(): proc.stdin.close() + ctx.cluster.only(client).run( + args=[ + 'rm', + '-rf', + '/tmp/cephtest/rgw.opslog.sock', + ], + ) + run.wait(rgws.itervalues()) diff --git a/teuthology/task/s3tests.py b/teuthology/task/s3tests.py index a7ef4264a75dd..cf321561ecb27 100644 --- a/teuthology/task/s3tests.py +++ b/teuthology/task/s3tests.py @@ -15,8 +15,7 @@ from ..orchestra.connection import split_user log = logging.getLogger(__name__) -@contextlib.contextmanager -def download(ctx, config): +def do_download(ctx, config): assert isinstance(config, dict) log.info('Downloading s3-tests...') for (client, cconf) in config.items(): @@ -52,6 +51,10 @@ def download(ctx, config): ], ) +@contextlib.contextmanager +def download(ctx, config): + return do_downoad(ctx, config) + def _config_user(s3tests_conf, section, user): s3tests_conf[section].setdefault('user_id', user) s3tests_conf[section].setdefault('email', '{user}+test@test.test'.format(user=user)) @@ -59,8 +62,7 @@ def _config_user(s3tests_conf, section, user): s3tests_conf[section].setdefault('access_key', ''.join(random.choice(string.uppercase) for i in xrange(20))) s3tests_conf[section].setdefault('secret_key', base64.b64encode(os.urandom(40))) -@contextlib.contextmanager -def create_users(ctx, config): +def do_create_users(ctx, config): assert isinstance(config, dict) log.info('Creating rgw users...') for client in config['clients']: @@ -87,9 +89,11 @@ def create_users(ctx, config): ) yield - @contextlib.contextmanager -def configure(ctx, config): +def create_users(ctx, config): + return do_create_users(ctx, config) + +def do_configure(ctx, config): assert isinstance(config, dict) log.info('Configuring s3-tests...') for client, properties in config['clients'].iteritems(): @@ -124,9 +128,11 @@ def configure(ctx, config): ) yield - @contextlib.contextmanager -def run_tests(ctx, config): +def configure(ctx, config): + return do_configure(ctx, config) + +def do_run_tests(ctx, config): assert isinstance(config, dict) for client, client_config in config.iteritems(): args = [ @@ -143,8 +149,11 @@ def run_tests(ctx, config): ctx.cluster.only(client).run( args=args, ) - yield +@contextlib.contextmanager +def run_tests(ctx, config): + do_run_tests(ctx, config) + yield @contextlib.contextmanager def task(ctx, config): -- 2.39.5