| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from collections import defaultdict | 5 from collections import defaultdict |
| 6 | 6 |
| 7 from google.appengine.ext import ndb | 7 from google.appengine.ext import ndb |
| 8 | 8 |
| 9 from model.base_build_model import BaseBuildModel | 9 from model.base_build_model import BaseBuildModel |
| 10 from model import analysis_status | 10 from model import analysis_status |
| 11 | 11 |
| 12 | 12 |
| 13 class WfSwarmingTask(BaseBuildModel): | 13 class WfSwarmingTask(BaseBuildModel): |
| 14 """Represents a swarming task for a failed step. | 14 """Represents a swarming task for a failed step. |
| 15 | 15 |
| 16 'Wf' is short for waterfall. | 16 'Wf' is short for waterfall. |
| 17 """ | 17 """ |
| 18 # The id of the Swarming task scheduled or running on Swarming Server. | 18 # The id of the Swarming task scheduled or running on Swarming Server. |
| 19 task_id = ndb.StringProperty(indexed=False) | 19 task_id = ndb.StringProperty(indexed=False) |
| 20 | 20 |
| 21 # A dict to keep track of running information for each test: | 21 # A dict to keep track of running information for each test: |
| 22 # number of total runs, number of each status (such as 'SUCCESS' or 'FAILED') | 22 # number of total runs, number of each status (such as 'SUCCESS' or 'FAILED') |
| 23 tests_statuses = ndb.JsonProperty(default={}, indexed=False, compressed=True) | 23 tests_statuses = ndb.JsonProperty(indexed=False, compressed=True) |
| 24 | 24 |
| 25 # The status of the swarming task. | 25 # The status of the swarming task. |
| 26 status = ndb.IntegerProperty( | 26 status = ndb.IntegerProperty( |
| 27 default=analysis_status.PENDING, indexed=False) | 27 default=analysis_status.PENDING, indexed=False) |
| 28 | 28 |
| 29 # The revision of the failed build. | 29 # The revision of the failed build. |
| 30 build_revision = ndb.StringProperty(indexed=False) | 30 build_revision = ndb.StringProperty(indexed=False) |
| 31 | 31 |
| 32 # Time when the task is created. | 32 # Time when the task is created. |
| 33 created_time = ndb.DateTimeProperty(indexed=True) | 33 created_time = ndb.DateTimeProperty(indexed=True) |
| 34 # Time when the task is started. | 34 # Time when the task is started. |
| 35 started_time = ndb.DateTimeProperty(indexed=False) | 35 started_time = ndb.DateTimeProperty(indexed=False) |
| 36 # Time when the task is completed. | 36 # Time when the task is completed. |
| 37 completed_time = ndb.DateTimeProperty(indexed=False) | 37 completed_time = ndb.DateTimeProperty(indexed=False) |
| 38 | 38 |
| 39 # parameters need to be stored and analyzed later. | 39 # parameters need to be stored and analyzed later. |
| 40 parameters = ndb.JsonProperty(default={}, indexed=False, compressed=True) | 40 parameters = ndb.JsonProperty(indexed=False, compressed=True) |
| 41 | 41 |
| 42 @property | 42 @property |
| 43 def classified_tests(self): | 43 def classified_tests(self): |
| 44 """Classification of tests into lists of reliable and flaky tests. | 44 """Classification of tests into lists of reliable and flaky tests. |
| 45 | 45 |
| 46 example format would be: | 46 example format would be: |
| 47 { | 47 { |
| 48 'flaky_tests': ['test1', 'test2', ...], | 48 'flaky_tests': ['test1', 'test2', ...], |
| 49 'reliable_tests': ['test3', ...], | 49 'reliable_tests': ['test3', ...], |
| 50 'unknown_tests': ['test4', ...] | 50 'unknown_tests': ['test4', ...] |
| (...skipping 16 matching lines...) Expand all Loading... |
| 67 @staticmethod | 67 @staticmethod |
| 68 def _CreateKey( | 68 def _CreateKey( |
| 69 master_name, builder_name, build_number, step_name): # pragma: no cover | 69 master_name, builder_name, build_number, step_name): # pragma: no cover |
| 70 build_id = BaseBuildModel.CreateBuildId( | 70 build_id = BaseBuildModel.CreateBuildId( |
| 71 master_name, builder_name, build_number) | 71 master_name, builder_name, build_number) |
| 72 return ndb.Key('WfBuild', build_id, 'WfSwarmingTask', step_name) | 72 return ndb.Key('WfBuild', build_id, 'WfSwarmingTask', step_name) |
| 73 | 73 |
| 74 @staticmethod | 74 @staticmethod |
| 75 def Create( | 75 def Create( |
| 76 master_name, builder_name, build_number, step_name): # pragma: no cover | 76 master_name, builder_name, build_number, step_name): # pragma: no cover |
| 77 return WfSwarmingTask( | 77 task = WfSwarmingTask( |
| 78 key=WfSwarmingTask._CreateKey( | 78 key=WfSwarmingTask._CreateKey( |
| 79 master_name, builder_name, build_number, step_name)) | 79 master_name, builder_name, build_number, step_name)) |
| 80 task.parameters = task.parameters or {} |
| 81 task.tests_statuses = task.tests_statuses or {} |
| 82 return task |
| 80 | 83 |
| 81 @staticmethod | 84 @staticmethod |
| 82 def Get( | 85 def Get( |
| 83 master_name, builder_name, build_number, step_name): # pragma: no cover | 86 master_name, builder_name, build_number, step_name): # pragma: no cover |
| 84 return WfSwarmingTask._CreateKey( | 87 return WfSwarmingTask._CreateKey( |
| 85 master_name, builder_name, build_number, step_name).get() | 88 master_name, builder_name, build_number, step_name).get() |
| OLD | NEW |