[autotest] Reimager.attempt() doesn't need pool=
We always instantiate a Reimager right before we call attempt() on it.
Thus, we should just instantiate Reimager() with a given pool.
Also, passing pool=None to Reimager() wasn't working correctly, due
to a bug in inject_vars(). Fix this.
BUG=None
TEST=./site_utils/run_suite.py -b x86-mario -i x86-mario-release/R19-1865.0.0-a1-b1702 -s bvt
Change-Id: Icfd31ccca8c89c10e5c7049e04cd2b03f2ee581f
Reviewed-on: https://gerrit.chromium.org/gerrit/17366
Commit-Ready: Chris Masone <cmasone@chromium.org>
Reviewed-by: Chris Masone <cmasone@chromium.org>
Tested-by: Chris Masone <cmasone@chromium.org>
diff --git a/server/cros/dynamic_suite.py b/server/cros/dynamic_suite.py
index 805d3c2..3fd7458 100644
--- a/server/cros/dynamic_suite.py
+++ b/server/cros/dynamic_suite.py
@@ -102,7 +102,11 @@
"""
control_file = ''
for key, value in vars.iteritems():
- control_file += "%s='%s'\n" % (key, value)
+ # None gets injected as 'None' without this check; same for digits.
+ if isinstance(value, str):
+ control_file += "%s='%s'\n" % (key, value)
+ else:
+ control_file += "%s=%r\n" % (key, value)
return control_file + control_file_in
@@ -159,7 +163,7 @@
return 'SKIP_IMAGE' in g and g['SKIP_IMAGE']
- def attempt(self, build, board, record, num=None, pool=None):
+ def attempt(self, build, board, record, num=None):
"""
Synchronously attempt to reimage some machines.
@@ -174,14 +178,10 @@
prototype:
record(status, subdir, name, reason)
@param num: how many devices to reimage.
- @param pool: Specify the pool of machines to use for scheduling
- purposes.
@return True if all reimaging jobs succeed, false otherwise.
"""
if not num:
num = CONFIG.get_config_value('CROS', 'sharding_factor', type=int)
- if pool:
- self._pool = pool
logging.debug("scheduling reimaging across %d machines", num)
wrapper_job_name = 'try_new_image'
record('START', None, wrapper_job_name)
diff --git a/server/cros/dynamic_suite_unittest.py b/server/cros/dynamic_suite_unittest.py
index 81bb848..ae75be8 100755
--- a/server/cros/dynamic_suite_unittest.py
+++ b/server/cros/dynamic_suite_unittest.py
@@ -158,9 +158,16 @@
"""Should inject dict of varibles into provided strings."""
def find_all_in(d, s):
"""Returns true if all key-value pairs in |d| are printed in |s|."""
- return reduce(lambda b,i: "%s='%s'\n" % i in s, d.iteritems(), True)
+ for k,v in d.iteritems():
+ if isinstance(v, str):
+ if "%s='%s'\n" % (k,v) not in s:
+ return False
+ else:
+ if "%s=%r\n" % (k,v) not in s:
+ return False
+ return True
- v = {'v1': 'one', 'v2': 'two'}
+ v = {'v1': 'one', 'v2': 'two', 'v3': None, 'v4': False, 'v5': 5}
self.assertTrue(find_all_in(v, dynamic_suite.inject_vars(v, '')))
self.assertTrue(find_all_in(v, dynamic_suite.inject_vars(v, 'ctrl')))