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

Side by Side Diff: dashboard/dashboard/pinpoint/models/quest/find_isolate_test.py

Issue 3019553002: [pinpoint] Gerrit patch support. (Closed)
Patch Set: Example URL Created 3 years, 2 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
OLDNEW
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 unittest 5 import unittest
6 6
7 import mock 7 import mock
8 8
9 from google.appengine.ext import ndb 9 from google.appengine.ext import ndb
10 from google.appengine.ext import testbed 10 from google.appengine.ext import testbed
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 def testUnknownBuilder(self): 107 def testUnknownBuilder(self):
108 with self.assertRaises(NotImplementedError): 108 with self.assertRaises(NotImplementedError):
109 find_isolate.FindIsolate('Unix Perf', 'telemetry_perf_tests') 109 find_isolate.FindIsolate('Unix Perf', 'telemetry_perf_tests')
110 110
111 111
112 @mock.patch('dashboard.services.buildbucket_service.GetJobStatus') 112 @mock.patch('dashboard.services.buildbucket_service.GetJobStatus')
113 @mock.patch('dashboard.services.buildbucket_service.Put') 113 @mock.patch('dashboard.services.buildbucket_service.Put')
114 class BuildTest(_FindIsolateTest): 114 class BuildTest(_FindIsolateTest):
115 115
116 def testBuildLifecycle(self, put, get_job_status): 116 @mock.patch.object(change_module.GerritPatch, 'BuildParameters')
117 def testBuildLifecycle(self, build_parameters, put, get_job_status):
117 change = change_module.Change( 118 change = change_module.Change(
118 (change_module.Commit('src', 'base git hash'), 119 (change_module.Commit('src', 'base git hash'),
119 change_module.Commit('v8', 'dep git hash')), 120 change_module.Commit('v8', 'dep git hash')),
120 patch=change_module.Patch('https://example.org', 2565263002, 20001)) 121 patch=change_module.GerritPatch('https://example.org', 672011, '2f0d'))
121 quest = find_isolate.FindIsolate('Mac Pro Perf', 'telemetry_perf_tests') 122 quest = find_isolate.FindIsolate('Mac Pro Perf', 'telemetry_perf_tests')
122 execution = quest.Start(change) 123 execution = quest.Start(change)
123 124
124 # Request a build. 125 # Request a build.
126 build_parameters.return_value = {'patch_storage': 'gerrit'}
125 put.return_value = {'build': {'id': 'build_id'}} 127 put.return_value = {'build': {'id': 'build_id'}}
126 execution.Poll() 128 execution.Poll()
127 129
128 self.assertFalse(execution.completed) 130 self.assertFalse(execution.completed)
129 put.assert_called_once_with(find_isolate.BUCKET, { 131 put.assert_called_once_with(find_isolate.BUCKET, {
130 'builder_name': 'Mac Builder', 132 'builder_name': 'Mac Builder',
131 'properties': { 133 'properties': {
132 'clobber': True, 134 'clobber': True,
133 'parent_got_revision': 'base git hash', 135 'parent_got_revision': 'base git hash',
134 'deps_revision_overrides': { 136 'deps_revision_overrides': {
135 'https://chromium.googlesource.com/v8/v8': 'dep git hash', 137 'https://chromium.googlesource.com/v8/v8': 'dep git hash',
136 }, 138 },
137 'patch_storage': 'rietveld', 139 'patch_storage': 'gerrit',
138 'rietveld': 'https://example.org',
139 'issue': 2565263002,
140 'patchset': 20001,
141 } 140 }
142 }) 141 })
143 142
144 # Check build status. 143 # Check build status.
145 get_job_status.return_value = {'build': {'status': 'STARTED'}} 144 get_job_status.return_value = {'build': {'status': 'STARTED'}}
146 execution.Poll() 145 execution.Poll()
147 146
148 self.assertFalse(execution.completed) 147 self.assertFalse(execution.completed)
149 get_job_status.assert_called_once_with('build_id') 148 get_job_status.assert_called_once_with('build_id')
150 149
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 isolate.Put((('Mac Builder', change, 185 isolate.Put((('Mac Builder', change,
187 'telemetry_perf_tests', 'isolate git hash'),)) 186 'telemetry_perf_tests', 'isolate git hash'),))
188 execution_1.Poll() 187 execution_1.Poll()
189 execution_2.Poll() 188 execution_2.Poll()
190 189
191 self.assertExecutionSuccess(execution_1) 190 self.assertExecutionSuccess(execution_1)
192 self.assertExecutionSuccess(execution_2) 191 self.assertExecutionSuccess(execution_2)
193 192
194 def testBuildFailure(self, put, get_job_status): 193 def testBuildFailure(self, put, get_job_status):
195 change = change_module.Change( 194 change = change_module.Change(
196 (change_module.Commit('src', 'base git hash'), 195 (change_module.Commit('src', 'base git hash'),))
197 change_module.Commit('v8', 'dep git hash')),
198 patch=change_module.Patch('https://example.org', 2565263002, 20001))
199 quest = find_isolate.FindIsolate('Mac Pro Perf', 'telemetry_perf_tests') 196 quest = find_isolate.FindIsolate('Mac Pro Perf', 'telemetry_perf_tests')
200 execution = quest.Start(change) 197 execution = quest.Start(change)
201 198
202 # Request a build. 199 # Request a build.
203 put.return_value = {'build': {'id': 'build_id'}} 200 put.return_value = {'build': {'id': 'build_id'}}
204 execution.Poll() 201 execution.Poll()
205 202
206 # Check build status. 203 # Check build status.
207 get_job_status.return_value = { 204 get_job_status.return_value = {
208 'build': { 205 'build': {
209 'status': 'COMPLETED', 206 'status': 'COMPLETED',
210 'result': 'FAILURE', 207 'result': 'FAILURE',
211 'failure_reason': 'BUILD_FAILURE', 208 'failure_reason': 'BUILD_FAILURE',
212 } 209 }
213 } 210 }
214 execution.Poll() 211 execution.Poll()
215 212
216 self.assertExecutionFailure(execution, find_isolate.BuildError) 213 self.assertExecutionFailure(execution, find_isolate.BuildError)
217 214
218 def testBuildCanceled(self, put, get_job_status): 215 def testBuildCanceled(self, put, get_job_status):
219 change = change_module.Change( 216 change = change_module.Change(
220 (change_module.Commit('src', 'base git hash'), 217 (change_module.Commit('src', 'base git hash'),))
221 change_module.Commit('v8', 'dep git hash')),
222 patch=change_module.Patch('https://example.org', 2565263002, 20001))
223 quest = find_isolate.FindIsolate('Mac Pro Perf', 'telemetry_perf_tests') 218 quest = find_isolate.FindIsolate('Mac Pro Perf', 'telemetry_perf_tests')
224 execution = quest.Start(change) 219 execution = quest.Start(change)
225 220
226 # Request a build. 221 # Request a build.
227 put.return_value = {'build': {'id': 'build_id'}} 222 put.return_value = {'build': {'id': 'build_id'}}
228 execution.Poll() 223 execution.Poll()
229 224
230 # Check build status. 225 # Check build status.
231 get_job_status.return_value = { 226 get_job_status.return_value = {
232 'build': { 227 'build': {
233 'status': 'COMPLETED', 228 'status': 'COMPLETED',
234 'result': 'CANCELED', 229 'result': 'CANCELED',
235 'cancelation_reason': 'TIMEOUT', 230 'cancelation_reason': 'TIMEOUT',
236 } 231 }
237 } 232 }
238 execution.Poll() 233 execution.Poll()
239 234
240 self.assertExecutionFailure(execution, find_isolate.BuildError) 235 self.assertExecutionFailure(execution, find_isolate.BuildError)
241 236
242 def testBuildSucceededButIsolateIsMissing(self, put, get_job_status): 237 def testBuildSucceededButIsolateIsMissing(self, put, get_job_status):
243 change = change_module.Change( 238 change = change_module.Change(
244 (change_module.Commit('src', 'base git hash'), 239 (change_module.Commit('src', 'base git hash'),))
245 change_module.Commit('v8', 'dep git hash')),
246 patch=change_module.Patch('https://example.org', 2565263002, 20001))
247 quest = find_isolate.FindIsolate('Mac Pro Perf', 'telemetry_perf_tests') 240 quest = find_isolate.FindIsolate('Mac Pro Perf', 'telemetry_perf_tests')
248 execution = quest.Start(change) 241 execution = quest.Start(change)
249 242
250 # Request a build. 243 # Request a build.
251 put.return_value = {'build': {'id': 'build_id'}} 244 put.return_value = {'build': {'id': 'build_id'}}
252 execution.Poll() 245 execution.Poll()
253 246
254 # Check build status. 247 # Check build status.
255 get_job_status.return_value = { 248 get_job_status.return_value = {
256 'build': { 249 'build': {
257 'status': 'COMPLETED', 250 'status': 'COMPLETED',
258 'result': 'SUCCESS', 251 'result': 'SUCCESS',
259 } 252 }
260 } 253 }
261 execution.Poll() 254 execution.Poll()
262 255
263 self.assertExecutionFailure(execution, find_isolate.BuildError) 256 self.assertExecutionFailure(execution, find_isolate.BuildError)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698