mirror of
https://github.com/offen/docker-volume-backup.git
synced 2024-12-23 09:20:22 +01:00
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:
parent
c87dc09ad4
commit
e7631d8d53
@ -35,7 +35,7 @@ services:
|
||||
volumes:
|
||||
- app_data:/backup/app_data:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- ./local:/archive
|
||||
- ${LOCAL_DIR:-./local}:/archive
|
||||
|
||||
offen:
|
||||
image: offen/offen:latest
|
||||
|
@ -9,7 +9,7 @@ cd "$(dirname "$0")"
|
||||
. ../util.sh
|
||||
current_test=$(basename $(pwd))
|
||||
|
||||
mkdir -p local
|
||||
export LOCAL_DIR=$(mktemp -d)
|
||||
|
||||
docker compose up -d --quiet-pull
|
||||
sleep 5
|
||||
@ -20,7 +20,7 @@ sleep 5
|
||||
|
||||
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 \
|
||||
-v minio_backup_data:/minio_data \
|
||||
@ -36,7 +36,9 @@ info "Create backup with no prune for s3 backend"
|
||||
docker compose exec backup backup
|
||||
|
||||
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)"
|
||||
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)
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
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"
|
||||
fi
|
||||
|
||||
|
17
test/test.sh
17
test/test.sh
@ -49,16 +49,27 @@ for dir in $(find $find_args | sort); do
|
||||
|
||||
if [ -z "$NO_IMAGE_CACHE" ]; then
|
||||
docker_run_args="$docker_run_args \
|
||||
-v "${sandbox}_image":/var/lib/docker/image \
|
||||
-v "${sandbox}_overlay2":/var/lib/docker/overlay2"
|
||||
-v "${sandbox}_image":/var/lib/docker/image \
|
||||
-v "${sandbox}_overlay2":/var/lib/docker/overlay2"
|
||||
fi
|
||||
|
||||
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
|
||||
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
|
||||
retry_counter=$((retry_counter+1))
|
||||
done
|
||||
sleep 0.5
|
||||
|
||||
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"
|
||||
|
Loading…
Reference in New Issue
Block a user