]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/rgw_logsocket.py
2 rgw s3tests logging wrappers
5 from configobj
import ConfigObj
8 from tasks
import s3tests
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
.items():
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
= BytesIO()
73 for client
, client_config
in config
.items():
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 hasattr(ctx
, 'rgw'), 'rgw-logsocket must run after the rgw task'
116 assert config
is None or isinstance(config
, list) \
117 or isinstance(config
, dict), \
118 "task rgw-logsocket only supports a list or dictionary for configuration"
119 all_clients
= ['client.{id}'.format(id=id_
)
120 for id_
in teuthology
.all_roles_of_type(ctx
.cluster
, 'client')]
123 if isinstance(config
, list):
124 config
= dict.fromkeys(config
)
125 clients
= config
.keys()
127 overrides
= ctx
.config
.get('overrides', {})
128 # merge each client section, not the top level.
129 for (client
, cconf
) in config
.items():
130 teuthology
.deep_merge(cconf
, overrides
.get('rgw-logsocket', {}))
132 log
.debug('config is %s', config
)
135 for client
in clients
:
136 endpoint
= ctx
.rgw
.role_endpoints
.get(client
)
137 assert endpoint
, 'rgw-logsocket: no rgw endpoint for {}'.format(client
)
139 s3tests_conf
[client
] = ConfigObj(
144 'port' : endpoint
.port
,
145 'is_secure' : endpoint
.cert
is not None,
153 with contextutil
.nested(
154 lambda: download(ctx
=ctx
, config
=config
),
155 lambda: create_users(ctx
=ctx
, config
=dict(
157 s3tests_conf
=s3tests_conf
,
159 lambda: configure(ctx
=ctx
, config
=dict(
161 s3tests_conf
=s3tests_conf
,
163 lambda: run_tests(ctx
=ctx
, config
=config
),