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

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

Issue 2187763004: [Findit] Refactor Findit pipeline. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: rebase 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 logging
7
8 from common.waterfall import failure_type
9 from model.wf_try_job import WfTryJob
10 from waterfall.schedule_try_job_pipeline import ScheduleTryJobPipeline
11
12
13 def _GetTargetedTests(reliable_tests):
14 targeted_tests = defaultdict(list)
15 for step_reliable_tests in reliable_tests.itervalues():
16 step_name_no_platform = step_reliable_tests[0]
17 tests = step_reliable_tests[1]
18 if tests:
19 targeted_tests[step_name_no_platform].extend(tests)
20 return targeted_tests
21
22
23 class ScheduleTestTryJobPipeline(ScheduleTryJobPipeline):
24 """A pipeline for scheduling a new try job for failed test build."""
25
26 def _GetBuildProperties(
27 self, master_name, builder_name, build_number, good_revision,
28 bad_revision, try_job_type, suspected_revisions):
29 properties = super(ScheduleTestTryJobPipeline, self)._GetBuildProperties(
30 master_name, builder_name, build_number, good_revision,
31 bad_revision, try_job_type, suspected_revisions)
32 properties['target_testername'] = builder_name
33
34 return properties
35
36 # Arguments number differs from overridden method - pylint: disable=W0221
37 def run(
38 self, master_name, builder_name, build_number, good_revision,
39 bad_revision, try_job_type, suspected_revisions, *reliable_tests):
40 """
41 Args:
42 master_name (str): the master name of a build.
43 builder_name (str): the builder name of a build.
44 build_number (int): the build number of a build.
45 good_revision (str): the revision of the last passed build.
46 bad__revision (str): the revision of the first failed build.
47 try_job_type (int): type of the try job: TEST in this case.
48 suspected_revisions (list): a list of suspected revisions from heuristic.
49 reliable_tests (list): a list of reliable failed tests.
50
51 Returns:
52 build_id (str): id of the triggered try job.
53 """
54
55 properties = self._GetBuildProperties(
56 master_name, builder_name, build_number, good_revision, bad_revision,
57 try_job_type, suspected_revisions)
58
59 targeted_tests = _GetTargetedTests(dict(reliable_tests))
60 if not targeted_tests: # pragma: no cover
61 logging.info('All tests are flaky, no try job will be triggered.')
62 return
63
64 additional_parameters = {'tests': targeted_tests}
65
66 build_id = self._TriggerTryJob(
67 master_name, builder_name, properties, additional_parameters)
68
69 try_job_result = WfTryJob.Get(master_name, builder_name, build_number)
70 try_job_result.test_results.append({'try_job_id': build_id})
71 try_job_result.try_job_ids.append(build_id)
72 try_job_result.put()
73
74 # Create a corresponding WfTryJobData entity to capture as much metadata as
75 # early as possible.
76 self._CreateTryJobData(
77 build_id, master_name, builder_name, build_number,
78 failure_type.GetDescriptionForFailureType(try_job_type),
79 False, bool(suspected_revisions))
80
81 return build_id
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698