| 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 import analysis_status |
| 8 from model.base_build_model import BaseBuildModel |
| 9 from model.base_analysis import BaseAnalysis |
| 10 from model.flake.flake_swarming_task import FlakeSwarmingTask |
| 11 |
| 12 class MasterFlakeAnalysis(BaseAnalysis, BaseBuildModel): |
| 13 """Represents an analysis of a flaky test in a Chromium Waterfall.""" |
| 14 @staticmethod |
| 15 def CreateAnalysisId(master_name, builder_name, |
| 16 build_number, step_name, test_name): |
| 17 return '%s/%s/%s/%s/%s' % (master_name, builder_name, |
| 18 build_number, step_name, test_name) |
| 19 |
| 20 @ndb.ComputedProperty |
| 21 def step_name(self): |
| 22 return self.key.pairs()[0][1].split('/')[3] |
| 23 |
| 24 @ndb.ComputedProperty |
| 25 def test_name(self): |
| 26 return self.key.pairs()[0][1].split('/')[4] |
| 27 |
| 28 @staticmethod |
| 29 def _CreateKey(master_name, builder_name, build_number, |
| 30 step_name, test_name): # pragma: no cover |
| 31 return ndb.Key('MasterFlakeAnalysis', |
| 32 MasterFlakeAnalysis.CreateAnalysisId( |
| 33 master_name, builder_name, build_number, |
| 34 step_name, test_name)) |
| 35 |
| 36 @staticmethod |
| 37 def Create(master_name, builder_name, build_number, |
| 38 step_name, test_name): # pragma: no cover |
| 39 return MasterFlakeAnalysis( |
| 40 key=MasterFlakeAnalysis._CreateKey( |
| 41 master_name, builder_name, build_number, |
| 42 step_name, test_name)) |
| 43 |
| 44 @staticmethod |
| 45 def Get(master_name, builder_name, build_number, |
| 46 step_name, test_name): # pragma: no cover |
| 47 return MasterFlakeAnalysis._CreateKey( |
| 48 master_name, builder_name, build_number, step_name, test_name).get() |
| 49 |
| 50 # List of tested build_numbers and their corresponding success rates. |
| 51 # We need to keep these sorted manually. |
| 52 build_numbers = ndb.IntegerProperty(indexed=True, repeated=True) |
| 53 success_rates = ndb.FloatProperty(indexed=False, repeated=True) |
| 54 flake_swarming_tasks = ndb.KeyProperty( |
| 55 kind='FlakeSwarmingTask', repeated=True) |
| OLD | NEW |