]> git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/rgw_logsocket.py
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / qa / tasks / rgw_logsocket.py
1 """
2 rgw s3tests logging wrappers
3 """
4 from cStringIO import StringIO
5 from configobj import ConfigObj
6 import contextlib
7 import logging
8 import s3tests
9
10 from teuthology import misc as teuthology
11 from teuthology import contextutil
12
13 log = logging.getLogger(__name__)
14
15
16 @contextlib.contextmanager
17 def download(ctx, config):
18 """
19 Run s3tests download function
20 """
21 return s3tests.download(ctx, config)
22
23 def _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
30 def create_users(ctx, config):
31 """
32 Run s3tests user create function
33 """
34 return s3tests.create_users(ctx, config)
35
36 @contextlib.contextmanager
37 def configure(ctx, config):
38 """
39 Run s3tests user configure function
40 """
41 return s3tests.configure(ctx, config)
42
43 @contextlib.contextmanager
44 def run_tests(ctx, config):
45 """
46 Run remote netcat tests
47 """
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',
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
71 netcat_out = StringIO()
72
73 for client, client_config in config.iteritems():
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
93 def 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 """
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')]
120 if config is None:
121 config = all_clients
122 if isinstance(config, list):
123 config = dict.fromkeys(config)
124 clients = config.keys()
125
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', {}))
130
131 log.debug('config is %s', config)
132
133 s3tests_conf = {}
134 for client in clients:
135 s3tests_conf[client] = ConfigObj(
136 indent_type='',
137 infile={
138 'DEFAULT':
139 {
140 'port' : 7280,
141 'is_secure' : 'no',
142 },
143 'fixtures' : {},
144 's3 main' : {},
145 's3 alt' : {},
146 }
147 )
148
149 with contextutil.nested(
150 lambda: download(ctx=ctx, config=config),
151 lambda: create_users(ctx=ctx, config=dict(
152 clients=clients,
153 s3tests_conf=s3tests_conf,
154 )),
155 lambda: configure(ctx=ctx, config=dict(
156 clients=config,
157 s3tests_conf=s3tests_conf,
158 )),
159 lambda: run_tests(ctx=ctx, config=config),
160 ):
161 yield