]> git.proxmox.com Git - ceph.git/blobdiff - ceph/qa/tasks/workunit.py
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / qa / tasks / workunit.py
index 46eeef41f2e089890268059db9418e508fa3cfa5..491f683082e008724008ad2bbdf080a9887c594f 100644 (file)
@@ -5,8 +5,7 @@ import logging
 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
@@ -62,6 +61,14 @@ def task(ctx, config):
               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:
@@ -105,7 +112,7 @@ def task(ctx, config):
     # 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
 
@@ -316,7 +323,7 @@ def _run_tests(ctx, refspec, role, tests, env, basedir,
                     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)
@@ -364,15 +371,18 @@ def _run_tests(ctx, refspec, role, tests, env, basedir,
     )
 
     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:
@@ -411,7 +421,7 @@ def _run_tests(ctx, refspec, role, tests, env, basedir,
                 ])
                 remote.run(
                     logger=log.getChild(role),
-                    args=args,
+                    args=args + optional_args,
                     label="workunit test {workunit}".format(workunit=workunit)
                 )
                 if cleanup: