2013-10-12 08:28:27 +00:00
|
|
|
"""
|
|
|
|
Rbd testing task
|
|
|
|
"""
|
2011-06-09 18:46:04 +00:00
|
|
|
import contextlib
|
|
|
|
import logging
|
2012-04-14 05:28:05 +00:00
|
|
|
import os
|
2017-08-17 13:35:42 +00:00
|
|
|
import tempfile
|
2017-10-26 16:41:16 +00:00
|
|
|
import sys
|
2011-06-09 18:46:04 +00:00
|
|
|
|
2020-06-28 11:44:26 +00:00
|
|
|
from io import StringIO
|
2014-08-07 14:24:59 +00:00
|
|
|
from teuthology.orchestra import run
|
2011-06-09 18:47:52 +00:00
|
|
|
from teuthology import misc as teuthology
|
2011-06-17 00:47:53 +00:00
|
|
|
from teuthology import contextutil
|
2012-11-20 22:01:03 +00:00
|
|
|
from teuthology.parallel import parallel
|
2013-10-15 21:43:39 +00:00
|
|
|
from teuthology.task.common_fs_utils import generic_mkfs
|
|
|
|
from teuthology.task.common_fs_utils import generic_mount
|
|
|
|
from teuthology.task.common_fs_utils import default_image_name
|
2011-06-09 18:47:52 +00:00
|
|
|
|
2019-12-09 16:27:46 +00:00
|
|
|
|
2018-03-14 07:46:27 +00:00
|
|
|
#V1 image unsupported but required for testing purposes
|
|
|
|
os.environ["RBD_FORCE_ALLOW_V1"] = "1"
|
|
|
|
|
2011-06-09 18:46:04 +00:00
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
@contextlib.contextmanager
|
|
|
|
def create_image(ctx, config):
|
|
|
|
"""
|
|
|
|
Create an rbd image.
|
|
|
|
|
|
|
|
For example::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rbd.create_image:
|
|
|
|
client.0:
|
|
|
|
image_name: testimage
|
|
|
|
image_size: 100
|
2012-09-10 14:23:08 +00:00
|
|
|
image_format: 1
|
2011-06-09 18:46:04 +00:00
|
|
|
client.1:
|
2012-09-10 14:23:08 +00:00
|
|
|
|
|
|
|
Image size is expressed as a number of megabytes; default value
|
|
|
|
is 10240.
|
|
|
|
|
|
|
|
Image format value must be either 1 or 2; default value is 1.
|
|
|
|
|
2011-06-09 18:46:04 +00:00
|
|
|
"""
|
|
|
|
assert isinstance(config, dict) or isinstance(config, list), \
|
|
|
|
"task create_image only supports a list or dictionary for configuration"
|
|
|
|
|
|
|
|
if isinstance(config, dict):
|
|
|
|
images = config.items()
|
|
|
|
else:
|
|
|
|
images = [(role, None) for role in config]
|
|
|
|
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
2011-06-09 18:46:04 +00:00
|
|
|
for role, properties in images:
|
|
|
|
if properties is None:
|
|
|
|
properties = {}
|
|
|
|
name = properties.get('image_name', default_image_name(role))
|
2011-08-21 22:14:02 +00:00
|
|
|
size = properties.get('image_size', 10240)
|
2012-09-10 14:23:08 +00:00
|
|
|
fmt = properties.get('image_format', 1)
|
2014-03-27 16:35:28 +00:00
|
|
|
(remote,) = ctx.cluster.only(role).remotes.keys()
|
2011-06-09 18:46:04 +00:00
|
|
|
log.info('Creating image {name} with size {size}'.format(name=name,
|
|
|
|
size=size))
|
2012-09-12 18:30:40 +00:00
|
|
|
args = [
|
2013-09-06 20:08:01 +00:00
|
|
|
'adjust-ulimits',
|
2020-01-09 07:27:37 +00:00
|
|
|
'ceph-coverage',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
2013-02-06 19:16:52 +00:00
|
|
|
'rbd',
|
2011-06-09 18:46:04 +00:00
|
|
|
'-p', 'rbd',
|
|
|
|
'create',
|
2012-09-10 14:23:08 +00:00
|
|
|
'--size', str(size),
|
2011-06-09 18:46:04 +00:00
|
|
|
name,
|
2012-09-12 18:30:40 +00:00
|
|
|
]
|
|
|
|
# omit format option if using the default (format 1)
|
|
|
|
# since old versions of don't support it
|
2012-09-13 21:29:43 +00:00
|
|
|
if int(fmt) != 1:
|
2015-10-21 20:27:08 +00:00
|
|
|
args += ['--image-format', str(fmt)]
|
2012-09-12 18:30:40 +00:00
|
|
|
remote.run(args=args)
|
2011-06-09 18:46:04 +00:00
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
log.info('Deleting rbd images...')
|
|
|
|
for role, properties in images:
|
|
|
|
if properties is None:
|
|
|
|
properties = {}
|
|
|
|
name = properties.get('image_name', default_image_name(role))
|
2014-03-27 16:35:28 +00:00
|
|
|
(remote,) = ctx.cluster.only(role).remotes.keys()
|
2011-06-09 18:46:04 +00:00
|
|
|
remote.run(
|
|
|
|
args=[
|
2013-09-06 20:08:01 +00:00
|
|
|
'adjust-ulimits',
|
2013-02-06 19:16:52 +00:00
|
|
|
'ceph-coverage',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
2013-02-06 19:16:52 +00:00
|
|
|
'rbd',
|
2011-06-09 18:46:04 +00:00
|
|
|
'-p', 'rbd',
|
|
|
|
'rm',
|
|
|
|
name,
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2015-10-21 20:27:08 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def clone_image(ctx, config):
|
|
|
|
"""
|
|
|
|
Clones a parent imag
|
|
|
|
|
|
|
|
For example::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rbd.clone_image:
|
|
|
|
client.0:
|
|
|
|
parent_name: testimage
|
|
|
|
image_name: cloneimage
|
|
|
|
"""
|
|
|
|
assert isinstance(config, dict) or isinstance(config, list), \
|
|
|
|
"task clone_image only supports a list or dictionary for configuration"
|
|
|
|
|
|
|
|
if isinstance(config, dict):
|
|
|
|
images = config.items()
|
|
|
|
else:
|
|
|
|
images = [(role, None) for role in config]
|
|
|
|
|
|
|
|
testdir = teuthology.get_testdir(ctx)
|
|
|
|
for role, properties in images:
|
|
|
|
if properties is None:
|
|
|
|
properties = {}
|
|
|
|
|
|
|
|
name = properties.get('image_name', default_image_name(role))
|
|
|
|
parent_name = properties.get('parent_name')
|
|
|
|
assert parent_name is not None, \
|
|
|
|
"parent_name is required"
|
|
|
|
parent_spec = '{name}@{snap}'.format(name=parent_name, snap=name)
|
|
|
|
|
|
|
|
(remote,) = ctx.cluster.only(role).remotes.keys()
|
|
|
|
log.info('Clone image {parent} to {child}'.format(parent=parent_name,
|
|
|
|
child=name))
|
|
|
|
for cmd in [('snap', 'create', parent_spec),
|
|
|
|
('snap', 'protect', parent_spec),
|
|
|
|
('clone', parent_spec, name)]:
|
|
|
|
args = [
|
|
|
|
'adjust-ulimits',
|
2020-01-09 07:27:37 +00:00
|
|
|
'ceph-coverage',
|
2015-10-21 20:27:08 +00:00
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
|
|
|
'rbd', '-p', 'rbd'
|
|
|
|
]
|
|
|
|
args.extend(cmd)
|
|
|
|
remote.run(args=args)
|
|
|
|
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
log.info('Deleting rbd clones...')
|
|
|
|
for role, properties in images:
|
|
|
|
if properties is None:
|
|
|
|
properties = {}
|
|
|
|
name = properties.get('image_name', default_image_name(role))
|
|
|
|
parent_name = properties.get('parent_name')
|
|
|
|
parent_spec = '{name}@{snap}'.format(name=parent_name, snap=name)
|
|
|
|
|
|
|
|
(remote,) = ctx.cluster.only(role).remotes.keys()
|
|
|
|
|
|
|
|
for cmd in [('rm', name),
|
|
|
|
('snap', 'unprotect', parent_spec),
|
|
|
|
('snap', 'rm', parent_spec)]:
|
|
|
|
args = [
|
|
|
|
'adjust-ulimits',
|
2020-01-09 07:27:37 +00:00
|
|
|
'ceph-coverage',
|
2015-10-21 20:27:08 +00:00
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
|
|
|
'rbd', '-p', 'rbd'
|
|
|
|
]
|
|
|
|
args.extend(cmd)
|
|
|
|
remote.run(args=args)
|
|
|
|
|
2011-06-09 18:46:59 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def modprobe(ctx, config):
|
|
|
|
"""
|
|
|
|
Load the rbd kernel module..
|
|
|
|
|
|
|
|
For example::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rbd.create_image: [client.0]
|
|
|
|
- rbd.modprobe: [client.0]
|
|
|
|
"""
|
2011-06-22 23:36:25 +00:00
|
|
|
log.info('Loading rbd kernel module...')
|
2011-06-09 18:46:59 +00:00
|
|
|
for role in config:
|
2014-03-27 16:35:28 +00:00
|
|
|
(remote,) = ctx.cluster.only(role).remotes.keys()
|
2011-06-09 18:46:59 +00:00
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'sudo',
|
|
|
|
'modprobe',
|
|
|
|
'rbd',
|
|
|
|
],
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
log.info('Unloading rbd kernel module...')
|
|
|
|
for role in config:
|
2014-03-27 16:35:28 +00:00
|
|
|
(remote,) = ctx.cluster.only(role).remotes.keys()
|
2011-06-09 18:46:59 +00:00
|
|
|
remote.run(
|
|
|
|
args=[
|
|
|
|
'sudo',
|
|
|
|
'modprobe',
|
|
|
|
'-r',
|
|
|
|
'rbd',
|
2012-04-14 05:28:05 +00:00
|
|
|
# force errors to be ignored; necessary if more
|
|
|
|
# than one device was created, which may mean
|
|
|
|
# the module isn't quite ready to go the first
|
|
|
|
# time through.
|
|
|
|
run.Raw('||'),
|
|
|
|
'true',
|
2011-06-09 18:46:59 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2011-06-09 18:47:52 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def dev_create(ctx, config):
|
|
|
|
"""
|
|
|
|
Map block devices to rbd images.
|
|
|
|
|
|
|
|
For example::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rbd.create_image: [client.0]
|
|
|
|
- rbd.modprobe: [client.0]
|
|
|
|
- rbd.dev_create:
|
|
|
|
client.0: testimage.client.0
|
|
|
|
"""
|
|
|
|
assert isinstance(config, dict) or isinstance(config, list), \
|
|
|
|
"task dev_create only supports a list or dictionary for configuration"
|
|
|
|
|
|
|
|
if isinstance(config, dict):
|
|
|
|
role_images = config.items()
|
|
|
|
else:
|
|
|
|
role_images = [(role, None) for role in config]
|
|
|
|
|
2011-06-22 23:36:25 +00:00
|
|
|
log.info('Creating rbd block devices...')
|
2013-01-23 20:37:39 +00:00
|
|
|
|
|
|
|
testdir = teuthology.get_testdir(ctx)
|
|
|
|
|
2011-06-09 18:47:52 +00:00
|
|
|
for role, image in role_images:
|
|
|
|
if image is None:
|
|
|
|
image = default_image_name(role)
|
2014-03-27 16:35:28 +00:00
|
|
|
(remote,) = ctx.cluster.only(role).remotes.keys()
|
2011-06-09 18:47:52 +00:00
|
|
|
|
|
|
|
remote.run(
|
|
|
|
args=[
|
2013-02-06 07:01:25 +00:00
|
|
|
'sudo',
|
2013-09-06 20:08:01 +00:00
|
|
|
'adjust-ulimits',
|
2013-02-06 19:16:52 +00:00
|
|
|
'ceph-coverage',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
2013-02-06 19:16:52 +00:00
|
|
|
'rbd',
|
2011-06-09 18:47:52 +00:00
|
|
|
'--user', role.rsplit('.')[-1],
|
|
|
|
'-p', 'rbd',
|
|
|
|
'map',
|
|
|
|
image,
|
2011-06-22 23:36:12 +00:00
|
|
|
run.Raw('&&'),
|
|
|
|
# wait for the symlink to be created by udev
|
|
|
|
'while', 'test', '!', '-e', '/dev/rbd/rbd/{image}'.format(image=image), run.Raw(';'), 'do',
|
|
|
|
'sleep', '1', run.Raw(';'),
|
|
|
|
'done',
|
2011-06-09 18:47:52 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
finally:
|
|
|
|
log.info('Unmapping rbd devices...')
|
|
|
|
for role, image in role_images:
|
|
|
|
if image is None:
|
|
|
|
image = default_image_name(role)
|
2014-03-27 16:35:28 +00:00
|
|
|
(remote,) = ctx.cluster.only(role).remotes.keys()
|
2011-06-09 18:47:52 +00:00
|
|
|
remote.run(
|
|
|
|
args=[
|
2013-01-23 20:37:39 +00:00
|
|
|
'LD_LIBRARY_PATH={tdir}/binary/usr/local/lib'.format(tdir=testdir),
|
2013-02-06 07:01:25 +00:00
|
|
|
'sudo',
|
2013-09-06 20:08:01 +00:00
|
|
|
'adjust-ulimits',
|
2013-02-06 19:16:52 +00:00
|
|
|
'ceph-coverage',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
2013-02-06 19:16:52 +00:00
|
|
|
'rbd',
|
2011-06-09 18:47:52 +00:00
|
|
|
'-p', 'rbd',
|
|
|
|
'unmap',
|
|
|
|
'/dev/rbd/rbd/{imgname}'.format(imgname=image),
|
2011-06-23 00:32:10 +00:00
|
|
|
run.Raw('&&'),
|
|
|
|
# wait for the symlink to be deleted by udev
|
|
|
|
'while', 'test', '-e', '/dev/rbd/rbd/{image}'.format(image=image),
|
|
|
|
run.Raw(';'),
|
|
|
|
'do',
|
|
|
|
'sleep', '1', run.Raw(';'),
|
|
|
|
'done',
|
2011-06-09 18:47:52 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2011-08-09 23:25:00 +00:00
|
|
|
|
2013-10-15 21:43:39 +00:00
|
|
|
def rbd_devname_rtn(ctx, image):
|
|
|
|
return '/dev/rbd/rbd/{image}'.format(image=image)
|
2011-06-16 23:41:29 +00:00
|
|
|
|
2012-04-14 05:28:05 +00:00
|
|
|
def canonical_path(ctx, role, path):
|
2013-10-12 08:28:27 +00:00
|
|
|
"""
|
|
|
|
Determine the canonical path for a given path on the host
|
|
|
|
representing the given role. A canonical path contains no
|
|
|
|
. or .. components, and includes no symbolic links.
|
|
|
|
"""
|
2020-06-28 11:44:26 +00:00
|
|
|
version_fp = StringIO()
|
2012-04-14 05:28:05 +00:00
|
|
|
ctx.cluster.only(role).run(
|
|
|
|
args=[ 'readlink', '-f', path ],
|
|
|
|
stdout=version_fp,
|
|
|
|
)
|
2020-06-28 11:44:26 +00:00
|
|
|
canonical_path = version_fp.getvalue().rstrip('\n')
|
2012-04-14 05:28:05 +00:00
|
|
|
version_fp.close()
|
|
|
|
return canonical_path
|
|
|
|
|
|
|
|
@contextlib.contextmanager
|
|
|
|
def run_xfstests(ctx, config):
|
|
|
|
"""
|
|
|
|
Run xfstests over specified devices.
|
|
|
|
|
|
|
|
Warning: both the test and scratch devices specified will be
|
|
|
|
overwritten. Normally xfstests modifies (but does not destroy)
|
|
|
|
the test device, but for now the run script used here re-makes
|
|
|
|
both filesystems.
|
|
|
|
|
|
|
|
Note: Only one instance of xfstests can run on a single host at
|
|
|
|
a time, although this is not enforced.
|
|
|
|
|
|
|
|
This task in its current form needs some improvement. For
|
|
|
|
example, it assumes all roles provided in the config are
|
|
|
|
clients, and that the config provided is a list of key/value
|
|
|
|
pairs. For now please use the xfstests() interface, below.
|
|
|
|
|
|
|
|
For example::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rbd.run_xfstests:
|
|
|
|
client.0:
|
2012-11-01 18:32:56 +00:00
|
|
|
count: 2
|
2012-04-14 05:28:05 +00:00
|
|
|
test_dev: 'test_dev'
|
|
|
|
scratch_dev: 'scratch_dev'
|
|
|
|
fs_type: 'xfs'
|
2014-05-29 13:55:08 +00:00
|
|
|
tests: 'generic/100 xfs/003 xfs/005 xfs/006 generic/015'
|
2017-08-17 13:35:42 +00:00
|
|
|
exclude:
|
|
|
|
- generic/42
|
2014-05-29 13:55:08 +00:00
|
|
|
randomize: true
|
2012-04-14 05:28:05 +00:00
|
|
|
"""
|
2012-11-20 22:01:03 +00:00
|
|
|
with parallel() as p:
|
|
|
|
for role, properties in config.items():
|
|
|
|
p.spawn(run_xfstests_one_client, ctx, role, properties)
|
2020-07-19 09:37:57 +00:00
|
|
|
exc = None
|
2017-10-26 16:41:16 +00:00
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
p.next()
|
|
|
|
except StopIteration:
|
|
|
|
break
|
|
|
|
except:
|
2020-07-19 09:37:57 +00:00
|
|
|
exc = sys.exc_info()[1]
|
|
|
|
if exc is not None:
|
|
|
|
raise exc
|
2012-11-20 22:01:03 +00:00
|
|
|
yield
|
2012-04-14 05:28:05 +00:00
|
|
|
|
2012-11-20 22:01:03 +00:00
|
|
|
def run_xfstests_one_client(ctx, role, properties):
|
2013-10-12 08:28:27 +00:00
|
|
|
"""
|
|
|
|
Spawned routine to handle xfs tests for a single client
|
|
|
|
"""
|
2013-01-23 20:37:39 +00:00
|
|
|
testdir = teuthology.get_testdir(ctx)
|
2012-11-20 22:01:03 +00:00
|
|
|
try:
|
2012-11-01 18:32:56 +00:00
|
|
|
count = properties.get('count')
|
2012-04-14 05:28:05 +00:00
|
|
|
test_dev = properties.get('test_dev')
|
|
|
|
assert test_dev is not None, \
|
|
|
|
"task run_xfstests requires test_dev to be defined"
|
|
|
|
test_dev = canonical_path(ctx, role, test_dev)
|
|
|
|
|
|
|
|
scratch_dev = properties.get('scratch_dev')
|
|
|
|
assert scratch_dev is not None, \
|
|
|
|
"task run_xfstests requires scratch_dev to be defined"
|
|
|
|
scratch_dev = canonical_path(ctx, role, scratch_dev)
|
|
|
|
|
|
|
|
fs_type = properties.get('fs_type')
|
|
|
|
tests = properties.get('tests')
|
2017-08-17 13:35:42 +00:00
|
|
|
exclude_list = properties.get('exclude')
|
2014-05-29 13:55:08 +00:00
|
|
|
randomize = properties.get('randomize')
|
2012-04-14 05:28:05 +00:00
|
|
|
|
2014-03-27 16:35:28 +00:00
|
|
|
(remote,) = ctx.cluster.only(role).remotes.keys()
|
2012-04-14 05:28:05 +00:00
|
|
|
|
|
|
|
# Fetch the test script
|
2013-01-23 20:37:39 +00:00
|
|
|
test_root = teuthology.get_testdir(ctx)
|
2017-08-17 13:35:42 +00:00
|
|
|
test_script = 'run_xfstests.sh'
|
2012-04-14 05:28:05 +00:00
|
|
|
test_path = os.path.join(test_root, test_script)
|
|
|
|
|
2015-04-21 22:01:47 +00:00
|
|
|
xfstests_url = properties.get('xfstests_url')
|
|
|
|
assert xfstests_url is not None, \
|
|
|
|
"task run_xfstests requires xfstests_url to be defined"
|
|
|
|
|
2015-03-31 15:52:52 +00:00
|
|
|
xfstests_krbd_url = xfstests_url + '/' + test_script
|
|
|
|
|
|
|
|
log.info('Fetching {script} for {role} from {url}'.format(
|
|
|
|
script=test_script,
|
|
|
|
role=role,
|
|
|
|
url=xfstests_krbd_url))
|
2012-04-14 05:28:05 +00:00
|
|
|
|
2015-03-31 15:52:52 +00:00
|
|
|
args = [ 'wget', '-O', test_path, '--', xfstests_krbd_url ]
|
2012-04-14 05:28:05 +00:00
|
|
|
remote.run(args=args)
|
|
|
|
|
|
|
|
log.info('Running xfstests on {role}:'.format(role=role))
|
2012-11-01 18:32:56 +00:00
|
|
|
log.info(' iteration count: {count}:'.format(count=count))
|
2012-04-14 05:28:05 +00:00
|
|
|
log.info(' test device: {dev}'.format(dev=test_dev))
|
|
|
|
log.info(' scratch device: {dev}'.format(dev=scratch_dev))
|
|
|
|
log.info(' using fs_type: {fs_type}'.format(fs_type=fs_type))
|
|
|
|
log.info(' tests to run: {tests}'.format(tests=tests))
|
2017-08-17 13:35:42 +00:00
|
|
|
log.info(' exclude list: {}'.format(' '.join(exclude_list)))
|
2014-05-29 13:55:08 +00:00
|
|
|
log.info(' randomize: {randomize}'.format(randomize=randomize))
|
2012-04-14 05:28:05 +00:00
|
|
|
|
2017-08-17 13:35:42 +00:00
|
|
|
if exclude_list:
|
2020-04-28 21:22:17 +00:00
|
|
|
with tempfile.NamedTemporaryFile(mode='w', prefix='exclude') as exclude_file:
|
2017-08-17 13:35:42 +00:00
|
|
|
for test in exclude_list:
|
|
|
|
exclude_file.write("{}\n".format(test))
|
2020-04-28 21:22:17 +00:00
|
|
|
exclude_file.flush()
|
2017-08-17 13:35:42 +00:00
|
|
|
remote.put_file(exclude_file.name, exclude_file.name)
|
|
|
|
|
2012-04-14 05:28:05 +00:00
|
|
|
# Note that the device paths are interpreted using
|
|
|
|
# readlink -f <path> in order to get their canonical
|
|
|
|
# pathname (so it matches what the kernel remembers).
|
|
|
|
args = [
|
2013-09-05 21:41:27 +00:00
|
|
|
'/usr/bin/sudo',
|
2013-09-24 23:50:07 +00:00
|
|
|
'TESTDIR={tdir}'.format(tdir=testdir),
|
2013-09-06 20:08:01 +00:00
|
|
|
'adjust-ulimits',
|
2013-02-06 19:16:52 +00:00
|
|
|
'ceph-coverage',
|
2013-01-23 20:37:39 +00:00
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
2012-04-14 05:28:05 +00:00
|
|
|
'/bin/bash',
|
|
|
|
test_path,
|
2012-11-01 18:32:56 +00:00
|
|
|
'-c', str(count),
|
2012-04-14 05:28:05 +00:00
|
|
|
'-f', fs_type,
|
|
|
|
'-t', test_dev,
|
|
|
|
'-s', scratch_dev,
|
|
|
|
]
|
2017-08-17 13:35:42 +00:00
|
|
|
if exclude_list:
|
|
|
|
args.extend(['-x', exclude_file.name])
|
2014-05-29 13:55:08 +00:00
|
|
|
if randomize:
|
|
|
|
args.append('-r')
|
2012-04-14 05:28:05 +00:00
|
|
|
if tests:
|
2014-05-29 13:55:08 +00:00
|
|
|
args.extend(['--', tests])
|
2012-11-20 22:01:03 +00:00
|
|
|
remote.run(args=args, logger=log.getChild(role))
|
2012-04-14 05:28:05 +00:00
|
|
|
finally:
|
2012-11-20 22:01:03 +00:00
|
|
|
log.info('Removing {script} on {role}'.format(script=test_script,
|
|
|
|
role=role))
|
|
|
|
remote.run(args=['rm', '-f', test_path])
|
2012-04-14 05:28:05 +00:00
|
|
|
|
|
|
|
@contextlib.contextmanager
|
|
|
|
def xfstests(ctx, config):
|
|
|
|
"""
|
|
|
|
Run xfstests over rbd devices. This interface sets up all
|
|
|
|
required configuration automatically if not otherwise specified.
|
|
|
|
Note that only one instance of xfstests can run on a single host
|
2012-11-01 18:32:56 +00:00
|
|
|
at a time. By default, the set of tests specified is run once.
|
|
|
|
If a (non-zero) count value is supplied, the complete set of
|
|
|
|
tests will be run that number of times.
|
2012-04-14 05:28:05 +00:00
|
|
|
|
|
|
|
For example::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
# Image sizes are in MB
|
|
|
|
- rbd.xfstests:
|
|
|
|
client.0:
|
2012-11-01 18:32:56 +00:00
|
|
|
count: 3
|
2012-04-14 05:28:05 +00:00
|
|
|
test_image: 'test_image'
|
2012-05-21 03:50:19 +00:00
|
|
|
test_size: 250
|
2012-09-10 14:23:08 +00:00
|
|
|
test_format: 2
|
2012-04-14 05:28:05 +00:00
|
|
|
scratch_image: 'scratch_image'
|
|
|
|
scratch_size: 250
|
2012-09-10 14:23:08 +00:00
|
|
|
scratch_format: 1
|
2012-04-14 05:28:05 +00:00
|
|
|
fs_type: 'xfs'
|
2014-05-29 13:55:08 +00:00
|
|
|
tests: 'generic/100 xfs/003 xfs/005 xfs/006 generic/015'
|
2017-08-17 13:35:42 +00:00
|
|
|
exclude:
|
|
|
|
- generic/42
|
2014-05-29 13:55:08 +00:00
|
|
|
randomize: true
|
2015-03-31 15:52:52 +00:00
|
|
|
xfstests_branch: master
|
|
|
|
xfstests_url: 'https://raw.github.com/ceph/branch/master/qa'
|
2012-04-14 05:28:05 +00:00
|
|
|
"""
|
|
|
|
if config is None:
|
|
|
|
config = { 'all': None }
|
|
|
|
assert isinstance(config, dict) or isinstance(config, list), \
|
|
|
|
"task xfstests only supports a list or dictionary for configuration"
|
|
|
|
if isinstance(config, dict):
|
|
|
|
config = teuthology.replace_all_with_clients(ctx.cluster, config)
|
|
|
|
runs = config.items()
|
|
|
|
else:
|
|
|
|
runs = [(role, None) for role in config]
|
|
|
|
|
|
|
|
running_xfstests = {}
|
|
|
|
for role, properties in runs:
|
|
|
|
assert role.startswith('client.'), \
|
|
|
|
"task xfstests can only run on client nodes"
|
|
|
|
for host, roles_for_host in ctx.cluster.remotes.items():
|
|
|
|
if role in roles_for_host:
|
|
|
|
assert host not in running_xfstests, \
|
|
|
|
"task xfstests allows only one instance at a time per host"
|
|
|
|
running_xfstests[host] = True
|
|
|
|
|
2012-11-20 22:01:03 +00:00
|
|
|
images_config = {}
|
|
|
|
scratch_config = {}
|
|
|
|
modprobe_config = {}
|
|
|
|
image_map_config = {}
|
|
|
|
scratch_map_config = {}
|
|
|
|
xfstests_config = {}
|
2012-04-14 05:28:05 +00:00
|
|
|
for role, properties in runs:
|
|
|
|
if properties is None:
|
|
|
|
properties = {}
|
|
|
|
|
2012-11-20 22:01:03 +00:00
|
|
|
test_image = properties.get('test_image', 'test_image.{role}'.format(role=role))
|
2015-04-06 19:23:38 +00:00
|
|
|
test_size = properties.get('test_size', 10000) # 10G
|
2012-09-10 14:23:08 +00:00
|
|
|
test_fmt = properties.get('test_format', 1)
|
2012-11-20 22:01:03 +00:00
|
|
|
scratch_image = properties.get('scratch_image', 'scratch_image.{role}'.format(role=role))
|
2013-12-23 17:54:11 +00:00
|
|
|
scratch_size = properties.get('scratch_size', 10000) # 10G
|
2012-09-10 14:23:08 +00:00
|
|
|
scratch_fmt = properties.get('scratch_format', 1)
|
2012-04-14 05:28:05 +00:00
|
|
|
|
2012-11-20 22:01:03 +00:00
|
|
|
images_config[role] = dict(
|
|
|
|
image_name=test_image,
|
|
|
|
image_size=test_size,
|
|
|
|
image_format=test_fmt,
|
|
|
|
)
|
|
|
|
|
|
|
|
scratch_config[role] = dict(
|
|
|
|
image_name=scratch_image,
|
|
|
|
image_size=scratch_size,
|
|
|
|
image_format=scratch_fmt,
|
|
|
|
)
|
|
|
|
|
2015-04-21 22:01:47 +00:00
|
|
|
xfstests_branch = properties.get('xfstests_branch', 'master')
|
|
|
|
xfstests_url = properties.get('xfstests_url', 'https://raw.github.com/ceph/ceph/{branch}/qa'.format(branch=xfstests_branch))
|
|
|
|
|
2012-11-20 22:01:03 +00:00
|
|
|
xfstests_config[role] = dict(
|
|
|
|
count=properties.get('count', 1),
|
|
|
|
test_dev='/dev/rbd/rbd/{image}'.format(image=test_image),
|
|
|
|
scratch_dev='/dev/rbd/rbd/{image}'.format(image=scratch_image),
|
|
|
|
fs_type=properties.get('fs_type', 'xfs'),
|
2014-05-29 13:55:08 +00:00
|
|
|
randomize=properties.get('randomize', False),
|
2012-11-20 22:01:03 +00:00
|
|
|
tests=properties.get('tests'),
|
2017-08-17 13:35:42 +00:00
|
|
|
exclude=properties.get('exclude', []),
|
2015-04-21 22:31:16 +00:00
|
|
|
xfstests_url=xfstests_url,
|
2012-11-20 22:01:03 +00:00
|
|
|
)
|
2012-04-14 05:28:05 +00:00
|
|
|
|
|
|
|
log.info('Setting up xfstests using RBD images:')
|
|
|
|
log.info(' test ({size} MB): {image}'.format(size=test_size,
|
|
|
|
image=test_image))
|
|
|
|
log.info(' scratch ({size} MB): {image}'.format(size=scratch_size,
|
|
|
|
image=scratch_image))
|
2012-11-20 22:01:03 +00:00
|
|
|
modprobe_config[role] = None
|
|
|
|
image_map_config[role] = test_image
|
|
|
|
scratch_map_config[role] = scratch_image
|
|
|
|
|
|
|
|
with contextutil.nested(
|
|
|
|
lambda: create_image(ctx=ctx, config=images_config),
|
|
|
|
lambda: create_image(ctx=ctx, config=scratch_config),
|
|
|
|
lambda: modprobe(ctx=ctx, config=modprobe_config),
|
|
|
|
lambda: dev_create(ctx=ctx, config=image_map_config),
|
|
|
|
lambda: dev_create(ctx=ctx, config=scratch_map_config),
|
|
|
|
lambda: run_xfstests(ctx=ctx, config=xfstests_config),
|
|
|
|
):
|
|
|
|
yield
|
2012-04-14 05:28:05 +00:00
|
|
|
|
|
|
|
|
2011-06-09 18:46:04 +00:00
|
|
|
@contextlib.contextmanager
|
|
|
|
def task(ctx, config):
|
2011-06-17 00:47:53 +00:00
|
|
|
"""
|
|
|
|
Create and mount an rbd image.
|
|
|
|
|
2011-09-07 23:54:24 +00:00
|
|
|
For example, you can specify which clients to run on::
|
2011-06-17 00:47:53 +00:00
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rbd: [client.0, client.1]
|
|
|
|
|
2011-09-07 23:54:24 +00:00
|
|
|
There are a few image options::
|
2011-06-17 00:47:53 +00:00
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rbd:
|
|
|
|
client.0: # uses defaults
|
|
|
|
client.1:
|
|
|
|
image_name: foo
|
|
|
|
image_size: 2048
|
2012-09-10 14:23:08 +00:00
|
|
|
image_format: 2
|
2011-06-17 00:47:53 +00:00
|
|
|
fs_type: xfs
|
2011-09-07 23:54:24 +00:00
|
|
|
|
|
|
|
To use default options on all clients::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rbd:
|
|
|
|
all:
|
|
|
|
|
|
|
|
To create 20GiB images and format them with xfs on all clients::
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- ceph:
|
|
|
|
- rbd:
|
|
|
|
all:
|
|
|
|
image_size: 20480
|
|
|
|
fs_type: xfs
|
2011-06-17 00:47:53 +00:00
|
|
|
"""
|
2011-09-23 16:40:52 +00:00
|
|
|
if config is None:
|
2012-03-26 18:54:49 +00:00
|
|
|
config = { 'all': None }
|
2011-09-08 00:50:12 +00:00
|
|
|
norm_config = config
|
|
|
|
if isinstance(config, dict):
|
|
|
|
norm_config = teuthology.replace_all_with_clients(ctx.cluster, config)
|
2011-09-07 23:54:24 +00:00
|
|
|
if isinstance(norm_config, dict):
|
2011-06-17 00:47:53 +00:00
|
|
|
role_images = {}
|
2019-10-09 12:36:58 +00:00
|
|
|
for role, properties in norm_config.items():
|
2011-06-23 00:34:08 +00:00
|
|
|
if properties is None:
|
|
|
|
properties = {}
|
2011-06-17 00:47:53 +00:00
|
|
|
role_images[role] = properties.get('image_name')
|
|
|
|
else:
|
2011-09-07 23:54:24 +00:00
|
|
|
role_images = norm_config
|
2011-06-17 00:47:53 +00:00
|
|
|
|
2012-03-26 18:54:49 +00:00
|
|
|
log.debug('rbd config is: %s', norm_config)
|
|
|
|
|
2011-06-17 00:47:53 +00:00
|
|
|
with contextutil.nested(
|
2011-09-07 23:54:24 +00:00
|
|
|
lambda: create_image(ctx=ctx, config=norm_config),
|
|
|
|
lambda: modprobe(ctx=ctx, config=norm_config),
|
2011-06-17 00:47:53 +00:00
|
|
|
lambda: dev_create(ctx=ctx, config=role_images),
|
2013-10-15 21:43:39 +00:00
|
|
|
lambda: generic_mkfs(ctx=ctx, config=norm_config,
|
|
|
|
devname_rtn=rbd_devname_rtn),
|
|
|
|
lambda: generic_mount(ctx=ctx, config=role_images,
|
|
|
|
devname_rtn=rbd_devname_rtn),
|
2011-06-17 00:47:53 +00:00
|
|
|
):
|
|
|
|
yield
|