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

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: cleanup Created 4 years, 5 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 import datetime
7 import logging
8 import time
9
10 from google.appengine.ext import ndb
11
12 from common.http_client_appengine import HttpClientAppengine as HttpClient
13 from common.pipeline_wrapper import BasePipeline
14
15 from model import analysis_status
16 from model.flake.master_flake_analysis import MasterFlakeAnalysis
17 from model.flake.flake_swarming_task import FlakeSwarmingTask
18 from waterfall.process_base_swarming_task_result_pipeline import (
19 ProcessBaseSwarmingTaskResultPipeline as PBSTRP)
20
21
22 class ProcessFlakeSwarmingTaskResultPipeline(PBSTRP):
23 """A pipeline for monitoring swarming task and processing task result.
24
25 This pipeline waits for result for a swarming task and processes the result to
26 generate a dict for statuses for each test run.
27 """
28 # Arguments number differs from overridden method - pylint: disable=W0221
29 def _CheckTestsRunStatuses(self, output_json, master_name,
30 builder_name, build_number, step_name,
31 master_build_number, test_name):
32 """Checks result status for each test run and saves the numbers accordingly.
33
34 Args:
35 output_json (dict): A dict of all test results in the swarming task.
36 master_name (string): Name of master of swarming rerun.
37 builder_name (dict): Name of builder of swarming rerun.
38 build_number (int): Build Number of swarming rerun.
39 step_name (dict): Name of step of swarming rerun.
40 master_build_number (int): Build number of corresponding mfa
41 test_name (string): Name of test of swarming rerun
42 Returns:
lijeffrey 2016/07/19 22:44:10 nit: empty line before Returns
caiw 2016/07/20 18:26:47 Done.
43 tests_statuses (dict): A dict of different statuses for each test.
44
45 Currently for each test, we are saving number of total runs,
46 number of succeeded runs and number of failed runs.
47 """
48
49 mfa = MasterFlakeAnalysis.Get(master_name, builder_name,
lijeffrey 2016/07/19 22:44:10 nit: it's ok to use longer variable names with the
caiw 2016/07/20 18:26:47 Done.
50 master_build_number,
51 step_name, test_name)
52 fst = FlakeSwarmingTask.Get(master_name, builder_name, build_number,
53 step_name, test_name)
54
55 tests_statuses = defaultdict(lambda: defaultdict(int))
56 successes = 0
57 tries = 0
58
59 if output_json:
60 for iteration in output_json.get('per_iteration_data'):
61 for test_name, tests in iteration.iteritems():
62 tries += 1
63 tests_statuses[test_name]['total_run'] += len(tests)
64 for test in tests:
65 if test['status'] == 'SUCCESS':
66 successes += 1
67 tests_statuses[test_name][test['status']] += 1
68 mfa.build_numbers.append(build_number)
69 mfa.success_rates.append(successes * 1.0/tries)
70 fst.tries = tries
71 fst.successes = successes
72 fst.put()
73 mfa.put()
74 return tests_statuses
75
76 def _GetArgs(self, master_name, builder_name, build_number,
77 step_name, *args):
78 master_build_number = args[0]
79 test_name = args[1]
80 return (master_name, builder_name, build_number, step_name,
81 master_build_number, test_name)
82
83 # Unused Argument - pylint: disable=W0612,W0613
84 def _GetSwarmingTask(self, master_name, builder_name, build_number,
85 step_name, master_build_number, test_name):
86 # Get the appropriate kind of Swarming Task (Flake)
87 return FlakeSwarmingTask.Get(master_name, builder_name,
88 build_number, step_name, test_name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698