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 common import constants | |
| 8 from model import analysis_status | |
| 9 from model.progress import Progress | |
| 10 from model.base_build_model import BaseBuildModel | |
| 11 | |
| 12 class FlakeSwarmingTask(Progress, BaseBuildModel): | |
| 13 """Represents a swarming task for a step w/candidate flaky tests. | |
| 14 """ | |
| 15 | |
| 16 @staticmethod | |
| 17 def CreateSwarmingTaskId( | |
| 18 master_name, builder_name, build_number, | |
| 19 step_name, test_name): # pragma: no cover | |
| 20 return '%s/%s/%s/%s/%s' % (master_name, builder_name, | |
| 21 build_number, step_name, test_name) | |
| 22 | |
| 23 @staticmethod | |
| 24 def _CreateKey( | |
| 25 master_name, builder_name, build_number, | |
| 26 step_name, test_name): # pragma: no cover | |
| 27 return ndb.Key('FlakeSwarmingTask', | |
| 28 FlakeSwarmingTask.CreateSwarmingTaskId( | |
| 29 master_name, builder_name, build_number, | |
| 30 step_name, test_name)) | |
| 31 | |
| 32 @staticmethod | |
| 33 def Create( | |
| 34 master_name, builder_name, build_number, | |
| 35 step_name, test_name): # pragma: no cover | |
| 36 return FlakeSwarmingTask(key=FlakeSwarmingTask._CreateKey( | |
| 37 master_name, builder_name, build_number, step_name, test_name)) | |
| 38 | |
| 39 @ndb.ComputedProperty | |
| 40 def step_name(self): | |
| 41 return self.key.pairs()[0][1].split('/')[3] | |
| 42 | |
| 43 @ndb.ComputedProperty | |
| 44 def test_name(self): | |
| 45 return self.key.pairs()[0][1].split('/')[4] | |
| 46 | |
| 47 | |
| 48 @staticmethod | |
| 49 def Get( | |
| 50 master_name, builder_name, build_number, | |
| 51 step_name, test_name): # pragma: no cover | |
| 52 return FlakeSwarmingTask._CreateKey( | |
| 53 master_name, builder_name, build_number, step_name, test_name).get( | |
| 54 ) | |
| 55 # In how many runs did the test succeed? | |
| 56 successes = ndb.IntegerProperty(default=0, indexed=False) | |
| 57 # How many times did we rerun the test? | |
| 58 tries = ndb.IntegerProperty(default=0, indexed=False) | |
| 59 # Identifier for code build. | |
| 60 git_hash = ndb.StringProperty(indexed=False) | |
|
stgao
2016/07/14 18:01:33
In other code, we use revision instead.
| |
| 61 # Another identifier for code build. | |
| 62 commit_position = ndb.IntegerProperty(indexed=False) | |
| OLD | NEW |