import pipes
import os
import re
-
-import six
+import shlex
from tasks.util import get_remote_for_role
from tasks.util.workunit import get_refspec_after_overrides
BAZ: quux
timeout: 3h
+ You can also pass optional arguments to the found workunits:
+
+ tasks:
+ - workunit:
+ clients:
+ all:
+ - test-ceph-helpers.sh test_get_config
+
This task supports roles that include a ceph cluster, e.g.::
tasks:
# Create scratch dirs for any non-all workunits
log.info('Making a separate scratch dir for every client...')
for role in clients.keys():
- assert isinstance(role, six.string_types)
+ assert isinstance(role, str)
if role == "all":
continue
to False is passed, the 'timeout' command is not used.
"""
testdir = misc.get_testdir(ctx)
- assert isinstance(role, six.string_types)
+ assert isinstance(role, str)
cluster, type_, id_ = misc.split_role(role)
assert type_ == 'client'
remote = get_remote_for_role(ctx, role)
)
workunits_file = '{tdir}/workunits.list.{role}'.format(tdir=testdir, role=role)
- workunits = sorted(six.ensure_str(misc.get_file(remote, workunits_file)).split('\0'))
+ workunits = sorted(remote.read_file(workunits_file).decode().split('\0'))
assert workunits
try:
assert isinstance(tests, list)
for spec in tests:
- log.info('Running workunits matching %s on %s...', spec, role)
- prefix = '{spec}/'.format(spec=spec)
- to_run = [w for w in workunits if w == spec or w.startswith(prefix)]
+ dir_or_fname, *optional_args = shlex.split(spec)
+ log.info('Running workunits matching %s on %s...', dir_or_fname, role)
+ # match executables named "foo" or "foo/*" with workunit named
+ # "foo"
+ to_run = [w for w in workunits
+ if os.path.commonpath([w, dir_or_fname]) == dir_or_fname]
if not to_run:
raise RuntimeError('Spec did not match any workunits: {spec!r}'.format(spec=spec))
for workunit in to_run:
])
remote.run(
logger=log.getChild(role),
- args=args,
+ args=args + optional_args,
label="workunit test {workunit}".format(workunit=workunit)
)
if cleanup: