| # Copyright 2021 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| from recipe_engine.recipe_api import Property |
| |
| DEPS = [ |
| "fuchsia/autocorrelator", |
| "fuchsia/buildbucket_util", |
| "recipe_engine/properties", |
| "recipe_engine/runtime", |
| "recipe_engine/step", |
| ] |
| |
| PROPERTIES = { |
| "step_status": Property(kind=str, help="Status of the wrapped step", default=None), |
| } |
| |
| |
| def RunSteps(api, step_status): |
| with api.autocorrelator.context( |
| ci_base_commit="foo", |
| ignore_failed_build=True, |
| ignore_skipped_build=True, |
| ignore_skipped_tests=True, |
| ): |
| api.step.empty("wrapped step", status=step_status or api.step.FAILURE) |
| |
| |
| def GenTests(api): |
| check_ci_test_data = { |
| "build_id": "123", |
| "score": 0.97, |
| "commit_dist": 1, |
| "is_green": False, |
| } |
| check_try_test_data = [ |
| {"build_id": "456", "score": 0.98, "is_green": False}, |
| {"build_id": "789", "score": 0.0, "is_green": True}, |
| {"build_id": "987", "score": 0.96, "is_green": False}, |
| {"build_id": "654", "score": 0.99, "is_green": False}, |
| ] |
| |
| yield ( |
| api.buildbucket_util.test("basic", tryjob=True, status="failure") |
| + api.properties( |
| **{"$fuchsia/autocorrelator": {"ci_bucket": "ci", "ci_builder": "foo.x64"}} |
| ) |
| + api.autocorrelator.check_ci(check_ci_test_data) |
| + api.autocorrelator.check_try(check_try_test_data) |
| ) |
| |
| yield ( |
| api.buildbucket_util.test( |
| "build_cancelled", |
| tryjob=True, |
| # Technically the build's status should be cancelled, not |
| # infra-failed, cancellations are mapped to infra failures during |
| # recipe testing. |
| status="infra_failure", |
| ) |
| + api.step_data("wrapped step", cancel=True) |
| + api.runtime.global_shutdown_on_step("wrapped step") |
| ) |
| |
| yield ( |
| api.buildbucket_util.test("skip_ci", tryjob=True, status="infra_failure") |
| + api.properties(step_status="EXCEPTION") # Cover infra failure path. |
| + api.autocorrelator.check_try(check_try_test_data) |
| ) |
| |
| yield ( |
| api.buildbucket_util.test("warning_step", tryjob=True, status="failure") |
| + api.properties(step_status="WARNING") # Cover warning path. |
| + api.autocorrelator.check_try(check_try_test_data) |
| ) |
| |
| yield ( |
| api.buildbucket_util.test("no_findings", tryjob=True, status="failure") |
| + api.properties( |
| **{"$fuchsia/autocorrelator": {"ci_bucket": "ci", "ci_builder": "foo.x64"}} |
| ) |
| + api.autocorrelator.check_ci(None) |
| + api.autocorrelator.check_try(None) |
| ) |
| yield api.buildbucket_util.test( |
| "try_no_changes", tryjob=True, gerrit_changes=[], status="failure" |
| ) |