Skip to content

Commit

Permalink
Store KinD logs artifact in E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Schlicht committed Jan 8, 2020
1 parent 3e2625e commit 9a21216
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
- run: ./test/run_tests.sh e2e-test
- store_test_results:
path: reports/
- store_artifacts:
path: kind-logs.tar.bz2

lint:
docker:
Expand Down
19 changes: 17 additions & 2 deletions test/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
set -o errexit
set -o nounset
set -o pipefail
set -o xtrace

# "TARGET" is a Makefile target that runs tests
TARGET=$1

INTEGRATION_OUTPUT_JUNIT=${INTEGRATION_OUTPUT_JUNIT:-false}

# Set test harness artifacts dir to '/tmp/kudo-e2e-test', as it's easier to copy from in a container.
echo 'artifactsDir: /tmp/kudo-e2e-test' >> kudo-e2e-test.yaml

# Pull the builder image with retries if it doesn't already exist.
retries=0
builder_image=$(awk '/FROM/ {print $2}' test/Dockerfile)
Expand All @@ -26,10 +30,21 @@ if ! docker inspect "$builder_image"; then
fi

if docker build -f test/Dockerfile -t kudo-test .; then
if docker run -e INTEGRATION_OUTPUT_JUNIT --net=host -it -m 4g -v /var/run/docker.sock:/var/run/docker.sock -v "$(pwd)"/reports:/go/src/github.com/kudobuilder/kudo/reports --rm kudo-test make "$TARGET"; then
docker run -e INTEGRATION_OUTPUT_JUNIT --net=host -it -m 4g \
--name kudo-e2e-test \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$(pwd)"/reports:/go/src/github.com/kudobuilder/kudo/reports \
kudo-test make "$TARGET"
RESULT=$?

# Archive test harness artifacts
docker cp kudo-e2e-test:/tmp/kudo-e2e-test - | bzip2 > kind-logs.tar.bz2
docker rm kudo-e2e-test

if [ $RESULT -eq 0 ]; then
echo "Tests finished successfully! ヽ(•‿•)ノ"
else
exit $?
exit $RESULT
fi
else
echo "Error when building test docker image, cannot run tests."
Expand Down

0 comments on commit 9a21216

Please sign in to comment.