blob: 65b7fd59a1322d5eab475add5ab84e35b10c237f [file] [log] [blame]
# Copyright 2020 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
load("//metadata/", "test_common")
tnull_pb = "chromiumos.config.api.test.tnull.v1"
DOC = """
{name}: Helper test verifying reporting {artifact_desc} works correctly.
Used to verify that the RTD's interface with the RTS is working.
def _tests():
return [
_define_artifact_test("no-artifact", "absent artifacts", []),
_define_artifact_test("simple-artifact", "a simple artifact", [
_make_mock_artifact("simple-sink", single_obj)
_define_artifact_test("multiline-artifact", "a multi-line artifact", [
_make_mock_artifact("simple-sink", second_obj)
_define_artifact_test("two-artifacts", "two artifacts to one request", [
_make_mock_artifact("simple-sink", single_obj),
_make_mock_artifact("simple-sink", second_obj)
_define_artifact_test("duped-artifacts", "duplicate artifacts", [
_make_mock_artifact("simple-sink", single_obj),
_make_mock_artifact("simple-sink", single_obj)
_define_artifact_test("two-requests", "artifacts to two requests", [
_make_mock_artifact("simple-sink", single_obj),
_make_mock_artifact("second-sink", second_obj)
def _define_artifact_test(test_name, artifact_desc, artifacts):
Helper function to dedupe boilerplate for specifying simple ArchiveArtifact
tests. Not usable for testing artifacts for multiple requests in one test.
test_name: Unique name for this particular test. Must be unique across all
tests for this RTD, but will be prefixed with the RTD name so can
overlap with test names for other RTDs. Also used to name the request
for the purposes of the ArchiveArtifact RPC. Tests which report
artifacts for multiple requests should not use this helper function.
artifact_desc: simple text description of the type of artifact archived.
Used in docstring and purpose string.
artifacts: List of MockArtifact objects which will be archived in this
metadata.Test object
return test_common.define_test(
test_name = test_name,
purpose = "report a {} to the RTS.".format(artifact_desc),
doc = DOC.format(name = test_name, artifact_desc = artifact_desc),
owner_emails = [""],
owner_groups = ["team-mdb-group"],
setup = test_common.define_setup(setup_config = {"artifacts": artifacts}),
attrs = ["suite:dummy"],
steps = [_archive_step("{}-request".format(test_name))]
single_obj = """Hamlet: Methinks it is like a weasel.
Polonius: It is backed like a weasel."""
second_obj = "To be, or not to be, that is the question"
def _make_mock_artifact(sink, obj):
return tnull_pb.MockArtifact(
name = sink,
file_bytes = obj
def _archive_step(request_name):
return {
"method": "archive",
"common_args": {
"request": request_name,
TESTS= _tests()