Chromium Code Reviews| 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 import json | 5 import json |
| 6 | 6 |
| 7 from recipe_engine.config import List | 7 from recipe_engine.config import List |
| 8 from recipe_engine.config import Single | 8 from recipe_engine.config import Single |
| 9 from recipe_engine.recipe_api import Property | 9 from recipe_engine.recipe_api import Property |
| 10 | 10 |
| 11 | 11 |
| 12 DEPS = [ | 12 DEPS = [ |
| 13 'buildbucket', | |
| 13 'chromium', | 14 'chromium', |
| 14 'chromium_tests', | 15 'chromium_tests', |
| 15 'findit', | 16 'findit', |
| 16 'depot_tools/gclient', | 17 'depot_tools/gclient', |
| 17 'recipe_engine/json', | 18 'recipe_engine/json', |
| 18 'recipe_engine/path', | 19 'recipe_engine/path', |
| 19 'recipe_engine/platform', | 20 'recipe_engine/platform', |
| 20 'recipe_engine/properties', | 21 'recipe_engine/properties', |
| 21 'recipe_engine/python', | 22 'recipe_engine/python', |
| 22 'recipe_engine/raw_io', | 23 'recipe_engine/raw_io', |
| 23 'recipe_engine/step', | 24 'recipe_engine/step', |
| 24 ] | 25 ] |
| 25 | 26 |
| 26 | 27 |
| 27 PROPERTIES = { | 28 PROPERTIES = { |
| 28 'target_mastername': Property( | 29 'target_mastername': Property( |
| 29 kind=str, help='The target master to match compile config to.'), | 30 kind=str, help='The target master to match compile config to.'), |
| 30 'target_buildername': Property( | 31 'target_buildername': Property( |
| 31 kind=str, help='The target builder to match compile config to.'), | 32 kind=str, help='The target builder to match compile config to.'), |
| 32 'good_revision': Property( | 33 'good_revision': Property( |
| 33 kind=str, help='The last known good chromium revision.'), | 34 kind=str, help='The last known good chromium revision.'), |
| 34 'bad_revision': Property( | 35 'bad_revision': Property( |
| 35 kind=str, help='The first known bad chromium revision.'), | 36 kind=str, help='The first known bad chromium revision.'), |
| 36 'compile_targets': Property( | 37 'compile_targets': Property( |
| 37 kind=List(basestring), default=None, | 38 kind=List(basestring), default=None, |
| 38 help='The failed compile targets, eg: browser_tests, ' | 39 help='The failed compile targets, eg: browser_tests, ' |
| 39 'obj/path/to/source.o, gen/path/to/generated.cc, etc.'), | 40 'obj/path/to/source.o, gen/path/to/generated.cc, etc.'), |
| 41 'buildbucket': Property( | |
| 42 default=None, | |
| 43 help='The buildbucket property in which we can find build id. ' | |
| 44 'We need to use build id to get compile_targets.'), | |
| 40 'use_analyze': Property( | 45 'use_analyze': Property( |
| 41 kind=Single(bool, empty_val=False, required=False), default=True, | 46 kind=Single(bool, empty_val=False, required=False), default=True, |
| 42 help='Use analyze to filter out affected targets.'), | 47 help='Use analyze to filter out affected targets.'), |
| 43 'suspected_revisions': Property( | 48 'suspected_revisions': Property( |
| 44 kind=List(basestring), default=[], | 49 kind=List(basestring), default=[], |
| 45 help='A list of suspected revisions from heuristic analysis.'), | 50 help='A list of suspected revisions from heuristic analysis.'), |
| 46 'use_bisect': Property( | 51 'use_bisect': Property( |
| 47 kind=Single(bool, empty_val=False, required=False), default=True, | 52 kind=Single(bool, empty_val=False, required=False), default=True, |
| 48 help='Use bisect to skip more revisions. ' | 53 help='Use bisect to skip more revisions. ' |
| 49 'Effective only when compile_targets is given.'), | 54 'Effective only when compile_targets is given.'), |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 mb_buildername=target_buildername, | 113 mb_buildername=target_buildername, |
| 109 override_bot_type='builder_tester') | 114 override_bot_type='builder_tester') |
| 110 return CompileResult.PASSED | 115 return CompileResult.PASSED |
| 111 except api.step.InfraFailure: | 116 except api.step.InfraFailure: |
| 112 raise | 117 raise |
| 113 except api.step.StepFailure: | 118 except api.step.StepFailure: |
| 114 return CompileResult.FAILED | 119 return CompileResult.FAILED |
| 115 | 120 |
| 116 | 121 |
| 117 def RunSteps(api, target_mastername, target_buildername, | 122 def RunSteps(api, target_mastername, target_buildername, |
| 118 good_revision, bad_revision, | 123 good_revision, bad_revision, compile_targets, |
| 119 compile_targets, use_analyze, suspected_revisions, use_bisect): | 124 buildbucket, use_analyze, suspected_revisions, use_bisect): |
| 125 if not compile_targets: | |
| 126 # compile_targets should be saved in build parameter in this case. | |
|
stgao
2016/06/21 05:43:16
nit: It might not be set though if no ninja output
chanli
2016/06/21 21:51:19
Done.
| |
| 127 buildbucket_json = json.loads(buildbucket) | |
| 128 build_id = buildbucket_json['build']['id'] | |
| 129 get_build_result = api.buildbucket.get_build(build_id) | |
| 130 compile_targets = json.loads( | |
| 131 get_build_result.stdout['build']['parameters_json']).get( | |
| 132 'additional_build_parameters', {}).get('compile_targets') | |
| 133 | |
| 120 bot_config = api.chromium_tests.create_bot_config_object( | 134 bot_config = api.chromium_tests.create_bot_config_object( |
| 121 target_mastername, target_buildername) | 135 target_mastername, target_buildername) |
| 122 api.chromium_tests.configure_build( | 136 api.chromium_tests.configure_build( |
| 123 bot_config, override_bot_type='builder_tester') | 137 bot_config, override_bot_type='builder_tester') |
| 124 | 138 |
| 125 # Sync to bad revision, and retrieve revisions in the regression range. | 139 # Sync to bad revision, and retrieve revisions in the regression range. |
| 126 api.chromium_tests.prepare_checkout( | 140 api.chromium_tests.prepare_checkout( |
| 127 bot_config, | 141 bot_config, |
| 128 root_solution_revision=bad_revision) | 142 root_solution_revision=bad_revision) |
| 129 | 143 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 # Set the report as a build property too, so that it will be reported back | 301 # Set the report as a build property too, so that it will be reported back |
| 288 # to Buildbucket and Findit will pull from there instead of buildbot master. | 302 # to Buildbucket and Findit will pull from there instead of buildbot master. |
| 289 step_result.presentation.properties['report'] = report | 303 step_result.presentation.properties['report'] = report |
| 290 | 304 |
| 291 return report | 305 return report |
| 292 | 306 |
| 293 | 307 |
| 294 def GenTests(api): | 308 def GenTests(api): |
| 295 def props(compile_targets=None, use_analyze=False, | 309 def props(compile_targets=None, use_analyze=False, |
| 296 good_revision=None, bad_revision=None, | 310 good_revision=None, bad_revision=None, |
| 297 suspected_revisions=None, use_bisect=False): | 311 suspected_revisions=None, use_bisect=False, buildbucket=None): |
| 298 properties = { | 312 properties = { |
| 299 'mastername': 'tryserver.chromium.linux', | 313 'mastername': 'tryserver.chromium.linux', |
| 300 'buildername': 'linux_variable', | 314 'buildername': 'linux_variable', |
| 301 'slavename': 'build1-a1', | 315 'slavename': 'build1-a1', |
| 302 'buildnumber': '1', | 316 'buildnumber': '1', |
| 303 'target_mastername': 'chromium.linux', | 317 'target_mastername': 'chromium.linux', |
| 304 'target_buildername': 'Linux Builder', | 318 'target_buildername': 'Linux Builder', |
| 305 'good_revision': good_revision or 'r0', | 319 'good_revision': good_revision or 'r0', |
| 306 'bad_revision': bad_revision or 'r1', | 320 'bad_revision': bad_revision or 'r1', |
| 307 'use_analyze': use_analyze, | 321 'use_analyze': use_analyze, |
| 308 'use_bisect': use_bisect, | 322 'use_bisect': use_bisect, |
| 309 } | 323 } |
| 310 if compile_targets: | 324 if compile_targets: |
| 311 properties['compile_targets'] = compile_targets | 325 properties['compile_targets'] = compile_targets |
| 312 if suspected_revisions: | 326 if suspected_revisions: |
| 313 properties['suspected_revisions'] = suspected_revisions | 327 properties['suspected_revisions'] = suspected_revisions |
| 328 if buildbucket: | |
| 329 properties['buildbucket'] = buildbucket | |
| 314 return api.properties(**properties) + api.platform.name('linux') | 330 return api.properties(**properties) + api.platform.name('linux') |
| 315 | 331 |
| 332 def simulated_buildbucket_output(additional_build_parameters): | |
| 333 buildbucket_output = { | |
| 334 'build':{ | |
| 335 'parameters_json': json.dumps(additional_build_parameters) | |
| 336 } | |
| 337 } | |
| 338 | |
| 339 return api.buildbucket.step_data( | |
| 340 'buildbucket.get', | |
| 341 stdout=api.raw_io.output(json.dumps(buildbucket_output))) | |
| 342 | |
| 316 yield ( | 343 yield ( |
| 317 api.test('compile_specified_targets') + | 344 api.test('compile_specified_targets') + |
| 318 props(compile_targets=['target_name']) + | 345 props(compile_targets=['target_name']) + |
| 319 api.override_step_data('test r1.check_targets', | 346 api.override_step_data('test r1.check_targets', |
| 320 api.json.output({ | 347 api.json.output({ |
| 321 'found': ['target_name'], | 348 'found': ['target_name'], |
| 322 'not_found': [], | 349 'not_found': [], |
| 323 })) | 350 })) |
| 324 ) | 351 ) |
| 325 | 352 |
| 326 yield ( | 353 yield ( |
| 354 api.test('compile_specified_targets_from_parameter') + | |
| 355 props(buildbucket=json.dumps({'build': {'id': 'id1'}})) + | |
| 356 simulated_buildbucket_output({ | |
| 357 'additional_build_parameters': { | |
| 358 'compile_targets': ['target_name'] | |
| 359 }}) + | |
| 360 api.override_step_data('test r1.check_targets', | |
| 361 api.json.output({ | |
| 362 'found': ['target_name'], | |
| 363 'not_found': [], | |
| 364 })) | |
| 365 ) | |
| 366 | |
| 367 yield ( | |
| 327 api.test('compile_none_existing_targets') + | 368 api.test('compile_none_existing_targets') + |
| 328 props(compile_targets=['gen/a/b/source.cc']) + | 369 props(compile_targets=['gen/a/b/source.cc']) + |
| 329 api.override_step_data('test r1.check_targets', | 370 api.override_step_data('test r1.check_targets', |
| 330 api.json.output({ | 371 api.json.output({ |
| 331 'found': [], | 372 'found': [], |
| 332 'not_found': ['gen/a/b/source.cc'], | 373 'not_found': ['gen/a/b/source.cc'], |
| 333 })) | 374 })) |
| 334 ) | 375 ) |
| 335 | 376 |
| 336 | 377 |
| 337 yield ( | 378 yield ( |
| 338 api.test('compile_default_targets') + | 379 api.test('compile_default_targets') + |
| 339 props() + | 380 props(buildbucket=json.dumps({'build': {'id': 'id1'}})) + |
| 381 simulated_buildbucket_output({ | |
| 382 'additional_build_parameters': { | |
| 383 'compile_targets': None | |
| 384 }}) + | |
| 340 api.override_step_data('test r1.read test spec', | 385 api.override_step_data('test r1.read test spec', |
| 341 api.json.output({ | 386 api.json.output({ |
| 342 'Linux Builder': { | 387 'Linux Builder': { |
| 343 'additional_compile_targets': [ | 388 'additional_compile_targets': [ |
| 344 'base_unittests', | 389 'base_unittests', |
| 345 ], | 390 ], |
| 346 } | 391 } |
| 347 })) | 392 })) |
| 348 ) | 393 ) |
| 349 | 394 |
| 350 yield ( | 395 yield ( |
| 351 api.test('compile_succeeded') + | 396 api.test('compile_succeeded') + |
| 352 props() + | 397 props(buildbucket=json.dumps({'build': {'id': 'id1'}})) + |
| 398 simulated_buildbucket_output({}) + | |
| 353 api.override_step_data('test r1.compile', retcode=0) | 399 api.override_step_data('test r1.compile', retcode=0) |
| 354 ) | 400 ) |
| 355 | 401 |
| 356 yield ( | 402 yield ( |
| 357 api.test('compile_failed') + | 403 api.test('compile_failed') + |
| 358 props() + | 404 props(buildbucket=json.dumps({'build': {'id': 'id1'}})) + |
| 405 simulated_buildbucket_output({}) + | |
| 359 api.override_step_data('test r1.compile', retcode=1) | 406 api.override_step_data('test r1.compile', retcode=1) |
| 360 ) | 407 ) |
| 361 | 408 |
| 362 yield ( | 409 yield ( |
| 363 api.test('failed_compile_upon_infra_failure_goma_setup_failure') + | 410 api.test('failed_compile_upon_infra_failure_goma_setup_failure') + |
| 364 props(compile_targets=['target_name']) + | 411 props(compile_targets=['target_name']) + |
| 365 api.override_step_data('test r1.check_targets', | 412 api.override_step_data('test r1.check_targets', |
| 366 api.json.output({ | 413 api.json.output({ |
| 367 'found': ['target_name'], | 414 'found': ['target_name'], |
| 368 'not_found': [], | 415 'not_found': [], |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 'num_user_error': 1, | 466 'num_user_error': 1, |
| 420 }, | 467 }, |
| 421 }, | 468 }, |
| 422 ], | 469 ], |
| 423 }), | 470 }), |
| 424 retcode=1) | 471 retcode=1) |
| 425 ) | 472 ) |
| 426 | 473 |
| 427 yield ( | 474 yield ( |
| 428 api.test('compile_skipped') + | 475 api.test('compile_skipped') + |
| 429 props(use_analyze=True) + | 476 props(use_analyze=True, |
| 477 buildbucket=json.dumps({'build': {'id': 'id1'}})) + | |
| 478 simulated_buildbucket_output({}) + | |
| 430 api.override_step_data( | 479 api.override_step_data( |
| 431 'test r1.analyze', | 480 'test r1.analyze', |
| 432 api.json.output({ | 481 api.json.output({ |
| 433 'status': 'No dependencies', | 482 'status': 'No dependencies', |
| 434 'compile_targets': [], | 483 'compile_targets': [], |
| 435 'test_targets': [], | 484 'test_targets': [], |
| 436 }) | 485 }) |
| 437 ) | 486 ) |
| 438 ) | 487 ) |
| 439 | 488 |
| 440 yield ( | 489 yield ( |
| 441 api.test('compile_affected_targets_only') + | 490 api.test('compile_affected_targets_only') + |
| 442 props(use_analyze=True) + | 491 props(use_analyze=True, |
| 492 buildbucket=json.dumps({'build': {'id': 'id1'}})) + | |
| 493 simulated_buildbucket_output({}) + | |
| 443 api.override_step_data('test r1.read test spec', | 494 api.override_step_data('test r1.read test spec', |
| 444 api.json.output({ | 495 api.json.output({ |
| 445 'Linux Builder': { | 496 'Linux Builder': { |
| 446 'additional_compile_targets': [ | 497 'additional_compile_targets': [ |
| 447 'a', 'a_run', | 498 'a', 'a_run', |
| 448 'b', 'b_run', | 499 'b', 'b_run', |
| 449 ], | 500 ], |
| 450 } | 501 } |
| 451 })) + | 502 })) + |
| 452 api.override_step_data( | 503 api.override_step_data( |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 'found': ['target_name'], | 679 'found': ['target_name'], |
| 629 'not_found': [], | 680 'not_found': [], |
| 630 })) + | 681 })) + |
| 631 api.override_step_data('test r5.check_targets', | 682 api.override_step_data('test r5.check_targets', |
| 632 api.json.output({ | 683 api.json.output({ |
| 633 'found': ['target_name'], | 684 'found': ['target_name'], |
| 634 'not_found': [], | 685 'not_found': [], |
| 635 })) + | 686 })) + |
| 636 api.override_step_data('test r5.compile', retcode=1) | 687 api.override_step_data('test r5.compile', retcode=1) |
| 637 ) | 688 ) |
| OLD | NEW |