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