| 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 from collections import defaultdict | 5 from collections import defaultdict |
| 6 | 6 |
| 7 from common.pipeline_wrapper import BasePipeline | 7 from model.flake.flake_swarming_task import FlakeSwarmingTask |
| 8 | |
| 9 from model.flake.master_flake_analysis import MasterFlakeAnalysis | 8 from model.flake.master_flake_analysis import MasterFlakeAnalysis |
| 10 from model.flake.flake_swarming_task import FlakeSwarmingTask | |
| 11 from waterfall.process_base_swarming_task_result_pipeline import ( | 9 from waterfall.process_base_swarming_task_result_pipeline import ( |
| 12 ProcessBaseSwarmingTaskResultPipeline) | 10 ProcessBaseSwarmingTaskResultPipeline) |
| 13 | 11 |
| 14 | 12 |
| 15 class ProcessFlakeSwarmingTaskResultPipeline( | 13 class ProcessFlakeSwarmingTaskResultPipeline( |
| 16 ProcessBaseSwarmingTaskResultPipeline): | 14 ProcessBaseSwarmingTaskResultPipeline): |
| 17 """A pipeline for monitoring swarming task and processing task result. | 15 """A pipeline for monitoring swarming task and processing task result. |
| 18 | 16 |
| 19 This pipeline waits for result for a swarming task and processes the result to | 17 This pipeline waits for result for a swarming task and processes the result to |
| 20 generate a dict for statuses for each test run. | 18 generate a dict for statuses for each test run. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 tests_statuses[name]['total_run'] += len(test_runs) | 50 tests_statuses[name]['total_run'] += len(test_runs) |
| 53 for test_run in test_runs: | 51 for test_run in test_runs: |
| 54 tests_statuses[name][test_run['status']] += 1 | 52 tests_statuses[name][test_run['status']] += 1 |
| 55 | 53 |
| 56 # Should query by test name, because some test has dependencies which | 54 # Should query by test name, because some test has dependencies which |
| 57 # are also run, like TEST and PRE_TEST in browser_tests. | 55 # are also run, like TEST and PRE_TEST in browser_tests. |
| 58 tries = tests_statuses.get(test_name, {}).get('total_run', 0) | 56 tries = tests_statuses.get(test_name, {}).get('total_run', 0) |
| 59 successes = tests_statuses.get(test_name, {}).get('SUCCESS', 0) | 57 successes = tests_statuses.get(test_name, {}).get('SUCCESS', 0) |
| 60 | 58 |
| 61 if tries > 0: | 59 if tries > 0: |
| 62 success_rate = successes * 1.0 / tries | 60 pass_rate = successes * 1.0 / tries |
| 63 else: | 61 else: |
| 64 success_rate = -1 # Special value to indicate test is not existing. | 62 pass_rate = -1 # Special value to indicate test is not existing. |
| 65 | 63 |
| 66 master_flake_analysis = MasterFlakeAnalysis.Get(master_name, builder_name, | 64 master_flake_analysis = MasterFlakeAnalysis.GetVersion( |
| 67 master_build_number, | 65 master_name, builder_name, master_build_number, step_name, test_name) |
| 68 step_name, test_name) | 66 master_flake_analysis.build_numbers.append(build_number) |
| 67 master_flake_analysis.pass_rates.append(pass_rate) |
| 68 |
| 69 flake_swarming_task = FlakeSwarmingTask.Get( | 69 flake_swarming_task = FlakeSwarmingTask.Get( |
| 70 master_name, builder_name, build_number, step_name, test_name) | 70 master_name, builder_name, build_number, step_name, test_name) |
| 71 | |
| 72 master_flake_analysis.build_numbers.append(build_number) | |
| 73 master_flake_analysis.success_rates.append(success_rate) | |
| 74 flake_swarming_task.tries = tries | 71 flake_swarming_task.tries = tries |
| 75 flake_swarming_task.successes = successes | 72 flake_swarming_task.successes = successes |
| 76 flake_swarming_task.put() | 73 flake_swarming_task.put() |
| 74 |
| 75 results = flake_swarming_task.ResultsToDict() |
| 76 # TODO(lijeffrey): Determine whether or not this flake swarming task |
| 77 # was a cache hit (already ran results for more iterations than were |
| 78 # requested) and update results['cache_hit'] accordingly. |
| 79 results['cache_hit'] = False |
| 80 |
| 81 task_id = flake_swarming_task.task_id |
| 82 master_flake_analysis.swarming_rerun_results[task_id] = results |
| 77 master_flake_analysis.put() | 83 master_flake_analysis.put() |
| 78 return tests_statuses | 84 return tests_statuses |
| 79 | 85 |
| 80 def _GetArgs(self, master_name, builder_name, build_number, | 86 def _GetArgs(self, master_name, builder_name, build_number, |
| 81 step_name, *args): | 87 step_name, *args): |
| 82 master_build_number = args[0] | 88 master_build_number = args[0] |
| 83 test_name = args[1] | 89 test_name = args[1] |
| 84 return (master_name, builder_name, build_number, step_name, | 90 return (master_name, builder_name, build_number, step_name, |
| 85 master_build_number, test_name) | 91 master_build_number, test_name) |
| 86 | 92 |
| 87 # Unused Argument - pylint: disable=W0612,W0613 | 93 # Unused Argument - pylint: disable=W0612,W0613 |
| 88 def _GetSwarmingTask(self, master_name, builder_name, build_number, | 94 def _GetSwarmingTask(self, master_name, builder_name, build_number, |
| 89 step_name, master_build_number, test_name): | 95 step_name, master_build_number, test_name): |
| 90 # Get the appropriate kind of Swarming Task (Flake). | 96 # Get the appropriate kind of Swarming Task (Flake). |
| 91 return FlakeSwarmingTask.Get(master_name, builder_name, | 97 return FlakeSwarmingTask.Get(master_name, builder_name, |
| 92 build_number, step_name, test_name) | 98 build_number, step_name, test_name) |
| OLD | NEW |