| 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 import pickle | 7 import pickle |
| 8 import subprocess | 8 import subprocess |
| 9 | 9 |
| 10 from crash_queries import crash_iterator | 10 from crash_queries import crash_iterator |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 git_hash2 (str): A git hash of findit repository. | 193 git_hash2 (str): A git hash of findit repository. |
| 194 start_date (str): Run delta test on testcases after (including) | 194 start_date (str): Run delta test on testcases after (including) |
| 195 the start_date, format should be '%Y-%m-%d'. | 195 the start_date, format should be '%Y-%m-%d'. |
| 196 end_date (str): Run delta test on testcases before (not including) | 196 end_date (str): Run delta test on testcases before (not including) |
| 197 the end_date, format should be '%Y-%m-%d'. | 197 the end_date, format should be '%Y-%m-%d'. |
| 198 client_id (CrashClient): Possible values are 'fracas', 'cracas', | 198 client_id (CrashClient): Possible values are 'fracas', 'cracas', |
| 199 'cluterfuzz'. | 199 'cluterfuzz'. |
| 200 app_id (str): Appengine app id to query. | 200 app_id (str): Appengine app id to query. |
| 201 batch_size (int): Size of a batch that can be queried at one time. | 201 batch_size (int): Size of a batch that can be queried at one time. |
| 202 property_values (dict): Property values to query. | 202 property_values (dict): Property values to query. |
| 203 batch_size (int): The size of crashes that can be queried at one time. | 203 batch_size (int): The size of crashes that can be queried at one time. |
| 204 verbose (bool): If True, print all the findit results. | 204 verbose (bool): If True, print all the findit results. |
| 205 Return: | 205 Return: |
| 206 (deltas, crash_count). | 206 (deltas, crash_count). |
| 207 deltas (dict): Mappings id to delta for each culprit value. | 207 deltas (dict): Mappings id to delta for each culprit value. |
| 208 crash_count (int): Total count of all the crashes. | 208 crash_count (int): Total count of all the crashes. |
| 209 """ | 209 """ |
| 210 head_branch_name = subprocess.check_output( | 210 head_branch_name = subprocess.check_output( |
| 211 ['git', 'rev-parse', '--abbrev-ref', 'HEAD']).replace('\n', '') | 211 ['git', 'rev-parse', '--abbrev-ref', 'HEAD']).replace('\n', '') |
| 212 try: | 212 try: |
| 213 deltas = {} | 213 deltas = {} |
| 214 crash_count = 0 | 214 crash_count = 0 |
| 215 # Iterate batches of crash informations. | 215 # Iterate batches of crash informations. |
| 216 for index, crashes in enumerate( | 216 for index, crashes in enumerate( |
| 217 crash_iterator.IterateCrashes(client_id, app_id, | 217 crash_iterator.CachedCrashIterator(client_id, app_id, |
| 218 fields=CRASH_FIELDS, | 218 fields=CRASH_FIELDS, |
| 219 property_values=property_values, | 219 property_values=property_values, |
| 220 start_date=start_date, | 220 start_date=start_date, |
| 221 end_date=end_date, | 221 end_date=end_date, |
| 222 batch_size=batch_size, | 222 batch_size=batch_size, |
| 223 batch_run=True)): | 223 batch_run=True)): |
| 224 | |
| 225 results = [] | 224 results = [] |
| 226 for git_hash in [git_hash1, git_hash2]: | 225 for git_hash in [git_hash1, git_hash2]: |
| 227 result_path = os.path.join( | 226 result_path = os.path.join( |
| 228 PREDATOR_RESULTS_DIRECTORY, delta_util.GenerateFileName( | 227 PREDATOR_RESULTS_DIRECTORY, delta_util.GenerateFileName( |
| 229 client_id, property_values, start_date, end_date, | 228 client_id, property_values, start_date, end_date, |
| 230 batch_size, index, git_hash)) | 229 batch_size, index, git_hash)) |
| 231 # Get the culprit results of this batch of crashes. | 230 # Get the culprit results of this batch of crashes. |
| 232 results.append(GetResults(crashes, client_id, app_id, | 231 results.append(GetResults(crashes, client_id, app_id, |
| 233 git_hash, result_path, | 232 git_hash, result_path, |
| 234 verbose=verbose)) | 233 verbose=verbose)) |
| 235 | 234 |
| 236 crash_count += len(crashes) | 235 crash_count += len(crashes) |
| 237 # Compute delta between 2 versions of culprit results for this batch. | 236 # Compute delta between 2 versions of culprit results for this batch. |
| 238 batch_deltas = GetDeltasFromTwoSetsOfResults(*results) | 237 batch_deltas = GetDeltasFromTwoSetsOfResults(*results) |
| 239 # Print the deltas of the current batch. | 238 # Print the deltas of the current batch. |
| 240 print '========= Delta of this batch =========' | 239 print '========= Delta of this batch =========' |
| 241 delta_util.PrintDelta(batch_deltas, len(crashes), app_id) | 240 delta_util.PrintDelta(batch_deltas, len(crashes), app_id) |
| 242 deltas.update(batch_deltas) | 241 deltas.update(batch_deltas) |
| 243 | 242 |
| 244 return deltas, crash_count | 243 return deltas, crash_count |
| 245 finally: | 244 finally: |
| 246 with open(os.devnull, 'w') as null_handle: | 245 with open(os.devnull, 'w') as null_handle: |
| 247 subprocess.check_call(['git', 'checkout', head_branch_name], | 246 subprocess.check_call(['git', 'checkout', head_branch_name], |
| 248 stdout=null_handle, | 247 stdout=null_handle, |
| 249 stderr=null_handle) | 248 stderr=null_handle) |
| OLD | NEW |