mirror of
https://github.com/offen/docker-volume-backup.git
synced 2026-02-09 05:42:27 +01:00
Check whether container and service labels collide
This commit is contained in:
28
test/collision/docker-compose.yml
Normal file
28
test/collision/docker-compose.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
# Copyright 2020-2021 - Offen Authors <hioffen@posteo.de>
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
backup:
|
||||
image: offen/docker-volume-backup:${TEST_VERSION:-canary}
|
||||
environment:
|
||||
BACKUP_FILENAME: test.tar.gz
|
||||
volumes:
|
||||
- offen_data:/backup/offen_data:ro
|
||||
- ${LOCAL_DIR:-./local}:/archive
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
|
||||
offen:
|
||||
image: offen/offen:latest
|
||||
labels:
|
||||
- docker-volume-backup.stop-during-backup=true
|
||||
deploy:
|
||||
labels:
|
||||
- docker-volume-backup.stop-during-backup=true
|
||||
replicas: 2
|
||||
volumes:
|
||||
- offen_data:/var/opt/offen
|
||||
|
||||
volumes:
|
||||
offen_data:
|
||||
34
test/collision/run.sh
Executable file
34
test/collision/run.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
. ../util.sh
|
||||
current_test=$(basename $(pwd))
|
||||
|
||||
export LOCAL_DIR=$(mktemp -d)
|
||||
|
||||
docker swarm init
|
||||
|
||||
docker stack deploy --compose-file=docker-compose.yml test_stack
|
||||
|
||||
while [ -z $(docker ps -q -f name=backup) ]; do
|
||||
info "Backup container not ready yet. Retrying."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
sleep 20
|
||||
|
||||
set +e
|
||||
docker exec $(docker ps -q -f name=backup) backup
|
||||
if [ $? = "0" ]; then
|
||||
fail "Expected script to exit with error code."
|
||||
fi
|
||||
|
||||
if [ -f "${LOCAL_DIR}/test.tar.gz" ]; then
|
||||
fail "Found backup file that should not have been created."
|
||||
fi
|
||||
|
||||
expect_running_containers "3"
|
||||
|
||||
pass "Script did not perform backup as there was a label collision."
|
||||
Reference in New Issue
Block a user