Retry creation of sandbox container (#276)

* Extend sleep when Docker daemon seems ready

* Pruning test shall not write to local fs

* Make sure container names do not conflict
This commit is contained in:
Frederik Ring 2023-09-19 14:45:09 +02:00 committed by GitHub
parent c87dc09ad4
commit e7631d8d53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 9 deletions

View File

@ -35,7 +35,7 @@ services:
volumes: volumes:
- app_data:/backup/app_data:ro - app_data:/backup/app_data:ro
- /var/run/docker.sock:/var/run/docker.sock - /var/run/docker.sock:/var/run/docker.sock
- ./local:/archive - ${LOCAL_DIR:-./local}:/archive
offen: offen:
image: offen/offen:latest image: offen/offen:latest

View File

@ -9,7 +9,7 @@ cd "$(dirname "$0")"
. ../util.sh . ../util.sh
current_test=$(basename $(pwd)) current_test=$(basename $(pwd))
mkdir -p local export LOCAL_DIR=$(mktemp -d)
docker compose up -d --quiet-pull docker compose up -d --quiet-pull
sleep 5 sleep 5
@ -20,7 +20,7 @@ sleep 5
expect_running_containers "3" expect_running_containers "3"
touch -r ./local/test-hostnametoken.tar.gz -d "14 days ago" ./local/test-hostnametoken-old.tar.gz touch -r "$LOCAL_DIR/test-hostnametoken.tar.gz" -d "14 days ago" "$LOCAL_DIR/test-hostnametoken-old.tar.gz"
docker run --rm \ docker run --rm \
-v minio_backup_data:/minio_data \ -v minio_backup_data:/minio_data \
@ -36,7 +36,9 @@ info "Create backup with no prune for s3 backend"
docker compose exec backup backup docker compose exec backup backup
info "Check if old backup has been pruned (local)" info "Check if old backup has been pruned (local)"
test ! -f ./local/test-hostnametoken-old.tar.gz if [ -f "$LOCAL_DIR/test-hostnametoken-old.tar.gz" ]; then
fail "Expired backup was not pruned from local storage."
fi
info "Check if old backup has NOT been pruned (s3)" info "Check if old backup has NOT been pruned (s3)"
docker run --rm \ docker run --rm \
@ -48,7 +50,7 @@ pass "Old remote backup has been pruned locally, skipped S3 backend is untouched
# Skip local and s3 backend from prune (all backends) # Skip local and s3 backend from prune (all backends)
touch -r ./local/test-hostnametoken.tar.gz -d "14 days ago" ./local/test-hostnametoken-old.tar.gz touch -r "$LOCAL_DIR/test-hostnametoken.tar.gz" -d "14 days ago" "$LOCAL_DIR/test-hostnametoken-old.tar.gz"
docker compose up -d docker compose up -d
sleep 5 sleep 5
@ -57,7 +59,7 @@ info "Create backup with no prune for both backends"
docker compose exec -e BACKUP_SKIP_BACKENDS_FROM_PRUNE="s3,local" backup backup docker compose exec -e BACKUP_SKIP_BACKENDS_FROM_PRUNE="s3,local" backup backup
info "Check if old backup has NOT been pruned (local)" info "Check if old backup has NOT been pruned (local)"
if [ ! -f ./local/test-hostnametoken-old.tar.gz ]; then if [ ! -f "$LOCAL_DIR/test-hostnametoken-old.tar.gz" ]; then
fail "Backdated file has not been deleted" fail "Backdated file has not been deleted"
fi fi

View File

@ -55,10 +55,21 @@ for dir in $(find $find_args | sort); do
docker run $docker_run_args offen/docker-volume-backup:test-sandbox docker run $docker_run_args offen/docker-volume-backup:test-sandbox
retry_counter=0
until docker exec $sandbox /bin/sh -c 'docker info' > /dev/null 2>&1; do until docker exec $sandbox /bin/sh -c 'docker info' > /dev/null 2>&1; do
if [ $retry_counter -gt 20 ]; then
echo "Gave up waiting for Docker daemon to become ready after 20 attempts"
exit 1
fi
if [ "$(docker inspect $sandbox --format '{{ .State.Running }}')" = "false" ]; then
docker rm $sandbox
docker run $docker_run_args offen/docker-volume-backup:test-sandbox
fi
sleep 0.5 sleep 0.5
retry_counter=$((retry_counter+1))
done done
sleep 0.5
docker exec $sandbox /bin/sh -c "docker load -i /cache/image.tar.gz" docker exec $sandbox /bin/sh -c "docker load -i /cache/image.tar.gz"
docker exec -e TEST_VERSION=$IMAGE_TAG $sandbox /bin/sh -c "/code/test/$test" docker exec -e TEST_VERSION=$IMAGE_TAG $sandbox /bin/sh -c "/code/test/$test"