From d67c9843c4cad03e234acc43a1b2927e1f105184 Mon Sep 17 00:00:00 2001 From: Seungjae Yoo Date: Thu, 16 Jul 2026 04:34:44 +0000 Subject: [PATCH 1/2] Refactor: Don't directly set ANDROID_CUTTLEFISH_KOKORO_BUILD_SCRIPT_ARGS --- .kokoro/presubmit.sh | 6 +++++- .kokoro/presubmit_gpu.cfg | 4 ++-- .kokoro/presubmit_gpu_staging.cfg | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.kokoro/presubmit.sh b/.kokoro/presubmit.sh index 6b6626cc3ed..a3940abc8ab 100755 --- a/.kokoro/presubmit.sh +++ b/.kokoro/presubmit.sh @@ -37,9 +37,13 @@ fi # Add test user to the kokoro group so it has access to the source dir "${TOOL_DIR}/testutils/prepare_host.sh" -d "${REPO_DIR}" -u testrunner -g kokoro +if [[ "${ENABLE_GPU:-}" == "true" ]]; then + ANDROID_CUTTLEFISH_KOKORO_BUILD_SCRIPT_ARGS+=" -g" +fi + # Allow kokoro group to the source dir: sudo chmod -R g+w /tmpfs/src # Run as different user without sudo privileges sudo -u testrunner CREDENTIAL_SOURCE=gce "${TOOL_DIR}/testutils/runcvde2etests.sh" \ - "${ANDROID_CUTTLEFISH_KOKORO_BUILD_SCRIPT_ARGS}" + ${ANDROID_CUTTLEFISH_KOKORO_BUILD_SCRIPT_ARGS} diff --git a/.kokoro/presubmit_gpu.cfg b/.kokoro/presubmit_gpu.cfg index 317c18b5567..ee4ae171f8e 100644 --- a/.kokoro/presubmit_gpu.cfg +++ b/.kokoro/presubmit_gpu.cfg @@ -1,7 +1,7 @@ build_file: "android-cuttlefish/.kokoro/presubmit.sh" env_vars { - key: "ANDROID_CUTTLEFISH_KOKORO_BUILD_SCRIPT_ARGS" - value: "-g" + key: "ENABLE_GPU" + value: "true" } action { diff --git a/.kokoro/presubmit_gpu_staging.cfg b/.kokoro/presubmit_gpu_staging.cfg index 317c18b5567..ee4ae171f8e 100644 --- a/.kokoro/presubmit_gpu_staging.cfg +++ b/.kokoro/presubmit_gpu_staging.cfg @@ -1,7 +1,7 @@ build_file: "android-cuttlefish/.kokoro/presubmit.sh" env_vars { - key: "ANDROID_CUTTLEFISH_KOKORO_BUILD_SCRIPT_ARGS" - value: "-g" + key: "ENABLE_GPU" + value: "true" } action { From c258e72610ef368edbd3d7267e23f41b2658971d Mon Sep 17 00:00:00 2001 From: Seungjae Yoo Date: Thu, 16 Jul 2026 04:34:44 +0000 Subject: [PATCH 2/2] Configure Kokoro to do podcvd E2E tests --- .kokoro/presubmit.sh | 25 ++++++++++++++++------- .kokoro/presubmit_gpu.cfg | 4 ++-- .kokoro/presubmit_gpu_staging.cfg | 4 ++-- .kokoro/presubmit_podcvd.cfg | 14 +++++++++++++ tools/testutils/prepare_host.sh | 33 ++++++++++++++++++++++--------- tools/testutils/runcvde2etests.sh | 10 ++++++++-- 6 files changed, 68 insertions(+), 22 deletions(-) create mode 100644 .kokoro/presubmit_podcvd.cfg diff --git a/.kokoro/presubmit.sh b/.kokoro/presubmit.sh index a3940abc8ab..38482f4e22b 100755 --- a/.kokoro/presubmit.sh +++ b/.kokoro/presubmit.sh @@ -32,13 +32,24 @@ if [ -f "$CACHE_CONFIG_FILE" ]; then source "$CACHE_CONFIG_FILE" fi -"${TOOL_DIR}/buildutils/build_packages.sh" -r "${BAZEL_REMOTE_CACHE}" -c "${CACHE_VERSION}" - -# Add test user to the kokoro group so it has access to the source dir -"${TOOL_DIR}/testutils/prepare_host.sh" -d "${REPO_DIR}" -u testrunner -g kokoro - -if [[ "${ENABLE_GPU:-}" == "true" ]]; then - ANDROID_CUTTLEFISH_KOKORO_BUILD_SCRIPT_ARGS+=" -g" +if [[ "${ANDROID_CUTTLEFISH_KOKORO_BUILD_SCRIPT_ARGS:-}" == *"-p"* ]]; then + retry sudo apt-get install -y docker.io + sudo systemctl start docker || true + + sudo docker build -t android-cuttlefish-build:latest -f "${TOOL_DIR}/buildutils/cw/Containerfile" "${REPO_DIR}" + sudo docker run --rm --network=host -v="${REPO_DIR}":/mnt/build -w /mnt/build android-cuttlefish-build:latest base -r "${BAZEL_REMOTE_CACHE}" -c "${CACHE_VERSION}" + sudo docker run --rm --network=host -v="${REPO_DIR}":/mnt/build -w /mnt/build android-cuttlefish-build:latest container + sudo docker run --rm --network=host -v="${REPO_DIR}":/mnt/build -w /mnt/build android-cuttlefish-build:latest frontend + # Clean up temporary packaging directories created during debuild + sudo rm -rf "${REPO_DIR}"/*/debian/tmp + + "${TOOL_DIR}/testutils/prepare_host.sh" -d "${REPO_DIR}" -u testrunner -g kokoro -p + sudo -u testrunner "${REPO_DIR}/container/image/image-builder.sh" -c podman -m dev -t localhost/cuttlefish-orchestration:latest +else + "${TOOL_DIR}/buildutils/build_packages.sh" -r "${BAZEL_REMOTE_CACHE}" -c "${CACHE_VERSION}" + + # Add test user to the kokoro group so it has access to the source dir + "${TOOL_DIR}/testutils/prepare_host.sh" -d "${REPO_DIR}" -u testrunner -g kokoro fi # Allow kokoro group to the source dir: diff --git a/.kokoro/presubmit_gpu.cfg b/.kokoro/presubmit_gpu.cfg index ee4ae171f8e..317c18b5567 100644 --- a/.kokoro/presubmit_gpu.cfg +++ b/.kokoro/presubmit_gpu.cfg @@ -1,7 +1,7 @@ build_file: "android-cuttlefish/.kokoro/presubmit.sh" env_vars { - key: "ENABLE_GPU" - value: "true" + key: "ANDROID_CUTTLEFISH_KOKORO_BUILD_SCRIPT_ARGS" + value: "-g" } action { diff --git a/.kokoro/presubmit_gpu_staging.cfg b/.kokoro/presubmit_gpu_staging.cfg index ee4ae171f8e..317c18b5567 100644 --- a/.kokoro/presubmit_gpu_staging.cfg +++ b/.kokoro/presubmit_gpu_staging.cfg @@ -1,7 +1,7 @@ build_file: "android-cuttlefish/.kokoro/presubmit.sh" env_vars { - key: "ENABLE_GPU" - value: "true" + key: "ANDROID_CUTTLEFISH_KOKORO_BUILD_SCRIPT_ARGS" + value: "-g" } action { diff --git a/.kokoro/presubmit_podcvd.cfg b/.kokoro/presubmit_podcvd.cfg new file mode 100644 index 00000000000..f75dfdf7fe5 --- /dev/null +++ b/.kokoro/presubmit_podcvd.cfg @@ -0,0 +1,14 @@ +build_file: "android-cuttlefish/.kokoro/presubmit.sh" +env_vars { + key: "ANDROID_CUTTLEFISH_KOKORO_BUILD_SCRIPT_ARGS" + value: "-p" +} + +action { + define_artifacts { + regex: "github/android-cuttlefish/*.deb" + + # Matches all files regardless of directory depth: + regex: "kokoro_test_results/**" + } +} diff --git a/tools/testutils/prepare_host.sh b/tools/testutils/prepare_host.sh index 259af614652..edf6ccfaa46 100755 --- a/tools/testutils/prepare_host.sh +++ b/tools/testutils/prepare_host.sh @@ -44,7 +44,8 @@ function create_test_user() { PKG_DIR="" TEST_USER="" EXTRA_GROUPS="" -while getopts "d:u:g:" opt; do +PODCVD_MODE=false +while getopts "d:u:g:p" opt; do case "${opt}" in u) TEST_USER="${OPTARG}" @@ -55,9 +56,12 @@ while getopts "d:u:g:" opt; do d) PKG_DIR="${OPTARG}" ;; + p) + PODCVD_MODE=true + ;; *) echo "Invalid option: -${opt}" - echo "Usage: $0 -d PACKAGE_DIR [-u TEST_USER [-g EXTRA_GROUPS]]" + echo "Usage: $0 -d PACKAGE_DIR [-u TEST_USER [-g EXTRA_GROUPS]] [-p]" exit 1 ;; esac @@ -69,13 +73,24 @@ if [[ "${PKG_DIR}" == "" ]] || ! [[ -d "${PKG_DIR}" ]]; then fi sudo apt-get update -install_pkgs "${PKG_DIR}" cuttlefish-base cuttlefish-metrics cuttlefish-user -check_service_started cuttlefish-host-resources -load_kernel_modules kvm vhost-vsock vhost-net bridge -grant_device_access vhost-vsock vhost-net kvm -check_service_started cuttlefish-operator +if [[ "${PODCVD_MODE}" == true ]]; then + install_pkgs "${PKG_DIR}" cuttlefish-podcvd + load_kernel_modules kvm vhost-vsock vhost-net bridge + grant_device_access vhost-vsock vhost-net kvm + if [[ "${TEST_USER}" != "" ]]; then + create_test_user "${TEST_USER}" "${EXTRA_GROUPS}" + sudo /usr/bin/podcvd-setup "${TEST_USER}" + fi +else + install_pkgs "${PKG_DIR}" cuttlefish-base cuttlefish-metrics cuttlefish-user + + check_service_started cuttlefish-host-resources + load_kernel_modules kvm vhost-vsock vhost-net bridge + grant_device_access vhost-vsock vhost-net kvm + check_service_started cuttlefish-operator -if [[ "${TEST_USER}" != "" ]]; then - create_test_user "${TEST_USER}" "${EXTRA_GROUPS}" + if [[ "${TEST_USER}" != "" ]]; then + create_test_user "${TEST_USER}" "${EXTRA_GROUPS}" + fi fi diff --git a/tools/testutils/runcvde2etests.sh b/tools/testutils/runcvde2etests.sh index 6d674b6da5e..1ac339f4a1b 100755 --- a/tools/testutils/runcvde2etests.sh +++ b/tools/testutils/runcvde2etests.sh @@ -7,17 +7,22 @@ OUTPUT_DIR="$(pwd)" CREDENTIAL_SOURCE="${CREDENTIAL_SOURCE:-}" bazel_test_tag_filter_arg="--test_tag_filters=-requires_gpu" -while getopts "g" opt; do +podcvd_arg="" +while getopts "gp" opt; do case "${opt}" in g) bazel_test_tag_filter_arg="--test_tag_filters=requires_gpu" ;; + p) + podcvd_arg="--test_env=USE_PODCVD=true --test_env=HOME=${HOME} --test_env=XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/run/user/$(id -u)}" + ;; *) echo "Invalid option: -${opt}" - echo "Usage: $0 [-g]" + echo "Usage: $0 [-g] [-p]" echo "" echo "Options" echo " -g only run tests with the 'requires_gpu' tag" + echo " -p test podcvd instead of cvd" exit 1 ;; esac @@ -63,5 +68,6 @@ fi bazel test \ ${bazel_test_tag_filter_arg} \ ${credential_arg} \ + ${podcvd_arg} \ --zip_undeclared_test_outputs \ cvd/...