1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
"""
rgw s3tests logging wrappers
"""
from io import BytesIO
from configobj import ConfigObj
import contextlib
import logging
from tasks import s3tests
from teuthology import misc as teuthology
from teuthology import contextutil
log = logging.getLogger(__name__)
@contextlib.contextmanager
def download(ctx, config):
"""
Run s3tests download function
"""
return s3tests.download(ctx, config)
def _config_user(s3tests_conf, section, user):
"""
Run s3tests user config function
"""
return s3tests._config_user(s3tests_conf, section, user)
@contextlib.contextmanager
def create_users(ctx, config):
"""
Run s3tests user create function
"""
return s3tests.create_users(ctx, config)
@contextlib.contextmanager
def configure(ctx, config):
"""
Run s3tests user configure function
"""
return s3tests.configure(ctx, config)
@contextlib.contextmanager
def run_tests(ctx, config):
"""
Run remote netcat tests
"""
assert isinstance(config, dict)
testdir = teuthology.get_testdir(ctx)
for client, client_config in config.items():
client_config['extra_args'] = [
's3tests.functional.test_s3:test_bucket_list_return_data',
]
# args = [
# 'S3TEST_CONF={tdir}/archive/s3-tests.{client}.conf'.format(tdir=testdir, client=client),
# '{tdir}/s3-tests/virtualenv/bin/nosetests'.format(tdir=testdir),
# '-w',
# '{tdir}/s3-tests'.format(tdir=testdir),
# '-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.run_tests(ctx, config)
netcat_out = BytesIO()
for client, client_config in config.items():
ctx.cluster.only(client).run(
args = [
'netcat',
'-w', '5',
'-U', '{tdir}/rgw.opslog.sock'.format(tdir=testdir),
],
stdout = netcat_out,
)
out = netcat_out.getvalue()
assert len(out) > 100
log.info('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 hasattr(ctx, 'rgw'), 'rgw-logsocket must run after the rgw task'
assert config is None or isinstance(config, list) \
or isinstance(config, dict), \
"task rgw-logsocket 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.items():
teuthology.deep_merge(cconf, overrides.get('rgw-logsocket', {}))
log.debug('config is %s', config)
s3tests_conf = {}
for client in clients:
endpoint = ctx.rgw.role_endpoints.get(client)
assert endpoint, 'rgw-logsocket: no rgw endpoint for {}'.format(client)
s3tests_conf[client] = ConfigObj(
indent_type='',
infile={
'DEFAULT':
{
'port' : endpoint.port,
'is_secure' : endpoint.cert is not None,
},
'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
|