2014-02-12 04:21:06 +00:00
|
|
|
"""
|
|
|
|
Run a set of s3 tests on rgw.
|
|
|
|
"""
|
2020-02-15 10:12:40 +00:00
|
|
|
from io import BytesIO
|
2011-06-25 00:09:47 +00:00
|
|
|
from configobj import ConfigObj
|
|
|
|
import base64
|
|
|
|
import contextlib
|
|
|
|
import logging
|
|
|
|
import os
|
2012-02-21 20:12:03 +00:00
|
|
|
import random
|
2012-02-21 22:54:33 +00:00
|
|
|
import string
|
2011-06-25 00:09:47 +00:00
|
|
|
|
|
|
|
from teuthology import misc as teuthology
|
|
|
|
from teuthology import contextutil
|
2014-08-07 14:24:59 +00:00
|
|
|
from teuthology.config import config as teuth_config
|
|
|
|
from teuthology.orchestra import run
|
2019-09-09 13:12:24 +00:00
|
|
|
from teuthology.exceptions import ConfigError
|
2011-06-25 00:09:47 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2013-04-30 20:23:22 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def download(ctx, config):
|
2014-02-12 04:21:06 +00:00
|
|
|
"""
|
|
|
|
Download the s3 tests from the git builder.
|
|
|
|
Remove downloaded s3 file upon exit.
|
2014-10-22 15:12:43 +00:00
|
|
|
|
2014-02-12 04:21:06 +00:00
|
|
|
The context passed in should be identical to the context
|
|
|
|
passed in to the main task.
|
|
|
|
"""
|
2012-09-10 18:08:57 +00:00
|
|
|
assert isinstance(config, dict)
|
2011-06-25 00:09:47 +00:00
|
|
|
log.info('Downloading s3-tests...')
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
2019-11-25 02:30:03 +00:00
|
|
|
for (client, client_config) in config.items():
|
|
|
|
s3tests_branch = client_config.get('force-branch', None)
|
|
|
|
if not s3tests_branch:
|
2014-10-22 15:12:43 +00:00
|
|
|
raise ValueError(
|
2019-11-25 02:30:03 +00:00
|
|
|
"Could not determine what branch to use for s3-tests. Please add 'force-branch: {s3-tests branch name}' to the .yaml config for this s3tests task.")
|
|
|
|
|
|
|
|
log.info("Using branch '%s' for s3tests", s3tests_branch)
|
|
|
|
sha1 = client_config.get('sha1')
|
|
|
|
git_remote = client_config.get('git_remote', teuth_config.ceph_git_base_url)
|
2011-06-25 00:09:47 +00:00
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
|
|
|
'git', 'clone',
|
2019-11-25 02:30:03 +00:00
|
|
|
'-b', s3tests_branch,
|
2017-06-02 09:03:03 +00:00
|
|
|
git_remote + 's3-tests.git',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/s3-tests'.format(tdir=testdir),
|
2011-06-25 00:09:47 +00:00
|
|
|
],
|
|
|
|
)
|
2012-09-10 18:08:57 +00:00
|
|
|
if sha1 is not None:
|
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
2013-01-23 20:37:39 +00:00
|
|
|
'cd', '{tdir}/s3-tests'.format(tdir=testdir),
|
2012-09-10 18:08:57 +00:00
|
|
|
run.Raw('&&'),
|
|
|
|
'git', 'reset', '--hard', sha1,
|
|
|
|
],
|
|
|
|
)
|
2011-06-25 00:09:47 +00:00
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
2013-04-30 23:47:34 +00:00
|
|
|
log.info('Removing s3-tests...')
|
|
|
|
testdir = teuthology.get_testdir(ctx)
|
|
|
|
for client in config:
|
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
|
|
|
'rm',
|
|
|
|
'-rf',
|
|
|
|
'{tdir}/s3-tests'.format(tdir=testdir),
|
|
|
|
],
|
|
|
|
)
|
2011-06-25 00:09:47 +00:00
|
|
|
|
2012-11-20 00:19:06 +00:00
|
|
|
|
2011-06-25 00:09:47 +00:00
|
|
|
def _config_user(s3tests_conf, section, user):
|
2014-02-12 04:21:06 +00:00
|
|
|
"""
|
|
|
|
Configure users for this section by stashing away keys, ids, and
|
|
|
|
email addresses.
|
|
|
|
"""
|
2011-08-09 20:43:46 +00:00
|
|
|
s3tests_conf[section].setdefault('user_id', user)
|
|
|
|
s3tests_conf[section].setdefault('email', '{user}+test@test.test'.format(user=user))
|
|
|
|
s3tests_conf[section].setdefault('display_name', 'Mr. {user}'.format(user=user))
|
2020-02-15 10:12:40 +00:00
|
|
|
s3tests_conf[section].setdefault('access_key',
|
|
|
|
''.join(random.choice(string.ascii_uppercase) for i in range(20)))
|
|
|
|
s3tests_conf[section].setdefault('secret_key',
|
2020-06-28 11:45:05 +00:00
|
|
|
base64.b64encode(os.urandom(40)).decode())
|
2020-02-15 10:12:40 +00:00
|
|
|
s3tests_conf[section].setdefault('totp_serial',
|
|
|
|
''.join(random.choice(string.digits) for i in range(10)))
|
|
|
|
s3tests_conf[section].setdefault('totp_seed',
|
2020-06-28 11:45:05 +00:00
|
|
|
base64.b32encode(os.urandom(40)).decode())
|
2018-04-04 18:31:37 +00:00
|
|
|
s3tests_conf[section].setdefault('totp_seconds', '5')
|
2011-06-25 00:09:47 +00:00
|
|
|
|
2013-04-30 20:23:22 +00:00
|
|
|
|
|
|
|
@contextlib.contextmanager
|
|
|
|
def create_users(ctx, config):
|
2014-02-12 04:21:06 +00:00
|
|
|
"""
|
|
|
|
Create a main and an alternate s3 user.
|
|
|
|
"""
|
2011-06-25 00:09:47 +00:00
|
|
|
assert isinstance(config, dict)
|
|
|
|
log.info('Creating rgw users...')
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
2020-05-22 20:58:53 +00:00
|
|
|
users = {'s3 main': 'foo', 's3 alt': 'bar', 's3 tenant': 'testx$tenanteduser', 'iam': 'foobar'}
|
2011-06-25 00:09:47 +00:00
|
|
|
for client in config['clients']:
|
|
|
|
s3tests_conf = config['s3tests_conf'][client]
|
2011-09-09 20:22:03 +00:00
|
|
|
s3tests_conf.setdefault('fixtures', {})
|
2011-08-09 20:43:46 +00:00
|
|
|
s3tests_conf['fixtures'].setdefault('bucket prefix', 'test-' + client + '-{random}-')
|
2019-10-09 12:36:58 +00:00
|
|
|
for section, user in users.items():
|
2011-06-25 00:09:47 +00:00
|
|
|
_config_user(s3tests_conf, section, '{user}.{client}'.format(user=user, client=client))
|
2014-02-12 04:21:06 +00:00
|
|
|
log.debug('Creating user {user} on {host}'.format(user=s3tests_conf[section]['user_id'], host=client))
|
2016-12-16 18:23:09 +00:00
|
|
|
cluster_name, daemon_type, client_id = teuthology.split_role(client)
|
|
|
|
client_with_id = daemon_type + '.' + client_id
|
2020-05-22 20:58:53 +00:00
|
|
|
if section=='iam':
|
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
|
|
|
'adjust-ulimits',
|
|
|
|
'ceph-coverage',
|
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
|
|
|
'radosgw-admin',
|
|
|
|
'-n', client_with_id,
|
|
|
|
'user', 'create',
|
|
|
|
'--uid', s3tests_conf[section]['user_id'],
|
|
|
|
'--display-name', s3tests_conf[section]['display_name'],
|
|
|
|
'--access-key', s3tests_conf[section]['access_key'],
|
|
|
|
'--secret', s3tests_conf[section]['secret_key'],
|
|
|
|
'--cluster', cluster_name,
|
|
|
|
],
|
|
|
|
)
|
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
|
|
|
'adjust-ulimits',
|
|
|
|
'ceph-coverage',
|
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
|
|
|
'radosgw-admin',
|
|
|
|
'-n', client_with_id,
|
|
|
|
'caps', 'add',
|
|
|
|
'--uid', s3tests_conf[section]['user_id'],
|
|
|
|
'--caps', 'user-policy=*',
|
|
|
|
'--cluster', cluster_name,
|
|
|
|
],
|
|
|
|
)
|
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
|
|
|
'adjust-ulimits',
|
|
|
|
'ceph-coverage',
|
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
|
|
|
'radosgw-admin',
|
|
|
|
'-n', client_with_id,
|
|
|
|
'caps', 'add',
|
|
|
|
'--uid', s3tests_conf[section]['user_id'],
|
|
|
|
'--caps', 'roles=*',
|
|
|
|
'--cluster', cluster_name,
|
|
|
|
],
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
|
|
|
'adjust-ulimits',
|
|
|
|
'ceph-coverage',
|
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
|
|
|
'radosgw-admin',
|
|
|
|
'-n', client_with_id,
|
|
|
|
'user', 'create',
|
|
|
|
'--uid', s3tests_conf[section]['user_id'],
|
|
|
|
'--display-name', s3tests_conf[section]['display_name'],
|
|
|
|
'--access-key', s3tests_conf[section]['access_key'],
|
|
|
|
'--secret', s3tests_conf[section]['secret_key'],
|
|
|
|
'--email', s3tests_conf[section]['email'],
|
|
|
|
'--caps', 'user-policy=*',
|
|
|
|
'--cluster', cluster_name,
|
|
|
|
],
|
|
|
|
)
|
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
|
|
|
'adjust-ulimits',
|
|
|
|
'ceph-coverage',
|
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
|
|
|
'radosgw-admin',
|
|
|
|
'-n', client_with_id,
|
|
|
|
'mfa', 'create',
|
|
|
|
'--uid', s3tests_conf[section]['user_id'],
|
|
|
|
'--totp-serial', s3tests_conf[section]['totp_serial'],
|
|
|
|
'--totp-seed', s3tests_conf[section]['totp_seed'],
|
|
|
|
'--totp-seconds', s3tests_conf[section]['totp_seconds'],
|
|
|
|
'--totp-window', '8',
|
|
|
|
'--totp-seed-type', 'base32',
|
|
|
|
'--cluster', cluster_name,
|
|
|
|
],
|
|
|
|
)
|
2013-04-30 23:49:04 +00:00
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
for client in config['clients']:
|
2020-02-15 10:12:40 +00:00
|
|
|
for user in users.values():
|
2013-04-30 23:49:04 +00:00
|
|
|
uid = '{user}.{client}'.format(user=user, client=client)
|
2016-12-16 18:23:09 +00:00
|
|
|
cluster_name, daemon_type, client_id = teuthology.split_role(client)
|
|
|
|
client_with_id = daemon_type + '.' + client_id
|
2013-04-30 23:49:04 +00:00
|
|
|
ctx.cluster.only(client).run(
|
|
|
|
args=[
|
2013-09-06 20:08:01 +00:00
|
|
|
'adjust-ulimits',
|
2013-04-30 23:49:04 +00:00
|
|
|
'ceph-coverage',
|
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
|
|
|
'radosgw-admin',
|
2016-12-16 18:23:09 +00:00
|
|
|
'-n', client_with_id,
|
2013-04-30 23:49:04 +00:00
|
|
|
'user', 'rm',
|
|
|
|
'--uid', uid,
|
|
|
|
'--purge-data',
|
2016-12-16 18:23:09 +00:00
|
|
|
'--cluster', cluster_name,
|
2013-04-30 23:49:04 +00:00
|
|
|
],
|
|
|
|
)
|
2011-06-25 00:09:47 +00:00
|
|
|
|
2012-11-20 00:19:06 +00:00
|
|
|
|
2013-04-30 20:23:22 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def configure(ctx, config):
|
2014-02-12 04:21:06 +00:00
|
|
|
"""
|
|
|
|
Configure the s3-tests. This includes the running of the
|
|
|
|
bootstrap code and the updating of local conf files.
|
|
|
|
"""
|
2011-06-25 00:09:47 +00:00
|
|
|
assert isinstance(config, dict)
|
|
|
|
log.info('Configuring s3-tests...')
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
2019-10-09 12:36:58 +00:00
|
|
|
for client, properties in config['clients'].items():
|
2019-09-05 19:51:16 +00:00
|
|
|
properties = properties or {}
|
2011-06-25 00:09:47 +00:00
|
|
|
s3tests_conf = config['s3tests_conf'][client]
|
2019-09-06 19:08:29 +00:00
|
|
|
s3tests_conf['DEFAULT']['calling_format'] = properties.get('calling-format', 'ordinary')
|
2011-06-25 00:09:47 +00:00
|
|
|
|
2019-09-05 19:51:16 +00:00
|
|
|
# use rgw_server if given, or default to local client
|
|
|
|
role = properties.get('rgw_server', client)
|
|
|
|
|
|
|
|
endpoint = ctx.rgw.role_endpoints.get(role)
|
|
|
|
assert endpoint, 's3tests: no rgw endpoint for {}'.format(role)
|
|
|
|
|
|
|
|
s3tests_conf['DEFAULT']['host'] = endpoint.dns_name
|
|
|
|
|
2019-09-05 19:52:15 +00:00
|
|
|
website_role = properties.get('rgw_website_server')
|
|
|
|
if website_role:
|
|
|
|
website_endpoint = ctx.rgw.role_endpoints.get(website_role)
|
|
|
|
assert website_endpoint, \
|
|
|
|
's3tests: no rgw endpoint for rgw_website_server {}'.format(website_role)
|
|
|
|
assert website_endpoint.website_dns_name, \
|
|
|
|
's3tests: no dns-s3website-name for rgw_website_server {}'.format(website_role)
|
|
|
|
s3tests_conf['DEFAULT']['s3website_domain'] = website_endpoint.website_dns_name
|
|
|
|
|
2019-09-09 13:12:24 +00:00
|
|
|
if hasattr(ctx, 'barbican'):
|
|
|
|
properties = properties['barbican']
|
|
|
|
if properties is not None and 'kms_key' in properties:
|
|
|
|
if not (properties['kms_key'] in ctx.barbican.keys):
|
|
|
|
raise ConfigError('Key '+properties['kms_key']+' not defined')
|
|
|
|
|
|
|
|
if not (properties['kms_key2'] in ctx.barbican.keys):
|
|
|
|
raise ConfigError('Key '+properties['kms_key2']+' not defined')
|
|
|
|
|
|
|
|
key = ctx.barbican.keys[properties['kms_key']]
|
|
|
|
s3tests_conf['DEFAULT']['kms_keyid'] = key['id']
|
|
|
|
|
|
|
|
key = ctx.barbican.keys[properties['kms_key2']]
|
|
|
|
s3tests_conf['DEFAULT']['kms_keyid2'] = key['id']
|
|
|
|
|
|
|
|
elif hasattr(ctx, 'vault'):
|
2019-11-07 15:33:14 +00:00
|
|
|
properties = properties['vault_%s' % ctx.vault.engine]
|
2019-09-09 13:12:24 +00:00
|
|
|
s3tests_conf['DEFAULT']['kms_keyid'] = properties['key_path']
|
|
|
|
s3tests_conf['DEFAULT']['kms_keyid2'] = properties['key_path2']
|
2019-11-07 15:33:14 +00:00
|
|
|
|
2019-09-09 13:12:24 +00:00
|
|
|
else:
|
|
|
|
# Fallback scenario where it's the local (ceph.conf) kms being tested
|
|
|
|
s3tests_conf['DEFAULT']['kms_keyid'] = 'testkey-1'
|
|
|
|
s3tests_conf['DEFAULT']['kms_keyid2'] = 'testkey-2'
|
2017-08-21 09:34:21 +00:00
|
|
|
|
2019-09-05 19:51:16 +00:00
|
|
|
slow_backend = properties.get('slow_backend')
|
|
|
|
if slow_backend:
|
2019-12-09 16:27:46 +00:00
|
|
|
s3tests_conf['fixtures']['slow backend'] = slow_backend
|
2014-10-13 22:07:06 +00:00
|
|
|
|
2014-03-27 16:35:28 +00:00
|
|
|
(remote,) = ctx.cluster.only(client).remotes.keys()
|
2011-06-25 00:09:47 +00:00
|
|
|
remote.run(
|
|
|
|
args=[
|
2011-07-05 16:27:28 +00:00
|
|
|
'cd',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/s3-tests'.format(tdir=testdir),
|
2011-06-25 00:09:47 +00:00
|
|
|
run.Raw('&&'),
|
|
|
|
'./bootstrap',
|
|
|
|
],
|
|
|
|
)
|
2020-02-15 10:12:40 +00:00
|
|
|
conf_fp = BytesIO()
|
2011-06-25 00:09:47 +00:00
|
|
|
s3tests_conf.write(conf_fp)
|
2020-07-20 09:20:43 +00:00
|
|
|
remote.write_file(
|
2013-01-23 20:37:39 +00:00
|
|
|
path='{tdir}/archive/s3-tests.{client}.conf'.format(tdir=testdir, client=client),
|
2011-06-25 00:09:47 +00:00
|
|
|
data=conf_fp.getvalue(),
|
|
|
|
)
|
2014-08-22 22:28:33 +00:00
|
|
|
|
|
|
|
log.info('Configuring boto...')
|
|
|
|
boto_src = os.path.join(os.path.dirname(__file__), 'boto.cfg.template')
|
2019-10-09 12:36:58 +00:00
|
|
|
for client, properties in config['clients'].items():
|
2020-06-28 11:45:05 +00:00
|
|
|
with open(boto_src) as f:
|
2014-08-22 22:28:33 +00:00
|
|
|
(remote,) = ctx.cluster.only(client).remotes.keys()
|
2020-06-28 11:45:05 +00:00
|
|
|
conf = f.read().format(
|
2014-08-22 22:28:33 +00:00
|
|
|
idle_timeout=config.get('idle_timeout', 30)
|
|
|
|
)
|
2020-07-20 09:20:43 +00:00
|
|
|
remote.write_file('{tdir}/boto.cfg'.format(tdir=testdir), conf)
|
2014-08-22 22:28:33 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
|
|
|
|
finally:
|
|
|
|
log.info('Cleaning up boto...')
|
2019-10-09 12:36:58 +00:00
|
|
|
for client, properties in config['clients'].items():
|
2014-08-22 22:28:33 +00:00
|
|
|
(remote,) = ctx.cluster.only(client).remotes.keys()
|
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'rm',
|
|
|
|
'{tdir}/boto.cfg'.format(tdir=testdir),
|
|
|
|
],
|
|
|
|
)
|
2011-06-25 00:09:47 +00:00
|
|
|
|
|
|
|
@contextlib.contextmanager
|
2013-04-30 20:23:22 +00:00
|
|
|
def run_tests(ctx, config):
|
2014-02-12 04:21:06 +00:00
|
|
|
"""
|
|
|
|
Run the s3tests after everything is set up.
|
|
|
|
|
|
|
|
:param ctx: Context passed to task
|
|
|
|
:param config: specific configuration information
|
|
|
|
"""
|
2011-06-25 00:09:47 +00:00
|
|
|
assert isinstance(config, dict)
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
2019-10-09 12:36:58 +00:00
|
|
|
for client, client_config in config.items():
|
2019-09-06 19:08:29 +00:00
|
|
|
client_config = client_config or {}
|
2018-02-15 15:40:35 +00:00
|
|
|
(remote,) = ctx.cluster.only(client).remotes.keys()
|
2011-06-25 00:09:47 +00:00
|
|
|
args = [
|
2014-08-22 22:28:33 +00:00
|
|
|
'S3TEST_CONF={tdir}/archive/s3-tests.{client}.conf'.format(tdir=testdir, client=client),
|
2018-02-15 15:40:35 +00:00
|
|
|
'BOTO_CONFIG={tdir}/boto.cfg'.format(tdir=testdir)
|
|
|
|
]
|
|
|
|
# the 'requests' library comes with its own ca bundle to verify ssl
|
|
|
|
# certificates - override that to use the system's ca bundle, which
|
|
|
|
# is where the ssl task installed this certificate
|
|
|
|
if remote.os.package_type == 'deb':
|
|
|
|
args += ['REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt']
|
|
|
|
else:
|
|
|
|
args += ['REQUESTS_CA_BUNDLE=/etc/pki/tls/certs/ca-bundle.crt']
|
2019-09-06 19:08:29 +00:00
|
|
|
# civetweb > 1.8 && beast parsers are strict on rfc2616
|
2020-05-22 20:58:53 +00:00
|
|
|
attrs = ["!fails_on_rgw", "!lifecycle_expiration", "!fails_strict_rfc2616","!s3select","!sts_test"]
|
2019-09-06 19:08:29 +00:00
|
|
|
if client_config.get('calling-format') != 'ordinary':
|
|
|
|
attrs += ['!fails_with_subdomain']
|
2020-05-22 20:58:53 +00:00
|
|
|
|
|
|
|
if 'extra_attrs' in client_config:
|
|
|
|
attrs = client_config.get('extra_attrs')
|
|
|
|
|
2018-02-15 15:40:35 +00:00
|
|
|
args += [
|
2019-12-17 18:57:57 +00:00
|
|
|
'{tdir}/s3-tests/virtualenv/bin/python'.format(tdir=testdir),
|
|
|
|
'-m', 'nose',
|
2014-08-22 22:28:33 +00:00
|
|
|
'-w',
|
|
|
|
'{tdir}/s3-tests'.format(tdir=testdir),
|
|
|
|
'-v',
|
2015-02-16 21:02:33 +00:00
|
|
|
'-a', ','.join(attrs),
|
2014-08-22 22:28:33 +00:00
|
|
|
]
|
2019-09-06 19:08:29 +00:00
|
|
|
if 'extra_args' in client_config:
|
2019-09-05 19:48:43 +00:00
|
|
|
args.append(client_config['extra_args'])
|
2011-06-25 00:09:47 +00:00
|
|
|
|
2018-02-15 15:40:35 +00:00
|
|
|
remote.run(
|
2011-06-25 00:09:47 +00:00
|
|
|
args=args,
|
2015-02-04 21:42:40 +00:00
|
|
|
label="s3 tests against rgw"
|
2011-06-25 00:09:47 +00:00
|
|
|
)
|
2012-11-20 00:19:06 +00:00
|
|
|
yield
|
2011-06-25 00:09:47 +00:00
|
|
|
|
2017-03-06 20:13:22 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def scan_for_leaked_encryption_keys(ctx, config):
|
|
|
|
"""
|
|
|
|
Scan radosgw logs for the encryption keys used by s3tests to
|
|
|
|
verify that we're not leaking secrets.
|
|
|
|
|
|
|
|
:param ctx: Context passed to task
|
|
|
|
:param config: specific configuration information
|
|
|
|
"""
|
|
|
|
assert isinstance(config, dict)
|
|
|
|
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
# x-amz-server-side-encryption-customer-key
|
|
|
|
s3test_customer_key = 'pO3upElrwuEXSoFwCfnZPdSsmt/xWeFa0N9KgDijwVs='
|
|
|
|
|
|
|
|
log.debug('Scanning radosgw logs for leaked encryption keys...')
|
|
|
|
procs = list()
|
2019-10-09 12:36:58 +00:00
|
|
|
for client, client_config in config.items():
|
2017-04-20 18:49:04 +00:00
|
|
|
if not client_config.get('scan_for_encryption_keys', True):
|
|
|
|
continue
|
2017-04-27 18:46:06 +00:00
|
|
|
cluster_name, daemon_type, client_id = teuthology.split_role(client)
|
|
|
|
client_with_cluster = '.'.join((cluster_name, daemon_type, client_id))
|
2017-03-06 20:13:22 +00:00
|
|
|
(remote,) = ctx.cluster.only(client).remotes.keys()
|
|
|
|
proc = remote.run(
|
|
|
|
args=[
|
|
|
|
'grep',
|
|
|
|
'--binary-files=text',
|
|
|
|
s3test_customer_key,
|
2017-04-27 18:46:06 +00:00
|
|
|
'/var/log/ceph/rgw.{client}.log'.format(client=client_with_cluster),
|
2017-03-06 20:13:22 +00:00
|
|
|
],
|
|
|
|
wait=False,
|
|
|
|
check_status=False,
|
|
|
|
)
|
|
|
|
procs.append(proc)
|
|
|
|
|
|
|
|
for proc in procs:
|
|
|
|
proc.wait()
|
|
|
|
if proc.returncode == 1: # 1 means no matches
|
|
|
|
continue
|
|
|
|
log.error('radosgw log is leaking encryption keys!')
|
|
|
|
raise Exception('radosgw log is leaking encryption keys')
|
|
|
|
|
2011-06-25 00:09:47 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def task(ctx, config):
|
|
|
|
"""
|
|
|
|
Run the s3-tests suite against rgw.
|
|
|
|
|
|
|
|
To run all tests on all clients::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rgw:
|
|
|
|
- s3tests:
|
|
|
|
|
|
|
|
To restrict testing to particular clients::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rgw: [client.0]
|
|
|
|
- s3tests: [client.0]
|
|
|
|
|
2014-08-22 22:28:33 +00:00
|
|
|
To run against a server on client.1 and increase the boto timeout to 10m::
|
2011-06-25 00:09:47 +00:00
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rgw: [client.1]
|
|
|
|
- s3tests:
|
|
|
|
client.0:
|
|
|
|
rgw_server: client.1
|
2014-08-22 22:28:33 +00:00
|
|
|
idle_timeout: 600
|
2011-06-25 00:09:47 +00:00
|
|
|
|
|
|
|
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']
|
|
|
|
"""
|
2018-02-21 16:19:48 +00:00
|
|
|
assert hasattr(ctx, 'rgw'), 's3tests must run after the rgw task'
|
2011-06-25 00:09:47 +00:00
|
|
|
assert config is None or isinstance(config, list) \
|
|
|
|
or isinstance(config, dict), \
|
|
|
|
"task s3tests 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()
|
|
|
|
|
2012-09-10 18:08:57 +00:00
|
|
|
overrides = ctx.config.get('overrides', {})
|
|
|
|
# merge each client section, not the top level.
|
2019-10-11 15:57:47 +00:00
|
|
|
for client in config.keys():
|
2013-07-10 01:50:52 +00:00
|
|
|
if not config[client]:
|
|
|
|
config[client] = {}
|
|
|
|
teuthology.deep_merge(config[client], overrides.get('s3tests', {}))
|
2012-09-10 18:08:57 +00:00
|
|
|
|
2013-08-24 02:54:53 +00:00
|
|
|
log.debug('s3tests config is %s', config)
|
2012-09-10 18:08:57 +00:00
|
|
|
|
2011-06-25 00:09:47 +00:00
|
|
|
s3tests_conf = {}
|
|
|
|
for client in clients:
|
2018-02-21 16:19:48 +00:00
|
|
|
endpoint = ctx.rgw.role_endpoints.get(client)
|
|
|
|
assert endpoint, 's3tests: no rgw endpoint for {}'.format(client)
|
|
|
|
|
2011-06-25 00:09:47 +00:00
|
|
|
s3tests_conf[client] = ConfigObj(
|
|
|
|
indent_type='',
|
|
|
|
infile={
|
|
|
|
'DEFAULT':
|
|
|
|
{
|
2018-02-21 16:19:48 +00:00
|
|
|
'port' : endpoint.port,
|
2019-06-18 13:07:33 +00:00
|
|
|
'is_secure' : endpoint.cert is not None,
|
2018-06-23 09:09:54 +00:00
|
|
|
'api_name' : 'default',
|
2011-06-25 00:09:47 +00:00
|
|
|
},
|
|
|
|
'fixtures' : {},
|
|
|
|
's3 main' : {},
|
|
|
|
's3 alt' : {},
|
2017-06-02 09:03:03 +00:00
|
|
|
's3 tenant': {},
|
2020-05-22 20:58:53 +00:00
|
|
|
'iam' : {},
|
2011-06-25 00:09:47 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
with contextutil.nested(
|
2012-09-10 18:08:57 +00:00
|
|
|
lambda: download(ctx=ctx, config=config),
|
2011-06-25 00:09:47 +00:00
|
|
|
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),
|
2017-03-06 20:13:22 +00:00
|
|
|
lambda: scan_for_leaked_encryption_keys(ctx=ctx, config=config),
|
2011-06-25 00:09:47 +00:00
|
|
|
):
|
2013-04-30 23:47:34 +00:00
|
|
|
pass
|
|
|
|
yield
|