2 rgw s3tests logging wrappers
4 from cStringIO import StringIO
5 from configobj import ConfigObj
10 from teuthology import misc as teuthology
11 from teuthology import contextutil
13 log = logging.getLogger(__name__)
16 @contextlib.contextmanager
17 def download(ctx, config):
19 Run s3tests download function
21 return s3tests.download(ctx, config)
23 def _config_user(s3tests_conf, section, user):
25 Run s3tests user config function
27 return s3tests._config_user(s3tests_conf, section, user)
29 @contextlib.contextmanager
30 def create_users(ctx, config):
32 Run s3tests user create function
34 return s3tests.create_users(ctx, config)
36 @contextlib.contextmanager
37 def configure(ctx, config):
39 Run s3tests user configure function
41 return s3tests.configure(ctx, config)
43 @contextlib.contextmanager
44 def run_tests(ctx, config):
46 Run remote netcat tests
48 assert isinstance(config, dict)
49 testdir = teuthology.get_testdir(ctx)
50 for client, client_config in config.iteritems():
51 client_config['extra_args'] = [
52 's3tests.functional.test_s3:test_bucket_list_return_data',
55 # 'S3TEST_CONF={tdir}/archive/s3-tests.{client}.conf'.format(tdir=testdir, client=client),
56 # '{tdir}/s3-tests/virtualenv/bin/nosetests'.format(tdir=testdir),
58 # '{tdir}/s3-tests'.format(tdir=testdir),
60 # 's3tests.functional.test_s3:test_bucket_list_return_data',
62 # if client_config is not None and 'extra_args' in client_config:
63 # args.extend(client_config['extra_args'])
65 # ctx.cluster.only(client).run(
69 s3tests.run_tests(ctx, config)
71 netcat_out = StringIO()
73 for client, client_config in config.iteritems():
74 ctx.cluster.only(client).run(
78 '-U', '{tdir}/rgw.opslog.sock'.format(tdir=testdir),
83 out = netcat_out.getvalue()
87 log.info('Received', out)
92 @contextlib.contextmanager
93 def task(ctx, config):
95 Run some s3-tests suite against rgw, verify opslog socket returns data
97 Must restrict testing to a particular client::
102 - s3tests: [client.0]
104 To pass extra arguments to nose (e.g. to run a certain test)::
111 extra_args: ['test_s3:test_object_acl_grand_public_read']
113 extra_args: ['--exclude', 'test_100_continue']
115 assert config is None or isinstance(config, list) \
116 or isinstance(config, dict), \
117 "task s3tests only supports a list or dictionary for configuration"
118 all_clients = ['client.{id}'.format(id=id_)
119 for id_ in teuthology.all_roles_of_type(ctx.cluster, 'client')]
122 if isinstance(config, list):
123 config = dict.fromkeys(config)
124 clients = config.keys()
126 overrides = ctx.config.get('overrides', {})
127 # merge each client section, not the top level.
128 for (client, cconf) in config.iteritems():
129 teuthology.deep_merge(cconf, overrides.get('rgw-logsocket', {}))
131 log.debug('config is %s', config)
134 for client in clients:
135 s3tests_conf[client] = ConfigObj(
149 with contextutil.nested(
150 lambda: download(ctx=ctx, config=config),
151 lambda: create_users(ctx=ctx, config=dict(
153 s3tests_conf=s3tests_conf,
155 lambda: configure(ctx=ctx, config=dict(
157 s3tests_conf=s3tests_conf,
159 lambda: run_tests(ctx=ctx, config=config),