mirror of
https://github.com/offen/docker-volume-backup.git
synced 2026-01-11 03:15:39 +08:00
Add integration tests
This commit is contained in:
parent
af35c763a5
commit
f615c2b3fa
4 changed files with 78 additions and 0 deletions
2
test/show-config/conf.d/01show-config.env
Normal file
2
test/show-config/conf.d/01show-config.env
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
BACKUP_SOURCES=/conf-backup
|
||||
NOTIFICATION_URLS_FILE=/run/secrets/notification_urls
|
||||
6
test/show-config/docker-compose.confd.yml
Normal file
6
test/show-config/docker-compose.confd.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
services:
|
||||
backup:
|
||||
image: offen/docker-volume-backup:${TEST_VERSION:-canary}
|
||||
volumes:
|
||||
- ${CONF_DIR}:/etc/dockervolumebackup/conf.d:ro
|
||||
- ${SECRET_FILE}:/run/secrets/notification_urls:ro
|
||||
7
test/show-config/docker-compose.yml
Normal file
7
test/show-config/docker-compose.yml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
services:
|
||||
backup:
|
||||
image: offen/docker-volume-backup:${TEST_VERSION:-canary}
|
||||
environment:
|
||||
BACKUP_SOURCES: /backup
|
||||
NOTIFICATION_URLS: "stdout://"
|
||||
AWS_S3_BUCKET_NAME: example-bucket
|
||||
63
test/show-config/run.sh
Executable file
63
test/show-config/run.sh
Executable file
|
|
@ -0,0 +1,63 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
. ../util.sh
|
||||
current_test=$(basename $(pwd))
|
||||
|
||||
info "show-config with environment variables"
|
||||
docker compose up -d --quiet-pull
|
||||
logs=$(docker compose exec -T backup backup show-config)
|
||||
|
||||
echo "$logs"
|
||||
|
||||
if ! echo "$logs" | grep -q "source=from environment"; then
|
||||
fail "Missing source line."
|
||||
fi
|
||||
pass "Source line present."
|
||||
|
||||
if ! echo "$logs" | grep -q "BackupSources:/backup"; then
|
||||
fail "Missing BACKUP_SOURCES in output."
|
||||
fi
|
||||
pass "BACKUP_SOURCES present."
|
||||
|
||||
if ! echo "$logs" | grep -q "NotificationURLs:\[stdout://\]"; then
|
||||
fail "Missing NOTIFICATION_URLS in output."
|
||||
fi
|
||||
pass "NOTIFICATION_URLS present."
|
||||
|
||||
if ! echo "$logs" | grep -q "AwsS3BucketName:example-bucket"; then
|
||||
fail "Missing AWS_S3_BUCKET_NAME in output."
|
||||
fi
|
||||
pass "AWS_S3_BUCKET_NAME present."
|
||||
|
||||
docker compose down
|
||||
|
||||
info "show-config with conf.d and _FILE"
|
||||
export CONF_DIR=$(pwd)/conf.d
|
||||
export SECRET_FILE=$(mktemp)
|
||||
printf "stdout://\n" > "$SECRET_FILE"
|
||||
|
||||
docker compose -f docker-compose.confd.yml up -d --quiet-pull
|
||||
logs=$(docker compose -f docker-compose.confd.yml exec -T backup backup show-config)
|
||||
|
||||
echo "$logs"
|
||||
|
||||
if ! echo "$logs" | grep -q "source=01show-config.env"; then
|
||||
fail "Missing conf.d source line."
|
||||
fi
|
||||
pass "conf.d source line present."
|
||||
|
||||
if ! echo "$logs" | grep -q "BackupSources:/conf-backup"; then
|
||||
fail "Missing conf.d BACKUP_SOURCES in output."
|
||||
fi
|
||||
pass "conf.d BACKUP_SOURCES present."
|
||||
|
||||
if ! echo "$logs" | grep -q "NotificationURLs:\\[stdout://"; then
|
||||
fail "Missing conf.d NOTIFICATION_URLS in output."
|
||||
fi
|
||||
pass "conf.d NOTIFICATION_URLS present."
|
||||
|
||||
docker compose -f docker-compose.confd.yml down
|
||||
rm -f "$SECRET_FILE"
|
||||
Loading…
Add table
Reference in a new issue