From d19eb523723c3dd6a26610722d698f644e92c5b1 Mon Sep 17 00:00:00 2001 From: Jean Pierre Date: Wed, 29 Dec 2021 15:19:08 +0000 Subject: [PATCH] Run ide integration in separate werft job --- .werft/run-ide-integration-tests.yaml | 83 +++++++++++++++++++ components/BUILD.yaml | 3 +- test/BUILD.yaml | 19 ++++- test/ide-integration.Dockerfile | 19 +++++ ...eway.Dockerfile => integration.Dockerfile} | 2 +- test/leeway-build.sh | 18 ++-- 6 files changed, 135 insertions(+), 9 deletions(-) create mode 100644 .werft/run-ide-integration-tests.yaml create mode 100644 test/ide-integration.Dockerfile rename test/{leeway.Dockerfile => integration.Dockerfile} (93%) diff --git a/.werft/run-ide-integration-tests.yaml b/.werft/run-ide-integration-tests.yaml new file mode 100644 index 00000000000000..4544533d1180ae --- /dev/null +++ b/.werft/run-ide-integration-tests.yaml @@ -0,0 +1,83 @@ +args: +- name: version + desc: "The version of the integration tests to use" + required: true +- name: namespace + desc: "The namespace to run the integration test against" + required: true +- name: username + desc: "The username to run the integration test with" + required: false +pod: + serviceAccount: werft + nodeSelector: + dev/workload: builds + imagePullSecrets: + - name: eu-gcr-io-pull-secret + volumes: + - name: gcp-sa + secret: + secretName: gcp-sa-gitpod-dev-deployer + - name: config + emptyDir: {} + initContainers: + - name: gcloud + image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:cw-dev-tools.2 + workingDir: /workspace + imagePullPolicy: Always + volumeMounts: + - name: gcp-sa + mountPath: /mnt/secrets/gcp-sa + readOnly: true + - name: config + mountPath: /config + readOnly: false + command: + - bash + - -c + - | + + echo "[prep] preparing config." + + gcloud auth activate-service-account --key-file /mnt/secrets/gcp-sa/service-account.json + cp -R /home/gitpod/.config/gcloud /config/gcloud + cp /home/gitpod/.kube/config /config/kubeconfig + + echo "[prep] copied config..." + containers: + - name: tests + image: eu.gcr.io/gitpod-core-dev/build/ide-integration-tests:{{ .Annotations.version }} + workingDir: /workspace + imagePullPolicy: Always + volumeMounts: + - name: config + mountPath: /config + readOnly: true + command: + - /bin/bash + - -c + - | + sleep 1 + set -Eeuo pipefail + + echo "[prep] receiving config..." + mkdir /root/.config + cp -R /config/gcloud /root/.config/gcloud + export GOOGLE_APPLICATION_CREDENTIALS=/config/gcloud/legacy_credentials/gitpod-deployer@gitpod-core-dev.iam.gserviceaccount.com/adc.json + echo "[prep] received config." + + USERNAME="{{ .Annotations.username }}" + if [[ "$USERNAME" == "" ]]; then + USERNAME="" + fi + echo "[prep] using username: $USERNAME" + echo "[prep|DONE]" + + /entrypoint.sh -kubeconfig=/config/kubeconfig -namespace={{ .Annotations.namespace }} -username=$USERNAME 2>&1 | ts "[int-tests] " + + RC=${PIPESTATUS[0]} + if [ $RC -eq 1 ]; then + echo "[int-tests|FAIL]" + else + echo "[int-tests|DONE]" + fi diff --git a/components/BUILD.yaml b/components/BUILD.yaml index b8523e5f13ec83..c0e9292dddf3c8 100644 --- a/components/BUILD.yaml +++ b/components/BUILD.yaml @@ -65,7 +65,8 @@ packages: - components/ws-manager:docker - components/ws-proxy:docker - components/ide-proxy:docker - - test:docker + - test:docker-integration-tests + - test:docker-ide-integration-tests - dev/version-manifest:app config: commands: diff --git a/test/BUILD.yaml b/test/BUILD.yaml index e06797233fde2c..7f511e17e0c7d9 100644 --- a/test/BUILD.yaml +++ b/test/BUILD.yaml @@ -26,7 +26,7 @@ packages: - ["sh", "leeway-build.sh"] config: dontTest: true - - name: docker + - name: docker-integration-tests type: docker srcs: - entrypoint.sh @@ -35,9 +35,24 @@ packages: argdeps: - imageRepoBase config: - dockerfile: leeway.Dockerfile + dockerfile: integration.Dockerfile metadata: helm-component: integrationTest image: - ${imageRepoBase}/integration-tests:${version} - ${imageRepoBase}/integration-tests:commit-${__git_commit} + - name: docker-ide-integration-tests + type: docker + srcs: + - entrypoint.sh + deps: + - :app + argdeps: + - imageRepoBase + config: + dockerfile: ide-integration.Dockerfile + metadata: + helm-component: integrationTest + image: + - ${imageRepoBase}/ide-integration-tests:${version} + - ${imageRepoBase}/ide-integration-tests:commit-${__git_commit} diff --git a/test/ide-integration.Dockerfile b/test/ide-integration.Dockerfile new file mode 100644 index 00000000000000..648b624813891d --- /dev/null +++ b/test/ide-integration.Dockerfile @@ -0,0 +1,19 @@ +# Copyright (c) 2020 Gitpod GmbH. All rights reserved. +# Licensed under the GNU Affero General Public License (AGPL). +# See License-AGPL.txt in the project root for license information. + +FROM alpine:3.15 + +# Ensure latest packages are present, like security updates. +RUN apk upgrade --no-cache \ + && apk add --no-cache \ + ca-certificates \ + coreutils + +# convenience scripting tools +RUN apk add --no-cache bash moreutils + +COPY test--app/bin/ide-integration /tests +ENV PATH=$PATH:/tests +COPY entrypoint.sh /entrypoint.sh +ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/test/leeway.Dockerfile b/test/integration.Dockerfile similarity index 93% rename from test/leeway.Dockerfile rename to test/integration.Dockerfile index b430adda990a28..0871ee0c7007a5 100644 --- a/test/leeway.Dockerfile +++ b/test/integration.Dockerfile @@ -13,7 +13,7 @@ RUN apk upgrade --no-cache \ # convenience scripting tools RUN apk add --no-cache bash moreutils -COPY test--app/bin /tests +COPY test--app/bin/integration /tests ENV PATH=$PATH:/tests COPY entrypoint.sh /entrypoint.sh ENTRYPOINT [ "/entrypoint.sh" ] diff --git a/test/leeway-build.sh b/test/leeway-build.sh index d5f5a8fb62acf7..b5fd61f7b0093a 100755 --- a/test/leeway-build.sh +++ b/test/leeway-build.sh @@ -5,20 +5,28 @@ export CGO_ENABLED=0 -mkdir -p bin +# Compile integration tests + +mkdir -p bin/integration for AGENT in pkg/agent/*; do echo building agent "$AGENT" base=$(basename "$AGENT") - go build -trimpath -ldflags="-buildid= -w -s" -o bin/gitpod-integration-test-"${base%_agent}"-agent ./"$AGENT" + go build -trimpath -ldflags="-buildid= -w -s" -o bin/integration/gitpod-integration-test-"${base%_agent}"-agent ./"$AGENT" done for COMPONENT in tests/components/*; do echo building test "$COMPONENT" OUTPUT=$(basename "$COMPONENT") - go test -trimpath -ldflags="-buildid= -w -s" -c -o bin/"$OUTPUT".test ./"$COMPONENT" + go test -trimpath -ldflags="-buildid= -w -s" -c -o bin/integration/"$OUTPUT".test ./"$COMPONENT" done -go test -trimpath -ldflags="-buildid= -w -s" -o bin/workspace.test -c ./tests/workspace +go test -trimpath -ldflags="-buildid= -w -s" -o bin/integration/workspace.test -c ./tests/workspace + +# Ide integration test run separately so compile them in a different folder + +mkdir -p bin/ide-integration + +cp bin/integration/gitpod-integration-test-*-agent bin/ide-integration/ -go test -trimpath -ldflags="-buildid= -w -s" -o bin/ide.test -c ./tests/ide +go test -trimpath -ldflags="-buildid= -w -s" -o bin/ide-integration/ide.test -c ./tests/ide