Skip to content

Commit 18db772

Browse files
committed
Add integration tests
1 parent d9353c1 commit 18db772

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BACKUP_SOURCES=/conf-backup
2+
NOTIFICATION_URLS_FILE=/run/secrets/notification_urls
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
services:
2+
backup:
3+
image: offen/docker-volume-backup:${TEST_VERSION:-canary}
4+
volumes:
5+
- ${CONF_DIR}:/etc/dockervolumebackup/conf.d:ro
6+
- ${SECRET_FILE}:/run/secrets/notification_urls:ro
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
services:
2+
backup:
3+
image: offen/docker-volume-backup:${TEST_VERSION:-canary}
4+
environment:
5+
BACKUP_SOURCES: /backup
6+
NOTIFICATION_URLS: "stdout://"
7+
AWS_S3_BUCKET_NAME: example-bucket

test/show-config/run.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
cd "$(dirname "$0")"
6+
. ../util.sh
7+
current_test=$(basename $(pwd))
8+
9+
info "show-config with environment variables"
10+
docker compose up -d --quiet-pull
11+
logs=$(docker compose exec -T backup backup show-config)
12+
13+
echo "$logs"
14+
15+
if ! echo "$logs" | grep -q "source=from environment"; then
16+
fail "Missing source line."
17+
fi
18+
pass "Source line present."
19+
20+
if ! echo "$logs" | grep -q "BackupSources:/backup"; then
21+
fail "Missing BACKUP_SOURCES in output."
22+
fi
23+
pass "BACKUP_SOURCES present."
24+
25+
if ! echo "$logs" | grep -q "NotificationURLs:\[stdout://\]"; then
26+
fail "Missing NOTIFICATION_URLS in output."
27+
fi
28+
pass "NOTIFICATION_URLS present."
29+
30+
if ! echo "$logs" | grep -q "AwsS3BucketName:example-bucket"; then
31+
fail "Missing AWS_S3_BUCKET_NAME in output."
32+
fi
33+
pass "AWS_S3_BUCKET_NAME present."
34+
35+
docker compose down
36+
37+
info "show-config with conf.d and _FILE"
38+
export CONF_DIR=$(pwd)/conf.d
39+
export SECRET_FILE=$(mktemp)
40+
printf "stdout://\n" > "$SECRET_FILE"
41+
42+
docker compose -f docker-compose.confd.yml up -d --quiet-pull
43+
logs=$(docker compose -f docker-compose.confd.yml exec -T backup backup show-config)
44+
45+
echo "$logs"
46+
47+
if ! echo "$logs" | grep -q "source=01show-config.env"; then
48+
fail "Missing conf.d source line."
49+
fi
50+
pass "conf.d source line present."
51+
52+
if ! echo "$logs" | grep -q "BackupSources:/conf-backup"; then
53+
fail "Missing conf.d BACKUP_SOURCES in output."
54+
fi
55+
pass "conf.d BACKUP_SOURCES present."
56+
57+
if ! echo "$logs" | grep -q "NotificationURLs:\\[stdout://"; then
58+
fail "Missing conf.d NOTIFICATION_URLS in output."
59+
fi
60+
pass "conf.d NOTIFICATION_URLS present."
61+
62+
docker compose -f docker-compose.confd.yml down
63+
rm -f "$SECRET_FILE"

0 commit comments

Comments
 (0)