| 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 import base64 | |
| 6 | |
| 7 from google.appengine.ext import ndb | |
| 8 | |
| 9 from model.base_build_model import BaseBuildModel | |
| 10 | |
| 11 | |
| 12 class CheckFlakeAnalysisData(BaseBuildModel): | |
| 13 """Represents a check flake task's metadata for a complete run.""" | |
| 14 # The UTC timestamp the check flake task was requested. | |
| 15 created_time = ndb.DateTimeProperty(indexed=True) | |
| 16 | |
| 17 # The UTC timestamp the check flake task came completed. | |
| 18 completed_time = ndb.DateTimeProperty(indexed=True) | |
| 19 | |
| 20 # A dict containing information about each swarming rerun's results that can | |
| 21 # be used for metrics, such as number of cache hits, average run time, etc. | |
| 22 # Example dict: | |
| 23 # { | |
| 24 # task_id_1: { | |
| 25 # 'request_time': 2016-09-06 (10:21:26.288) UTC | |
| 26 # 'start_time': 2016-09-06 (10:21:26.288) UTC, | |
| 27 # 'end_time': 2016-09-06 (10:21:26.288) UTC, | |
| 28 # 'build_number': 12345, | |
| 29 # 'cache_hit': True/False, | |
| 30 # 'number_of_iterations': 100, | |
| 31 # 'number_of_passes': 90, | |
| 32 # }, | |
| 33 # task_id_2: { | |
| 34 # ... | |
| 35 # }, | |
| 36 # ... | |
| 37 # } | |
| 38 swarming_rerun_results = ndb.JsonProperty(indexed=False) | |
| 39 | |
| 40 # Error code and message, if any. | |
| 41 error = ndb.JsonProperty(indexed=False) | |
| 42 | |
| 43 # Integer representing the suspected build number that regressed. | |
| 44 regression_build_number = ndb.IntegerProperty(indexed=False) | |
| 45 | |
| 46 # Boolean whether or not the suspected regression range/build is correct. | |
| 47 correct = ndb.BooleanProperty(indexed=False) | |
| 48 | |
| 49 # The look back algorithm parameters that were used, as specified in Findit's | |
| 50 # configuration. For example, | |
| 51 # { | |
| 52 # 'iterations_to_rerun': 100, | |
| 53 # 'lower_flake_threshold': 0.02, | |
| 54 # 'max_build_numbers_to_look_back': 500, | |
| 55 # 'max_flake_in_a_row': 4, | |
| 56 # 'max_stable_in_a_row': 4, | |
| 57 # 'upper_flake_threshold': 0.98 | |
| 58 # } | |
| 59 algorithm_parameters = ndb.JsonProperty(indexed=False) | |
| 60 | |
| 61 @staticmethod | |
| 62 def _CreateKey(master_name, builder_name, build_number, step_name, test_name, | |
| 63 version): | |
| 64 encoded_test_name = base64.urlsafe_b64encode(test_name) | |
| 65 key = '%s/%s/%s/%s/%s/%s' % (master_name, builder_name, build_number, | |
| 66 step_name, encoded_test_name, version) | |
| 67 return ndb.Key('CheckFlakeAnalysisData', key) | |
| 68 | |
| 69 @staticmethod | |
| 70 def Create(master_name, builder_name, build_number, step_name, test_name, | |
| 71 version): | |
| 72 return CheckFlakeAnalysisData(key=CheckFlakeAnalysisData._CreateKey( | |
| 73 master_name, builder_name, build_number, step_name, test_name, version)) | |
| 74 | |
| 75 @staticmethod | |
| 76 def Get(master_name, builder_name, build_number, step_name, test_name, | |
| 77 version): | |
| 78 return CheckFlakeAnalysisData._CreateKey( | |
| 79 master_name, builder_name, build_number, step_name, test_name, | |
| 80 version).get() | |
| 81 | |
| 82 @ndb.ComputedProperty | |
| 83 def step_name(self): | |
| 84 return self.key.pairs()[0][1].split('/')[3] | |
| 85 | |
| 86 @ndb.ComputedProperty | |
| 87 def test_name(self): | |
| 88 return base64.urlsafe_b64decode(self.key.pairs()[0][1].split('/')[4]) | |
| 89 | |
| 90 @ndb.ComputedProperty | |
| 91 def version(self): | |
| 92 return self.key.pairs()[0][1].split('/')[5] | |
| OLD | NEW |