blob: 6f373d2ebfd8afdf29b18e2d43524a1ae6fb4bed [file] [log] [blame]
# 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.
import("//build/config.gni")
import("//build/package.gni")
import("//build/rust/rustc_library.gni")
import("//build/test/test_package.gni")
import("//src/diagnostics/sampler/build/config_generator.gni")
import("//src/sys/build/components.gni")
# Library containing core logic for sampler,
# library launched by generic diagnostics Launcher
# to bundle multiple products together and save space.
rustc_library("lib") {
name = "sampler"
edition = "2018"
with_unit_tests = true
deps = [
"//sdk/fidl/fuchsia.cobalt:fuchsia.cobalt-rustc",
"//sdk/fidl/fuchsia.diagnostics:fuchsia.diagnostics-rustc",
"//src/diagnostics/control:controller-rustc",
"//src/diagnostics/control:controller-rustc",
"//src/lib/diagnostics/hierarchy/rust",
"//src/lib/diagnostics/reader/rust",
"//src/lib/fdio/rust:fdio",
"//src/lib/fidl/rust/fidl",
"//src/lib/fuchsia-async",
"//src/lib/fuchsia-async",
"//src/lib/fuchsia-component",
"//src/lib/syslog/rust:syslog",
"//src/lib/syslog/rust:syslog-listener",
"//src/lib/zircon/rust:fuchsia-zircon",
"//third_party/rust_crates:anyhow",
"//third_party/rust_crates:argh",
"//third_party/rust_crates:async-trait",
"//third_party/rust_crates:chrono",
"//third_party/rust_crates:futures",
"//third_party/rust_crates:itertools",
"//third_party/rust_crates:lazy_static",
"//third_party/rust_crates:log",
"//third_party/rust_crates:matches",
"//third_party/rust_crates:parking_lot",
"//third_party/rust_crates:serde",
"//third_party/rust_crates:serde_json",
"//third_party/rust_crates:serde_json5",
"//third_party/rust_crates:tempfile",
"//third_party/rust_crates:thiserror",
]
sources = [
"src/config.rs",
"src/executor.rs",
"src/lib.rs",
]
}
# Test package for the unit test from the
# lapis library.
test_package("sampler-tests") {
deps = [ ":lib_test" ]
v2_tests = [
{
name = "sampler_lib_test"
environments = basic_envs
},
]
}
# Custom build rule responsible for generating them
# default config-data the production Lapis service uses
# as well as the resource rule used by the configuration
# verification test.
lapis_configuration("production_lapis") {
configs = [
"config/archivist.json",
"config/ftl.json",
]
}
# Rules defining the V1 and V2 Lapis components.
fuchsia_component("sampler-component") {
component_name = "sampler"
deps = [
":production_lapis_config_data",
"//src/diagnostics/launcher:bin",
]
manifest = "meta/sampler.cml"
}
fuchsia_component("sampler-v1") {
component_name = "sampler"
manifest = "meta/sampler.cmx"
deps = [
":lib",
"//src/diagnostics/launcher:bin",
]
}
fuchsia_package("sampler") {
deps = [ ":sampler-component" ]
}
# Test binary responsible for readings
# and validating all client configurations
# listed in the "production lapis" lapis_configuration.
rustc_test("config-validation") {
testonly = true
name = "config_validation_test"
deps = [
":lib",
"//src/lib/fuchsia-async",
]
source_root = "tests/config_validation.rs"
sources = [ "tests/config_validation.rs" ]
}
# Test component for config validation.
fuchsia_component("config-validation-test") {
testonly = true
manifest = "meta/config-validation-test.cmx"
deps = [
":config-validation",
":production_lapis_resources",
]
}
# Integration test binary for lapis service.
rustc_test("test-bin") {
testonly = true
name = "sampler_integration_tests"
deps = [
"//sdk/fidl/fuchsia.cobalt:fuchsia.cobalt-rustc",
"//sdk/fidl/fuchsia.cobalt.test:fuchsia.cobalt.test-rustc",
"//src/diagnostics/sampler/tests/fidl-for-test:fuchsia.samplertestcontroller-rustc",
"//src/lib/diagnostics/reader/rust",
"//src/lib/diagnostics/testing/rust",
"//src/lib/fuchsia-async",
"//src/lib/fuchsia-component",
"//src/lib/zircon/rust:fuchsia-zircon",
]
data_deps = [ ":lib" ]
source_root = "tests/integration.rs"
sources = [ "tests/integration.rs" ]
}
# Config-data for the integration test.
config_data("test-config") {
for_pkg = "sampler-integration-tests"
sources = [ "tests/configs/test_config.json" ]
outputs = [ "metrics/test_config.json" ]
}
# Test component for lapis service integration test.
fuchsia_component("sampler-integration-test") {
testonly = true
manifest = "meta/integration-tests.cmx"
deps = [
":sampler-v1",
":test-bin",
"//src/diagnostics/sampler/tests/test_component:single_counter_test_component",
]
}
fuchsia_test_package("sampler-integration-tests") {
test_components = [
":sampler-integration-test",
":config-validation-test",
]
deps = [
":production_lapis_resources",
":test-config",
]
}
group("tests") {
testonly = true
deps = [
":sampler-integration-tests",
":sampler-tests",
]
}