| 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 | 7 |
| 8 from google.appengine.api import app_identity | 8 from google.appengine.api import app_identity |
| 9 | 9 |
| 10 from crash import detect_regression_range |
| 10 from crash import findit_for_client | 11 from crash import findit_for_client |
| 11 from crash import findit_for_chromecrash | 12 from crash import findit_for_chromecrash |
| 13 from crash.chromecrash_parser import ChromeCrashParser |
| 12 from crash.test.crash_testcase import CrashTestCase | 14 from crash.test.crash_testcase import CrashTestCase |
| 13 from crash.type_enums import CrashClient | 15 from crash.type_enums import CrashClient |
| 14 from model.crash.fracas_crash_analysis import FracasCrashAnalysis | 16 from model.crash.fracas_crash_analysis import FracasCrashAnalysis |
| 15 | 17 |
| 16 | 18 |
| 17 class FinditForClientTest(CrashTestCase): | 19 class FinditForClientTest(CrashTestCase): |
| 18 | 20 |
| 19 def testCheckPolicyUnsupportedClient(self): | 21 def testCheckPolicyUnsupportedClient(self): |
| 20 pass_check, _ = findit_for_client.CheckPolicyForClient( | 22 pass_check, _ = findit_for_client.CheckPolicyForClient( |
| 21 {'signature': 'sig'}, '1', 'sig', 'unsupported_client', | 23 {'signature': 'sig'}, '1', 'sig', 'unsupported_client', |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 platform = 'linux' | 98 platform = 'linux' |
| 97 stack_trace = 'stack_trace' | 99 stack_trace = 'stack_trace' |
| 98 crash_identifiers = { | 100 crash_identifiers = { |
| 99 'chrome_version': chrome_version, | 101 'chrome_version': chrome_version, |
| 100 'signature': signature, | 102 'signature': signature, |
| 101 'channel': 'canary', | 103 'channel': 'canary', |
| 102 'platform': platform, | 104 'platform': platform, |
| 103 'process_type': 'browser', | 105 'process_type': 'browser', |
| 104 } | 106 } |
| 105 customized_data = {'channel': 'canary'} | 107 customized_data = {'channel': 'canary'} |
| 108 regression_range = ['53.0.1235.1', '53.0.1235.1'] |
| 106 | 109 |
| 107 analysis = FracasCrashAnalysis.Create(crash_identifiers) | 110 analysis = FracasCrashAnalysis.Create(crash_identifiers) |
| 108 | 111 |
| 109 findit_for_client.ResetAnalysis( | 112 findit_for_client.ResetAnalysis( |
| 110 analysis, chrome_version, signature, CrashClient.FRACAS, platform, | 113 analysis, chrome_version, signature, CrashClient.FRACAS, platform, |
| 111 stack_trace, customized_data) | 114 stack_trace, customized_data, regression_range) |
| 112 | 115 |
| 113 analysis = FracasCrashAnalysis.Get(crash_identifiers) | 116 analysis = FracasCrashAnalysis.Get(crash_identifiers) |
| 114 self.assertEqual(analysis.crashed_version, chrome_version) | 117 self.assertEqual(analysis.crashed_version, chrome_version) |
| 115 self.assertEqual(analysis.signature, signature) | 118 self.assertEqual(analysis.signature, signature) |
| 116 self.assertEqual(analysis.platform, platform) | 119 self.assertEqual(analysis.platform, platform) |
| 117 self.assertEqual(analysis.stack_trace, stack_trace) | 120 self.assertEqual(analysis.stack_trace, stack_trace) |
| 118 self.assertEqual(analysis.channel, customized_data['channel']) | 121 self.assertEqual(analysis.channel, customized_data['channel']) |
| 122 self.assertEqual(analysis.regression_range, regression_range) |
| 119 | 123 |
| 120 def testCreateAnalysisForClient(self): | 124 def testCreateAnalysisForClient(self): |
| 121 crash_identifiers = {'signature': 'sig'} | 125 crash_identifiers = {'signature': 'sig'} |
| 122 self.assertIsNotNone(findit_for_client.CreateAnalysisForClient( | 126 self.assertIsNotNone(findit_for_client.CreateAnalysisForClient( |
| 123 crash_identifiers, CrashClient.FRACAS)) | 127 crash_identifiers, CrashClient.FRACAS)) |
| 124 | 128 |
| 125 def testCreateAnalysisForUnsupportedClientId(self): | 129 def testCreateAnalysisForUnsupportedClientId(self): |
| 126 crash_identifiers = {'signature': 'sig'} | 130 crash_identifiers = {'signature': 'sig'} |
| 127 self.assertIsNone(findit_for_client.CreateAnalysisForClient( | 131 self.assertIsNone(findit_for_client.CreateAnalysisForClient( |
| 128 crash_identifiers, 'unsupported_id')) | 132 crash_identifiers, 'unsupported_id')) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 return expected_result, expected_tags | 211 return expected_result, expected_tags |
| 208 self.mock(findit_for_chromecrash, 'FinditForChromeCrash', | 212 self.mock(findit_for_chromecrash, 'FinditForChromeCrash', |
| 209 _MockFinditForChromeCrash) | 213 _MockFinditForChromeCrash) |
| 210 | 214 |
| 211 analysis = FracasCrashAnalysis.Create({'signature': 'sig'}) | 215 analysis = FracasCrashAnalysis.Create({'signature': 'sig'}) |
| 212 analysis.client_id = CrashClient.FRACAS | 216 analysis.client_id = CrashClient.FRACAS |
| 213 | 217 |
| 214 result, tags = findit_for_client.FindCulprit(analysis) | 218 result, tags = findit_for_client.FindCulprit(analysis) |
| 215 self.assertEqual(result, expected_result) | 219 self.assertEqual(result, expected_result) |
| 216 self.assertEqual(tags, expected_tags) | 220 self.assertEqual(tags, expected_tags) |
| 221 |
| 222 analysis.client_id = 'unsupported_client' |
| 223 result, tags = findit_for_client.FindCulprit(analysis) |
| 224 self.assertEqual(result, expected_result) |
| 225 self.assertEqual(tags, expected_tags) |
| 226 |
| 227 |
| 228 def testGetRegressionRange(self): |
| 229 expected_regression_range = ['51.0.1233.1', '51.0.1233.2'] |
| 230 def _MockDetectRegressionRange(*_): |
| 231 return expected_regression_range |
| 232 |
| 233 self.mock(detect_regression_range, 'DetectRegressionRange', |
| 234 _MockDetectRegressionRange) |
| 235 historical_metadata = [{'chrome_version': '51.0.1233.0', 'cpm': 0}, |
| 236 {'chrome_version': '51.0.1233.1', 'cpm': 0}, |
| 237 {'chrome_version': '51.0.1233.2', 'cpm': 0.89}] |
| 238 |
| 239 regression_range = findit_for_client.GetRegressionRange( |
| 240 CrashClient.FRACAS, {'historical_metadata': historical_metadata}) |
| 241 self.assertEqual(regression_range, expected_regression_range) |
| 242 |
| 243 regression_range = findit_for_client.GetRegressionRange( |
| 244 'unsupported_client', {'historical_metadata': historical_metadata}) |
| 245 self.assertEqual(regression_range, None) |
| OLD | NEW |