mirror of
https://github.com/offen/docker-volume-backup.git
synced 2025-09-05 05:54:52 +08:00
Compose profiles can be used
This commit is contained in:
parent
295387acd1
commit
c050d38b93
4 changed files with 24 additions and 78 deletions
|
@ -39,14 +39,6 @@ Setting this value lets you run tests against different existing images, so you
|
|||
IMAGE_TAG=v2.30.0 ./test.sh
|
||||
```
|
||||
|
||||
#### `NO_IMAGE_CACHE`
|
||||
|
||||
When set, images from remote registries will not be cached and shared between sandbox containers.
|
||||
|
||||
```sh
|
||||
NO_IMAGE_CACHE=1 ./test.sh
|
||||
```
|
||||
|
||||
By default, two local images are created that persist the image data and provide it to containers at runtime.
|
||||
|
||||
## Understanding the test setup
|
||||
|
@ -68,3 +60,10 @@ cd "$(dirname "$0")"
|
|||
. ../util.sh
|
||||
current_test=$(basename $(pwd))
|
||||
```
|
||||
|
||||
### Running tests in swarm mode
|
||||
|
||||
A test case can signal it wants to run in swarm mode by placing an empty `.swarm` file inside the directory.
|
||||
In case the swarm setup should be compose of multiple nodes, a `.multinode` file can be used.
|
||||
|
||||
A multinode setup will contain one manager (`manager`) and two worker nodes (`worker1` and `worker2`).
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
services:
|
||||
manager:
|
||||
privileged: true
|
||||
image: offen/docker-volume-backup:test-sandbox
|
||||
environment:
|
||||
DOCKER_TLS_CERTDIR: ''
|
||||
healthcheck:
|
||||
test: ["CMD", "docker", "info"]
|
||||
interval: 1s
|
||||
timeout: 5s
|
||||
retries: 50
|
||||
volumes:
|
||||
- $SOURCE:/code
|
||||
- $TARBALL:/cache/image.tar.gz
|
||||
- docker_volume_backup_test_sandbox_image:/var/lib/docker/image
|
||||
- docker_volume_backup_test_sandbox_overlay2:/var/lib/docker/overlay2
|
||||
networks:
|
||||
- sandbox
|
||||
|
||||
worker1:
|
||||
privileged: true
|
||||
image: offen/docker-volume-backup:test-sandbox
|
||||
healthcheck:
|
||||
test: ["CMD", "docker", "info"]
|
||||
interval: 1s
|
||||
timeout: 5s
|
||||
retries: 50
|
||||
environment:
|
||||
DOCKER_TLS_CERTDIR: ''
|
||||
volumes:
|
||||
- $SOURCE:/code
|
||||
- $TARBALL:/cache/image.tar.gz
|
||||
- docker_volume_backup_test_sandbox_image:/var/lib/docker/image
|
||||
- docker_volume_backup_test_sandbox_overlay2:/var/lib/docker/overlay2
|
||||
networks:
|
||||
- sandbox
|
||||
|
||||
worker2:
|
||||
privileged: true
|
||||
image: offen/docker-volume-backup:test-sandbox
|
||||
healthcheck:
|
||||
test: ["CMD", "docker", "info"]
|
||||
interval: 1s
|
||||
timeout: 5s
|
||||
retries: 50
|
||||
environment:
|
||||
DOCKER_TLS_CERTDIR: ''
|
||||
volumes:
|
||||
- $SOURCE:/code
|
||||
- $TARBALL:/cache/image.tar.gz
|
||||
- docker_volume_backup_test_sandbox_image:/var/lib/docker/image
|
||||
- docker_volume_backup_test_sandbox_overlay2:/var/lib/docker/overlay2
|
||||
networks:
|
||||
- sandbox
|
||||
|
||||
networks:
|
||||
sandbox:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
docker_volume_backup_test_sandbox_image:
|
||||
docker_volume_backup_test_sandbox_overlay2:
|
|
@ -1,5 +1,5 @@
|
|||
services:
|
||||
manager:
|
||||
manager: &node
|
||||
privileged: true
|
||||
image: offen/docker-volume-backup:test-sandbox
|
||||
healthcheck:
|
||||
|
@ -13,6 +13,15 @@ services:
|
|||
- docker_volume_backup_test_sandbox_image:/var/lib/docker/image
|
||||
- docker_volume_backup_test_sandbox_overlay2:/var/lib/docker/overlay2
|
||||
|
||||
worker1:
|
||||
<<: *node
|
||||
profiles:
|
||||
- multinode
|
||||
worker2:
|
||||
<<: *node
|
||||
profiles:
|
||||
- multinode
|
||||
|
||||
volumes:
|
||||
docker_volume_backup_test_sandbox_image:
|
||||
docker_volume_backup_test_sandbox_overlay2:
|
||||
|
|
14
test/test.sh
14
test/test.sh
|
@ -7,13 +7,13 @@ IMAGE_TAG=${IMAGE_TAG:-canary}
|
|||
|
||||
sandbox="docker_volume_backup_test_sandbox"
|
||||
tarball="$(mktemp -d)/image.tar.gz"
|
||||
compose_file="docker-compose.yml"
|
||||
compose_profile="default"
|
||||
|
||||
trap finish EXIT INT TERM
|
||||
|
||||
finish () {
|
||||
rm -rf $(dirname $tarball)
|
||||
docker compose -f $compose_file down
|
||||
docker compose --profile $compose_profile down
|
||||
}
|
||||
|
||||
docker build -t offen/docker-volume-backup:test-sandbox .
|
||||
|
@ -40,15 +40,15 @@ for dir in $(find $find_args | sort); do
|
|||
export TARBALL=$tarball
|
||||
export SOURCE=$(dirname $(pwd))
|
||||
|
||||
if [ -f ${dir}/.multinodeswarm ]; then
|
||||
compose_file="docker-compose.multinode.yml"
|
||||
if [ -f ${dir}/.multinode ]; then
|
||||
compose_profile="multinode"
|
||||
fi
|
||||
|
||||
docker compose -f $compose_file up -d --wait
|
||||
docker compose --profile $compose_profile up -d --wait
|
||||
|
||||
if [ -f "${dir}/.swarm" ]; then
|
||||
docker compose exec manager docker swarm init
|
||||
elif [ -f "${dir}/.multinodeswarm" ]; then
|
||||
elif [ -f "${dir}/.multinode" ]; then
|
||||
docker compose exec manager docker swarm init
|
||||
manager_ip=$(docker compose exec manager docker node inspect $(docker compose exec manager docker node ls -q) --format '{{ .Status.Addr }}')
|
||||
token=$(docker compose exec manager docker swarm join-token -q worker)
|
||||
|
@ -59,7 +59,7 @@ for dir in $(find $find_args | sort); do
|
|||
docker compose exec manager /bin/sh -c "docker load -i /cache/image.tar.gz"
|
||||
docker compose exec -e TEST_VERSION=$IMAGE_TAG manager /bin/sh -c "/code/test/$test"
|
||||
|
||||
docker compose -f $compose_file down
|
||||
docker compose --profile $compose_profile down
|
||||
echo ""
|
||||
echo "$test passed"
|
||||
echo ""
|
||||
|
|
Loading…
Add table
Reference in a new issue