Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store KinD logs artifact in E2E tests #1250

Merged
merged 14 commits into from
Jan 24, 2020
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,16 +3,27 @@
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 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)

function archive_logs() {
nfnt marked this conversation as resolved.
Show resolved Hide resolved
# Archive test harness artifacts
if [ "$TARGET" == "e2e-test" ]; then
tar -cjvf kind-logs.tar.bz2 kind-logs/
fi
}

if ! docker inspect "$builder_image"; then
until docker pull "$builder_image"; do
if [ $retries -eq 3 ]; then
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; chmod a+r -R /tmp/kudo-e2e-test"
nfnt marked this conversation as resolved.
Show resolved Hide resolved
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