Skip to content

Commit

Permalink
Use a KUDO deployment for E2E testing (#1243)
Browse files Browse the repository at this point in the history
A Docker image of the KUDO manager is built and deployed in the E2E test cluster.
This is done by adding the build KUDO image to the KinD cluster and changing the 'kubectl kudo init' output to ensure that this image will be used when deploying KUDO.


Co-Authored-By: Andreas Neumann <aneumann@mesosphere.com>
  • Loading branch information
Jan Schlicht and ANeumann82 committed Jan 8, 2020
1 parent c953e30 commit 20bdc93
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 24 deletions.
8 changes: 2 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
FROM golang:1.13 as builder

# Setting arguments
ARG git_version_arg
ARG git_commit_arg
ARG build_date_arg
ARG ldflags_arg


# Copy in the go src
Expand All @@ -17,9 +15,7 @@ ENV GO111MODULE on

# Build with ldflags set
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager \
-ldflags "-X ${git_version_arg} \
-X ${git_commit_arg} \
-X ${build_date_arg}" github.com/kudobuilder/kudo/cmd/manager
-ldflags "${ldflags_arg}" github.com/kudobuilder/kudo/cmd/manager

# Copy the controller-manager into a thin image
FROM ubuntu:18.04
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ clean: cli-clean test-clean manager-clean deploy-clean
.PHONY: docker-build
# Build the docker image
docker-build: generate lint
docker build --build-arg git_version_arg=${GIT_VERSION_PATH}=v${GIT_VERSION} \
--build-arg git_commit_arg=${GIT_COMMIT_PATH}=${GIT_COMMIT} \
--build-arg build_date_arg=${BUILD_DATE_PATH}=${BUILD_DATE} . -t ${DOCKER_IMG}:${DOCKER_TAG}
docker build --build-arg ldflags_arg="${LDFLAGS}" . -t ${DOCKER_IMG}:${DOCKER_TAG}
docker tag ${DOCKER_IMG}:${DOCKER_TAG} ${DOCKER_IMG}:v${GIT_VERSION}
docker tag ${DOCKER_IMG}:${DOCKER_TAG} ${DOCKER_IMG}:latest

Expand Down
42 changes: 30 additions & 12 deletions hack/run-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,46 @@ set -o pipefail
set -o xtrace

INTEGRATION_OUTPUT_JUNIT=${INTEGRATION_OUTPUT_JUNIT:-false}
VERSION=${VERSION:-test}

docker build . \
--build-arg ldflags_arg="" \
-t "kudobuilder/controller:$VERSION"

# Generate the kudo.yaml that is used to install KUDO while running e2e-test
./bin/kubectl-kudo init --dry-run --output yaml \
| sed -E -e "/image:/ s/:[[:alnum:]]+/:$VERSION/" -e '/imagePullPolicy/ s/Always/Never/' \
> test/manifests/kudo.yaml

sed "s/%version%/$VERSION/" kudo-e2e-test.yaml.tmpl > kudo-e2e-test.yaml

if [ "$INTEGRATION_OUTPUT_JUNIT" == true ]
then
echo "Running E2E tests with junit output"
mkdir -p reports/
go get github.com/jstemmer/go-junit-report

go run ./cmd/kubectl-kudo test --config kudo-e2e-test.yaml 2>&1 |tee /dev/fd/2 |go-junit-report -set-exit-code > reports/kudo_e2e_test_report.xml
./bin/kubectl-kudo test --config kudo-e2e-test.yaml 2>&1 \
| tee /dev/fd/2 \
| go-junit-report -set-exit-code \
> reports/kudo_e2e_test_report.xml

rm -rf operators
git clone https://github.com/kudobuilder/operators
mkdir operators/bin/
cp ./bin/kubectl-kudo operators/bin/
cd operators && go run ../cmd/kubectl-kudo test 2>&1 |tee /dev/fd/2 |go-junit-report -set-exit-code > ../reports/kudo_operators_test_report.xml
rm -rf operators
git clone https://github.com/kudobuilder/operators
mkdir operators/bin/
cp ./bin/kubectl-kudo operators/bin/
cd operators && ./bin/kubectl-kudo test 2>&1 \
| tee /dev/fd/2 \
| go-junit-report -set-exit-code \
> ../reports/kudo_operators_test_report.xml
else
echo "Running E2E tests without junit output"

go run ./cmd/kubectl-kudo test --config kudo-e2e-test.yaml
./bin/kubectl-kudo test --config kudo-e2e-test.yaml

rm -rf operators
git clone https://github.com/kudobuilder/operators
mkdir operators/bin/
cp ./bin/kubectl-kudo operators/bin/
cd operators && go run ../cmd/kubectl-kudo test
rm -rf operators
git clone https://github.com/kudobuilder/operators
mkdir operators/bin/
cp ./bin/kubectl-kudo operators/bin/
cd operators && ./bin/kubectl-kudo test
fi
4 changes: 3 additions & 1 deletion kudo-e2e-test.yaml → kudo-e2e-test.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ manifestDirs:
testDirs:
- ./test/e2e
startKIND: true
startKUDO: true
kindContainers:
- kudobuilder/controller:%version%
startKUDO: false
timeout: 300
4 changes: 2 additions & 2 deletions test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN apt-get update && apt-get install -y \
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" && \
apt-get update && apt-get install -y docker-ce-cli

COPY Makefile go.mod go.sum ./
COPY Dockerfile Makefile go.mod go.sum ./
RUN make download
COPY config/ config/
COPY pkg/ pkg/
Expand All @@ -21,4 +21,4 @@ COPY hack/run-integration-tests.sh hack/run-integration-tests.sh
COPY hack/run-e2e-tests.sh hack/run-e2e-tests.sh
COPY test/ test/
COPY kudo-test.yaml kudo-test.yaml
COPY kudo-e2e-test.yaml kudo-e2e-test.yaml
COPY kudo-e2e-test.yaml.tmpl kudo-e2e-test.yaml.tmpl

0 comments on commit 20bdc93

Please sign in to comment.