Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(819)

Unified Diff: scripts/slave/recipe_modules/swarming/api.py

Issue 2073923002: Support sharding for swarmed isolated script tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Explicitly handle missing shards' output. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: scripts/slave/recipe_modules/swarming/api.py
diff --git a/scripts/slave/recipe_modules/swarming/api.py b/scripts/slave/recipe_modules/swarming/api.py
index af138e6d97b830dee776e58a4e61b4ccb2d6ba46..ceac2ef5b217dce86083142a9c3ace958beee04c 100644
--- a/scripts/slave/recipe_modules/swarming/api.py
+++ b/scripts/slave/recipe_modules/swarming/api.py
@@ -703,6 +703,41 @@ class SwarmingApi(recipe_api.RecipeApi):
link_name = 'shard #%d isolated out' % index
p.links[link_name] = outputs_ref['view_url']
+
+ def _merge_isolated_script_shards(self, task, step_result):
+ # This code is unfortunately specialized to the "simplified"
+ # JSON format that used to be the standard for recipes. The
+ # isolated scripts should be changed to use the now-standard
+ # Chromium JSON test results format:
+ # https://www.chromium.org/developers/the-json-test-results-format
+ # . Note that gtests, above, don't seem to conform to this
+ # format yet, so it didn't seem like a good prerequisite to
+ # switch the isolated tests over when adding sharding support.
+ #
+ # These are the only keys we pay attention to in the output JSON.
+ merged_results = {
+ 'successes': [],
+ 'failures': [],
+ 'valid': True,
+ }
+ for i in xrange(task.shards):
+ path = self.m.path.join(str(i), 'output.json')
+ if path not in step_result.raw_io.output_dir:
+ raise Exception('no results from shard #%d' % i)
+ results_raw = step_result.raw_io.output_dir[path]
+ results_json = self.m.json.loads(results_raw)
+ for key in merged_results:
+ if key in results_json:
+ if isinstance(merged_results[key], list):
+ merged_results[key].extend(results_json[key])
+ elif isinstance(merged_results[key], bool):
+ merged_results[key] = merged_results[key] and results_json[key]
+ else:
+ raise recipe_api.InfraFailure(
+ 'Unknown key type ' + type(merged_results[key]) +
+ ' when handling key ' + key + '.') # pragma: no cover
+ return merged_results
+
def _isolated_script_collect_step(self, task, **kwargs):
step_test_data = kwargs.pop('step_test_data', None)
if not step_test_data:
@@ -736,12 +771,17 @@ class SwarmingApi(recipe_api.RecipeApi):
if any(shard['internal_failure'] for shard in summary['shards']):
raise recipe_api.InfraFailure('Internal swarming failure.')
- # TODO(nednguyen, kbr): Combine isolated script results from multiple
- # shards rather than assuming that there is always just one shard.
- assert len(summary['shards']) == 1
- results_raw = step_result.raw_io.output_dir[
- self.m.path.join('0', 'output.json')]
- step_result.isolated_script_results = self.m.json.loads(results_raw)
+ # Always show the shards' links in the collect step. (It looks
+ # like show_isolated_out_in_collect_step is false by default
+ # in recipe runs.)
+ links = step_result.presentation.links
+ for index in xrange(task.shards):
+ url = task.get_shard_view_url(index)
+ if url:
+ links['shard #%d' % index] = url
+
+ step_result.isolated_script_results = \
+ self._merge_isolated_script_shards(task, step_result)
self._display_pending(summary, step_result.presentation)
except Exception as e:
« no previous file with comments | « scripts/slave/recipe_modules/chromium_tests/steps.py ('k') | scripts/slave/recipe_modules/test_utils/test_api.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698