blob: fa442f305818703d9dabbc669dda085b378412db [file] [log] [blame]
# Copyright 2019 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/testing/host_test.gni")
# The service account that allows the test to download build artifacts.
_environment_service_account =
"internal-artifacts-readers@fuchsia-infra.iam.gserviceaccount.com"
# A template that configures a System Test Upgrade Suite against a given release
# builder.
#
# Parameters
#
# release_builder
# - Required: Builder from which build artifacts will be downloaded. This has
# the the form of `project/bucket/builder id`, like
# `fuchsia/ci/fuchsia-x64-release`. Conflicts with `release_build_id`.
# - Type: string
#
# release_build_id
# - Required: Build ID from which build artifacts will be downloaded. This has
# the the form of `1234...`. Conflicts with `release_builder`.
# - Type: string
#
# installer
# - Optional: Installer to use to install OTA.
# - Type: string
#
# service_account
# - Optional: The service account that has permission to download the build
# artifacts.
# - Type: string
#
# environments
# - Required: What environments this test should target.
# - Type: see //build/testing/test_spec.gni for more details. Note that
# any label and service_account in each environment is ignored.
#
# timeout
# - Optional: Err if this test takes longer than this time.
# - Type: duration string
#
# pave_timeout
# - Optional: Err if paving takes longer than this time.
# - Type: duration string
#
# cycle_timeout
# - Optional: Err if the test cycle takes longer than this time.
# - Type: duration string
#
# cycle_count
# - Optional: How many test cycles should the test execute. Defaults to 1
# cycle.
# - Type: integer string
template("system_test_upgrade_suite") {
assert(is_linux || is_mac, "system_tests are for linux/mac only")
assert(defined(invoker.release_builder) || defined(invoker.release_build_id),
"release_builder or release_build_id must be defined for $target_name")
assert(
!(defined(invoker.release_builder) && defined(invoker.release_build_id)),
"release_builder and release_build_id are mutually exclusive for $target_name")
assert(defined(invoker.environments),
"environments must be defined for $target_name")
_tests = [ "//src/sys/pkg/tests/system-tests:system_tests_upgrade" ]
_deps = []
foreach(test, _tests) {
_test_name = get_label_info(test, "name")
_test_binary = "$root_out_dir/$_test_name"
_host_test_target_name = "${target_name}_${_test_name}"
_deps += [ ":${_host_test_target_name}" ]
_args = [ "-test.v" ] # Print test detailed case status
if (defined(invoker.release_builder)) {
_args += [
"-downgrade-builder-name",
invoker.release_builder,
]
}
if (defined(invoker.release_build_id)) {
_args += [
"-downgrade-build-id",
invoker.release_build_id,
]
}
_service_account = _environment_service_account
if (defined(invoker.service_account)) {
assert(invoker.service_account != "",
"'${_host_test_target_name}' cannot have an empty service_account")
_service_account = invoker.service_account
}
if (defined(invoker.timeout)) {
assert(invoker.timeout != "",
"'${_host_test_target_name}' cannot have an empty timeout")
_args += [
"-test.timeout",
invoker.timeout,
]
}
if (defined(invoker.pave_timeout)) {
assert(invoker.pave_timeout != "",
"'${_host_test_target_name}' cannot have an empty pave timeout")
_args += [
"-pave-timeout",
invoker.pave_timeout,
]
}
if (defined(invoker.cycle_timeout)) {
assert(invoker.cycle_timeout != "",
"'${_host_test_target_name}' cannot have an empty cycle timeout")
_args += [
"-cycle-timeout",
invoker.cycle_timeout,
]
}
if (defined(invoker.cycle_count)) {
assert(invoker.cycle_count != "",
"'${_host_test_target_name}' cannot have an empty cycle count")
_args += [
"-cycle-count",
invoker.cycle_count,
]
}
if (defined(invoker.installer)) {
assert(invoker.installer != "",
"'${_host_test_target_name}' cannot have an empty installer")
_args += [
"-installer",
invoker.installer,
]
}
host_test(_host_test_target_name) {
binary_path = _test_binary
args = _args
deps = [ test ]
environments = []
foreach(env, invoker.environments) {
env.service_account = _service_account
environments += [ env ]
}
}
}
# Finally, group all the generated test specs into a group to make it easy to
# reference.
group(target_name) {
testonly = true
deps = _deps
}
}
# A template that configures a System Test Reboot Suite against a given release
# builder.
#
# Parameters
#
# environments
# - Required: What environments this test should target.
# - Type: see //build/testing/test_spec.gni for more details. Note that
# any label and service_account in each environment is ignored.
#
# timeout
# - Optional: Err if this test takes longer than this time.
# - Type: duration string
#
# cycle_timeout
# - Optional: Err if the test cycle takes longer than this time.
# - Type: duration string
#
# cycle_count
# - Optional: How many test cycles should the test execute. Defaults to 1
# cycle.
# - Type: integer string
template("system_test_reboot_suite") {
assert(is_linux || is_mac, "system_test_reboot_suite is for linux/mac only")
assert(defined(invoker.environments),
"environments must be defined for $target_name")
_tests = [ "//src/sys/pkg/tests/system-tests:system_tests_reboot" ]
_deps = []
foreach(test, _tests) {
_test_name = get_label_info(test, "name")
_test_binary = "$root_out_dir/$_test_name"
_host_test_target_name = "${target_name}_${_test_name}"
_deps += [ ":${_host_test_target_name}" ]
_args = [ "-test.v" ] # Print test detailed case status
if (defined(invoker.timeout)) {
assert(invoker.timeout != "",
"'${_host_test_target_name}' cannot have an empty timeout")
_args += [
"-test.timeout",
invoker.timeout,
]
}
if (defined(invoker.cycle_timeout)) {
assert(invoker.cycle_timeout != "",
"'${_host_test_target_name}' cannot have an empty cycle timeout")
_args += [
"-cycle-timeout",
invoker.cycle_timeout,
]
}
if (defined(invoker.cycle_count)) {
assert(invoker.cycle_count != "",
"'${_host_test_target_name}' cannot have an empty cycle count")
_args += [
"-cycle-count",
invoker.cycle_count,
]
}
host_test(_host_test_target_name) {
binary_path = _test_binary
args = _args
deps = [ test ]
environments = invoker.environments
}
}
# Finally, group all the generated test specs into a group to make it easy to
# reference.
group(target_name) {
testonly = true
deps = _deps
}
}