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

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

Issue 2336293002: Updating swarming api to check for chartjson results from a finished (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | scripts/slave/recipes/chromium.expected/dynamic_swarmed_failed_isolated_script_test.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 de26cf14f11a01db085f0a8f4b7654c3a986b60e..b2fe03b1fb563ed4624f202f343026dd48efda2f 100644
--- a/scripts/slave/recipe_modules/swarming/api.py
+++ b/scripts/slave/recipe_modules/swarming/api.py
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import logging
import datetime
import functools
@@ -407,6 +408,19 @@ class SwarmingApi(recipe_api.RecipeApi):
self._gtest_collect_step(test_launcher_summary_output, *args, **kw))
return task
+ def _check_and_set_output_flag(self, extra_args, flag, output_file_name):
+ extra_args = list(extra_args or [])
+ # Ensure flag is not already passed. We are going to overwrite it.
+ flag_value = '--%s=' % flag
+ bad_args = any(x.startswith(flag_value) for x in extra_args)
+ if bad_args: # pragma: no cover
+ error = '--%s should not be used' % flag
+ raise ValueError(error)
+
+ # Append it.
+ output_arg = '--%s=${ISOLATED_OUTDIR}/%s' % (flag, output_file_name)
+ return extra_args.append(output_arg)
+
def isolated_script_task(self, title, isolated_hash, extra_args=None,
idempotent=False, **kwargs):
"""Returns a new SwarmingTask to run an isolated script test on Swarming.
@@ -418,18 +432,16 @@ class SwarmingApi(recipe_api.RecipeApi):
For meaning of the rest of the arguments see 'task' method.
"""
- extra_args = list(extra_args or [])
- # Ensure --isolated-script-test-output is not already passed. We are going
- # to overwrite it.
- bad_args = any(
- x.startswith('--isolated-script-test-output=') for x in extra_args)
- if bad_args: # pragma: no cover
- raise ValueError('--isolated-script-test-output should not be used.')
-
- # Append it. output.json name is expected by collect_gtest_task.py.
- extra_args.append(
- '--isolated-script-test-output=${ISOLATED_OUTDIR}/output.json')
+ # Ensure output flags are not already passed. We are going
+ # to overwrite them.
+ # output.json name is expected by collect_gtest_task.py.
+ extra_args = self._check_and_set_output_flag( \
+ extra_args, 'isolated-script-test-output', 'output.json')
+ # chart-output.json name is expected by benchmarks generating chartjson
+ # output
+ extra_args = self._check_and_set_output_flag( \
Ken Russell (switch to Gerrit) 2016/09/13 19:34:47 Should the addition of this command line argument
eyaich1 2016/09/14 18:14:27 This code is not requiring the command line, it is
+ extra_args, 'isolated-script-test-chart-output', 'chart-output.json')
Ken Russell (switch to Gerrit) 2016/09/13 19:34:46 I'd like to suggest using "isolated-script-test-ch
eyaich1 2016/09/14 18:14:28 Done.
task = self.task(title, isolated_hash, extra_args=extra_args,
idempotent=idempotent, **kwargs)
@@ -717,6 +729,44 @@ class SwarmingApi(recipe_api.RecipeApi):
p.links[link_name] = outputs_ref['view_url']
+ def _merge_isolated_script_chart_ouput_shards(self, task, step_result):
Ken Russell (switch to Gerrit) 2016/09/13 19:34:46 chart -> chartjson?
eyaich1 2016/09/14 18:14:28 Done.
+ # Taken from third_party/catapult/telemetry/telemetry/internal/results/
+ # chart_json_output_formatter.py, the json entries are as follows:
+ # result_dict = {
+ # 'format_version': '0.1',
+ # 'next_version': '0.2',
+ # 'benchmark_name': benchmark_metadata.name,
+ # 'benchmark_description': benchmark_metadata.description,
+ # 'trace_rerun_options': benchmark_metadata.rerun_options,
+ # 'benchmark_metadata': benchmark_metadata.AsDict(),
+ # 'charts': charts,
+ # }
+ #
+ # Therefore, all entries should be the same and we should only need to merge
+ # the chat from each shard.
Ken Russell (switch to Gerrit) 2016/09/13 19:34:46 chat -> chart
eyaich1 2016/09/14 18:14:27 Done.
+ merged_results = {}
+ seen_first_shard = False
+ for i in xrange(task.shards):
+ path = self.m.path.join(str(i), 'chart-output.json')
+ if path not in step_result.raw_io.output_dir:
+ logging.info("No chart json present, isolated_script_chart_results " +
+ " will be unset.")
+ results_raw = step_result.raw_io.output_dir[path]
+ try:
+ chart_results_json = self.m.json.loads(results_raw)
+ except Exception as e:
+ raise Exception('error decoding JSON results from shard #%d' % i)
+ if not seen_first_shard:
+ merged_results = chart_results_json
+ seen_first_shard = True
+ continue
+ for key in chart_results_json:
+ if key == 'charts':
+ merged_results[key].extend(results_json[key])
+ break
+ return merged_results
+
+
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
@@ -799,6 +849,10 @@ class SwarmingApi(recipe_api.RecipeApi):
step_result.isolated_script_results = \
self._merge_isolated_script_shards(task, step_result)
+ # Obtain chart json results if present
+ step_result.isolated_script_chart_results = \
Ken Russell (switch to Gerrit) 2016/09/13 19:34:46 chart_results -> chartjson_results?
eyaich1 2016/09/14 18:14:27 Done.
+ self._merge_isolated_script_chart_ouput_shards(task, step_result)
Ken Russell (switch to Gerrit) 2016/09/13 19:34:46 Is this sufficient to test the above code paths? H
eyaich1 2016/09/14 18:14:28 wow thanks for pointing me at the test_api.py file
+
self._display_pending(summary, step_result.presentation)
except Exception as e:
self.m.step.active_result.presentation.logs['no_results_exc'] = [str(e)]
« no previous file with comments | « no previous file | scripts/slave/recipes/chromium.expected/dynamic_swarmed_failed_isolated_script_test.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698