From 119ab4edd5bccfc2c6c4416325054c081417a8eb Mon Sep 17 00:00:00 2001 From: Yecheng Fu Date: Fri, 20 Mar 2020 11:02:14 +0800 Subject: [PATCH] Mount google-cloud-sdk into e2e image --- hack/run-e2e.sh | 10 ++++++++++ tests/images/e2e/Dockerfile | 3 +++ tests/images/e2e/entrypoint.sh | 17 +++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100755 tests/images/e2e/entrypoint.sh diff --git a/hack/run-e2e.sh b/hack/run-e2e.sh index a2be877399f..b83846cb9ec 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 ccce271038c..2d78d69f51d 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 00000000000..820c594a794 --- /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 "$@"