| 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 copy | 5 import copy |
| 6 import json | 6 import json |
| 7 import logging | 7 import logging |
| 8 | 8 |
| 9 from crash import monitoring | 9 from crash import monitoring |
| 10 | 10 |
| 11 from common import appengine_util | 11 from common import appengine_util |
| 12 from common import pubsub_util | 12 from common import pubsub_util |
| 13 from common.http_client_appengine import HttpClientAppengine | 13 from common.http_client_appengine import HttpClientAppengine |
| 14 from common.pipeline_wrapper import BasePipeline | 14 from common.pipeline_wrapper import BasePipeline |
| 15 from common.pipeline_wrapper import pipeline | 15 from common.pipeline_wrapper import pipeline |
| 16 from crash import findit_for_chromecrash | 16 from crash import findit_for_chromecrash |
| 17 from crash import findit_for_clusterfuzz | 17 from crash import findit_for_clusterfuzz |
| 18 from crash.type_enums import CrashClient | 18 from crash.type_enums import CrashClient |
| 19 from lib import time_util | 19 from lib import time_util |
| 20 from lib.gitiles import gitiles_repository | 20 from gae_libs.gitiles import cached_gitiles_repository |
| 21 from model import analysis_status | 21 from model import analysis_status |
| 22 | 22 |
| 23 | 23 |
| 24 # TODO(http://crbug.com/659346): write complete coverage tests for this. | 24 # TODO(http://crbug.com/659346): write complete coverage tests for this. |
| 25 def FinditForClientID(client_id, repository): # pragma: no cover | 25 def FinditForClientID(client_id, repository): # pragma: no cover |
| 26 """Construct a Findit object from a client id string specifying the class. | 26 """Construct a Findit object from a client id string specifying the class. |
| 27 | 27 |
| 28 We cannot pass Findit objects to the various methods in | 28 We cannot pass Findit objects to the various methods in |
| 29 ``crash.crash_pipeline``, because they are not JSON serializable. For | 29 ``crash.crash_pipeline``, because they are not JSON serializable. For |
| 30 now, we just serialize Findit objects as their ``client_id``, and then | 30 now, we just serialize Findit objects as their ``client_id``, and then |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 # processes, so we'll actually end up reconstructing the ``Findit`` object | 86 # processes, so we'll actually end up reconstructing the ``Findit`` object |
| 87 # twice. This also means ``run`` can't store anything in the pipeline | 87 # twice. This also means ``run`` can't store anything in the pipeline |
| 88 # object and expect it to still be available in the ``finalized`` method. | 88 # object and expect it to still be available in the ``finalized`` method. |
| 89 | 89 |
| 90 class CrashBasePipeline(BasePipeline): | 90 class CrashBasePipeline(BasePipeline): |
| 91 def __init__(self, client_id, crash_identifiers): | 91 def __init__(self, client_id, crash_identifiers): |
| 92 super(CrashBasePipeline, self).__init__(client_id, crash_identifiers) | 92 super(CrashBasePipeline, self).__init__(client_id, crash_identifiers) |
| 93 self._crash_identifiers = crash_identifiers | 93 self._crash_identifiers = crash_identifiers |
| 94 self._findit = FinditForClientID( | 94 self._findit = FinditForClientID( |
| 95 client_id, | 95 client_id, |
| 96 gitiles_repository.GitilesRepository(HttpClientAppengine())) | 96 cached_gitiles_repository.CachedGitilesRepository( |
| 97 HttpClientAppengine())) |
| 97 | 98 |
| 98 @property | 99 @property |
| 99 def client_id(self): # pragma: no cover | 100 def client_id(self): # pragma: no cover |
| 100 return self._findit.client_id | 101 return self._findit.client_id |
| 101 | 102 |
| 102 def run(self, *args, **kwargs): | 103 def run(self, *args, **kwargs): |
| 103 raise NotImplementedError() | 104 raise NotImplementedError() |
| 104 | 105 |
| 105 | 106 |
| 106 class CrashAnalysisPipeline(CrashBasePipeline): | 107 class CrashAnalysisPipeline(CrashBasePipeline): |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 N.B., due to the structure of AppEngine pipelines, this method must | 230 N.B., due to the structure of AppEngine pipelines, this method must |
| 230 accept the same arguments as are passed to ``__init__``; however, | 231 accept the same arguments as are passed to ``__init__``; however, |
| 231 because they were already passed to ``__init__`` there's no use in | 232 because they were already passed to ``__init__`` there's no use in |
| 232 recieving them here. Thus, we discard all the arguments to this method | 233 recieving them here. Thus, we discard all the arguments to this method |
| 233 (except for ``self``, naturally). | 234 (except for ``self``, naturally). |
| 234 """ | 235 """ |
| 235 run_analysis = yield CrashAnalysisPipeline( | 236 run_analysis = yield CrashAnalysisPipeline( |
| 236 self._client_id, self._crash_identifiers) | 237 self._client_id, self._crash_identifiers) |
| 237 with pipeline.After(run_analysis): | 238 with pipeline.After(run_analysis): |
| 238 yield PublishResultPipeline(self._client_id, self._crash_identifiers) | 239 yield PublishResultPipeline(self._client_id, self._crash_identifiers) |
| OLD | NEW |