From f59b3fca11d40648c3b5a351786c893c4cd695cd Mon Sep 17 00:00:00 2001 From: az Date: Wed, 1 Dec 2021 18:24:29 +0100 Subject: [PATCH] add error handling for missing config --- .../local-integration-test/README.md | 20 +++++++++++++------ .../local-integration-test/setup-docker.sh | 16 ++++++++++++++- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/test/resources/local-integration-test/README.md b/src/test/resources/local-integration-test/README.md index 3ac8d69..e4d54b0 100644 --- a/src/test/resources/local-integration-test/README.md +++ b/src/test/resources/local-integration-test/README.md @@ -28,14 +28,22 @@ Note: In case of not being able to connect to "k3stesthost/health", you might ne - check files `aws --endpoint-url=http://k3stesthost s3 ls s3://mybucket` ## Run docker locally -`docker pull docker:19.03.12-dind` -`docker run -d --privileged --name integration-test docker:19.03.12-dind` + + +``` +docker pull docker:19.03.12-dind +docker run -d --privileged --name integration-test docker:19.03.12-dind +docker exec integration-test sh -c "apk add bash" + +``` Set up docker container integration-test: -`docker cp setup-docker.sh integration-test:/` -`docker exec -it integration-test sh` -`chmod +x setup-docker.sh` -`./setup-docker.sh` + +``` +docker cp setup-docker.sh integration-test:/ +docker exec -it integration-test sh +./setup-docker.sh +``` ## Deploy nextcloud diff --git a/src/test/resources/local-integration-test/setup-docker.sh b/src/test/resources/local-integration-test/setup-docker.sh index 5646c5c..5dae22a 100755 --- a/src/test/resources/local-integration-test/setup-docker.sh +++ b/src/test/resources/local-integration-test/setup-docker.sh @@ -1,8 +1,22 @@ +#!/bin/bash + +set -ex + docker run -d --privileged --tmpfs /run --tmpfs /var/run --restart always -e K3S_TOKEN=12345678901234 -e K3S_KUBECONFIG_OUTPUT=./kubeconfig.yaml -e K3S_KUBECONFIG_MODE=666 -v k3s-server:/var/lib/rancher/k3s:z -v $(pwd):/output:z -p 6443:6443 -p 80:80 -p 443:443 rancher/k3s server --cluster-init export timeout=60; while [ ! -f /var/lib/docker/volumes/k3s-server/_data/server/kubeconfig.yaml ]; do if [ "$timeout" == 0 ]; then echo "ERROR: Timeout while waiting for file."; break; fi; sleep 1; ((timeout--)); done -mkdir -p $HOME/.kube/ +if [ "$timeout" == 0 ] +then + echo ------------------------------------------------------- + find . -name "kubeconfig.yaml"; + echo ------------------------------------------------------- + docker ps -a + echo ------------------------------------------------------- + exit -1 +fi + +mkdir -p $HOME/.kube/ cp /var/lib/docker/volumes/k3s-server/_data/server/kubeconfig.yaml $HOME/.kube/config apk add git curl bash sudo openjdk8 wget