| # Copyright 2020 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. |
| """API for recipe_engine testing.""" |
| |
| import datetime |
| |
| DEPS = [ |
| "fuchsia/commit_queue", |
| "fuchsia/recipe_testing", |
| "fuchsia/status_check", |
| "fuchsia/swarming_retry", |
| "recipe_engine/path", |
| "recipe_engine/properties", |
| "recipe_engine/swarming", |
| ] |
| |
| ONE_DAY = int(datetime.timedelta(days=1).total_seconds()) |
| MAX_BUILD_AGE_SECONDS = int(datetime.timedelta(days=28).total_seconds()) |
| |
| |
| def RunSteps(api): # pylint: disable=invalid-name |
| recipes_path = api.path["start_dir"].join("recipe_path") |
| |
| api.recipe_testing.run_lint(recipes_path, whitelist=r"allowed_module") |
| api.recipe_testing.run_unit_tests(recipes_path) |
| |
| selftest_cl = "https://fuchsia-review.googlesource.com/c/fuchsia/+/123456" |
| api.recipe_testing.run_led_tests(recipes_path, selftest_cl) |
| |
| |
| def GenTests(api): # pylint: disable=invalid-name |
| |
| test = api.recipe_testing |
| |
| yield ( |
| api.status_check.test("recursive_ls") |
| + api.commit_queue.test_data("empty") |
| + test.affected_recipes_data( |
| affected_recipes=[], |
| recipe_files=["fuchsia/fuchsia.py", "abc.resources/bar.py", "abc.py"], |
| ) |
| ) |
| |
| yield ( |
| api.status_check.test("recipes_cfg") |
| + api.commit_queue.test_data("empty") |
| + test.affected_recipes_data( |
| affected_recipes=[], |
| recipe_files=["a.py", "b.py", "c.py", "d.py", "e.py"], |
| changed_files=["infra/config/recipes.cfg"], |
| ) |
| ) |
| |
| yield ( |
| api.status_check.test("recipe_proto") |
| + api.commit_queue.test_data() |
| + test.affected_recipes_data( |
| affected_recipes=[], changed_files=["recipe_proto/infra/fuchsia.proto"], |
| ) |
| ) |
| |
| yield ( |
| api.status_check.test("no_build_old_build_ignored_build") |
| + api.commit_queue.test_data() |
| + test.affected_recipes_data(["fuchsia"]) |
| + test.build_data( |
| "fuchsia/try/cobalt-x64-linux", |
| "cobalt", |
| age_seconds=MAX_BUILD_AGE_SECONDS - ONE_DAY, |
| skip=True, |
| ) |
| + test.build_data( |
| "fuchsia/try/fuchsia-x64-debug", |
| "fuchsia", |
| age_seconds=MAX_BUILD_AGE_SECONDS + ONE_DAY, |
| ) |
| + test.no_build("fuchsia/try/fuchsia-arm64-debug") |
| ) |
| |
| yield ( |
| api.status_check.test("two_pass_one_skip") |
| + api.commit_queue.test_data() |
| + test.affected_recipes_data(["fuchsia"]) |
| + test.build_data("fuchsia/try/cobalt-x64-linux", "cobalt", skip=True) |
| + test.build_data("fuchsia/try/fuchsia-x64-debug", "fuchsia", |
| cl_cached=True, fake_id=100) |
| + test.build_data("fuchsia/try/fuchsia-arm64-debug", "fuchsia", fake_id=200) |
| + api.swarming_retry.collect_data( |
| [ |
| test.task_result(100, "fuchsia/try/fuchsia-x64-debug"), |
| test.task_result(200, "fuchsia/try/fuchsia-arm64-debug"), |
| ] |
| ) |
| ) |
| |
| yield ( |
| api.status_check.test("fuchsia_recipe_unaffected") |
| + api.commit_queue.test_data() |
| + test.affected_recipes_data(["qemu"]) |
| + test.build_data("fuchsia/try/cobalt-x64-linux", "cobalt", skip=True) |
| + test.build_data("fuchsia/try/fuchsia-x64-debug", "fuchsia", skip=True) |
| + test.build_data("fuchsia/try/fuchsia-arm64-debug", "fuchsia", skip=True) |
| ) |
| |
| yield ( |
| api.status_check.test("recipes") |
| + api.commit_queue.test_data("recipes-only") |
| + test.affected_recipes_data(["recipes"]) |
| + test.build_data("fuchsia/try/recipes", "recipes") |
| + api.swarming_retry.collect_data( |
| [test.task_result(100, "fuchsia/try/recipes")] |
| ) |
| ) |
| |
| yield ( |
| api.status_check.test("no_latest_cl") |
| + api.commit_queue.test_data() |
| + test.affected_recipes_data(["fuchsia"]) |
| + test.build_data("fuchsia/try/fuchsia-x64-debug", "fuchsia", cl_cached=True) |
| + test.build_data( |
| "fuchsia/try/fuchsia-arm64-debug", "fuchsia", num_log_entries=0, |
| fake_id=200, |
| ) |
| + api.swarming_retry.collect_data( |
| [ |
| test.task_result(100, "fuchsia/try/fuchsia-x64-debug"), |
| test.task_result(200, "fuchsia/try/fuchsia-arm64-debug"), |
| ] |
| ) |
| ) |
| |
| yield ( |
| api.status_check.test("depth", status="infra_failure") |
| + api.properties(**{"$fuchsia/recipe_testing": {"recipe_depth": 2}}) |
| ) |