From dc2720ab023d07b9b0d4afc1bb0946ab8228c87f Mon Sep 17 00:00:00 2001 From: ansgarz Date: Wed, 8 Dec 2021 10:20:22 +0100 Subject: [PATCH] initial --- .gitlab-ci.yml | 9 +++++---- infrastructure/docker-backup/image/resources/backup.sh | 3 ++- src/test/resources/local-integration-test/README.md | 3 ++- .../resources/local-integration-test/setup-docker.sh | 9 +++++---- .../local-integration-test/setup-local-s3-on-k3d.sh | 4 ++-- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e02a08a..903a5aa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -156,17 +156,18 @@ nextcloud-integrationtest: stage: integrationtest image: docker:latest rules: - - if: '$CI_COMMIT_BRANCH == "local-integration-test"' + - if: '$CI_COMMIT_BRANCH == "integration-test-w-o-db-backup"' services: - docker:dind before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - apk add bash + - docker build --pull -t "$CI_REGISTRY_IMAGE" . + #- docker run --name "$name" -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 --tls-san k3stesthost --tls-san cloudhost + #- docker run --privileged -dit --name c4k_test -v /var/run/docker.sock:/var/run/docker.sock $CI_REGISTRY_IMAGE + - docker inspect -f '{{.State.Running}}' c4k_test script: - echo "---------- Integration test -------------" -# - docker build --pull -t "$CI_REGISTRY_IMAGE" . -# - docker run --privileged -dit --name provs_test -v /var/run/docker.sock:/var/run/docker.sock $CI_REGISTRY_IMAGE -# - docker inspect -f '{{.State.Running}}' provs_test - ls -l - pwd - bash ./src/test/resources/local-integration-test/setup-docker.sh diff --git a/infrastructure/docker-backup/image/resources/backup.sh b/infrastructure/docker-backup/image/resources/backup.sh index c28cf98..22d7133 100755 --- a/infrastructure/docker-backup/image/resources/backup.sh +++ b/infrastructure/docker-backup/image/resources/backup.sh @@ -14,7 +14,8 @@ function main() { file_env RESTIC_DAYS_TO_KEEP 14 backup-roles 'oc_' - backup-db-dump + ;backup-db-dump + echo test-content > /var/backups/tmpfile backup-directory '/var/backups/' end-maintenance.sh diff --git a/src/test/resources/local-integration-test/README.md b/src/test/resources/local-integration-test/README.md index e4d54b0..ae3f8b9 100644 --- a/src/test/resources/local-integration-test/README.md +++ b/src/test/resources/local-integration-test/README.md @@ -40,8 +40,9 @@ docker exec integration-test sh -c "apk add bash" Set up docker container integration-test: ``` -docker cp setup-docker.sh integration-test:/ +docker cp ../../../../../c4k-nextcloud/ integration-test:/ docker exec -it integration-test sh +cd /c4k-nextcloud/src/test/resources/local-integration-test ./setup-docker.sh ``` diff --git a/src/test/resources/local-integration-test/setup-docker.sh b/src/test/resources/local-integration-test/setup-docker.sh index 62fd467..3ff2b7c 100755 --- a/src/test/resources/local-integration-test/setup-docker.sh +++ b/src/test/resources/local-integration-test/setup-docker.sh @@ -4,7 +4,10 @@ set -ex docker volume create k3s-server -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 +container_name='intst' + +[[ $(docker ps -f "name=$name" --format '{{.Names}}') == $name ]] || +docker run --name "$name" -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 --tls-san k3stesthost --tls-san cloudhost export timeout=30; 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 @@ -21,7 +24,7 @@ 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 +apk add wget curl bash sudo openjdk8 wget -P /etc/apk/keys/ https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub apk add --no-cache --repository=https://apkproxy.herokuapp.com/sgerrand/alpine-pkg-leiningen leiningen @@ -29,6 +32,4 @@ curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.22.0/bin/l chmod +x ./kubectl mv ./kubectl /usr/local/bin/kubectl -git clone https://gitlab.com/domaindrivenarchitecture/c4k-nextcloud.git -cd /c4k-nextcloud && git checkout local-integration-test cd /c4k-nextcloud/src/test/resources/local-integration-test && ./setup-local-s3-on-k3d.sh \ No newline at end of file diff --git a/src/test/resources/local-integration-test/setup-local-s3-on-k3d.sh b/src/test/resources/local-integration-test/setup-local-s3-on-k3d.sh index 531cfbe..1a20055 100755 --- a/src/test/resources/local-integration-test/setup-local-s3-on-k3d.sh +++ b/src/test/resources/local-integration-test/setup-local-s3-on-k3d.sh @@ -30,9 +30,9 @@ function main() kubectl scale deployment backup-restore --replicas 1 echo - until curl --silent --fail k3stesthost:80 k3stesthost/health | grep -o '"s3": "available"' + until curl --fail --silent k3stesthost/health | grep -oe '"s3": "available"' -oe '"s3": "running"' do - curl --fail k3stesthost:80 k3stesthost/health + curl --fail k3stesthost/health echo "[INFO] Waiting for s3 running" sleep 3 done