| 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 import base64 | 5 import base64 |
| 6 | 6 |
| 7 from google.appengine.ext import ndb | 7 from google.appengine.ext import ndb |
| 8 | 8 |
| 9 from model.base_try_job import BaseTryJob | 9 from model.base_try_job import BaseTryJob |
| 10 | 10 |
| 11 | 11 |
| 12 class FlakeTryJob(BaseTryJob): | 12 class FlakeTryJob(BaseTryJob): |
| 13 """Represents a try job results for a check flake try job.""" | 13 """Represents a try job results for a check flake try job.""" |
| 14 # A list of dict containing results and urls of each flake try job. | 14 # A list of dict containing results and urls of each flake try job. |
| 15 # For example: | 15 # For example: |
| 16 # [ | 16 # [ |
| 17 # { | 17 # { |
| 18 # 'report': (dict) The 'result' dict of the try job, | 18 # 'report': (dict) The 'result' dict of the try job, |
| 19 # 'url': (str) The url to the try job, | 19 # 'url': (str) The url to the try job, |
| 20 # 'try_job_id': (str) The try job id. | 20 # 'try_job_id': (str) The try job id. |
| 21 # }, | 21 # }, |
| 22 # ... | 22 # ... |
| 23 # ] | 23 # ] |
| 24 flake_results = ndb.JsonProperty(indexed=False, compressed=True) | 24 flake_results = ndb.JsonProperty(indexed=False, compressed=True) |
| 25 | 25 |
| 26 @classmethod |
| 27 def GetStepName(cls, key): |
| 28 return key.pairs()[0][1].split('/')[2] |
| 29 |
| 30 @classmethod |
| 31 def GetTestName(cls, key): |
| 32 return base64.b64decode(key.pairs()[0][1].split('/')[3]) |
| 33 |
| 34 @classmethod |
| 35 def GetGitHash(cls, key): |
| 36 return key.pairs()[0][1].split('/')[4] |
| 37 |
| 38 @ndb.ComputedProperty |
| 39 def step_name(self): |
| 40 return self.GetStepName(self.key) |
| 41 |
| 42 @ndb.ComputedProperty |
| 43 def test_name(self): |
| 44 return self.GetTestName(self.key) |
| 45 |
| 46 @ndb.ComputedProperty |
| 47 def git_hash(self): |
| 48 return self.GetGitHash(self.key) |
| 49 |
| 26 @staticmethod | 50 @staticmethod |
| 27 def _CreateTryJobId(master_name, builder_name, step_name, test_name, | 51 def _CreateTryJobId(master_name, builder_name, step_name, test_name, |
| 28 git_hash): # pragma: no cover | 52 git_hash): # pragma: no cover |
| 29 """Creates an ID to associate with this try job. | 53 """Creates an ID to associate with this try job. |
| 30 | 54 |
| 31 Args: | 55 Args: |
| 32 master_name (str): The name of the master the flake was detected on. | 56 master_name (str): The name of the master the flake was detected on. |
| 33 builder_name (str): the name of the builder the flake was detected on. | 57 builder_name (str): the name of the builder the flake was detected on. |
| 34 step_name (str): The name of the step the flake was detected on. | 58 step_name (str): The name of the step the flake was detected on. |
| 35 test_name (str): The original name of the test that flaked. This will be | 59 test_name (str): The original name of the test that flaked. This will be |
| (...skipping 21 matching lines...) Expand all Loading... |
| 57 key=FlakeTryJob._CreateKey(master_name, builder_name, step_name, | 81 key=FlakeTryJob._CreateKey(master_name, builder_name, step_name, |
| 58 test_name, git_hash)) | 82 test_name, git_hash)) |
| 59 flake_try_job.flake_results = flake_try_job.flake_results or [] | 83 flake_try_job.flake_results = flake_try_job.flake_results or [] |
| 60 flake_try_job.try_job_ids = flake_try_job.try_job_ids or [] | 84 flake_try_job.try_job_ids = flake_try_job.try_job_ids or [] |
| 61 return flake_try_job | 85 return flake_try_job |
| 62 | 86 |
| 63 @staticmethod | 87 @staticmethod |
| 64 def Get(master_name, builder_name, step_name, test_name, git_hash): | 88 def Get(master_name, builder_name, step_name, test_name, git_hash): |
| 65 return FlakeTryJob._CreateKey( | 89 return FlakeTryJob._CreateKey( |
| 66 master_name, builder_name, step_name, test_name, git_hash).get() | 90 master_name, builder_name, step_name, test_name, git_hash).get() |
| OLD | NEW |