]> git.proxmox.com Git - ceph.git/blame - ceph/qa/tasks/rgw_logsocket.py
import 15.2.4
[ceph.git] / ceph / qa / tasks / rgw_logsocket.py
CommitLineData
7c673cae
FG
1"""
2rgw s3tests logging wrappers
3"""
e306af50 4from io import BytesIO
7c673cae
FG
5from configobj import ConfigObj
6import contextlib
7import logging
e306af50 8from tasks import s3tests
7c673cae
FG
9
10from teuthology import misc as teuthology
11from teuthology import contextutil
12
13log = logging.getLogger(__name__)
14
15
16@contextlib.contextmanager
17def download(ctx, config):
18 """
19 Run s3tests download function
20 """
21 return s3tests.download(ctx, config)
22
23def _config_user(s3tests_conf, section, user):
24 """
25 Run s3tests user config function
26 """
27 return s3tests._config_user(s3tests_conf, section, user)
28
29@contextlib.contextmanager
30def create_users(ctx, config):
31 """
32 Run s3tests user create function
33 """
34 return s3tests.create_users(ctx, config)
35
36@contextlib.contextmanager
37def configure(ctx, config):
38 """
39 Run s3tests user configure function
40 """
41 return s3tests.configure(ctx, config)
42
43@contextlib.contextmanager
44def run_tests(ctx, config):
45 """
46 Run remote netcat tests
47 """
48 assert isinstance(config, dict)
49 testdir = teuthology.get_testdir(ctx)
9f95a23c 50 for client, client_config in config.items():
7c673cae
FG
51 client_config['extra_args'] = [
52 's3tests.functional.test_s3:test_bucket_list_return_data',
53 ]
54# args = [
55# 'S3TEST_CONF={tdir}/archive/s3-tests.{client}.conf'.format(tdir=testdir, client=client),
56# '{tdir}/s3-tests/virtualenv/bin/nosetests'.format(tdir=testdir),
57# '-w',
58# '{tdir}/s3-tests'.format(tdir=testdir),
59# '-v',
60# 's3tests.functional.test_s3:test_bucket_list_return_data',
61# ]
62# if client_config is not None and 'extra_args' in client_config:
63# args.extend(client_config['extra_args'])
64#
65# ctx.cluster.only(client).run(
66# args=args,
67# )
68
69 s3tests.run_tests(ctx, config)
70
e306af50 71 netcat_out = BytesIO()
7c673cae 72
9f95a23c 73 for client, client_config in config.items():
7c673cae
FG
74 ctx.cluster.only(client).run(
75 args = [
76 'netcat',
77 '-w', '5',
78 '-U', '{tdir}/rgw.opslog.sock'.format(tdir=testdir),
79 ],
80 stdout = netcat_out,
81 )
82
83 out = netcat_out.getvalue()
84
85 assert len(out) > 100
86
87 log.info('Received', out)
88
89 yield
90
91
92@contextlib.contextmanager
93def task(ctx, config):
94 """
95 Run some s3-tests suite against rgw, verify opslog socket returns data
96
97 Must restrict testing to a particular client::
98
99 tasks:
100 - ceph:
101 - rgw: [client.0]
102 - s3tests: [client.0]
103
104 To pass extra arguments to nose (e.g. to run a certain test)::
105
106 tasks:
107 - ceph:
108 - rgw: [client.0]
109 - s3tests:
110 client.0:
111 extra_args: ['test_s3:test_object_acl_grand_public_read']
112 client.1:
113 extra_args: ['--exclude', 'test_100_continue']
114 """
494da23a 115 assert hasattr(ctx, 'rgw'), 'rgw-logsocket must run after the rgw task'
7c673cae
FG
116 assert config is None or isinstance(config, list) \
117 or isinstance(config, dict), \
494da23a 118 "task rgw-logsocket only supports a list or dictionary for configuration"
7c673cae
FG
119 all_clients = ['client.{id}'.format(id=id_)
120 for id_ in teuthology.all_roles_of_type(ctx.cluster, 'client')]
121 if config is None:
122 config = all_clients
123 if isinstance(config, list):
124 config = dict.fromkeys(config)
125 clients = config.keys()
126
127 overrides = ctx.config.get('overrides', {})
128 # merge each client section, not the top level.
9f95a23c 129 for (client, cconf) in config.items():
7c673cae
FG
130 teuthology.deep_merge(cconf, overrides.get('rgw-logsocket', {}))
131
132 log.debug('config is %s', config)
133
134 s3tests_conf = {}
135 for client in clients:
494da23a
TL
136 endpoint = ctx.rgw.role_endpoints.get(client)
137 assert endpoint, 'rgw-logsocket: no rgw endpoint for {}'.format(client)
138
7c673cae
FG
139 s3tests_conf[client] = ConfigObj(
140 indent_type='',
141 infile={
142 'DEFAULT':
143 {
494da23a
TL
144 'port' : endpoint.port,
145 'is_secure' : endpoint.cert is not None,
7c673cae
FG
146 },
147 'fixtures' : {},
148 's3 main' : {},
149 's3 alt' : {},
150 }
151 )
152
153 with contextutil.nested(
154 lambda: download(ctx=ctx, config=config),
155 lambda: create_users(ctx=ctx, config=dict(
156 clients=clients,
157 s3tests_conf=s3tests_conf,
158 )),
159 lambda: configure(ctx=ctx, config=dict(
160 clients=config,
161 s3tests_conf=s3tests_conf,
162 )),
163 lambda: run_tests(ctx=ctx, config=config),
164 ):
165 yield