Chromium Code Reviews| 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 import collections | 5 import collections |
| 6 import logging | 6 import logging |
| 7 import numbers | 7 import numbers |
| 8 import os | 8 import os |
| 9 | 9 |
| 10 from google.appengine.api import taskqueue | 10 from google.appengine.api import taskqueue |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 # The name of the Task Queue task this job is running on. If it's present, the | 53 # The name of the Task Queue task this job is running on. If it's present, the |
| 54 # job is running. The task is also None for Task Queue retries. | 54 # job is running. The task is also None for Task Queue retries. |
| 55 task = ndb.StringProperty() | 55 task = ndb.StringProperty() |
| 56 | 56 |
| 57 # The string contents of any Exception that was thrown to the top level. | 57 # The string contents of any Exception that was thrown to the top level. |
| 58 # If it's present, the job failed. | 58 # If it's present, the job failed. |
| 59 exception = ndb.StringProperty() | 59 exception = ndb.StringProperty() |
| 60 | 60 |
| 61 # Request parameters. | 61 # Request parameters. |
| 62 configuration = ndb.StringProperty(required=True) | 62 configuration = ndb.StringProperty(required=True) |
| 63 test_suite = ndb.StringProperty() | 63 target = ndb.StringProperty() |
| 64 test = ndb.StringProperty() | 64 test_config = ndb.PickleProperty() |
|
perezju
2017/08/07 12:06:12
nit: wondering whether this should be called targe
dtu
2017/08/15 17:06:41
`target` has to be "config" object because it need
perezju
2017/08/16 08:15:25
Nice! This turned out pretty neat!
| |
| 65 metric = ndb.StringProperty() | 65 metric = ndb.StringProperty() |
| 66 | 66 |
| 67 # If True, the service should pick additional Changes to run (bisect). | 67 # If True, the service should pick additional Changes to run (bisect). |
| 68 # If False, only run the Changes explicitly added by the user. | 68 # If False, only run the Changes explicitly added by the user. |
| 69 auto_explore = ndb.BooleanProperty(required=True) | 69 auto_explore = ndb.BooleanProperty(required=True) |
| 70 | 70 |
| 71 # TODO: The bug id is only used for posting bug comments when a job starts and | 71 # TODO: The bug id is only used for posting bug comments when a job starts and |
| 72 # completes. This probably should not be the responsibility of Pinpoint. | 72 # completes. This probably should not be the responsibility of Pinpoint. |
| 73 bug_id = ndb.IntegerProperty() | 73 bug_id = ndb.IntegerProperty() |
| 74 | 74 |
| 75 state = ndb.PickleProperty(required=True) | 75 state = ndb.PickleProperty(required=True) |
| 76 | 76 |
| 77 @classmethod | 77 @classmethod |
| 78 def New(cls, configuration, test_suite, test, metric, auto_explore, bug_id): | 78 def New(cls, configuration, target, test_config, auto_explore, bug_id): |
| 79 # Get list of quests. | 79 # Get list of quests. |
| 80 quests = [quest_module.FindIsolate(configuration)] | 80 quests = [quest_module.FindIsolate(configuration)] |
| 81 if test_suite: | 81 quests += test_config.Quests() |
| 82 quests.append(quest_module.RunTest(configuration, test_suite, test, | |
| 83 _DEFAULT_REPEAT_COUNT)) | |
| 84 if metric: | |
| 85 quests.append(quest_module.ReadValue(metric, test)) | |
| 86 | 82 |
| 87 # Create job. | 83 # Create job. |
| 88 return cls( | 84 return cls( |
| 89 configuration=configuration, | 85 configuration=configuration, |
| 90 test_suite=test_suite, | 86 target=target, |
| 91 test=test, | 87 test_config=test_config, |
| 92 metric=metric, | |
| 93 auto_explore=auto_explore, | 88 auto_explore=auto_explore, |
| 94 bug_id=bug_id, | 89 bug_id=bug_id, |
| 95 state=_JobState(quests, _DEFAULT_ATTEMPT_COUNT)) | 90 state=_JobState(quests, _DEFAULT_ATTEMPT_COUNT)) |
| 96 | 91 |
| 97 @property | 92 @property |
| 98 def job_id(self): | 93 def job_id(self): |
| 99 return self.key.urlsafe() | 94 return self.key.urlsafe() |
| 100 | 95 |
| 101 @property | 96 @property |
| 102 def status(self): | 97 def status(self): |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 self.Complete() | 145 self.Complete() |
| 151 except BaseException as e: | 146 except BaseException as e: |
| 152 self.exception = str(e) | 147 self.exception = str(e) |
| 153 raise | 148 raise |
| 154 | 149 |
| 155 def AsDict(self): | 150 def AsDict(self): |
| 156 return { | 151 return { |
| 157 'job_id': self.job_id, | 152 'job_id': self.job_id, |
| 158 | 153 |
| 159 'configuration': self.configuration, | 154 'configuration': self.configuration, |
| 160 'test_suite': self.test_suite, | 155 'target': self.target, |
| 161 'test': self.test, | 156 'test_config': self.test_config.AsDict(), |
| 162 'metric': self.metric, | |
| 163 'auto_explore': self.auto_explore, | 157 'auto_explore': self.auto_explore, |
| 164 | 158 |
| 165 'created': self.created.strftime('%Y-%m-%d %H:%M:%S %Z'), | 159 'created': self.created.strftime('%Y-%m-%d %H:%M:%S %Z'), |
| 166 'updated': self.updated.strftime('%Y-%m-%d %H:%M:%S %Z'), | 160 'updated': self.updated.strftime('%Y-%m-%d %H:%M:%S %Z'), |
| 167 'status': self.status, | 161 'status': self.status, |
| 168 | 162 |
| 169 'state': self.state.AsDict(), | 163 'state': self.state.AsDict(), |
| 170 } | 164 } |
| 171 | 165 |
| 172 | 166 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 # We want the results_values to provide both a message that can be shown to | 340 # We want the results_values to provide both a message that can be shown to |
| 347 # the user for why something failed, and also something comparable that can | 341 # the user for why something failed, and also something comparable that can |
| 348 # be used for bisect. Therefore, they contain the thrown Exceptions. This | 342 # be used for bisect. Therefore, they contain the thrown Exceptions. This |
| 349 # function then converts them into comparable numbers for bisect. | 343 # function then converts them into comparable numbers for bisect. |
| 350 if isinstance(obj, numbers.Number): | 344 if isinstance(obj, numbers.Number): |
| 351 return obj | 345 return obj |
| 352 elif isinstance(obj, Exception): | 346 elif isinstance(obj, Exception): |
| 353 return hash(obj.__class__) | 347 return hash(obj.__class__) |
| 354 else: | 348 else: |
| 355 return hash(obj) | 349 return hash(obj) |
| OLD | NEW |