| 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 json | 5 import json |
| 6 import os | 6 import os |
| 7 | 7 |
| 8 from common import constants | 8 from common import constants |
| 9 from common.pipeline_wrapper import pipeline_handlers | 9 from common.pipeline_wrapper import pipeline_handlers |
| 10 from crash import fracas_crash_pipeline | 10 from crash import fracas_crash_pipeline |
| 11 from crash.test.crash_testcase import CrashTestCase | 11 from crash.test.crash_testcase import CrashTestCase |
| 12 from model import analysis_status | 12 from model import analysis_status |
| 13 from model import result_status | 13 from model import result_status |
| 14 from model.crash.fracas_crash_analysis import FracasCrashAnalysis | 14 from model.crash.fracas_crash_analysis import FracasCrashAnalysis |
| 15 from waterfall.test import wf_testcase | |
| 16 | 15 |
| 17 | 16 |
| 18 class FracasCrashPipelineTest(CrashTestCase): | 17 class FracasCrashPipelineTest(CrashTestCase): |
| 19 app_module = pipeline_handlers._APP | 18 app_module = pipeline_handlers._APP |
| 20 | 19 |
| 21 def testNoAnalysisIfLastOneIsNotFailed(self): | 20 def testNoAnalysisIfLastOneIsNotFailed(self): |
| 22 chrome_version = '1' | 21 chrome_version = '1' |
| 23 signature = 'signature' | 22 signature = 'signature' |
| 24 platform = 'win' | 23 platform = 'win' |
| 25 crash_identifiers = { | 24 crash_identifiers = { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 self.assertTrue( | 142 self.assertTrue( |
| 144 fracas_crash_pipeline.ScheduleNewAnalysisForCrash( | 143 fracas_crash_pipeline.ScheduleNewAnalysisForCrash( |
| 145 crash_identifiers, chrome_version, signature, 'fracas', | 144 crash_identifiers, chrome_version, signature, 'fracas', |
| 146 platform, stack_trace, channel, historic_metadata)) | 145 platform, stack_trace, channel, historic_metadata)) |
| 147 | 146 |
| 148 self.execute_queued_tasks() | 147 self.execute_queued_tasks() |
| 149 | 148 |
| 150 self.assertEqual(1, len(pubsub_publish_requests)) | 149 self.assertEqual(1, len(pubsub_publish_requests)) |
| 151 expected_messages_data = [json.dumps({ | 150 expected_messages_data = [json.dumps({ |
| 152 'crash_identifiers': crash_identifiers, | 151 'crash_identifiers': crash_identifiers, |
| 152 'client_id': 'fracas', |
| 153 'result': analysis_result, | 153 'result': analysis_result, |
| 154 }, sort_keys=True)] | 154 }, sort_keys=True)] |
| 155 self.assertEqual(expected_messages_data, pubsub_publish_requests[0][0]) | 155 self.assertEqual(expected_messages_data, pubsub_publish_requests[0][0]) |
| 156 | 156 |
| 157 self.assertEqual(1, len(analyzed_crashes)) | 157 self.assertEqual(1, len(analyzed_crashes)) |
| 158 self.assertEqual( | 158 self.assertEqual( |
| 159 (channel, platform, signature, stack_trace, | 159 (signature, platform, stack_trace, chrome_version, historic_metadata), |
| 160 chrome_version, historic_metadata), | |
| 161 analyzed_crashes[0]) | 160 analyzed_crashes[0]) |
| 162 | 161 |
| 163 analysis = FracasCrashAnalysis.Get(crash_identifiers) | 162 analysis = FracasCrashAnalysis.Get(crash_identifiers) |
| 164 self.assertEqual(analysis_result, analysis.result) | 163 self.assertEqual(analysis_result, analysis.result) |
| 165 self.assertTrue(analysis.has_regression_range) | 164 self.assertTrue(analysis.has_regression_range) |
| 166 self.assertTrue(analysis.found_suspects) | 165 self.assertTrue(analysis.found_suspects) |
| 167 self.assertEqual('core', analysis.solution) | 166 self.assertEqual('core', analysis.solution) |
| 168 | 167 |
| 169 def testAnalysisAborted(self): | 168 def testAnalysisAborted(self): |
| 170 chrome_version = '1' | 169 chrome_version = '1' |
| 171 signature = 'signature' | 170 signature = 'signature' |
| 172 platform = 'win' | 171 platform = 'win' |
| 173 crash_identifiers = { | 172 crash_identifiers = { |
| 174 'chrome_version': chrome_version, | 173 'chrome_version': chrome_version, |
| 175 'signature': signature, | 174 'signature': signature, |
| 176 'channel': 'canary', | 175 'channel': 'canary', |
| 177 'platform': platform, | 176 'platform': platform, |
| 178 'process_type': 'browser', | 177 'process_type': 'browser', |
| 179 } | 178 } |
| 180 analysis = FracasCrashAnalysis.Create(crash_identifiers) | 179 analysis = FracasCrashAnalysis.Create(crash_identifiers) |
| 181 analysis.status = analysis_status.RUNNING | 180 analysis.status = analysis_status.RUNNING |
| 182 analysis.put() | 181 analysis.put() |
| 183 | 182 |
| 184 pipeline = fracas_crash_pipeline.FracasAnalysisPipeline(crash_identifiers) | 183 pipeline = fracas_crash_pipeline.FracasAnalysisPipeline(crash_identifiers) |
| 185 pipeline._SetErrorIfAborted(True) | 184 pipeline._SetErrorIfAborted(True) |
| 186 analysis = FracasCrashAnalysis.Get(crash_identifiers) | 185 analysis = FracasCrashAnalysis.Get(crash_identifiers) |
| 187 self.assertEqual(analysis_status.ERROR, analysis.status) | 186 self.assertEqual(analysis_status.ERROR, analysis.status) |
| OLD | NEW |