Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 google.appengine.ext import ndb | |
| 6 | |
| 7 from model.flake.master_flake_analysis import MasterFlakeAnalysis | |
| 8 from model.versioned_model import VersionedModel | |
| 9 | |
| 10 | |
| 11 class BuildStep(ndb.Model): | |
| 12 """Represents a build step on Waterfall or Commit Queue. | |
| 13 | |
| 14 For a build step on Commit Queue, the matching Waterfall build step could be | |
| 15 added if found. | |
| 16 """ | |
| 17 | |
| 18 # The build step in which a flake actually occurred. | |
| 19 master_name = ndb.StringProperty(indexed=False) | |
| 20 builder_name = ndb.StringProperty(indexed=False) | |
| 21 build_number = ndb.IntegerProperty(indexed=False) | |
| 22 step_name = ndb.StringProperty(indexed=False) | |
| 23 | |
| 24 # When the flake was reported on this step. | |
| 25 reported_time = ndb.DateTimeProperty(indexed=False) | |
| 26 | |
| 27 # The matching build step on the Waterfall of the matching test configuration. | |
| 28 wf_master_name = ndb.StringProperty(indexed=False) | |
| 29 wf_builder_name = ndb.StringProperty(indexed=False) | |
| 30 wf_build_number = ndb.IntegerProperty(indexed=False) | |
| 31 wf_step_name = ndb.StringProperty(indexed=False) | |
| 32 | |
| 33 # Indicate whether the flake is run on Swarming. | |
| 34 swarmed = ndb.BooleanProperty(indexed=False, default=False) | |
| 35 | |
| 36 # Indicate whether analysis on the step is supported. | |
| 37 supported = ndb.BooleanProperty(indexed=False, default=False) | |
| 38 | |
| 39 # Indicate whether the flake on this configuration is analyzed. | |
| 40 analyzed = ndb.BooleanProperty(indexed=False, default=False) | |
| 41 | |
| 42 @staticmethod | |
| 43 def _StripMasterPrefix(name): | |
| 44 master_prefix = 'master.' | |
| 45 if name.startswith(master_prefix): | |
| 46 return name[len(master_prefix):] | |
| 47 return name | |
| 48 | |
| 49 @staticmethod | |
| 50 def Create(master_name, builder_name, build_number, step_name, reported_time): | |
| 51 return BuildStep( | |
| 52 master_name=BuildStep._StripMasterPrefix(master_name), | |
| 53 builder_name=builder_name, | |
| 54 build_number=build_number, | |
| 55 step_name=step_name, | |
| 56 reported_time=reported_time) | |
| 57 | |
| 58 | |
| 59 class FlakeAnalysisRequest(VersionedModel): | |
| 60 """Represents a request to analyze a flake. | |
| 61 | |
| 62 The name of the flake will be the key, and the model is versioned. | |
| 63 """ | |
| 64 | |
| 65 # Name of the flake. Could be a step name, or a test name. | |
| 66 # Assume there are no step and test with the same name. | |
| 67 name = ndb.StringProperty(indexed=True) | |
| 68 | |
| 69 # Indicate whether the flake is a step or a test. | |
| 70 is_step = ndb.BooleanProperty(indexed=True, default=True) | |
| 71 | |
| 72 # Indicate whether the flake is run on Swarming for some configuration. | |
| 73 swarmed = ndb.BooleanProperty(indexed=False, default=False) | |
| 74 | |
| 75 # Indicate whether analysis on this flake is supported. | |
| 76 supported = ndb.BooleanProperty(indexed=False, default=False) | |
| 77 | |
| 78 # The bug id for this flake on Monorail. | |
| 79 bug_id = ndb.IntegerProperty(indexed=False) | |
| 80 | |
| 81 # The emails of users who request analysis of this flake. | |
| 82 user_emails = ndb.StringProperty(indexed=False, repeated=True) | |
| 83 | |
| 84 # The build steps in which the flake occurred. | |
| 85 build_steps = ndb.LocalStructuredProperty( | |
| 86 BuildStep, compressed=True, repeated=True) | |
| 87 | |
| 88 # Executed analyses on different test configurations. | |
| 89 analyses = ndb.KeyProperty(MasterFlakeAnalysis, repeated=True) | |
| 90 | |
| 91 # Arguments number differs from overridden method - pylint: disable=W0221 | |
| 92 @classmethod | |
| 93 def Create(cls, name, is_step, bug_id): | |
| 94 instance = super(cls, FlakeAnalysisRequest).Create(key=name) | |
| 95 instance.name = name | |
| 96 instance.is_step = is_step | |
| 97 instance.bug_id = bug_id | |
| 98 return instance | |
| 99 | |
| 100 def AddBuildStep( | |
|
lijeffrey
2016/10/05 07:57:06
nit: this seems slightly misleading, since a build
stgao
2016/10/05 14:12:40
I will leave as is, but use a better name or fix t
| |
| 101 self, master_name, builder_name, build_number, step_name, reported_time): | |
| 102 """Adds a build step in which the flake is found.""" | |
| 103 for s in self.build_steps: | |
| 104 if s.master_name == master_name and s.builder_name == builder_name: | |
| 105 # For the same builder/tester, only analyze the earliest build. | |
| 106 # TODO: re-evaluate cases that flakes might be re-introduced in between. | |
| 107 if s.build_number <= build_number: | |
| 108 return False | |
| 109 s.build_number = build_number | |
| 110 s.reported_time = reported_time | |
| 111 return True | |
| 112 | |
| 113 self.build_steps.append( | |
| 114 BuildStep.Create( | |
| 115 master_name, builder_name, build_number, step_name, reported_time)) | |
| 116 return True | |
| OLD | NEW |