OLD | NEW |
---|---|
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import datetime | 5 import datetime |
6 import functools | 6 import functools |
7 | 7 |
8 from recipe_engine import recipe_api | 8 from recipe_engine import recipe_api |
9 | 9 |
10 | 10 |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
725 # https://www.chromium.org/developers/the-json-test-results-format | 725 # https://www.chromium.org/developers/the-json-test-results-format |
726 # . Note that gtests, above, don't seem to conform to this | 726 # . Note that gtests, above, don't seem to conform to this |
727 # format yet, so it didn't seem like a good prerequisite to | 727 # format yet, so it didn't seem like a good prerequisite to |
728 # switch the isolated tests over when adding sharding support. | 728 # switch the isolated tests over when adding sharding support. |
729 # | 729 # |
730 # These are the only keys we pay attention to in the output JSON. | 730 # These are the only keys we pay attention to in the output JSON. |
731 merged_results = { | 731 merged_results = { |
732 'successes': [], | 732 'successes': [], |
733 'failures': [], | 733 'failures': [], |
734 'valid': True, | 734 'valid': True, |
735 'chartjson': '', | |
735 } | 736 } |
736 for i in xrange(task.shards): | 737 for i in xrange(task.shards): |
737 path = self.m.path.join(str(i), 'output.json') | 738 path = self.m.path.join(str(i), 'output.json') |
738 if path not in step_result.raw_io.output_dir: | 739 if path not in step_result.raw_io.output_dir: |
739 raise Exception('no results from shard #%d' % i) | 740 raise Exception('no results from shard #%d' % i) |
740 results_raw = step_result.raw_io.output_dir[path] | 741 results_raw = step_result.raw_io.output_dir[path] |
741 try: | 742 try: |
742 results_json = self.m.json.loads(results_raw) | 743 results_json = self.m.json.loads(results_raw) |
743 except Exception as e: | 744 except Exception as e: |
744 raise Exception('error decoding JSON results from shard #%d' % i) | 745 raise Exception('error decoding JSON results from shard #%d' % i) |
745 for key in merged_results: | 746 for key in merged_results: |
746 if key in results_json: | 747 if key in results_json: |
747 if isinstance(merged_results[key], list): | 748 if isinstance(merged_results[key], list): |
748 merged_results[key].extend(results_json[key]) | 749 merged_results[key].extend(results_json[key]) |
749 elif isinstance(merged_results[key], bool): | 750 elif isinstance(merged_results[key], bool): |
750 merged_results[key] = merged_results[key] and results_json[key] | 751 merged_results[key] = merged_results[key] and results_json[key] |
752 elif key is 'chartjson': | |
753 # Not sure if this is the correct way to merge the chartjson. Also | |
754 # not sure if we will ever have more than one shard to merge. | |
755 merged_results[key].extend(results_json[key]) | |
Ken Russell (switch to Gerrit)
2016/09/12 19:35:41
See above. I think we should write a new merge fun
eyaich1
2016/09/13 16:52:59
Done.
| |
751 else: | 756 else: |
752 raise recipe_api.InfraFailure( | 757 raise recipe_api.InfraFailure( |
753 'Unknown key type ' + type(merged_results[key]) + | 758 'Unknown key type ' + type(merged_results[key]) + |
754 ' when handling key ' + key + '.') # pragma: no cover | 759 ' when handling key ' + key + '.') # pragma: no cover |
755 return merged_results | 760 return merged_results |
756 | 761 |
757 def _isolated_script_collect_step(self, task, **kwargs): | 762 def _isolated_script_collect_step(self, task, **kwargs): |
758 step_test_data = kwargs.pop('step_test_data', None) | 763 step_test_data = kwargs.pop('step_test_data', None) |
759 if not step_test_data: | 764 if not step_test_data: |
760 step_test_data = self.m.test_utils.test_api.canned_isolated_script_output( | 765 step_test_data = self.m.test_utils.test_api.canned_isolated_script_output( |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
989 | 994 |
990 def get_shard_view_url(self, index): | 995 def get_shard_view_url(self, index): |
991 """Returns URL of HTML page with shard details or None if not available. | 996 """Returns URL of HTML page with shard details or None if not available. |
992 | 997 |
993 Works only after the task has been successfully triggered. | 998 Works only after the task has been successfully triggered. |
994 """ | 999 """ |
995 if self._trigger_output and self._trigger_output.get('tasks'): | 1000 if self._trigger_output and self._trigger_output.get('tasks'): |
996 for shard_dict in self._trigger_output['tasks'].itervalues(): | 1001 for shard_dict in self._trigger_output['tasks'].itervalues(): |
997 if shard_dict['shard_index'] == index: | 1002 if shard_dict['shard_index'] == index: |
998 return shard_dict['view_url'] | 1003 return shard_dict['view_url'] |
OLD | NEW |