| 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 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 try_job_error | 10 from common.waterfall import try_job_error |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 'message': 'Buildbucket reported an error.', | 380 'message': 'Buildbucket reported an error.', |
| 381 'reason': MonitorTryJobPipeline.UNKNOWN | 381 'reason': MonitorTryJobPipeline.UNKNOWN |
| 382 } | 382 } |
| 383 | 383 |
| 384 self.assertEqual( | 384 self.assertEqual( |
| 385 MonitorTryJobPipeline._GetError(build_response, None, False), | 385 MonitorTryJobPipeline._GetError(build_response, None, False), |
| 386 (expected_error_dict, try_job_error.CI_REPORTED_ERROR)) | 386 (expected_error_dict, try_job_error.CI_REPORTED_ERROR)) |
| 387 | 387 |
| 388 def testGetErrorInfraFailure(self): | 388 def testGetErrorInfraFailure(self): |
| 389 build_response = { | 389 build_response = { |
| 390 'result': 'FAILED', |
| 391 'failure_reason': 'INFRA_FAILURE', |
| 390 'result_details_json': json.dumps({ | 392 'result_details_json': json.dumps({ |
| 391 'properties': { | 393 'properties': { |
| 392 'report': { | 394 'report': { |
| 393 'metadata': { | 395 'metadata': { |
| 394 'infra_failure': True | 396 'infra_failure': True |
| 395 } | 397 } |
| 396 } | 398 } |
| 397 } | 399 } |
| 398 }) | 400 }) |
| 399 } | 401 } |
| 400 | 402 |
| 401 expected_error_dict = { | 403 expected_error_dict = { |
| 402 'message': 'Try job encountered an infra issue during execution.', | 404 'message': 'Try job encountered an infra issue during execution.', |
| 403 'reason': MonitorTryJobPipeline.UNKNOWN | 405 'reason': MonitorTryJobPipeline.UNKNOWN |
| 404 } | 406 } |
| 405 | 407 |
| 406 self.assertEqual( | 408 self.assertEqual( |
| 407 MonitorTryJobPipeline._GetError(build_response, None, False), | 409 MonitorTryJobPipeline._GetError(build_response, None, False), |
| 408 (expected_error_dict, try_job_error.INFRA_FAILURE)) | 410 (expected_error_dict, try_job_error.INFRA_FAILURE)) |
| 409 | 411 |
| 412 def testGetErrorUnexpectedBuildFailure(self): |
| 413 build_response = { |
| 414 'result': 'FAILED', |
| 415 'failure_reason': 'BUILD_FAILURE', |
| 416 'result_details_json': json.dumps({ |
| 417 'properties': { |
| 418 'report': { |
| 419 'metadata': { |
| 420 'infra_failure': True |
| 421 } |
| 422 } |
| 423 } |
| 424 }) |
| 425 } |
| 426 |
| 427 expected_error_dict = { |
| 428 'message': 'Compile failed unexpectedly.', |
| 429 'reason': MonitorTryJobPipeline.UNKNOWN |
| 430 } |
| 431 |
| 432 self.assertEqual( |
| 433 MonitorTryJobPipeline._GetError(build_response, None, False), |
| 434 (expected_error_dict, try_job_error.INFRA_FAILURE)) |
| 435 |
| 436 def testGetErrorUnknownBuildbucketFailure(self): |
| 437 build_response = { |
| 438 'result': 'FAILED', |
| 439 'failure_reason': 'SOME_FAILURE', |
| 440 'result_details_json': json.dumps({ |
| 441 'properties': { |
| 442 'report': {} |
| 443 } |
| 444 }) |
| 445 } |
| 446 |
| 447 expected_error_dict = { |
| 448 'message': 'SOME_FAILURE', |
| 449 'reason': MonitorTryJobPipeline.UNKNOWN |
| 450 } |
| 451 |
| 452 self.assertEqual( |
| 453 MonitorTryJobPipeline._GetError(build_response, None, False), |
| 454 (expected_error_dict, try_job_error.UNKNOWN)) |
| 455 |
| 410 def testGetErrorReportMissing(self): | 456 def testGetErrorReportMissing(self): |
| 411 build_response = { | 457 build_response = { |
| 412 'result_details_json': json.dumps({ | 458 'result_details_json': json.dumps({ |
| 413 'properties': {} | 459 'properties': {} |
| 414 }) | 460 }) |
| 415 } | 461 } |
| 416 | 462 |
| 417 expected_error_dict = { | 463 expected_error_dict = { |
| 418 'message': 'No result report was found.', | 464 'message': 'No result report was found.', |
| 419 'reason': MonitorTryJobPipeline.UNKNOWN | 465 'reason': MonitorTryJobPipeline.UNKNOWN |
| 420 } | 466 } |
| 421 | 467 |
| 422 self.assertEqual( | 468 self.assertEqual( |
| 423 MonitorTryJobPipeline._GetError(build_response, None, False), | 469 MonitorTryJobPipeline._GetError(build_response, None, False), |
| 424 (expected_error_dict, try_job_error.UNKNOWN)) | 470 (expected_error_dict, try_job_error.UNKNOWN)) |
| OLD | NEW |