diff --git a/hack/run-e2e.sh b/hack/run-e2e.sh index a2be877399..b83846cb9e 100755 --- a/hack/run-e2e.sh +++ b/hack/run-e2e.sh @@ -28,6 +28,7 @@ GCP_PROJECT=${GCP_PROJECT:-} GCP_REGION=${GCP_REGION:-} GCP_ZONE=${GCP_ZONE:-} GCP_CREDENTIALS=${GCP_CREDENTIALS:-} +GCP_SDK=${GCP_SDK:-/google-cloud-sdk} IMAGE_TAG=${IMAGE_TAG:-} SKIP_IMAGE_LOAD=${SKIP_IMAGE_LOAD:-} TIDB_OPERATOR_IMAGE=${TIDB_OPERATOR_IMAGE:-localhost:5000/pingcap/tidb-operator:latest} @@ -370,6 +371,15 @@ elif [ "$PROVIDER" == "gke" ]; then -v ${GCP_CREDENTIALS}:${GCP_CREDENTIALS} --env GOOGLE_APPLICATION_CREDENTIALS=${GCP_CREDENTIALS} ) + # google-cloud-sdk is very large, we didn't pack it into our e2e image. + # instead, we use the sdk installed in CI image. + if [ ! -e "${GCP_SDK}/bin/gcloud" ]; then + echo "error: ${GCP_SDK} is not google cloud sdk, please install it here or specify correct path via GCP_SDK env" + exit 1 + fi + docker_args+=( + -v ${GCP_SDK}:/google-cloud-sdk + ) else e2e_args+=( --provider=${PROVIDER} diff --git a/tests/images/e2e/Dockerfile b/tests/images/e2e/Dockerfile index ccce271038..2d78d69f51 100644 --- a/tests/images/e2e/Dockerfile +++ b/tests/images/e2e/Dockerfile @@ -28,3 +28,6 @@ ADD bin/e2e.test /usr/local/bin/ ADD bin/webhook /usr/local/bin/ ADD bin/blockwriter /usr/local/bin/ ADD bin/apiserver /usr/local/bin/ + +ADD entrypoint.sh /usr/local/bin +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/tests/images/e2e/entrypoint.sh b/tests/images/e2e/entrypoint.sh new file mode 100755 index 0000000000..820c594a79 --- /dev/null +++ b/tests/images/e2e/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +# Add default command if no command provided or the first argument is an +# option. +if [ $# -lt 1 -o "${1:0:1}" = '-' ]; then + set -- /usr/local/bin/ginkgo "$@" +fi + +# If google-cloud-sdk is detected, install it. +if [ -d /google-cloud-sdk ]; then + source /google-cloud-sdk/path.bash.inc + export CLOUDSDK_CORE_DISABLE_PROMPTS=1 +fi + +exec "$@"