forked from grpc/grpc-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buildscripts: simplify PSM interop Kokoro buildscripts (grpc#11121)
Integrates the new features of the the Kokoro PSM Interop install library introduced in grpc/psm-interop#73. Nearly all common functionality was moved from per-language/per-branch PSM Interop build scripts to [psm_interop_kokoro_lib.sh](https://github.com/grpc/psm-interop/blob/main/.kokoro/psm_interop_kokoro_lib.sh): 1. The list of tests in the each test suite 2. Per-test-suite flag customization 3. `run_test` methods 4. `build_docker_images_if_needed` methods 5. Generic `build_test_app_docker_images` methods (simple docker build + docker push + docker tag). grpc-java is one exception, as it doesn't run docker directly, but a cloudbuild flow. Now all PSM Interop jobs share the same buildscripts by all test suites: 1. buildscript that invokes the test: `psm-interop-test-{language}.sh` (configured as `build_file` in the build cfg) 2. buildscript that builds the xDS test client/server and publishes them as a Docker image: `psm-interop-build-{language}.sh` (conventional name called from `psm_interop_kokoro_lib.sh`) `psm-interop-test-{language}.sh`: 1. Sets `GRPC_LANGUAGE`, `BUILD_SCRIPT_DIR` environment variables. 2. Downloads the shared `psm_interop_kokoro_lib.sh` from the main branch of the psm-interop repo. 3. Sources `psm-interop-build-{language}.sh` 4. Calls `psm::run "${PSM_TEST_SUITE}"` (`PSM_TEST_SUITE` configured in the cfg file). `psm-interop-build-{language}.sh`: 1. Defines `psm::lang::build_docker_images` which is called from `psm_interop_kokoro_lib.sh`. 2. Invokes any repo-specific logic. 3. May use `psm::build::docker_images_generic` for generic Docker build, tag, push, or provide implement its own build/publish method. References: - b/288578634 - See the full list of the new features at grpc/psm-interop#73. - Additional fixes to the shared lib: grpc/psm-interop#78, grpc/psm-interop#79
- Loading branch information
Showing
8 changed files
with
132 additions
and
552 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2024 gRPC authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
set -eo pipefail | ||
|
||
# This file defines psm::lang::build_docker_images, which is directly called | ||
# from psm_interop_kokoro_lib.sh. | ||
|
||
# Used locally. | ||
readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing" | ||
|
||
####################################### | ||
# Builds the test app using gradle and smoke-checks its binaries | ||
# Globals: | ||
# SRC_DIR Absolute path to the source repo. | ||
# BUILD_APP_PATH | ||
# Arguments: | ||
# None | ||
# Outputs: | ||
# Writes the output of xds-test-client and xds-test-server --help to stderr | ||
####################################### | ||
_build_java_test_app() { | ||
psm::tools::log "Building Java test app" | ||
cd "${SRC_DIR}" | ||
|
||
set -x | ||
GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx1g'" \ | ||
./gradlew --no-daemon grpc-interop-testing:installDist -x test \ | ||
-PskipCodegen=true -PskipAndroid=true --console=plain | ||
set +x | ||
|
||
psm::tools::log "Test-run grpc-java PSM interop binaries" | ||
psm::tools::run_ignore_exit_code "${SRC_DIR}/${BUILD_APP_PATH}/bin/xds-test-client" --help | ||
psm::tools::run_ignore_exit_code "${SRC_DIR}/${BUILD_APP_PATH}/bin/xds-test-server" --help | ||
} | ||
|
||
####################################### | ||
# Builds test app Docker images and pushes them to GCR | ||
# Globals: | ||
# BUILD_APP_PATH | ||
# SERVER_IMAGE_NAME: Test server Docker image name | ||
# CLIENT_IMAGE_NAME: Test client Docker image name | ||
# GIT_COMMIT: SHA-1 of git commit being built | ||
# TESTING_VERSION: version branch under test, f.e. v1.42.x, master | ||
# Arguments: | ||
# None | ||
# Outputs: | ||
# Writes the output of `gcloud builds submit` to stdout, stderr | ||
####################################### | ||
psm::lang::build_docker_images() { | ||
local java_build_log="${BUILD_LOGS_ROOT}/build-lang-java.log" | ||
_build_java_test_app |& tee "${java_build_log}" | ||
|
||
psm::tools::log "Building Java xDS interop test app Docker images" | ||
local docker_dir="${SRC_DIR}/buildscripts/xds-k8s" | ||
local build_dir | ||
build_dir="$(mktemp -d)" | ||
|
||
# Copy Docker files, log properties, and the test app to the build dir | ||
{ | ||
cp -v "${docker_dir}/"*.Dockerfile "${build_dir}" | ||
cp -v "${docker_dir}/"*.properties "${build_dir}" | ||
cp -rv "${SRC_DIR}/${BUILD_APP_PATH}" "${build_dir}" | ||
} >> "${java_build_log}" | ||
|
||
|
||
# cloudbuild.yaml substitution variables | ||
local substitutions="" | ||
substitutions+="_SERVER_IMAGE_NAME=${SERVER_IMAGE_NAME}," | ||
substitutions+="_CLIENT_IMAGE_NAME=${CLIENT_IMAGE_NAME}," | ||
substitutions+="COMMIT_SHA=${GIT_COMMIT}," | ||
substitutions+="BRANCH_NAME=${TESTING_VERSION}," | ||
|
||
# Run Google Cloud Build | ||
gcloud builds submit "${build_dir}" \ | ||
--config="${docker_dir}/cloudbuild.yaml" \ | ||
--substitutions="${substitutions}" \ | ||
| tee -a "${java_build_log}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
|
||
# Input parameters to psm:: methods of the install script. | ||
readonly GRPC_LANGUAGE="java" | ||
readonly BUILD_SCRIPT_DIR="$(dirname "$0")" | ||
|
||
# Used locally. | ||
readonly TEST_DRIVER_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/${TEST_DRIVER_REPO_OWNER:-grpc}/psm-interop/${TEST_DRIVER_BRANCH:-main}/.kokoro/psm_interop_kokoro_lib.sh" | ||
|
||
psm::lang::source_install_lib() { | ||
echo "Sourcing test driver install script from: ${TEST_DRIVER_INSTALL_SCRIPT_URL}" | ||
local install_lib | ||
# Download to a tmp file. | ||
install_lib="$(mktemp -d)/psm_interop_kokoro_lib.sh" | ||
curl -s --retry-connrefused --retry 5 -o "${install_lib}" "${TEST_DRIVER_INSTALL_SCRIPT_URL}" | ||
# Checksum. | ||
if command -v sha256sum &> /dev/null; then | ||
echo "Install script checksum:" | ||
sha256sum "${install_lib}" | ||
fi | ||
source "${install_lib}" | ||
} | ||
|
||
psm::lang::source_install_lib | ||
source "${BUILD_SCRIPT_DIR}/psm-interop-build-${GRPC_LANGUAGE}.sh" | ||
psm::run "${PSM_TEST_SUITE}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.