Skip to content

Commit

Permalink
Run ide integration in separate werft job
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanp413 committed Dec 29, 2021
1 parent 76c4839 commit d19eb52
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 9 deletions.
83 changes: 83 additions & 0 deletions .werft/run-ide-integration-tests.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]/adc.json
echo "[prep] received config."
USERNAME="{{ .Annotations.username }}"
if [[ "$USERNAME" == "<no value>" ]]; 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
3 changes: 2 additions & 1 deletion components/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 17 additions & 2 deletions test/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ packages:
- ["sh", "leeway-build.sh"]
config:
dontTest: true
- name: docker
- name: docker-integration-tests
type: docker
srcs:
- entrypoint.sh
Expand All @@ -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}
19 changes: 19 additions & 0 deletions test/ide-integration.Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
2 changes: 1 addition & 1 deletion test/leeway.Dockerfile → test/integration.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
18 changes: 13 additions & 5 deletions test/leeway-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d19eb52

Please sign in to comment.