Skip to content

Commit

Permalink
Store KinD logs artifact in E2E tests (#1250)
Browse files Browse the repository at this point in the history
Co-Authored-By: Marcin Owsiany <mowsiany@D2iQ.com>
  • Loading branch information
Jan Schlicht and porridge committed Jan 24, 2020
1 parent e57a7b1 commit 9fb5fcd
Show file tree
Hide file tree
Showing 2 changed files with 23 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
23 changes: 21 additions & 2 deletions test/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@
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}

function archive_logs() {
# Archive test harness artifacts
if [ "$TARGET" == "e2e-test" ]; then
tar -cjvf kind-logs.tar.bz2 kind-logs/
fi
}

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

# 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 +37,18 @@ 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
if docker run -e INTEGRATION_OUTPUT_JUNIT --net=host -it --rm -m 4g \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$(pwd)"/reports:/go/src/github.com/kudobuilder/kudo/reports \
-v "$(pwd)"/kind-logs:/tmp/kudo-e2e-test \
kudo-test bash -c "make $TARGET; ret=\$?; chmod a+r -R /tmp/kudo-e2e-test; exit \$ret"
then
archive_logs
echo "Tests finished successfully! ヽ(•‿•)ノ"
else
exit $?
RESULT=$?
archive_logs
exit $RESULT
fi
else
echo "Error when building test docker image, cannot run tests."
Expand Down

0 comments on commit 9fb5fcd

Please sign in to comment.