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

Side by Side Diff: dashboard/dashboard/file_bug_test.py

Issue 2618413002: Only label milestones for ChromiumPerf and ChromiumPerfFyi and corresponding test. (Closed)
Patch Set: Updates milestone label to use r_commit_pos if available. Created 3 years, 11 months 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 | « dashboard/dashboard/file_bug.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import json 5 import json
6 import unittest 6 import unittest
7 7
8 import mock 8 import mock
9 import webapp2 9 import webapp2
10 import webtest 10 import webtest
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 file_bug.issue_tracker_service = mock.MagicMock() 62 file_bug.issue_tracker_service = mock.MagicMock()
63 self.original_service = file_bug.issue_tracker_service.IssueTrackerService 63 self.original_service = file_bug.issue_tracker_service.IssueTrackerService
64 self.service = MockIssueTrackerService 64 self.service = MockIssueTrackerService
65 file_bug.issue_tracker_service.IssueTrackerService = self.service 65 file_bug.issue_tracker_service.IssueTrackerService = self.service
66 66
67 def tearDown(self): 67 def tearDown(self):
68 super(FileBugTest, self).tearDown() 68 super(FileBugTest, self).tearDown()
69 file_bug.issue_tracker_service.IssueTrackerService = self.original_service 69 file_bug.issue_tracker_service.IssueTrackerService = self.original_service
70 self.UnsetCurrentUser() 70 self.UnsetCurrentUser()
71 71
72 def _AddSampleAlerts(self): 72 def _AddSampleAlerts(self, is_chromium=True):
73 """Adds sample data and returns a dict of rev to anomaly key.""" 73 """Adds sample data and returns a dict of rev to anomaly key."""
74 # Add sample sheriff, masters, bots, and tests. 74 # Add sample sheriff, masters, bots, and tests.
75 sheriff_key = sheriff.Sheriff( 75 sheriff_key = sheriff.Sheriff(
76 id='Sheriff', 76 id='Sheriff',
77 labels=['Performance-Sheriff', 'Cr-Blink-Javascript']).put() 77 labels=['Performance-Sheriff', 'Cr-Blink-Javascript']).put()
78 testing_common.AddTests(['ChromiumPerf'], ['linux'], { 78 testing_common.AddTests(['ChromiumPerf'], ['linux'], {
79 'scrolling': { 79 'scrolling': {
80 'first_paint': {}, 80 'first_paint': {},
81 'mean_frame_time': {}, 81 'mean_frame_time': {},
82 } 82 }
83 }) 83 })
84 test_key1 = utils.TestKey('ChromiumPerf/linux/scrolling/first_paint') 84 test_path1 = 'ChromiumPerf/linux/scrolling/first_paint'
85 test_key2 = utils.TestKey('ChromiumPerf/linux/scrolling/mean_frame_time') 85 test_path2 = 'ChromiumPerf/linux/scrolling/mean_frame_time'
86 test_key1 = utils.TestKey(test_path1)
87 test_key2 = utils.TestKey(test_path2)
86 anomaly_key1 = self._AddAnomaly(111995, 112005, test_key1, sheriff_key) 88 anomaly_key1 = self._AddAnomaly(111995, 112005, test_key1, sheriff_key)
87 anomaly_key2 = self._AddAnomaly(112000, 112010, test_key2, sheriff_key) 89 anomaly_key2 = self._AddAnomaly(112000, 112010, test_key2, sheriff_key)
90 rows_1 = testing_common.AddRows(test_path1, [112005])
91 rows_2 = testing_common.AddRows(test_path2, [112010])
92 if is_chromium:
93 rows_1[0].r_commit_pos = 112005
94 rows_2[0].r_commit_pos = 112010
88 return (anomaly_key1, anomaly_key2) 95 return (anomaly_key1, anomaly_key2)
89 96
90 def _AddSampleAlertsV8(self): 97 def _AddSampleClankAlerts(self):
91 """Adds sample data and returns a dict of rev to anomaly key.""" 98 """Adds sample data and returns a dict of rev to anomaly key.
92 # Add sample sheriff, masters, bots, and tests. 99
100 The biggest difference here is that the start/end revs aren't chromium
101 commit positions. This tests the _MilestoneLabel function to make sure
102 it will update the end_revision if r_commit_pos is found.
103 """
104 # Add sample sheriff, masters, bots, and tests. Doesn't need to be Clank.
93 sheriff_key = sheriff.Sheriff( 105 sheriff_key = sheriff.Sheriff(
94 id='Sheriff', 106 id='Sheriff',
95 labels=['Performance-Sheriff', 'Cr-Blink-Javascript']).put() 107 labels=['Performance-Sheriff', 'Cr-Blink-Javascript']).put()
96 testing_common.AddTests(['v8'], ['linux'], { 108 testing_common.AddTests(['ChromiumPerf'], ['linux'], {
97 'scrolling': { 109 'scrolling': {
98 'first_paint': {}, 110 'first_paint': {},
99 'mean_frame_time': {}, 111 'mean_frame_time': {},
100 } 112 }
101 }) 113 })
102 test_key1 = utils.TestKey('v8/linux/scrolling/first_paint') 114 test_path1 = 'ChromiumPerf/linux/scrolling/first_paint'
103 test_key2 = utils.TestKey('v8/linux/scrolling/mean_frame_time') 115 test_path2 = 'ChromiumPerf/linux/scrolling/mean_frame_time'
104 anomaly_key1 = self._AddAnomaly(111995, 112005, test_key1, sheriff_key) 116 test_key1 = utils.TestKey(test_path1)
105 anomaly_key2 = self._AddAnomaly(112000, 112010, test_key2, sheriff_key) 117 test_key2 = utils.TestKey(test_path2)
118 anomaly_key1 = self._AddAnomaly(1476193324, 1476201840,
119 test_key1, sheriff_key)
120 anomaly_key2 = self._AddAnomaly(1476193320, 1476201870,
121 test_key2, sheriff_key)
122 rows_1 = testing_common.AddRows(test_path1, [1476201840])
123 rows_2 = testing_common.AddRows(test_path2, [1476201870])
124 # These will be the revisions used to determine label.
125 rows_1[0].r_commit_pos = 112005
126 rows_2[0].r_commit_pos = 112010
106 return (anomaly_key1, anomaly_key2) 127 return (anomaly_key1, anomaly_key2)
107 128
108 def _AddAnomaly(self, start_rev, end_rev, test_key, sheriff_key): 129 def _AddAnomaly(self, start_rev, end_rev, test_key, sheriff_key):
109 return anomaly.Anomaly( 130 return anomaly.Anomaly(
110 start_revision=start_rev, end_revision=end_rev, test=test_key, 131 start_revision=start_rev, end_revision=end_rev, test=test_key,
111 median_before_anomaly=100, median_after_anomaly=200, 132 median_before_anomaly=100, median_after_anomaly=200,
112 sheriff=sheriff_key).put() 133 sheriff=sheriff_key).put()
113 134
114 def testGet_WithNoKeys_ShowsError(self): 135 def testGet_WithNoKeys_ShowsError(self):
115 # When a request is made and no keys parameter is given, 136 # When a request is made and no keys parameter is given,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 self.assertIn('Performance>Blink', response.body) 177 self.assertIn('Performance>Blink', response.body)
157 self.assertIn('Performance-Sheriff', response.body) 178 self.assertIn('Performance-Sheriff', response.body)
158 self.assertIn('Blink>Javascript', response.body) 179 self.assertIn('Blink>Javascript', response.body)
159 180
160 @mock.patch( 181 @mock.patch(
161 'google.appengine.api.app_identity.get_default_version_hostname', 182 'google.appengine.api.app_identity.get_default_version_hostname',
162 mock.MagicMock(return_value='chromeperf.appspot.com')) 183 mock.MagicMock(return_value='chromeperf.appspot.com'))
163 @mock.patch.object( 184 @mock.patch.object(
164 file_bug.auto_bisect, 'StartNewBisectForBug', 185 file_bug.auto_bisect, 'StartNewBisectForBug',
165 mock.MagicMock(return_value={'issue_id': 123, 'issue_url': 'foo.com'})) 186 mock.MagicMock(return_value={'issue_id': 123, 'issue_url': 'foo.com'}))
166 def _PostSampleBug(self, is_v8=False): 187 def _PostSampleBug(self, is_chromium=True, is_clankium=False):
167 if is_v8: 188 if is_clankium:
168 alert_keys = self._AddSampleAlertsV8() 189 alert_keys = self._AddSampleClankAlerts()
169 else: 190 else:
170 alert_keys = self._AddSampleAlerts() 191 alert_keys = self._AddSampleAlerts(is_chromium)
171 response = self.testapp.post( 192 response = self.testapp.post(
172 '/file_bug', 193 '/file_bug',
173 [ 194 [
174 ('keys', '%s,%s' % (alert_keys[0].urlsafe(), 195 ('keys', '%s,%s' % (alert_keys[0].urlsafe(),
175 alert_keys[1].urlsafe())), 196 alert_keys[1].urlsafe())),
176 ('summary', 's'), 197 ('summary', 's'),
177 ('description', 'd\n'), 198 ('description', 'd\n'),
178 ('finish', 'true'), 199 ('finish', 'true'),
179 ('label', 'one'), 200 ('label', 'one'),
180 ('label', 'two'), 201 ('label', 'two'),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 'versions': [ 242 'versions': [
222 {'branch_base_position': '112000', 'current_version': '2.0'}, 243 {'branch_base_position': '112000', 'current_version': '2.0'},
223 {'branch_base_position': '111990', 'current_version': '1.0'} 244 {'branch_base_position': '111990', 'current_version': '1.0'}
224 ] 245 ]
225 } 246 }
226 ])) 247 ]))
227 @mock.patch.object( 248 @mock.patch.object(
228 file_bug.auto_bisect, 'StartNewBisectForBug', 249 file_bug.auto_bisect, 'StartNewBisectForBug',
229 mock.MagicMock(return_value={'issue_id': 123, 'issue_url': 'foo.com'})) 250 mock.MagicMock(return_value={'issue_id': 123, 'issue_url': 'foo.com'}))
230 def testGet_WithFinish_LabelsBugWithMilestone(self): 251 def testGet_WithFinish_LabelsBugWithMilestone(self):
231 # Here, we expect the bug to have the following start revisions: 252 # Here, we expect the bug to have the following end revisions:
232 # [111995, 112005] and the milestones are M-1 for rev 111990 and 253 # [112005, 112010] and the milestones are M-1 for rev 111990 and
233 # M-2 for 11200. Hence the expected behavior is to label the bug 254 # M-2 for 11200. Hence the expected behavior is to label the bug
234 # M-2 since 111995 (lowest possible revision introducing regression) 255 # M-2 since 111995 (lowest possible revision introducing regression)
235 # is less than 112000 (revision for M-2). 256 # is less than 112010 (revision for M-2).
236 self._PostSampleBug() 257 self._PostSampleBug()
237 self.assertIn('M-2', self.service.new_bug_kwargs['labels']) 258 self.assertIn('M-2', self.service.new_bug_kwargs['labels'])
238 259
239 @unittest.skip('Flaky; see #1555.') 260 @unittest.skip('Flaky; see #1555.')
240 @mock.patch( 261 @mock.patch(
241 'google.appengine.api.urlfetch.fetch', 262 'google.appengine.api.urlfetch.fetch',
242 mock.MagicMock(return_value=testing_common.FakeResponseObject( 263 mock.MagicMock(return_value=testing_common.FakeResponseObject(
243 200, json.dumps([ 264 200, json.dumps([
244 { 265 {
245 'versions': [ 266 'versions': [
(...skipping 22 matching lines...) Expand all
268 'versions': [ 289 'versions': [
269 {'branch_base_position': '112000', 'current_version': '2.0'}, 290 {'branch_base_position': '112000', 'current_version': '2.0'},
270 {'branch_base_position': '111990', 'current_version': '1.0'} 291 {'branch_base_position': '111990', 'current_version': '1.0'}
271 ] 292 ]
272 } 293 }
273 ])) 294 ]))
274 @mock.patch.object( 295 @mock.patch.object(
275 file_bug.auto_bisect, 'StartNewBisectForBug', 296 file_bug.auto_bisect, 'StartNewBisectForBug',
276 mock.MagicMock(return_value={'issue_id': 123, 'issue_url': 'foo.com'})) 297 mock.MagicMock(return_value={'issue_id': 123, 'issue_url': 'foo.com'}))
277 def testGet_WithFinish_LabelsBugWithNoMilestoneBecauseNotChromium(self): 298 def testGet_WithFinish_LabelsBugWithNoMilestoneBecauseNotChromium(self):
278 # Here, we expect to return no Milestone label because the alerts are 299 # Here, we expect to return no Milestone label because the alerts do not
279 # not of master 'ChromiumPerf' or 'ChromiumPerfFyi'. Assuming 300 # contain r_commit_pos (and therefore aren't chromium). Assuming
280 # testGet_WithFinish_LabelsBugWithMilestone passes, M-2 301 # testGet_WithFinish_LabelsBugWithMilestone passes, M-2
281 # would be the label that it would get if the alert was Chromium. 302 # would be the label that it would get if the alert was Chromium.
282 self._PostSampleBug(is_v8=True) 303 self._PostSampleBug(is_chromium=False)
283 labels = self.service.new_bug_kwargs['labels'] 304 labels = self.service.new_bug_kwargs['labels']
284 self.assertEqual(0, len([x for x in labels if x.startswith(u'M-')])) 305 self.assertEqual(0, len([x for x in labels if x.startswith(u'M-')]))
285 306
307 @mock.patch.object(
308 file_bug, '_GetAllCurrentVersionsFromOmahaProxy',
309 mock.MagicMock(return_value=[
310 {
311 'versions': [
312 {'branch_base_position': '113000', 'current_version': '2.0'},
313 {'branch_base_position': '112000', 'current_version': '2.0'},
314 {'branch_base_position': '111990', 'current_version': '1.0'}
315 ]
316 }
317 ]))
318 @mock.patch.object(
319 file_bug.auto_bisect, 'StartNewBisectForBug',
320 mock.MagicMock(return_value={'issue_id': 123, 'issue_url': 'foo.com'}))
321 def testGet_WithFinish_LabelsBugForClank(self):
322 # Here, we expect to return M-2 even though the alert revisions aren't
323 # even close to the branching points. We use r_commmit_pos to determine
324 # which revision to check. There are 3 branching points to ensure we are
325 # actually changing the revision that is checked to r_commit_pos instead
326 # of just displaying the highest one (previous behavior).
327 self._PostSampleBug(is_clankium=True)
328 self.assertIn('M-2', self.service.new_bug_kwargs['labels'])
329
286 @mock.patch( 330 @mock.patch(
287 'google.appengine.api.urlfetch.fetch', 331 'google.appengine.api.urlfetch.fetch',
288 mock.MagicMock(return_value=testing_common.FakeResponseObject( 332 mock.MagicMock(return_value=testing_common.FakeResponseObject(
289 200, '[]'))) 333 200, '[]')))
290 def testGet_WithFinish_SucceedsWithNoVersions(self): 334 def testGet_WithFinish_SucceedsWithNoVersions(self):
291 # Here, we test that we don't label the bug with an unexpected value when 335 # Here, we test that we don't label the bug with an unexpected value when
292 # there is no version information from omahaproxy (for whatever reason) 336 # there is no version information from omahaproxy (for whatever reason)
293 self._PostSampleBug() 337 self._PostSampleBug()
294 labels = self.service.new_bug_kwargs['labels'] 338 labels = self.service.new_bug_kwargs['labels']
295 self.assertEqual(0, len([x for x in labels if x.startswith(u'M-')])) 339 self.assertEqual(0, len([x for x in labels if x.startswith(u'M-')]))
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 @mock.patch('logging.warn') 376 @mock.patch('logging.warn')
333 def testGet_WithFinish_SucceedsWithNAAndLogsWarning(self, mock_warn): 377 def testGet_WithFinish_SucceedsWithNAAndLogsWarning(self, mock_warn):
334 self._PostSampleBug() 378 self._PostSampleBug()
335 labels = self.service.new_bug_kwargs['labels'] 379 labels = self.service.new_bug_kwargs['labels']
336 self.assertEqual(0, len([x for x in labels if x.startswith(u'M-')])) 380 self.assertEqual(0, len([x for x in labels if x.startswith(u'M-')]))
337 self.assertEqual(1, mock_warn.call_count) 381 self.assertEqual(1, mock_warn.call_count)
338 382
339 383
340 if __name__ == '__main__': 384 if __name__ == '__main__':
341 unittest.main() 385 unittest.main()
OLDNEW
« no previous file with comments | « dashboard/dashboard/file_bug.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698