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

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: 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 model.flake.flake_swarming_task_result import FlakeSwarmingTaskResult
19 from waterfall.process_base_swarming_task_result_pipeline import (
20 ProcessBaseSwarmingTaskResultPipeline as PBSTRP)
21
22
23
24 class ProcessFlakeSwarmingTaskResultPipeline(PBSTRP):
25 """A pipeline for monitoring swarming task and processing task result.
26
27 This pipeline waits for result for a swarming task and processes the result to
28 generate a dict for statuses for each test run.
29 """
30 # Arguments number differs from overridden method - pylint: disable=W0221
31 def _CheckTestsRunStatuses(self, output_json, master_name,
32 builder_name, build_number, step_name):
33 """Checks result status for each test run and saves the numbers accordingly.
34
35 Args:
36 output_json (dict): A dict of all test results in the swarming task.
stgao 2016/07/09 00:04:34 style nit: indent.
caiw 2016/07/14 00:59:45 Done.
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 mfa = MasterFlakeAnalysis.Get(master_name, builder_name, step_name)
45 mfa.build_numbers.append(build_number)
46
47 tests_statuses = defaultdict(lambda: defaultdict(int))
48 successes = 0
49 tries = 0
50
51 if output_json:
52 for iteration in output_json.get('per_iteration_data'):
53 test_name = ""
54 for test_name, tests in iteration.iteritems():
55 tries += 1
56 tests_statuses[test_name]['total_run'] += len(tests)
57 for test in tests:
58 if test['status'] == 'SUCCESS':
59 successes += 1
60 tests_statuses[test_name][test['status']] += 1
61 mfa.success_rates.append(successes * 1.0/tries)
stgao 2016/07/09 00:04:34 This might have to be out of both for loops, becau
caiw 2016/07/14 00:59:45 Done.
62 result = FlakeSwarmingTaskResult.Create(
63 master_name, builder_name, step_name,
64 build_number, test_name)
65 result.tries = tries
66 result.successes = successes
67 result.put()
68 mfa.put()
69 return tests_statuses
70
71 @ndb.transactional
72 def _GetSwarmingTask(self, master_name, builder_name,
73 step_name, build_number):
74 # Get the appropriate kind of Swarming Task (Flake)
75 swarming_task = FlakeSwarmingTask.Get(
76 master_name, builder_name, step_name, build_number)
77 return swarming_task
stgao 2016/07/09 00:04:33 nit: merge into one line. Does the read have to b
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698