Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildscripts: simplify PSM interop Kokoro buildscripts #11121

Merged
merged 18 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
90 changes: 90 additions & 0 deletions buildscripts/kokoro/psm-interop-build-java.sh
@@ -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}"
}
27 changes: 27 additions & 0 deletions buildscripts/kokoro/psm-interop-test-java.sh
@@ -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}"
6 changes: 5 additions & 1 deletion buildscripts/kokoro/psm-security.cfg
@@ -1,7 +1,7 @@
# Config file for internal CI

# Location of the continuous shell script in repository.
build_file: "grpc-java/buildscripts/kokoro/psm-security.sh"
build_file: "grpc-java/buildscripts/kokoro/psm-interop-test-java.sh"
timeout_mins: 240

action {
Expand All @@ -11,3 +11,7 @@ action {
strip_prefix: "artifacts"
}
}
env_vars {
key: "PSM_TEST_SUITE"
value: "security"
}
185 changes: 0 additions & 185 deletions buildscripts/kokoro/psm-security.sh

This file was deleted.

6 changes: 5 additions & 1 deletion buildscripts/kokoro/xds_k8s_lb.cfg
@@ -1,7 +1,7 @@
# Config file for internal CI

# Location of the continuous shell script in repository.
build_file: "grpc-java/buildscripts/kokoro/xds_k8s_lb.sh"
build_file: "grpc-java/buildscripts/kokoro/psm-interop-test-java.sh"
timeout_mins: 180

action {
Expand All @@ -11,3 +11,7 @@ action {
strip_prefix: "artifacts"
}
}
env_vars {
key: "PSM_TEST_SUITE"
value: "lb"
}