Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/net/buildbot.py

Issue 2446463002: Fetch retry summary and use it to determine what tests to rebaseline. (Closed)
Patch Set: Add test for case where no retry summary can be downloaded Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/common/net/buildbot_mock.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2009, Google Inc. All rights reserved. 1 # Copyright (c) 2009, Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 return super(Build, cls).__new__(cls, builder_name, build_number) 48 return super(Build, cls).__new__(cls, builder_name, build_number)
49 49
50 50
51 class BuildBot(object): 51 class BuildBot(object):
52 """This class represents an interface to BuildBot-related functionality. 52 """This class represents an interface to BuildBot-related functionality.
53 53
54 This includes fetching layout test results from Google Storage; 54 This includes fetching layout test results from Google Storage;
55 for more information about the layout test result format, see: 55 for more information about the layout test result format, see:
56 https://www.chromium.org/developers/the-json-test-results-format 56 https://www.chromium.org/developers/the-json-test-results-format
57 """ 57 """
58
59 def results_url(self, builder_name, build_number=None): 58 def results_url(self, builder_name, build_number=None):
60 """Returns a URL for one set of archived layout test results. 59 """Returns a URL for one set of archived layout test results.
61 60
62 If a build number is given, this will be results for a particular run; 61 If a build number is given, this will be results for a particular run;
63 otherwise it will be the accumulated results URL, which should have 62 otherwise it will be the accumulated results URL, which should have
64 the latest results. 63 the latest results.
65 """ 64 """
66 if build_number: 65 if build_number:
67 url_base = self.builder_results_url_base(builder_name) 66 url_base = self.builder_results_url_base(builder_name)
68 return "%s/%s/layout-test-results" % (url_base, build_number) 67 return "%s/%s/layout-test-results" % (url_base, build_number)
69 return self.accumulated_results_url_base(builder_name) 68 return self.accumulated_results_url_base(builder_name)
70 69
71 def builder_results_url_base(self, builder_name): 70 def builder_results_url_base(self, builder_name):
72 """Returns the URL for the given builder's directory in Google Storage. 71 """Returns the URL for the given builder's directory in Google Storage.
73 72
74 Each builder has a directory in the GS bucket, and the directory 73 Each builder has a directory in the GS bucket, and the directory
75 name is the builder name transformed to be more URL-friendly by 74 name is the builder name transformed to be more URL-friendly by
76 replacing all spaces, periods and parentheses with underscores. 75 replacing all spaces, periods and parentheses with underscores.
77 """ 76 """
78 return '%s/%s' % (RESULTS_URL_BASE, re.sub('[ .()]', '_', builder_name)) 77 return '%s/%s' % (RESULTS_URL_BASE, re.sub('[ .()]', '_', builder_name))
79 78
79 @memoized
80 def fetch_retry_summary_json(self, build):
81 """Fetches and returns the text of the archived retry_summary file.
82
83 This file is expected to contain the results of retrying layout tests
84 with and without a patch in a try job. It includes lists of tests
85 that failed only with the patch ("failures"), and tests that failed
86 both with and without ("ignored").
87 """
88 url_base = "%s/%s" % (self.builder_results_url_base(build.builder_name), build.build_number)
89 return self._fetch_file(url_base, 'retry_summary.json')
90
80 def accumulated_results_url_base(self, builder_name): 91 def accumulated_results_url_base(self, builder_name):
81 return self.builder_results_url_base(builder_name) + "/results/layout-te st-results" 92 return self.builder_results_url_base(builder_name) + "/results/layout-te st-results"
82 93
83 @memoized 94 @memoized
84 def latest_layout_test_results(self, builder_name): 95 def latest_layout_test_results(self, builder_name):
85 return self.fetch_layout_test_results(self.accumulated_results_url_base( builder_name)) 96 return self.fetch_layout_test_results(self.accumulated_results_url_base( builder_name))
86 97
87 @memoized 98 @memoized
88 def fetch_results(self, build): 99 def fetch_results(self, build):
89 return self.fetch_layout_test_results(self.results_url(build.builder_nam e, build.build_number)) 100 return self.fetch_layout_test_results(self.results_url(build.builder_nam e, build.build_number))
90 101
91 @memoized 102 @memoized
92 def fetch_layout_test_results(self, results_url): 103 def fetch_layout_test_results(self, results_url):
93 """Returns a LayoutTestResults object for results fetched from a given U RL.""" 104 """Returns a LayoutTestResults object for results fetched from a given U RL."""
94 results_file = NetworkTransaction(convert_404_to_None=True).run( 105 results_file = NetworkTransaction(convert_404_to_None=True).run(
95 lambda: self._fetch_file_from_results(results_url, "failing_results. json")) 106 lambda: self._fetch_file(results_url, "failing_results.json"))
96 revision = NetworkTransaction(convert_404_to_None=True).run( 107 revision = NetworkTransaction(convert_404_to_None=True).run(
97 lambda: self._fetch_file_from_results(results_url, "LAST_CHANGE")) 108 lambda: self._fetch_file(results_url, "LAST_CHANGE"))
98 if not revision: 109 if not revision:
99 results_file = None 110 results_file = None
100 return LayoutTestResults.results_from_string(results_file, revision) 111 return LayoutTestResults.results_from_string(results_file, revision)
101 112
102 def _fetch_file_from_results(self, results_url, file_name): 113 def _fetch_file(self, url_base, file_name):
103 # It seems this can return None if the url redirects and then returns 40 4. 114 # It seems this can return None if the url redirects and then returns 40 4.
104 # FIXME: This could use Web instead of using urllib2 directly. 115 # FIXME: This could use Web instead of using urllib2 directly.
105 result = urllib2.urlopen("%s/%s" % (results_url, file_name)) 116 result = urllib2.urlopen("%s/%s" % (url_base, file_name))
106 if not result: 117 if not result:
107 return None 118 return None
108 # urlopen returns a file-like object which sometimes works fine with str () 119 # urlopen returns a file-like object which sometimes works fine with str ()
109 # but sometimes is a addinfourl object. In either case calling read() i s correct. 120 # but sometimes is a addinfourl object. In either case calling read() i s correct.
110 return result.read() 121 return result.read()
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/common/net/buildbot_mock.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698