Skip to content

Commit 1ac46cf

Browse files
lidizhengejona86
authored andcommitted
[xDS interop] add Docker tagging logic to the xds_url_map job
1 parent 69aab82 commit 1ac46cf

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

buildscripts/kokoro/xds_url_map.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ readonly GITHUB_REPOSITORY_NAME="grpc-java"
77
readonly GKE_CLUSTER_NAME="interop-test-psm-basic"
88
readonly GKE_CLUSTER_ZONE="us-central1-c"
99
## xDS test client Docker images
10+
readonly SERVER_IMAGE_NAME="gcr.io/grpc-testing/xds-interop/java-server"
1011
readonly CLIENT_IMAGE_NAME="gcr.io/grpc-testing/xds-interop/java-client"
1112
readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}"
1213
readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing"
@@ -19,7 +20,7 @@ readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing"
1920
# Arguments:
2021
# None
2122
# Outputs:
22-
# Writes the output of xds-test-client --help to stderr
23+
# Writes the output of xds-test-client and xds-test-server --help to stderr
2324
#######################################
2425
build_java_test_app() {
2526
echo "Building Java test app"
@@ -29,12 +30,14 @@ build_java_test_app() {
2930

3031
# Test-run binaries
3132
run_ignore_exit_code "${SRC_DIR}/${BUILD_APP_PATH}/bin/xds-test-client" --help
33+
run_ignore_exit_code "${SRC_DIR}/${BUILD_APP_PATH}/bin/xds-test-server" --help
3234
}
3335

3436
#######################################
3537
# Builds test app Docker images and pushes them to GCR
3638
# Globals:
3739
# BUILD_APP_PATH
40+
# SERVER_IMAGE_NAME: Test server Docker image name
3841
# CLIENT_IMAGE_NAME: Test client Docker image name
3942
# GIT_COMMIT: SHA-1 of git commit being built
4043
# Arguments:
@@ -51,17 +54,24 @@ build_test_app_docker_images() {
5154
cp -v "${docker_dir}/"*.Dockerfile "${build_dir}"
5255
cp -v "${docker_dir}/"*.properties "${build_dir}"
5356
cp -rv "${SRC_DIR}/${BUILD_APP_PATH}" "${build_dir}"
57+
# Pick a branch name for the built image
58+
if [[ -n $KOKORO_JOB_NAME ]]; then
59+
branch_name="$(echo "$KOKORO_JOB_NAME" | sed -E 's|^grpc/java/([^/]+)/.*|\1|')"
60+
else
61+
branch_name='experimental'
62+
fi
5463
# Run Google Cloud Build
5564
gcloud builds submit "${build_dir}" \
5665
--config "${docker_dir}/cloudbuild.yaml" \
57-
--substitutions "_CLIENT_IMAGE_NAME=${CLIENT_IMAGE_NAME},COMMIT_SHA=${GIT_COMMIT},BRANCH_NAME=experimental"
66+
--substitutions "_SERVER_IMAGE_NAME=${SERVER_IMAGE_NAME},_CLIENT_IMAGE_NAME=${CLIENT_IMAGE_NAME},COMMIT_SHA=${GIT_COMMIT},BRANCH_NAME=${branch_name}"
5867
# TODO(sergiitk): extra "cosmetic" tags for versioned branches, e.g. v1.34.x
5968
# TODO(sergiitk): do this when adding support for custom configs per version
6069
}
6170

6271
#######################################
6372
# Builds test app and its docker images unless they already exist
6473
# Globals:
74+
# SERVER_IMAGE_NAME: Test server Docker image name
6575
# CLIENT_IMAGE_NAME: Test client Docker image name
6676
# GIT_COMMIT: SHA-1 of git commit being built
6777
# FORCE_IMAGE_BUILD
@@ -72,12 +82,16 @@ build_test_app_docker_images() {
7282
#######################################
7383
build_docker_images_if_needed() {
7484
# Check if images already exist
85+
server_tags="$(gcloud_gcr_list_image_tags "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}")"
86+
printf "Server image: %s:%s\n" "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}"
87+
echo "${server_tags:-Server image not found}"
88+
7589
client_tags="$(gcloud_gcr_list_image_tags "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}")"
7690
printf "Client image: %s:%s\n" "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}"
7791
echo "${client_tags:-Client image not found}"
7892

7993
# Build if any of the images are missing, or FORCE_IMAGE_BUILD=1
80-
if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${client_tags}" ]]; then
94+
if [[ "${FORCE_IMAGE_BUILD}" == "1" || -z "${server_tags}" || -z "${client_tags}" ]]; then
8195
build_java_test_app
8296
build_test_app_docker_images
8397
else

0 commit comments

Comments
 (0)