blob: 106f1b9c17fdb524f3522b0493ba9c47cb8d37bb [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"
load("//test/", "ENTRIES")
DOC = """
{name}: Helper test verifying reporting {log_type} works correctly.
Used to verify that the RTD's interface with the RTS is working.
def _tests():
return [
_define_log_test("no-log", "absent logs", []),
_define_log_test("simple-log", "a simple log", [
_make_mock_log("simple-sink", ENTRIES.single_log)
_define_log_test("parallel-log", "logs in parallel", [
_make_mock_log("split-sink", ENTRIES.split_log)
_define_log_test("multiline-logs", "a single-stream multi-line log",
[_make_mock_log("simple-sink", ENTRIES.second_log)]),
_define_log_test("two-logs", "two logs to one request",
[_make_mock_log("simple-sink", ENTRIES.single_log),
_make_mock_log("simple-sink", ENTRIES.second_log)]),
_define_log_test("two-requests", "logs to two requests",
[_make_mock_log("simple-sink", ENTRIES.single_log),
_make_mock_log("second-sink", ENTRIES.second_log)]),
_define_log_test("mixed-logs", "two types of log to one request",
[_make_mock_log("simple-sink", ENTRIES.single_log),
_make_mock_log("simple-sink", ENTRIES.split_log)]),
def _define_log_test(test_name, log_type, logs):
log_type: short string description of log contents
logs: list of tnull_pb.MockLog objects
return test_common.define_test(
test_name = test_name,
purpose = "report a {} to the RTS.".format(log_type),
doc = DOC.format(name = test_name, log_type = log_type),
owner_emails = [""],
owner_groups = ["chromeos-test-platform-team"],
setup = test_common.define_setup(setup_config = {"logs": logs}),
attrs = ["suite:dummy"],
steps = [_log_step("{}-request".format(test_name))]
def _make_mock_log(sink, logs):
return tnull_pb.MockLog(
name = sink,
messages = logs
def _log_step(request_name):
return {
"method": "log",
"common_args": {
"request": request_name,
TESTS = _tests()