| 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 common import constants |
| 8 from model import analysis_status |
| 9 from model.base_build_model import BaseBuildModel |
| 10 from model.base_analysis import BaseAnalysis |
| 11 from model.flake.flake_swarming_task import FlakeSwarmingTask |
| 12 |
| 13 class MasterFlakeAnalysis(BaseAnalysis, BaseBuildModel): |
| 14 """Represents an analysis of a candidate flaky test in a Chromium Waterfall. |
| 15 |
| 16 """ |
| 17 @staticmethod |
| 18 def CreateAnalysisId(master_name, builder_name, |
| 19 build_number, step_name, test_name): |
| 20 return '%s/%s/%s/%s/%s' % (master_name, builder_name, |
| 21 build_number, step_name, test_name) |
| 22 |
| 23 @ndb.ComputedProperty |
| 24 def step_name(self): |
| 25 return self.key.pairs()[0][1].split('/')[3] |
| 26 |
| 27 @ndb.ComputedProperty |
| 28 def test_name(self): |
| 29 return self.key.pairs()[0][1].split('/')[4] |
| 30 |
| 31 @staticmethod |
| 32 def _CreateKey(master_name, builder_name, build_number, |
| 33 step_name, test_name): # pragma: no cover |
| 34 return ndb.Key('MasterFlakeAnalysis', |
| 35 MasterFlakeAnalysis.CreateAnalysisId( |
| 36 master_name, builder_name, build_number, |
| 37 step_name, test_name)) |
| 38 |
| 39 @staticmethod |
| 40 def Create(master_name, builder_name, build_number, |
| 41 step_name, test_name): # pragma: no cover |
| 42 return MasterFlakeAnalysis( |
| 43 key=MasterFlakeAnalysis._CreateKey( |
| 44 master_name, builder_name, build_number, |
| 45 step_name, test_name)) |
| 46 |
| 47 @staticmethod |
| 48 def Get(master_name, builder_name, build_number, |
| 49 step_name, test_name): # pragma: no cover |
| 50 return MasterFlakeAnalysis._CreateKey( |
| 51 master_name, builder_name, build_number, step_name, test_name).get() |
| 52 |
| 53 @staticmethod |
| 54 def generate_data(flake_swarming_tasks): |
| 55 data = [] |
| 56 # Generates data in the format which the template can read |
| 57 # Go through list of flake_swarming_tasks |
| 58 for fst in flake_swarming_tasks: |
| 59 # Append results to a list (this is a placeholder) |
| 60 data.append((fst.successes, fst.tries, |
| 61 fst.master_name(), fst.builder_name(), |
| 62 fst.step_name(), fst.build_number(), |
| 63 fst.test_name())) |
| 64 |
| 65 # List of tested build_numbers and their corresponding success rates. |
| 66 # We need to keep these sorted manually. |
| 67 build_numbers = ndb.IntegerProperty(indexed=True, repeated=True) |
| 68 success_rates = ndb.FloatProperty(indexed=False, repeated=True) |
| 69 flake_swarming_tasks = ndb.KeyProperty( |
| 70 kind='FlakeSwarmingTask', repeated=True) |
| OLD | NEW |