| # Copyright 2022 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 PB.go.chromium.org.luci.lucictx import sections as sections_pb2 |
| from PB.go.chromium.org.luci.resultdb.proto.v1.test_result import TestStatus |
| |
| DEPS = [ |
| "fuchsia/reported_step", |
| "recipe_engine/context", |
| "recipe_engine/step", |
| ] |
| |
| |
| def RunSteps(api): |
| step = api.step("echo", ["echo", "reported_step_test"]) |
| step.presentation.logs["test"] = "This is a test log" |
| api.reported_step.upload("echo_test_id", step) |
| |
| step = api.step( |
| "raising step", |
| ["echo", "reported failed step"], |
| ok_ret="any", |
| ) |
| try: |
| if step.retcode: |
| step.presentation.status = api.step.FAILURE |
| raise api.step.StepFailure("test failing step") |
| finally: |
| api.reported_step.upload("raising_step_id", step) |
| |
| step = api.step("preparing step", ["echo", "reported_step_test"]) |
| prepared_step = api.reported_step.prepare_step("prepared_step", step) |
| prepared_step.add_log("specific_log") |
| prepared_step.add_artifact("string_artifact", "this is the content") |
| prepared_step.add_artifact("list_artifact", ["this", "is", "a", "list", "artifact"]) |
| prepared_step.upload() |
| |
| step = api.step("changing test status step", ["echo", "reported_step_test"]) |
| prepared_step = api.reported_step.prepare_step("changing_test_status", step) |
| prepared_step.set_test_status(TestStatus.FAIL) |
| prepared_step.upload() |
| |
| |
| def GenTests(api): |
| luci_context = api.context.luci_context( |
| realm=sections_pb2.Realm(name="proj:realm"), |
| resultdb=sections_pb2.ResultDB( |
| current_invocation=sections_pb2.ResultDBInvocation( |
| name="invocations/inv", |
| update_token="token", |
| ), |
| hostname="rdbhost", |
| ), |
| ) |
| |
| yield api.test("basic") + luci_context |
| |
| yield ( |
| api.test("raising_step", status="FAILURE") |
| + luci_context |
| + api.step_data("raising step", retcode=1) |
| ) |
| |
| yield api.test("resultdb_not_enabled") |