From 5470f00e3302c2e77b27063a6a7961373f608397 Mon Sep 17 00:00:00 2001 From: Elina Akhmanova Date: Thu, 11 May 2023 12:01:35 +0000 Subject: [PATCH] Move out pkg installation from Dockerfile.e2e-test Packages in Dockerfile.e2e-test are architecture dependant, and it's not easy to cross-compile such containers. They will always present original architecture. Therefore it's better to move it to runtime when architecture is 100% match. Signed-off-by: Elina Akhmanova --- Dockerfile.e2e-test | 18 +----------------- cmd/e2e-test/run.sh | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/Dockerfile.e2e-test b/Dockerfile.e2e-test index 795dfb6477..5ba6466bc3 100644 --- a/Dockerfile.e2e-test +++ b/Dockerfile.e2e-test @@ -18,26 +18,10 @@ FROM debian:11 #ARG_ARCH & ARG_BIN are replaces with sed in build/rules.mk ADD bin/ARG_ARCH/ARG_BIN /ARG_BIN +COPY cmd/e2e-test/run.sh /run.sh ARG CLOUD_SDK_VERSION="416.0.0" ENV CLOUD_SDK_VERSION=$CLOUD_SDK_VERSION ENV PATH /google-cloud-sdk/bin:$PATH -COPY cmd/e2e-test/run.sh /run.sh - -# Get architecture for gcloud cli installation -RUN if [ "ARG_ARCH" = "amd64" ]; \ - then echo -n "x86_64" > /tmp/arch; \ - else echo -n "arm" > /tmp/arch; fi; - -# Download Google Cloud GPG and install google-cloud-cli -# See recommended instructions: -# cloud.google.com/sdk/docs/install#installation_instructions -RUN ARCH=`cat /tmp/arch` && \ - apt-get update && \ - apt-get install -y curl python apt-transport-https ca-certificates gnupg && \ - curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-${CLOUD_SDK_VERSION}-linux-${ARCH}.tar.gz && \ - tar xvf google-cloud-cli-${CLOUD_SDK_VERSION}-linux-${ARCH}.tar.gz && \ - rm google-cloud-cli-${CLOUD_SDK_VERSION}-linux-${ARCH}.tar.gz - ENTRYPOINT ["/run.sh"] diff --git a/cmd/e2e-test/run.sh b/cmd/e2e-test/run.sh index 5e82fda521..59a1469960 100755 --- a/cmd/e2e-test/run.sh +++ b/cmd/e2e-test/run.sh @@ -16,7 +16,20 @@ # run.sh manages the settings required for running containerized in a # Kubernetes cluster. -echo '--- BEGIN ---' + +echo "Downloading test dependencies.." +CLOUDSDK_VERSION=${CLOUD_SDK_VERSION:-"416.0.0-0"} +apt-get update +apt-get install -y curl python apt-transport-https ca-certificates gnupg +echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] \ + http://packages.cloud.google.com/apt cloud-sdk main" | \ + tee -a /etc/apt/sources.list.d/google-cloud-sdk.list +curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | \ + apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - +apt-get update -y +apt-get install google-cloud-cli=$CLOUD_SDK_VERSION -y + +echo '--- TESTING BEGINS ---' for ATTEMPT in $(seq 60); do PROJECT=$(curl -H'Metadata-Flavor:Google' metadata.google.internal/computeMetadata/v1/project/project-id 2>/dev/null) @@ -126,4 +139,4 @@ fi echo ============================================================================== echo "RESULT: $RESULT" -echo '--- END ---' +echo '--- TESTING ENDS ---'