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

Side by Side Diff: appengine/findit/waterfall/test/monitor_try_job_pipeline_test.py

Issue 2187763004: [Findit] Refactor Findit pipeline. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: rebase Created 4 years, 4 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 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 from datetime import datetime 5 from datetime import datetime
6 import json 6 import json
7 import time 7 import time
8 8
9 from common.waterfall import buildbucket_client 9 from common.waterfall import buildbucket_client
10 from common.waterfall import failure_type
10 from common.waterfall import try_job_error 11 from common.waterfall import try_job_error
11 from model import analysis_status 12 from model import analysis_status
12 from model.wf_try_job import WfTryJob 13 from model.wf_try_job import WfTryJob
13 from model.wf_try_job_data import WfTryJobData 14 from model.wf_try_job_data import WfTryJobData
14 from waterfall import monitor_try_job_pipeline 15 from waterfall import monitor_try_job_pipeline
15 from waterfall import waterfall_config 16 from waterfall import waterfall_config
16 from waterfall.monitor_try_job_pipeline import MonitorTryJobPipeline 17 from waterfall.monitor_try_job_pipeline import MonitorTryJobPipeline
17 from waterfall.test import wf_testcase 18 from waterfall.test import wf_testcase
18 from waterfall.try_job_type import TryJobType
19 19
20 20
21 # A counter to enable different responses to requests in a loop. 21 # A counter to enable different responses to requests in a loop.
22 REQUEST_COUNTER = { 22 REQUEST_COUNTER = {
23 '1': 0, 23 '1': 0,
24 '2': 0, 24 '2': 0,
25 '3': 0 25 '3': 0
26 } 26 }
27 27
28 28
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 'url': 'url', 209 'url': 'url',
210 'try_job_id': '1', 210 'try_job_id': '1',
211 } 211 }
212 ] 212 ]
213 try_job.status = analysis_status.RUNNING 213 try_job.status = analysis_status.RUNNING
214 try_job.put() 214 try_job.put()
215 self._MockGetTryJobs(try_job_id) 215 self._MockGetTryJobs(try_job_id)
216 216
217 pipeline = MonitorTryJobPipeline() 217 pipeline = MonitorTryJobPipeline()
218 compile_result = pipeline.run( 218 compile_result = pipeline.run(
219 master_name, builder_name, build_number, TryJobType.COMPILE, 219 master_name, builder_name, build_number, failure_type.COMPILE,
220 try_job_id) 220 try_job_id)
221 221
222 expected_compile_result = { 222 expected_compile_result = {
223 'report': { 223 'report': {
224 'result': { 224 'result': {
225 'rev1': 'passed', 225 'rev1': 'passed',
226 'rev2': 'failed' 226 'rev2': 'failed'
227 }, 227 },
228 'metadata': { 228 'metadata': {
229 'regression_range_size': regression_range_size 229 'regression_range_size': regression_range_size
(...skipping 29 matching lines...) Expand all
259 try_job.status = analysis_status.RUNNING 259 try_job.status = analysis_status.RUNNING
260 try_job.put() 260 try_job.put()
261 261
262 try_job_data = WfTryJobData.Create(try_job_id) 262 try_job_data = WfTryJobData.Create(try_job_id)
263 try_job_data.put() 263 try_job_data.put()
264 264
265 self._MockGetTryJobs(try_job_id) 265 self._MockGetTryJobs(try_job_id)
266 266
267 pipeline = MonitorTryJobPipeline() 267 pipeline = MonitorTryJobPipeline()
268 test_result = pipeline.run( 268 test_result = pipeline.run(
269 master_name, builder_name, build_number, TryJobType.TEST, 269 master_name, builder_name, build_number, failure_type.TEST,
270 try_job_id) 270 try_job_id)
271 271
272 expected_test_result = { 272 expected_test_result = {
273 'report': { 273 'report': {
274 'result': { 274 'result': {
275 'rev1': { 275 'rev1': {
276 'a_test': { 276 'a_test': {
277 'status': 'passed', 277 'status': 'passed',
278 'valid': True 278 'valid': True
279 } 279 }
(...skipping 20 matching lines...) Expand all
300 master_name = 'm' 300 master_name = 'm'
301 builder_name = 'b' 301 builder_name = 'b'
302 build_number = 1 302 build_number = 1
303 try_job_id = '3' 303 try_job_id = '3'
304 304
305 try_job = WfTryJob.Create(master_name, builder_name, build_number).put() 305 try_job = WfTryJob.Create(master_name, builder_name, build_number).put()
306 306
307 pipeline = MonitorTryJobPipeline() 307 pipeline = MonitorTryJobPipeline()
308 pipeline._UpdateTryJobResult( 308 pipeline._UpdateTryJobResult(
309 buildbucket_client.BuildbucketBuild.STARTED, master_name, builder_name, 309 buildbucket_client.BuildbucketBuild.STARTED, master_name, builder_name,
310 build_number, TryJobType.TEST, try_job_id, 'url') 310 build_number, failure_type.TEST, try_job_id, 'url')
311 try_job = WfTryJob.Get(master_name, builder_name, build_number) 311 try_job = WfTryJob.Get(master_name, builder_name, build_number)
312 self.assertEqual(analysis_status.RUNNING, try_job.status) 312 self.assertEqual(analysis_status.RUNNING, try_job.status)
313 313
314 def testGetErrorForNoError(self): 314 def testGetErrorForNoError(self):
315 build_response = { 315 build_response = {
316 'id': 1, 316 'id': 1,
317 'url': 'url', 317 'url': 'url',
318 'status': 'COMPLETED', 318 'status': 'COMPLETED',
319 'completed_ts': '1454367574000000', 319 'completed_ts': '1454367574000000',
320 'created_ts': '1454367570000000', 320 'created_ts': '1454367570000000',
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 462 }
463 463
464 expected_error_dict = { 464 expected_error_dict = {
465 'message': 'No result report was found.', 465 'message': 'No result report was found.',
466 'reason': MonitorTryJobPipeline.UNKNOWN 466 'reason': MonitorTryJobPipeline.UNKNOWN
467 } 467 }
468 468
469 self.assertEqual( 469 self.assertEqual(
470 monitor_try_job_pipeline._GetError(build_response, None, False), 470 monitor_try_job_pipeline._GetError(build_response, None, False),
471 (expected_error_dict, try_job_error.UNKNOWN)) 471 (expected_error_dict, try_job_error.UNKNOWN))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698