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

Side by Side Diff: appengine/findit/waterfall/flake/initialize_flake_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 datetime import datetime
6
7 from google.appengine.ext import ndb
8
9 from common import appengine_util
10 from common import constants
11 from model import analysis_status
12 from model.flake.flake_swarming_task import FlakeSwarmingTask
13 from model.flake.master_flake_analysis import MasterFlakeAnalysis
14 from waterfall.flake.recursive_flake_pipeline import RecursiveFlakePipeline
15
16
17 @ndb.transactional
18 def NeedANewAnalysis(
19 master_name, builder_name, build_number, step_name, test_name):
20 """Checks status of analysis for the test and decides if a new one is needed.
21
22 A MasterFlakeAnalysis entity for the given build will be created if none
23 exists. When a new analysis is needed, this function will create and
24 save a MasterFlakeAnalysis entity to the datastore, or it will
25 reset the existing one but still keep the result of last analysis.
lijeffrey 2016/07/27 22:38:22 so where is this result being kept exactly?
caiw 2016/07/27 23:51:32 sorry, docstring was outdated
26
27 Returns:
28 True if an analysis is needed, otherwise False.
29 """
30 analysis = MasterFlakeAnalysis.Get(master_name, builder_name, build_number,
lijeffrey 2016/07/27 22:38:22 nit: rename this master_flake_analysis instead of
caiw 2016/07/27 23:51:32 Done.
31 step_name, test_name)
32
33 if not analysis:
34 analysis = MasterFlakeAnalysis.Create(
35 master_name, builder_name, build_number, step_name, test_name)
36 analysis.status = analysis_status.PENDING
37 analysis.put()
38 return True
39 elif (analysis.status == analysis_status.COMPLETED or
40 analysis.status == analysis_status.PENDING or
41 analysis.status == analysis_status.RUNNING):
42 return False
43 else:
44 # TODO(caiw): Reset method.
45 MasterFlakeAnalysis.Get(
46 master_name, builder_name, build_number,
47 step_name, test_name).key.delete()
48 analysis = MasterFlakeAnalysis.Create(
49 master_name, builder_name, build_number, step_name, test_name)
50 analysis.status = analysis_status.PENDING
51 analysis.put()
52 return True
53
54 # Unused arguments - pylint: disable=W0612, W0613
55 def ScheduleAnalysisIfNeeded(master_name, builder_name, build_number, step_name,
56 test_name, force=False,
57 queue_name=constants.DEFAULT_QUEUE):
58 """Schedules an analysis if needed and returns the MasterFlakeAnalysis.
59
60 When the build failure was already analyzed and a new analysis is scheduled,
61 the returned WfAnalysis will still have the result of last completed analysis.
62
63 Args:
64 master_name (str): The master name of the failed test
65 builder_name (str): The builder name of the failed test
66 build_number (int): The build number of the failed test
67 step_name (str): The name of the test suite
68 test_name (str): The single test we are checking
69
70 Returns:
71 A MasterFlakeAnalysis instance.
72 """
73 if NeedANewAnalysis(
74 master_name, builder_name, build_number, step_name, test_name):
75 pipeline_job = RecursiveFlakePipeline(
76 master_name, builder_name, build_number, step_name, test_name,
77 master_build_number=build_number)
78 pipeline_job.target = appengine_util.GetTargetNameForModule(
79 constants.WATERFALL_BACKEND)
80 pipeline_job.start(queue_name=queue_name)
81 return MasterFlakeAnalysis.Get(
82 master_name, builder_name, build_number, step_name, test_name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698