| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 """Task queue endpoints for creating and updating issues on issue tracker.""" | 5 """Task queue endpoints for creating and updating issues on issue tracker.""" |
| 6 | 6 |
| 7 import datetime | 7 import datetime |
| 8 import json | 8 import json |
| 9 import logging | 9 import logging |
| 10 import urllib2 | 10 import urllib2 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 from status import build_result, util | 23 from status import build_result, util |
| 24 from test_results.util import normalize_test_type, flatten_tests_trie | 24 from test_results.util import normalize_test_type, flatten_tests_trie |
| 25 | 25 |
| 26 | 26 |
| 27 MAX_UPDATED_ISSUES_PER_DAY = 50 | 27 MAX_UPDATED_ISSUES_PER_DAY = 50 |
| 28 MAX_TIME_DIFFERENCE_SECONDS = 12 * 60 * 60 | 28 MAX_TIME_DIFFERENCE_SECONDS = 12 * 60 * 60 |
| 29 MIN_REQUIRED_FLAKY_RUNS = 3 | 29 MIN_REQUIRED_FLAKY_RUNS = 3 |
| 30 DAYS_TILL_STALE = 30 | 30 DAYS_TILL_STALE = 30 |
| 31 USE_MONORAIL = True | 31 USE_MONORAIL = True |
| 32 DAYS_TO_REOPEN_ISSUE = 3 | 32 DAYS_TO_REOPEN_ISSUE = 3 |
| 33 MAX_INDIVIDUAL_FLAKES_PER_STEP = 50 |
| 33 FLAKY_RUNS_TEMPLATE = ( | 34 FLAKY_RUNS_TEMPLATE = ( |
| 34 'Detected %(new_flakes_count)d new flakes for test/step "%(name)s". To see ' | 35 'Detected %(new_flakes_count)d new flakes for test/step "%(name)s". To see ' |
| 35 'the actual flakes, please visit %(flakes_url)s. This message was posted ' | 36 'the actual flakes, please visit %(flakes_url)s. This message was posted ' |
| 36 'automatically by the chromium-try-flakes app. Since flakiness is ongoing, ' | 37 'automatically by the chromium-try-flakes app. Since flakiness is ongoing, ' |
| 37 'the issue was moved back into %(queue_name)s (unless already there).') | 38 'the issue was moved back into %(queue_name)s (unless already there).') |
| 38 SUMMARY_TEMPLATE = '"%(name)s" is flaky' | 39 SUMMARY_TEMPLATE = '"%(name)s" is flaky' |
| 39 DESCRIPTION_TEMPLATE = ( | 40 DESCRIPTION_TEMPLATE = ( |
| 40 '%(summary)s.\n\n' | 41 '%(summary)s.\n\n' |
| 41 'This issue was created automatically by the chromium-try-flakes app. ' | 42 'This issue was created automatically by the chromium-try-flakes app. ' |
| 42 'Please find the right owner to fix the respective test/step and assign ' | 43 'Please find the right owner to fix the respective test/step and assign ' |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 | 502 |
| 502 try: | 503 try: |
| 503 result = urlfetch.fetch(url) | 504 result = urlfetch.fetch(url) |
| 504 | 505 |
| 505 if result.status_code >= 200 and result.status_code < 400: | 506 if result.status_code >= 200 and result.status_code < 400: |
| 506 json_result = json.loads(result.content) | 507 json_result = json.loads(result.content) |
| 507 | 508 |
| 508 _, failed, _ = cls._flatten_tests( | 509 _, failed, _ = cls._flatten_tests( |
| 509 json_result.get('tests', {}), | 510 json_result.get('tests', {}), |
| 510 json_result.get('path_delimiter', '/')) | 511 json_result.get('path_delimiter', '/')) |
| 512 if len(failed) > MAX_INDIVIDUAL_FLAKES_PER_STEP: |
| 513 return [stepname], True |
| 511 return failed, False | 514 return failed, False |
| 512 | 515 |
| 513 if result.status_code == 404: | 516 if result.status_code == 404: |
| 514 # This is quite a common case (only some failing steps are actually | 517 # This is quite a common case (only some failing steps are actually |
| 515 # running tests and reporting results to flakiness dashboard). | 518 # running tests and reporting results to flakiness dashboard). |
| 516 logging.info('Failed to retrieve JSON from %s', url) | 519 logging.info('Failed to retrieve JSON from %s', url) |
| 517 else: | 520 else: |
| 518 logging.exception('Failed to retrieve JSON from %s', url) | 521 logging.exception('Failed to retrieve JSON from %s', url) |
| 519 except Exception: | 522 except Exception: |
| 520 logging.exception('Failed to retrieve or parse JSON from %s', url) | 523 logging.exception('Failed to retrieve or parse JSON from %s', url) |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 return | 659 return |
| 657 | 660 |
| 658 key = self.request.get('key') | 661 key = self.request.get('key') |
| 659 flake = ndb.Key(urlsafe=key).get() | 662 flake = ndb.Key(urlsafe=key).get() |
| 660 flake.issue_id = issue_id | 663 flake.issue_id = issue_id |
| 661 flake.put() | 664 flake.put() |
| 662 | 665 |
| 663 logging.info('%s updated issue_id for flake %s to %d.', user_email, | 666 logging.info('%s updated issue_id for flake %s to %d.', user_email, |
| 664 flake.name, issue_id) | 667 flake.name, issue_id) |
| 665 self.redirect('/all_flake_occurrences?key=%s' % key) | 668 self.redirect('/all_flake_occurrences?key=%s' % key) |
| OLD | NEW |