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

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: I now test everything that I wrote. 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 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)
lijeffrey 2016/07/27 22:38:23 I know this is a long name but it's probably bette
caiw 2016/07/27 23:51:33 Done.
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
43 Returns:
44 tests_statuses (dict): A dict of different statuses for each test.
45
46 Currently for each test, we are saving number of total runs,
47 number of succeeded runs and number of failed runs.
48 """
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 tests_statuses = defaultdict(lambda: defaultdict(int))
57
58 if not output_json:
lijeffrey 2016/07/27 22:38:23 it looks like you may be able to bail out even soo
caiw 2016/07/27 23:51:33 Done.
59 return tests_statuses
60
61 successes = 0
62 tries = 0
63 for iteration in output_json.get('per_iteration_data'):
64 for test_name, tests in iteration.iteritems():
65 tries += 1
66 tests_statuses[test_name]['total_run'] += len(tests)
67 for test in tests:
68 if test['status'] == 'SUCCESS':
69 successes += 1
70 tests_statuses[test_name][test['status']] += 1
71 master_flake_analysis.build_numbers.append(build_number)
lijeffrey 2016/07/27 22:38:23 nit: empty line before master_flake_analysis.build
caiw 2016/07/27 23:51:33 Done.
72 master_flake_analysis.success_rates.append(successes * 1.0/tries)
73 flake_swarming_task.tries = tries
74 flake_swarming_task.successes = successes
75 flake_swarming_task.put()
76 master_flake_analysis.put()
77 return tests_statuses
78
79 def _GetArgs(self, master_name, builder_name, build_number,
80 step_name, *args):
81 master_build_number = args[0]
82 test_name = args[1]
83 return (master_name, builder_name, build_number, step_name,
84 master_build_number, test_name)
85
86 # Unused Argument - pylint: disable=W0612,W0613
87 def _GetSwarmingTask(self, master_name, builder_name, build_number,
88 step_name, master_build_number, test_name):
89 # Get the appropriate kind of Swarming Task (Flake)
lijeffrey 2016/07/27 22:38:23 nit: comment ends with . You should be able to ru
caiw 2016/07/27 23:51:33 Done.
90 return FlakeSwarmingTask.Get(master_name, builder_name,
91 build_number, step_name, test_name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698