Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import base64 | 5 import base64 |
| 6 | 6 |
| 7 from google.appengine.ext import ndb | 7 from google.appengine.ext import ndb |
| 8 | 8 |
| 9 from common import time_util | |
| 10 | |
|
chanli
2016/09/27 22:15:24
Nit: remove this empty line.
lijeffrey
2016/09/28 03:12:30
Done.
| |
| 11 from model import analysis_status | |
| 12 from model.base_analysis import BaseAnalysis | |
| 9 from model.base_build_model import BaseBuildModel | 13 from model.base_build_model import BaseBuildModel |
| 10 from model.base_analysis import BaseAnalysis | 14 from model.versioned_model import VersionedModel |
| 11 from model.flake.flake_swarming_task import FlakeSwarmingTask | |
| 12 | 15 |
| 13 | 16 |
| 14 class MasterFlakeAnalysis(BaseAnalysis, BaseBuildModel): | 17 class MasterFlakeAnalysis(BaseAnalysis, BaseBuildModel, VersionedModel): |
| 15 """Represents an analysis of a flaky test in a Chromium Waterfall.""" | 18 """Represents an analysis of a flaky test in a Chromium Waterfall.""" |
| 16 | 19 |
| 17 @staticmethod | |
| 18 def _CreateAnalysisId(master_name, builder_name, | |
| 19 build_number, step_name, test_name): | |
| 20 encoded_test_name = base64.urlsafe_b64encode(test_name) | |
| 21 return '%s/%s/%s/%s/%s' % (master_name, builder_name, | |
| 22 build_number, step_name, encoded_test_name) | |
| 23 | |
| 24 @ndb.ComputedProperty | 20 @ndb.ComputedProperty |
| 25 def step_name(self): | 21 def step_name(self): |
| 26 return self.key.pairs()[0][1].split('/')[3] | 22 return self.key.pairs()[0][1].split('/')[3] |
| 27 | 23 |
| 28 @ndb.ComputedProperty | 24 @ndb.ComputedProperty |
| 29 def test_name(self): | 25 def test_name(self): |
| 30 return base64.urlsafe_b64decode(self.key.pairs()[0][1].split('/')[4]) | 26 return base64.urlsafe_b64decode(self.key.pairs()[0][1].split('/')[4]) |
| 31 | 27 |
| 32 @staticmethod | 28 @staticmethod |
| 33 def _CreateKey(master_name, builder_name, build_number, | 29 def _CreateAnalysisId( |
| 34 step_name, test_name): # pragma: no cover | 30 master_name, builder_name, build_number, step_name, test_name): |
| 35 return ndb.Key('MasterFlakeAnalysis', | 31 encoded_test_name = base64.urlsafe_b64encode(test_name) |
| 36 MasterFlakeAnalysis._CreateAnalysisId( | 32 return '%s/%s/%s/%s/%s' % ( |
| 37 master_name, builder_name, build_number, | 33 master_name, builder_name, build_number, step_name, encoded_test_name) |
| 38 step_name, test_name)) | |
| 39 | 34 |
| 40 @staticmethod | 35 # Arguments number differs from overridden method - pylint: disable=W0221 |
| 41 def Create(master_name, builder_name, build_number, | 36 @classmethod |
| 42 step_name, test_name): # pragma: no cover | 37 def Create(cls, master_name, builder_name, build_number, step_name, |
| 43 return MasterFlakeAnalysis( | 38 test_name): # pragma: no cover. |
| 44 key=MasterFlakeAnalysis._CreateKey( | 39 return super(MasterFlakeAnalysis, cls).Create( |
| 45 master_name, builder_name, build_number, | 40 MasterFlakeAnalysis._CreateAnalysisId( |
| 46 step_name, test_name)) | 41 master_name, builder_name, build_number, step_name, test_name)) |
| 47 | 42 |
| 48 @staticmethod | 43 # Arguments number differs from overridden method - pylint: disable=W0221 |
| 49 def Get(master_name, builder_name, build_number, | 44 @classmethod |
| 50 step_name, test_name): # pragma: no cover | 45 def GetVersion(cls, master_name, builder_name, build_number, step_name, |
| 51 return MasterFlakeAnalysis._CreateKey( | 46 test_name, version=None): # pragma: no cover. |
| 52 master_name, builder_name, build_number, step_name, test_name).get() | 47 return super(MasterFlakeAnalysis, cls).GetVersion( |
| 48 key=MasterFlakeAnalysis._CreateAnalysisId( | |
| 49 master_name, builder_name, build_number, step_name, test_name), | |
| 50 version=version) | |
| 53 | 51 |
| 54 # List of tested build_numbers and their corresponding success rates. | 52 def Reset(self): |
| 55 # We need to keep these sorted manually. | 53 self.created_time = time_util.GetUTCNow() |
| 54 self.status = analysis_status.PENDING | |
| 55 self.completed_time = None | |
| 56 self.swarming_rerun_results = {} | |
| 57 self.error = None | |
| 58 self.correct = None | |
| 59 self.algorithm_parameters = None | |
| 60 self.suspected_flake_build_number = None | |
| 61 self.build_numbers = [] | |
| 62 self.pass_rates = [] | |
| 63 | |
| 64 # The UTC timestamp the check flake task was requested. | |
|
stgao
2016/09/28 00:03:24
Let's avoid "check flake task" or similar in code.
lijeffrey
2016/09/28 03:12:30
Done.
| |
| 65 created_time = ndb.DateTimeProperty(indexed=True) | |
| 66 | |
| 67 # The UTC timestamp the check flake task came completed. | |
| 68 completed_time = ndb.DateTimeProperty(indexed=True) | |
| 69 | |
| 70 # A dict containing information about each swarming rerun's results that can | |
| 71 # be used for metrics, such as number of cache hits, average run time, etc. | |
|
stgao
2016/09/28 00:03:24
Are the metrics for running Swraming tasks or for
lijeffrey
2016/09/28 03:12:30
It is for the whole analysis, but depends on each
| |
| 72 # Example dict: | |
| 73 # { | |
| 74 # task_id_1: { | |
| 75 # 'request_time': 2016-09-06 (10:21:26.288) UTC | |
|
stgao
2016/09/28 00:03:24
Why do we need these detailed info about the Swarm
lijeffrey
2016/09/28 03:12:30
This is for calculating time per iteration. Later
| |
| 76 # 'start_time': 2016-09-06 (10:21:26.288) UTC, | |
| 77 # 'end_time': 2016-09-06 (10:21:26.288) UTC, | |
| 78 # 'build_number': 12345, | |
| 79 # 'cache_hit': True/False, | |
| 80 # 'number_of_iterations': 100, | |
| 81 # 'number_of_passes': 90, | |
| 82 # }, | |
| 83 # task_id_2: { | |
| 84 # ... | |
| 85 # }, | |
| 86 # ... | |
| 87 # } | |
| 88 swarming_rerun_results = ndb.JsonProperty(default={}, indexed=False) | |
|
stgao
2016/09/28 00:03:24
This will grow big very quickly, thus it should be
lijeffrey
2016/09/28 03:12:30
Done.
| |
| 89 | |
| 90 # Error code and message, if any. | |
| 91 error = ndb.JsonProperty(indexed=False) | |
| 92 | |
| 93 # Boolean whether or not the suspected regression range/build is correct. | |
| 94 correct = ndb.BooleanProperty(indexed=False) | |
|
stgao
2016/09/28 00:03:24
correct_regression_range? Later we might need corr
stgao
2016/09/28 00:03:24
Let's index this field for easier query.
lijeffrey
2016/09/28 03:12:30
Done.
lijeffrey
2016/09/28 03:12:30
Good point. Added correct_culprit and renamed this
| |
| 95 | |
| 96 # The look back algorithm parameters that were used, as specified in Findit's | |
| 97 # configuration. For example, | |
| 98 # { | |
| 99 # 'iterations_to_rerun': 100, | |
| 100 # 'lower_flake_threshold': 0.02, | |
| 101 # 'max_build_numbers_to_look_back': 500, | |
| 102 # 'max_flake_in_a_row': 4, | |
| 103 # 'max_stable_in_a_row': 4, | |
| 104 # 'upper_flake_threshold': 0.98 | |
| 105 # } | |
| 106 algorithm_parameters = ndb.JsonProperty(indexed=False) | |
| 107 | |
| 108 # The suspected build number to have introduced the flakiness. | |
| 109 suspected_flake_build_number = ndb.IntegerProperty() | |
| 110 | |
| 111 # The build numbers that were examined to generate this run's flakiness graph. | |
| 112 # This list needs to be kept sorted manually. | |
| 56 build_numbers = ndb.IntegerProperty(indexed=False, repeated=True) | 113 build_numbers = ndb.IntegerProperty(indexed=False, repeated=True) |
| 57 success_rates = ndb.FloatProperty(indexed=False, repeated=True) | 114 |
| 58 suspected_flake_build_number = ndb.IntegerProperty() | 115 # The corresponding pass rates of build number's swarming rerun results. |
| 116 # This list needs to be kept sorted manually. | |
| 117 pass_rates = ndb.FloatProperty(indexed=False, repeated=True) | |
| OLD | NEW |