[autotest] Treat special task labels like "provisionable" labels.
As it stands, to use the special task labels, you need to add the label
to every host, since we still treat it as a normal/standard DEPENDENCY.
If any special task treats a label differently, then we shouldn't
require that label on the DUT, as we're using it as a marker that we
want some special handling of this test rather than an actual
dependency.
BUG=chromium:334418
DEPLOY=scheduler, apache
TEST=added a potato->dummy_PassServer mapping, saw dummy_PassServer run
in cleanup on job with DEPENDENCIES=potato where host didn't have
potato.
Change-Id: I34936a5a84a42897c8dfc0e2acd50195e0e74ec5
Reviewed-on: https://chromium-review.googlesource.com/194212
Reviewed-by: Alex Miller <milleral@chromium.org>
Commit-Queue: Alex Miller <milleral@chromium.org>
Tested-by: Alex Miller <milleral@chromium.org>
diff --git a/server/cros/provision.py b/server/cros/provision.py
index 44f2b1d..c79f7d2 100644
--- a/server/cros/provision.py
+++ b/server/cros/provision.py
@@ -78,6 +78,29 @@
return cls._actions[label]
+ @classmethod
+ def partition(cls, labels):
+ """
+ Filter a list of labels into two sets: those labels that we know how to
+ act on and those that we don't know how to act on.
+
+ @param labels: A list of strings of labels.
+ @returns: A tuple where the first element is a set of unactionable
+ labels, and the second element is a set of the actionable
+ labels.
+ """
+ capabilities = set()
+ configurations = set()
+
+ for label in labels:
+ if cls.acts_on(label):
+ configurations.add(label)
+ else:
+ capabilities.add(label)
+
+ return capabilities, configurations
+
+
class Verify(_SpecialTaskAction):
"""
Tests to verify that the DUT is in a sane, known good state that we can run
@@ -133,11 +156,25 @@
name = 'repair'
-# For backwards compatibility with old control files, we still need the
-# following:
-can_provision = Provision.acts_on
-provisioner_for = Provision.test_for
+# TODO(milleral): crbug.com/364273
+# Label doesn't really mean label in this context. We're putting things into
+# DEPENDENCIES that really aren't DEPENDENCIES, and we should probably stop
+# doing that.
+def is_for_special_action(label):
+ """
+ If any special task handles the label specially, then we're using the label
+ to communicate that we want an action, and not as an actual dependency that
+ the test has.
+
+ @param label: A string label name.
+ @return True if any special task handles this label specially,
+ False if no special task handles this label.
+ """
+ return (Verify.acts_on(label) or
+ Provision.acts_on(label) or
+ Cleanup.acts_on(label) or
+ Repair.acts_on(label))
def filter_labels(labels):
@@ -155,16 +192,7 @@
(set(['bluetooth']), set(['cros-version:lumpy-release/R28-3993.0.0']))
"""
- capabilities = set()
- configurations = set()
-
- for label in labels:
- if can_provision(label):
- configurations.add(label)
- else:
- capabilities.add(label)
-
- return capabilities, configurations
+ return Provision.partition(labels)
def split_labels(labels):
@@ -188,7 +216,7 @@
configurations = dict()
for label in labels:
- if can_provision(label):
+ if Provision.acts_on(label):
name, value = label.split(':', 1)
configurations[name] = value
else: