| 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_swarming_task import BaseSwarmingTask |
| 10 from model.base_build_model import BaseBuildModel |
| 11 |
| 12 class FlakeSwarmingTask(BaseSwarmingTask, 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 # Number of runs the test passed. |
| 56 successes = ndb.IntegerProperty(default=0, indexed=False) |
| 57 # How many times the test was rerun. |
| 58 tries = ndb.IntegerProperty(default=0, indexed=False) |
| OLD | NEW |