blob: 301add90dbd0408c91d7006fea215a430b774b16 [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
#
# downgrade_release_builder
# - Required: Builder from which the downgrade build artifacts will be
# downloaded and installed on the device. This has the form of
# `project/bucket/builder id`, like `fuchsia/ci/fuchsia-x64-release`.
# Conflicts with `downgrade_release_build_id`.
# - Type: string
#
# downgrade_release_build_id
# - Required: Build ID from which the downgrade build artifacts will be
# downloaded and installed on the device. This has the form of `1234...`.
# Conflicts with `downgrade_release_builder`.
# - Type: string
#
# upgrade_release_builder
# - Optional: Builder from which the upgrade build artifacts will be
# downloaded and upgraded to on the device, rather than from the current
# build. This has the form of `project/bucket/builder id`, like
# `fuchsia/ci/fuchsia-x64-release`.
# Conflicts with `upgrade_release_build_id`.
# - Type: string
#
# upgrade_release_build_id
# - Optional: Build ID from which the upgrade build artifacts will be
# downloaded and upgraded to on the device, rather than from the current
# build. This has 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
#
# device_connect_timeout
# - Optional: How long to wait between connection attempts.
# - Type: duration string
template("system_test_upgrade_suite") {
assert(is_linux || is_mac, "system_tests are for linux/mac only")
# FIXME: remove after migration to the new name is complete.
if (defined(invoker.release_builder)) {
assert(
!defined(invoker.downgrade_release_builder),
"downgrade_release_builder and release_builder are mutually exclusive")
_downgrade_release_builder = invoker.release_builder
} else if (defined(invoker.downgrade_release_builder)) {
_downgrade_release_builder = invoker.downgrade_release_builder
}
# FIXME: remove after migration to the new name is complete.
if (defined(invoker.release_build_id)) {
assert(
!defined(invoker.downgrade_release_build_id),
"downgrade_release_build_id and release_build_id are mutually exclusive")
_downgrade_release_build_id = invoker.release_build_id
} else if (defined(invoker.downgrade_release_build_id)) {
_downgrade_release_build_id = invoker.downgrade_release_build_id
}
assert(
defined(_downgrade_release_builder) ||
defined(_downgrade_release_build_id),
"downgrade_release_builder or downgrade_release_build_id must be defined for $target_name")
assert(
!(defined(_downgrade_release_builder) &&
defined(_downgrade_release_build_id)),
"downgrade_release_builder and downgrade_release_build_id are mutually exclusive for $target_name")
assert(
!(defined(invoker.upgrade_release_builder) &&
defined(invoker.upgrade_release_build_id)),
"upgrade_release_builder and upgrade_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(_downgrade_release_builder)) {
_args += [
"-downgrade-builder-name",
_downgrade_release_builder,
]
}
if (defined(_downgrade_release_build_id)) {
_args += [
"-downgrade-build-id",
_downgrade_release_build_id,
]
}
if (defined(invoker.upgrade_release_builder)) {
_args += [
"-upgrade-builder-name",
invoker.upgrade_release_builder,
]
}
if (defined(invoker.upgrade_release_build_id)) {
_args += [
"-upgrade-build-id",
invoker.upgrade_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,
]
}
if (defined(invoker.device_connect_timeout)) {
assert(
invoker.device_connect_timeout != "",
"'${_host_test_target_name}' cannot have empty device connect timout")
_args += [
"-device-connect-timeout",
invoker.device_connect_timeout,
]
}
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
#
# release_builder
# - Optional: Builder from which build artifacts will be downloaded and
# installed on the device, instead of from the current build. This has
# the form of `project/bucket/builder id`, like
# `fuchsia/ci/fuchsia-x64-release`. Conflicts with `release_build_id`.
# - Type: string
#
# release_build_id
# - Optional: Build ID from which build artifacts will be downloaded and
# installed on the device, instead of from the current build. This has
# the form of `1234...`. Conflicts with `release_builder`.
# - 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
#
# 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
#
# device_connect_timeout
# - Optional: How long to wait between connection attempts.
# - Type: duration string
template("system_test_reboot_suite") {
assert(is_linux || is_mac, "system_test_reboot_suite is for linux/mac only")
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_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.release_builder)) {
_args += [
"-builder-name",
invoker.release_builder,
]
}
if (defined(invoker.release_build_id)) {
_args += [
"-build-id",
invoker.release_build_id,
]
}
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,
]
}
if (defined(invoker.device_connect_timeout)) {
assert(
invoker.device_connect_timeout != "",
"'${_host_test_target_name}' cannot have empty device connect timout")
_args += [
"-device-connect-timeout",
invoker.device_connect_timeout,
]
}
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
}
}