xds-k8s jobs: standardize TESTING_VERSION (#30027)

This Addresses the issue with skips not working in golang tests, ref b/235688697. 

1. Unifies `TESTING_VERSION` detection  in grpc_xds_k8s_install_test_driver.sh - new approach applicable to all languages.
2. Use `TESTING_VERSION` in all build files in `--testing_version` and when tagging docker images. This will be backported to all active test branches. Build Scripts in all other languages will be updated as well.
pull/30035/head^2
Sergii Tkachenko 2 years ago committed by GitHub
parent c27730218c
commit 48885b74b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 33
      tools/internal_ci/linux/grpc_xds_k8s_install_test_driver.sh
  2. 10
      tools/internal_ci/linux/grpc_xds_k8s_lb.sh
  3. 10
      tools/internal_ci/linux/grpc_xds_k8s_lb_python.sh
  4. 10
      tools/internal_ci/linux/grpc_xds_k8s_xlang.sh
  5. 9
      tools/internal_ci/linux/grpc_xds_url_map.sh
  6. 9
      tools/internal_ci/linux/grpc_xds_url_map_python.sh
  7. 18
      tools/internal_ci/linux/psm-security-python.sh
  8. 17
      tools/internal_ci/linux/psm-security.sh

@ -121,6 +121,29 @@ parse_src_repo_git_info() {
readonly GIT_COMMIT_SHORT=$(git -C "${src_dir}" rev-parse --short HEAD)
}
#######################################
# Checks if the given string is a version branch.
# Version branches: "master", "v1.47.x"
# NOT version branches: "v1.47.0", "1.47.x", "", "dev", "main"
# Arguments:
# Version to test
#######################################
is_version_branch() {
if [ $# -eq 0 ]; then
echo "Usage is_version_branch VERSION"
false
return
fi
if [[ $1 == "master" ]]; then
true
return
fi
# Do not inline version_regex: keep it a string to avoid issues with escaping chars in ~= expr.
local version_regex='^v[0-9]+\.[0-9]+\.x$'
[[ "${1}" =~ $version_regex ]]
}
#######################################
# List GCR image tags matching given tag name.
# Arguments:
@ -357,7 +380,9 @@ kokoro_setup_python_virtual_environment() {
# Installs and configures the test driver on Kokoro VM.
# Globals:
# KOKORO_ARTIFACTS_DIR
# KOKORO_JOB_NAME
# TEST_DRIVER_REPO_NAME
# TESTING_VERSION: Populated with the version branch under test, f.e. v1.42.x, master
# SRC_DIR: Populated with absolute path to the source repo on Kokoro VM
# TEST_DRIVER_REPO_DIR: Populated with the path to the repo containing
# the test driver
@ -379,6 +404,14 @@ kokoro_setup_test_driver() {
# Capture Kokoro VM version info in the log.
kokoro_print_version
# All grpc kokoro jobs names structured to have the version identifier in the third position:
# - grpc/core/master/linux/...
# - grpc/core/v1.42.x/branch/linux/...
# - grpc/java/v1.47.x/branch/...
# - grpc/go/v1.47.x/branch/...
# - grpc/node/v1.6.x/...
readonly TESTING_VERSION=$(echo "${KOKORO_JOB_NAME}" | cut -d '/' -f3)
# Kokoro clones repo to ${KOKORO_ARTIFACTS_DIR}/github/${GITHUB_REPOSITORY}
local github_root="${KOKORO_ARTIFACTS_DIR}/github"
readonly SRC_DIR="${github_root}/${src_repository_name}"

@ -85,6 +85,8 @@ build_docker_images_if_needed() {
# 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: used by the framework to determine the supported PSM
# features.
# Arguments:
# Test case name
# Outputs:
@ -95,18 +97,14 @@ run_test() {
# Test driver usage:
# https://github.com/grpc/grpc/tree/master/tools/run_tests/xds_k8s_test_driver#basic-usage
local test_name="${1:?Usage: run_test test_name}"
# testing_version is used by the framework to determine the supported PSM
# features. It's captured from Kokoro job name of the Core repo, which takes
# 2 forms:
# grpc/core/master/linux/...
# grpc/core/v1.42.x/branch/linux/...
set -x
python3 -m "tests.${test_name}" \
--flagfile="${TEST_DRIVER_FLAGFILE}" \
--kube_context="${KUBE_CONTEXT}" \
--secondary_kube_context="${SECONDARY_KUBE_CONTEXT}" \
--server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \
--client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
--testing_version=$(echo "$KOKORO_JOB_NAME" | sed -E 's|^grpc/core/([^/]+)/.*|\1|') \
--testing_version="${TESTING_VERSION}" \
--xml_output_file="${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml" \
${@:2}
}

@ -86,6 +86,8 @@ build_docker_images_if_needed() {
# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM
# features.
# Arguments:
# Test case name
# Outputs:
@ -96,18 +98,14 @@ run_test() {
# Test driver usage:
# https://github.com/grpc/grpc/tree/master/tools/run_tests/xds_k8s_test_driver#basic-usage
local test_name="${1:?Usage: run_test test_name}"
# testing_version is used by the framework to determine the supported PSM
# features. It's captured from Kokoro job name of the Core repo, which takes
# 2 forms:
# grpc/core/master/linux/...
# grpc/core/v1.42.x/branch/linux/...
set -x
python3 -m "tests.${test_name}" \
--flagfile="${TEST_DRIVER_FLAGFILE}" \
--kube_context="${KUBE_CONTEXT}" \
--secondary_kube_context="${SECONDARY_KUBE_CONTEXT}" \
--client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
--server_image="${SERVER_IMAGE_NAME}" \
--testing_version=$(echo "$KOKORO_JOB_NAME" | sed -E 's|^grpc/core/([^/]+)/.*|\1|') \
--testing_version="${TESTING_VERSION}" \
--xml_output_file="${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml"
}

@ -33,6 +33,8 @@ readonly VERSION_TAG="v1.41.x"
# 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: used by the framework to determine the supported PSM
# features.
# Arguments:
# Test case name
# Outputs:
@ -48,19 +50,13 @@ run_test() {
local server_image_name="${IMAGE_REPO}/${slang}-server:${tag}"
local client_image_name="${IMAGE_REPO}/${clang}-client:${tag}"
# TODO(sanjaypujare): skip test if image not found (by using gcloud_gcr_list_image_tags)
# testing_version is used by the framework to determine the supported PSM
# features. It's captured from Kokoro job name of the Core repo, which takes
# 2 forms:
# grpc/core/master/linux/...
# grpc/core/v1.42.x/branch/linux/...
set -x
python -m "tests.security_test" \
--flagfile="${TEST_DRIVER_FLAGFILE}" \
--kube_context="${KUBE_CONTEXT}" \
--server_image="${server_image_name}" \
--client_image="${client_image_name}" \
--testing_version=$(echo "$KOKORO_JOB_NAME" | sed -E 's|^grpc/core/([^/]+)/.*|\1|') \
--testing_version="${TESTING_VERSION}" \
--xml_output_file="${TEST_XML_OUTPUT_DIR}/${tag}/${clang}-${slang}/sponge_log.xml" \
--force_cleanup \
--nocheck_local_certs

@ -74,6 +74,8 @@ build_docker_images_if_needed() {
# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM
# features.
# Arguments:
# Test case name
# Outputs:
@ -84,17 +86,12 @@ run_test() {
# Test driver usage:
# https://github.com/grpc/grpc/tree/master/tools/run_tests/xds_k8s_test_driver#basic-usage
local test_name="${1:?Usage: run_test test_name}"
# testing_version is used by the framework to determine the supported PSM
# features. It's captured from Kokoro job name of the Core repo, which takes
# 2 forms:
# grpc/core/master/linux/...
# grpc/core/v1.42.x/branch/linux/...
set -x
python3 -m "tests.${test_name}" \
--flagfile="${TEST_DRIVER_FLAGFILE}" \
--kube_context="${KUBE_CONTEXT}" \
--client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
--testing_version=$(echo "$KOKORO_JOB_NAME" | sed -E 's|^grpc/core/([^/]+)/.*|\1|') \
--testing_version="${TESTING_VERSION}" \
--xml_output_file="${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml" \
--flagfile="config/url-map.cfg"
set +x

@ -84,6 +84,8 @@ build_docker_images_if_needed() {
# TEST_XML_OUTPUT_DIR: Output directory for the test xUnit XML report
# CLIENT_IMAGE_NAME: Test client Docker image name
# GIT_COMMIT: SHA-1 of git commit being built
# TESTING_VERSION: version branch under test: used by the framework to determine the supported PSM
# features.
# Arguments:
# Test case name
# Outputs:
@ -94,17 +96,12 @@ run_test() {
# Test driver usage:
# https://github.com/grpc/grpc/tree/master/tools/run_tests/xds_k8s_test_driver#basic-usage
local test_name="${1:?Usage: run_test test_name}"
# testing_version is used by the framework to determine the supported PSM
# features. It's captured from Kokoro job name of the Core repo, which takes
# 2 forms:
# grpc/core/master/linux/...
# grpc/core/v1.42.x/branch/linux/...
set -x
python3 -m "tests.${test_name}" \
--flagfile="${TEST_DRIVER_FLAGFILE}" \
--kube_context="${KUBE_CONTEXT}" \
--client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
--testing_version=$(echo "$KOKORO_JOB_NAME" | sed -E 's|^grpc/core/([^/]+)/.*|\1|') \
--testing_version="${TESTING_VERSION}" \
--xml_output_file="${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml" \
--flagfile="config/url-map.cfg"
set +x

@ -32,6 +32,7 @@ readonly LANGUAGE_NAME="Python"
# 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:
@ -58,10 +59,9 @@ build_test_app_docker_images() {
docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}"
docker push "${SERVER_IMAGE_NAME}:${GIT_COMMIT}"
if [[ -n $KOKORO_JOB_NAME ]]; then
branch_name=$(echo "$KOKORO_JOB_NAME" | sed -E 's|^grpc/core/([^/]+)/.*|\1|')
tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${branch_name}"
tag_and_push_docker_image "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" "${branch_name}"
if is_version_branch "${TESTING_VERSION}"; then
tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
tag_and_push_docker_image "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
fi
}
@ -104,6 +104,8 @@ build_docker_images_if_needed() {
# 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: used by the framework to determine the supported PSM
# features.
# Arguments:
# Test case name
# Outputs:
@ -114,19 +116,13 @@ run_test() {
# Test driver usage:
# https://github.com/grpc/grpc/tree/master/tools/run_tests/xds_k8s_test_driver#basic-usage
local test_name="${1:?Usage: run_test test_name}"
# testing_version is used by the framework to determine the supported PSM
# features. It's captured from Kokoro job name of the Core repo, which takes
# 2 forms:
# grpc/core/master/linux/...
# grpc/core/v1.42.x/branch/linux/...
set -x
python3 -m "tests.${test_name}" \
--flagfile="${TEST_DRIVER_FLAGFILE}" \
--kube_context="${KUBE_CONTEXT}" \
--server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \
--client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
--testing_version=$(echo "$KOKORO_JOB_NAME" | sed -E 's|^grpc/core/([^/]+)/.*|\1|') \
--testing_version="${TESTING_VERSION}" \
--xml_output_file="${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml" \
--force_cleanup \
--nocheck_local_certs

@ -31,6 +31,7 @@ readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing"
# 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:
@ -43,10 +44,9 @@ build_test_app_docker_images() {
gcloud -q auth configure-docker
docker push "${CLIENT_IMAGE_NAME}:${GIT_COMMIT}"
docker push "${SERVER_IMAGE_NAME}:${GIT_COMMIT}"
if [[ -n $KOKORO_JOB_NAME ]]; then
branch_name=$(echo "$KOKORO_JOB_NAME" | sed -E 's|^grpc/core/([^/]+)/.*|\1|')
tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${branch_name}"
tag_and_push_docker_image "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" "${branch_name}"
if is_version_branch "${TESTING_VERSION}"; then
tag_and_push_docker_image "${CLIENT_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
tag_and_push_docker_image "${SERVER_IMAGE_NAME}" "${GIT_COMMIT}" "${TESTING_VERSION}"
fi
}
@ -89,6 +89,8 @@ build_docker_images_if_needed() {
# 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: used by the framework to determine the supported PSM
# features.
# Arguments:
# Test case name
# Outputs:
@ -99,18 +101,13 @@ run_test() {
# Test driver usage:
# https://github.com/grpc/grpc/tree/master/tools/run_tests/xds_k8s_test_driver#basic-usage
local test_name="${1:?Usage: run_test test_name}"
# testing_version is used by the framework to determine the supported PSM
# features. It's captured from Kokoro job name of the Core repo, which takes
# 2 forms:
# grpc/core/master/linux/...
# grpc/core/v1.42.x/branch/linux/...
set -x
python3 -m "tests.${test_name}" \
--flagfile="${TEST_DRIVER_FLAGFILE}" \
--kube_context="${KUBE_CONTEXT}" \
--server_image="${SERVER_IMAGE_NAME}:${GIT_COMMIT}" \
--client_image="${CLIENT_IMAGE_NAME}:${GIT_COMMIT}" \
--testing_version=$(echo "$KOKORO_JOB_NAME" | sed -E 's|^grpc/core/([^/]+)/.*|\1|') \
--testing_version="${TESTING_VERSION}" \
--xml_output_file="${TEST_XML_OUTPUT_DIR}/${test_name}/sponge_log.xml" \
--force_cleanup \
--nocheck_local_certs

Loading…
Cancel
Save