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

[WIP] xds-k8s use shared driver install lib #17

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 45 additions & 15 deletions buildscripts/kokoro/xds-k8s.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/usr/bin/env bash
set -eo pipefail

# Constants
# Constants:
readonly GITHUB_REPOSITORY_NAME="grpc-java"
# GKE Cluster
readonly GKE_CLUSTER_NAME="interop-test-psm-sec-testing-api"
readonly GKE_CLUSTER_ZONE="us-west1-b"
export CLOUDSDK_API_ENDPOINT_OVERRIDES_CONTAINER="https://test-container.sandbox.googleapis.com/"
## xDS test server/client Docker images
## xDS test server/client Docker images.
readonly SERVER_IMAGE_NAME="gcr.io/grpc-testing/xds-interop/java-server"
readonly CLIENT_IMAGE_NAME="gcr.io/grpc-testing/xds-interop/java-client"
readonly FORCE_IMAGE_BUILD="${FORCE_IMAGE_BUILD:-0}"
readonly BUILD_APP_PATH="interop-testing/build/install/grpc-interop-testing"
# Test driver.
readonly TEST_DRIVER_REPO_URL="https://github.com/grpc/grpc.git"
readonly TEST_DRIVER_BRANCH="${TEST_DRIVER_BRANCH:-master}"
readonly TEST_DRIVER_INSTALL_LIB_PATH="tools/internal_ci/linux/grpc_xds_k8s_install_test_driver.sh"

#######################################
# Builds the test app using gradle and smoke-checks its binaries
Expand Down Expand Up @@ -95,7 +95,36 @@ build_docker_images_if_needed() {
}

#######################################
# Executes the test case
# Ensure the source code of the test driver is present at TEST_DRIVER_REPO_DIR.
#
# If TEST_DRIVER_REPO_DIR is set, this method only confirms that this directory exists.
# In this case, TEST_DRIVER_BRANCH is not used.
#
# Otherwise, clone branch TEST_DRIVER_BRANCH of the test driver from TEST_DRIVER_REPO_URL repo to
# a temporary folder, and export the path in TEST_DRIVER_REPO_DIR global variable.
#
# Globals:
# TEST_DRIVER_REPO_DIR: path to the repo containing the test driver.
# TEST_DRIVER_REPO_URL: the repo with the source code of test driver to clone
# TEST_DRIVER_BRANCH: (if the repo is cloned from TEST_DRIVER_REPO_URL) the branch to checkout
# Arguments:
# None
# Outputs:
# Writes the output of `git` command to stdout, stderr
# Writes driver source code to $TEST_DRIVER_REPO_DIR
#######################################
get_test_driver() {
if [[ -d "${TEST_DRIVER_REPO_DIR}" ]]; then
echo "Using exiting driver directory: ${TEST_DRIVER_REPO_DIR}"
else
readonly TEST_DRIVER_REPO_DIR="$(mktemp -d)/xds-k8s-driver-repo"
echo "Cloning driver to ${TEST_DRIVER_REPO_URL} branch ${TEST_DRIVER_BRANCH} to ${TEST_DRIVER_REPO_DIR}"
git clone -b "${TEST_DRIVER_BRANCH}" --depth=1 "${TEST_DRIVER_REPO_URL}" "${TEST_DRIVER_REPO_DIR}"
fi
}

#######################################
# Execute the test case
# Globals:
# TEST_DRIVER_FLAGFILE: Relative path to test driver flagfile
# KUBE_CONTEXT: The name of kubectl context with GKE cluster access
Expand Down Expand Up @@ -145,21 +174,22 @@ run_test() {
# Writes the output of test execution to stdout, stderr
#######################################
main() {
local script_dir
script_dir="$(dirname "$0")"
# shellcheck source=buildscripts/kokoro/xds-k8s-install-test-driver.sh
source "${script_dir}/xds-k8s-install-test-driver.sh"
set -x
get_test_driver
# shellcheck source=grpc_xds_k8s_install_test_driver.sh
source "${TEST_DRIVER_REPO_DIR}/${TEST_DRIVER_INSTALL_LIB_PATH}"

if [[ -n "${KOKORO_ARTIFACTS_DIR}" ]]; then
kokoro_setup_test_driver "${GITHUB_REPOSITORY_NAME}"
else
local_setup_test_driver "${script_dir}"
local_setup_test_driver "$(dirname "$0")"
fi
build_docker_images_if_needed
# build_docker_images_if_needed
# Run tests
cd "${TEST_DRIVER_FULL_DIR}"
run_test baseline_test
run_test security_test
echo "OK"
# run_test baseline_test
# run_test security_test
}

main "$@"