| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 google.appengine.ext import ndb | 5 from google.appengine.ext import ndb |
| 6 | 6 |
| 7 from model.base_build_model import BaseBuildModel | 7 from model.base_build_model import BaseBuildModel |
| 8 from model import analysis_status | 8 from model.base_try_job import BaseTryJob |
| 9 | 9 |
| 10 | 10 |
| 11 class WfTryJob(BaseBuildModel): | 11 class WfTryJob(BaseTryJob, BaseBuildModel): |
| 12 """Represents a try job results for a failed build. | 12 """Represents a try job results for a failed build. |
| 13 | 13 |
| 14 'Wf' is short for waterfall. | 14 'Wf' is short for waterfall. |
| 15 """ | 15 """ |
| 16 # A list of dict containing results and urls of each try job for compile. | 16 # A list of dict containing results and urls of each try job for compile. |
| 17 # For example: |
| 18 # [ |
| 19 # { |
| 20 # 'report': (dict) The 'result' dict of the compile try job, |
| 21 # 'url': (str) The url to the try job, |
| 22 # 'try_job_id': (str) The try job id, |
| 23 # 'culprit': (dict) The culprit info, if identified. |
| 24 # }, |
| 25 # ... |
| 26 # ] |
| 27 |
| 17 compile_results = ndb.JsonProperty(indexed=False, compressed=True) | 28 compile_results = ndb.JsonProperty(indexed=False, compressed=True) |
| 18 | 29 |
| 19 # A list of dict containing results and urls of each try job for test. | 30 # A list of dict containing results and urls of each try job for test. |
| 31 # For example: |
| 32 # [ |
| 33 # { |
| 34 # 'report': (dict) The 'result' dict of the test try job, |
| 35 # 'url': (str) The url to the try job, |
| 36 # 'try_job_id': (str) The try job id, |
| 37 # 'culprit': (dict) The culprit info, if identified. |
| 38 # }, |
| 39 # ... |
| 40 # ] |
| 20 test_results = ndb.JsonProperty(indexed=False, compressed=True) | 41 test_results = ndb.JsonProperty(indexed=False, compressed=True) |
| 21 | 42 |
| 22 # The status of the try job. | 43 # TODO(http://crbug.com/676511): Merge compile_results, test_results, and |
| 23 status = ndb.IntegerProperty( | 44 # flake_results from FlakeTryJob.py into 1 structure in BaseTryJob. |
| 24 default=analysis_status.PENDING, indexed=False) | |
| 25 | 45 |
| 26 # A list of try job IDs associated with each try job for collecting metadata. | 46 # Arguments number differs from overridden method - pylint: disable=W0221 |
| 27 try_job_ids = ndb.JsonProperty(indexed=False, compressed=True) | |
| 28 | |
| 29 @staticmethod | 47 @staticmethod |
| 30 def _CreateKey(master_name, builder_name, build_number): # pragma: no cover | 48 def _CreateKey(master_name, builder_name, build_number): |
| 31 return ndb.Key('WfTryJob', | 49 return ndb.Key('WfTryJob', |
| 32 BaseBuildModel.CreateBuildId( | 50 BaseBuildModel.CreateBuildId( |
| 33 master_name, builder_name, build_number)) | 51 master_name, builder_name, build_number)) |
| 34 | 52 |
| 35 @staticmethod | 53 @staticmethod |
| 36 def Create(master_name, builder_name, build_number): # pragma: no cover | 54 def Create(master_name, builder_name, build_number): |
| 37 try_job = WfTryJob( | 55 try_job = WfTryJob( |
| 38 key=WfTryJob._CreateKey(master_name, builder_name, build_number)) | 56 key=WfTryJob._CreateKey(master_name, builder_name, build_number)) |
| 39 try_job.compile_results = try_job.compile_results or [] | 57 try_job.compile_results = try_job.compile_results or [] |
| 40 try_job.test_results = try_job.test_results or [] | 58 try_job.test_results = try_job.test_results or [] |
| 41 try_job.try_job_ids = try_job.try_job_ids or [] | 59 try_job.try_job_ids = try_job.try_job_ids or [] |
| 42 return try_job | 60 return try_job |
| 43 | 61 |
| 44 @staticmethod | 62 @staticmethod |
| 45 def Get(master_name, builder_name, build_number): # pragma: no cover | 63 def Get(master_name, builder_name, build_number): |
| 46 return WfTryJob._CreateKey( | 64 return WfTryJob._CreateKey( |
| 47 master_name, builder_name, build_number).get() | 65 master_name, builder_name, build_number).get() |
| 48 | |
| 49 @property | |
| 50 def completed(self): | |
| 51 return self.status in ( | |
| 52 analysis_status.COMPLETED, analysis_status.ERROR) | |
| 53 | |
| 54 @property | |
| 55 def failed(self): | |
| 56 return self.status == analysis_status.ERROR | |
| OLD | NEW |