From 87bbe8a479b8970752c537032dae280251c24931 Mon Sep 17 00:00:00 2001 From: Jason Macnak Date: Fri, 5 Dec 2025 14:09:22 -0800 Subject: [PATCH] Start to add a kokoro GPU presubmit build config Updates the end2end test runner to by default filter out tests with the "requires_gpu" tag. Then, adds a kokoro build config which passes through a new -g command line flag to enable running the "requires_gpu" tag. Adds, a new test which has the "requires_gpu" tag to ensure that it does not run on the existing presubmit. Bug: b/466404901 Test: existing CI --- .kokoro/presubmit.sh | 3 ++- .kokoro/presubmit_gpu.cfg | 14 ++++++++++++++ e2etests/cvd/BUILD.bazel | 10 ++++++++++ e2etests/cvd/boot_tests.bzl | 4 ++-- tools/testutils/runcvde2etests.sh | 23 ++++++++++++++++++++++- 5 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 .kokoro/presubmit_gpu.cfg diff --git a/.kokoro/presubmit.sh b/.kokoro/presubmit.sh index 8e3ecdaf26..a22183e4a8 100755 --- a/.kokoro/presubmit.sh +++ b/.kokoro/presubmit.sh @@ -21,4 +21,5 @@ fi "${TOOL_DIR}/testutils/prepare_host.sh" -d "${REPO_DIR}" -u testrunner -g kokoro # Run as different user without sudo privileges -sudo -u testrunner CREDENTIAL_SOURCE=gce "${TOOL_DIR}/testutils/runcvde2etests.sh" +sudo -u testrunner CREDENTIAL_SOURCE=gce "${TOOL_DIR}/testutils/runcvde2etests.sh" \ + "${ANDROID_CUTTLEFISH_KOKORO_PRESUBMIT_SH_OPTIONAL_PASSTHROUGH_ARG_G}" diff --git a/.kokoro/presubmit_gpu.cfg b/.kokoro/presubmit_gpu.cfg new file mode 100644 index 0000000000..64043a4ce6 --- /dev/null +++ b/.kokoro/presubmit_gpu.cfg @@ -0,0 +1,14 @@ +build_file: "android-cuttlefish/.kokoro/presubmit_gpu.sh" +env_vars { + key: "ANDROID_CUTTLEFISH_KOKORO_PRESUBMIT_SH_OPTIONAL_PASSTHROUGH_ARG_G" + value: "-g" +} + +action { + define_artifacts { + regex: "*/*sponge_log.xml" # Actually a glob, not a regex + regex: "*/*sponge_log.log" + regex: "*/device_logs/**" # match all files regardless of directory depth + regex: "github/android-cuttlefish/*.deb" + } +} diff --git a/e2etests/cvd/BUILD.bazel b/e2etests/cvd/BUILD.bazel index a1089e88bd..43fa9a4c31 100644 --- a/e2etests/cvd/BUILD.bazel +++ b/e2etests/cvd/BUILD.bazel @@ -106,4 +106,14 @@ cvd_command_boot_test( target = "aosp_cf_x86_64_only_phone-userdebug", ) +cvd_command_boot_test( + name = "this_test_will_fail", + branch = "aosp-android-latest-release", + cvd_command = [ + "this_command_does_not_exist", + ], + target = "aosp_cf_x86_64_only_phone-userdebug", + tags = ["requires_gpu"], +) + # TODO(b/329100411) test loading older branches diff --git a/e2etests/cvd/boot_tests.bzl b/e2etests/cvd/boot_tests.bzl index 6f9a1f34ad..aa7264a6bb 100644 --- a/e2etests/cvd/boot_tests.bzl +++ b/e2etests/cvd/boot_tests.bzl @@ -31,7 +31,7 @@ def cvd_load_boot_test(name, env_file, size = "medium", credential_source = ""): ], ) -def cvd_command_boot_test(name, branch, target, cvd_command = [], credential_source = "", substitutions = ""): +def cvd_command_boot_test(name, branch, target, cvd_command = [], credential_source = "", substitutions = "", tags = []): args = ["-b", branch, "-t", target] if credential_source: args += ["-c", credential_source] @@ -47,5 +47,5 @@ def cvd_command_boot_test(name, branch, target, cvd_command = [], credential_sou "exclusive", "external", "no-sandbox", - ], + ] + tags, ) diff --git a/tools/testutils/runcvde2etests.sh b/tools/testutils/runcvde2etests.sh index 45516038a2..12d2b6375a 100755 --- a/tools/testutils/runcvde2etests.sh +++ b/tools/testutils/runcvde2etests.sh @@ -6,6 +6,23 @@ REPO_DIR="$(realpath "$(dirname "$0")/../..")" OUTPUT_DIR="$(pwd)" CREDENTIAL_SOURCE="${CREDENTIAL_SOURCE:-}" +bazel_test_tag_filter_arg="--test_tag_filters=-requires_gpu" +while getopts "g:" opt; do + case "${opt}" in + g) + bazel_test_tag_filter_arg="" + ;; + *) + echo "Invalid option: -${opt}" + echo "Usage: $0 [-g]" + echo "" + echo "Options" + echo " -g include tests with the `requires_gpu` tag" + exit 1 + ;; + esac +done + function gather_test_results() { # Don't immediately exit on error anymore set +e @@ -35,4 +52,8 @@ fi # --zip_undeclared_test_outputs triggers the creation of the outputs.zip file # everything written to $TEST_UNDECLARED_OUTPUTS_DIR is put into this zip -bazel test ${credential_arg} --zip_undeclared_test_outputs cvd/... +bazel test \ + ${bazel_test_tag_filter_arg} \ + ${credential_arg} \ + --zip_undeclared_test_outputs \ + cvd/...