| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 json | 5 import json |
| 6 import os | 6 import os |
| 7 | 7 |
| 8 import logging | 8 import logging |
| 9 | 9 |
| 10 from common import cache_decorator | 10 from common import cache_decorator |
| 11 from common.http_client_appengine import HttpClientAppEngine as HttpClient | 11 from common.http_client_appengine import HttpClientAppengine as HttpClient |
| 12 from waterfall import buildbot | 12 from waterfall import buildbot |
| 13 from waterfall import swarming_util | 13 from waterfall import swarming_util |
| 14 | 14 |
| 15 | 15 |
| 16 @cache_decorator.Cached( | 16 @cache_decorator.Cached( |
| 17 namespace='trybots', cacher=cache_decorator.CompressedMemCacher()) | 17 namespace='trybots', cacher=cache_decorator.CompressedMemCacher()) |
| 18 def _LoadTrybots(): # pragma: no cover. | 18 def _LoadTrybots(): # pragma: no cover. |
| 19 """Returns the mapping of Commit Queue trybots to Waterfall buildbots.""" | 19 """Returns the mapping of Commit Queue trybots to Waterfall buildbots.""" |
| 20 with open(os.path.join(os.path.dirname(__file__), 'trybots.json'), 'r') as f: | 20 with open(os.path.join(os.path.dirname(__file__), 'trybots.json'), 'r') as f: |
| 21 return json.load(f) | 21 return json.load(f) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 # 2. Get "name" of the CQ trybot step in the tags of a Swarming task. | 62 # 2. Get "name" of the CQ trybot step in the tags of a Swarming task. |
| 63 tasks = swarming_util.ListSwarmingTasksDataByTags( | 63 tasks = swarming_util.ListSwarmingTasksDataByTags( |
| 64 cq_build_step.master_name, cq_build_step.builder_name, | 64 cq_build_step.master_name, cq_build_step.builder_name, |
| 65 cq_build_step.build_number, http_client, | 65 cq_build_step.build_number, http_client, |
| 66 {'stepname': cq_build_step.step_name}) | 66 {'stepname': cq_build_step.step_name}) |
| 67 if not tasks: | 67 if not tasks: |
| 68 logging.info( | 68 logging.info( |
| 69 '%s/%s/%s is not Swarmed yet.', | 69 '%s/%s/%s is not Swarmed yet.', |
| 70 cq_build_step.master_name, cq_build_step.builder_name, | 70 cq_build_step.master_name, cq_build_step.builder_name, |
| 71 cq_build_step.build_step) | 71 cq_build_step.step_name) |
| 72 return no_matching_result # Not on Swarm yet. | 72 return no_matching_result # Not on Swarm yet. |
| 73 | 73 |
| 74 # Name of the step in the tags of a Swarming task. | 74 # Name of the step in the tags of a Swarming task. |
| 75 # Can't use step name, as cq one is with "(with patch)" while waterfall one | 75 # Can't use step name, as cq one is with "(with patch)" while waterfall one |
| 76 # without. | 76 # without. |
| 77 name = GetTagValue('name', tasks[0].get('tags', [])) | 77 name = GetTagValue('name', tasks[0].get('tags', [])) |
| 78 # The OS in which the test runs on. The same test binary might run on two | 78 # The OS in which the test runs on. The same test binary might run on two |
| 79 # different OS platforms. | 79 # different OS platforms. |
| 80 os_name = GetTagValue('os', tasks[0].get('tags', [])) | 80 os_name = GetTagValue('os', tasks[0].get('tags', [])) |
| 81 if not name or not os_name: | 81 if not name or not os_name: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 97 # 4. Check whether there is matching step. | 97 # 4. Check whether there is matching step. |
| 98 # TODO: we might have to check OS or dimension too. | 98 # TODO: we might have to check OS or dimension too. |
| 99 tasks = swarming_util.ListSwarmingTasksDataByTags( | 99 tasks = swarming_util.ListSwarmingTasksDataByTags( |
| 100 wf_master_name, wf_builder_name, builds[0], http_client, | 100 wf_master_name, wf_builder_name, builds[0], http_client, |
| 101 {'name': name, 'os': os_name}) | 101 {'name': name, 'os': os_name}) |
| 102 if tasks: # One matching buildbot is found. | 102 if tasks: # One matching buildbot is found. |
| 103 wf_step_name = GetTagValue('stepname', tasks[0].get('tags', [])) | 103 wf_step_name = GetTagValue('stepname', tasks[0].get('tags', [])) |
| 104 logging.info( | 104 logging.info( |
| 105 '%s/%s/%s is mapped to %s/%s/%s', | 105 '%s/%s/%s is mapped to %s/%s/%s', |
| 106 cq_build_step.master_name, cq_build_step.builder_name, | 106 cq_build_step.master_name, cq_build_step.builder_name, |
| 107 cq_build_step.build_step, wf_master_name, wf_builder_name, | 107 cq_build_step.step_name, wf_master_name, wf_builder_name, |
| 108 wf_step_name) | 108 wf_step_name) |
| 109 return wf_master_name, wf_builder_name, builds[0], wf_step_name | 109 return wf_master_name, wf_builder_name, builds[0], wf_step_name |
| 110 | 110 |
| 111 return no_matching_result | 111 return no_matching_result |
| 112 | 112 |
| 113 | 113 |
| 114 def FindMatchingWaterfallStep(build_step): # pragma: no cover. | 114 def FindMatchingWaterfallStep(build_step): # pragma: no cover. |
| 115 """Finds the matching Waterfall step and checks whether it is supported. | 115 """Finds the matching Waterfall step and checks whether it is supported. |
| 116 | 116 |
| 117 Only Swarmed and gtest-based steps are supported at the moment. | 117 Only Swarmed and gtest-based steps are supported at the moment. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 output = swarming_util.RetrieveShardedTestResultsFromIsolatedServer( | 161 output = swarming_util.RetrieveShardedTestResultsFromIsolatedServer( |
| 162 step_isolated_data[:1], http_client) | 162 step_isolated_data[:1], http_client) |
| 163 if output: | 163 if output: |
| 164 # Guess from the format. | 164 # Guess from the format. |
| 165 build_step.supported = ( | 165 build_step.supported = ( |
| 166 isinstance(output, dict) and | 166 isinstance(output, dict) and |
| 167 isinstance(output.get('all_tests'), list) and | 167 isinstance(output.get('all_tests'), list) and |
| 168 isinstance(output.get('per_iteration_data'), list) and | 168 isinstance(output.get('per_iteration_data'), list) and |
| 169 all(isinstance(i, dict) for i in output.get('per_iteration_data')) | 169 all(isinstance(i, dict) for i in output.get('per_iteration_data')) |
| 170 ) | 170 ) |
| OLD | NEW |