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

Side by Side Diff: appengine/findit/waterfall/process_flake_swarming_task_result_pipeline.py

Issue 2130543004: Waterfall components of regression range finder. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: addressed comments Created 4 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 from collections import defaultdict
6
7 from common.pipeline_wrapper import BasePipeline
8
9 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 (
12 ProcessBaseSwarmingTaskResultPipeline)
13
14
15 class ProcessFlakeSwarmingTaskResultPipeline(
16 ProcessBaseSwarmingTaskResultPipeline):
17 """A pipeline for monitoring swarming task and processing task result.
18
19 This pipeline waits for result for a swarming task and processes the result to
20 generate a dict for statuses for each test run.
21 """
22
23 # Arguments number differs from overridden method - pylint: disable=W0221
24 def _CheckTestsRunStatuses(self, output_json, master_name,
25 builder_name, build_number, step_name,
26 master_build_number, test_name):
27 """Checks result status for each test run and saves the numbers accordingly.
28
29 Args:
30 output_json (dict): A dict of all test results in the swarming task.
31 master_name (string): Name of master of swarming rerun.
32 builder_name (dict): Name of builder of swarming rerun.
33 build_number (int): Build Number of swarming rerun.
34 step_name (dict): Name of step of swarming rerun.
35 master_build_number (int): Build number of corresponding mfa
36 test_name (string): Name of test of swarming rerun
37
38 Returns:
39 tests_statuses (dict): A dict of different statuses for each test.
40
41 Currently for each test, we are saving number of total runs,
42 number of succeeded runs and number of failed runs.
43 """
44
45 tests_statuses = defaultdict(lambda: defaultdict(int))
46
47 if not output_json:
48 return tests_statuses
49
50 master_flake_analysis = MasterFlakeAnalysis.Get(master_name, builder_name,
51 master_build_number,
52 step_name, test_name)
53 flake_swarming_task = FlakeSwarmingTask.Get(
54 master_name, builder_name, build_number, step_name, test_name)
55
56 successes = 0
57 tries = 0
58 for iteration in output_json.get('per_iteration_data'):
59 for test_name, tests in iteration.iteritems():
60 tries += 1
61 tests_statuses[test_name]['total_run'] += len(tests)
62 for test in tests:
63 if test['status'] == 'SUCCESS':
64 successes += 1
65 tests_statuses[test_name][test['status']] += 1
66
67 master_flake_analysis.build_numbers.append(build_number)
68 master_flake_analysis.success_rates.append(float(successes)/tries)
lijeffrey 2016/07/29 20:06:32 nit: space before and after /
69 flake_swarming_task.tries = tries
70 flake_swarming_task.successes = successes
71 flake_swarming_task.put()
72 master_flake_analysis.put()
73 return tests_statuses
74
75 def _GetArgs(self, master_name, builder_name, build_number,
76 step_name, *args):
77 master_build_number = args[0]
78 test_name = args[1]
79 return (master_name, builder_name, build_number, step_name,
80 master_build_number, test_name)
81
82 # Unused Argument - pylint: disable=W0612,W0613
83 def _GetSwarmingTask(self, master_name, builder_name, build_number,
84 step_name, master_build_number, test_name):
85 # Get the appropriate kind of Swarming Task (Flake).
86 return FlakeSwarmingTask.Get(master_name, builder_name,
87 build_number, step_name, test_name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698