mirror of
https://github.com/offen/docker-volume-backup.git
synced 2026-04-15 05:45:34 +02:00
Run tests Docker in Docker (#261)
* Try running tests in Docker * Spawn new container for each test * Store test artifacts outside of mount * When requested, build up to date image in test script * sudo is unneccessary in containerized test env * Skip azure test * Backdate fixture file in JSON database * Pin versions for azure tools * Mount temp volume for /var/lib/docker to prevent dangling ones created by VOLUME instruction * Fail backdating tests with message * Add some documentation on test setup * Cache images * Run compose stacks with shortened default timeout
This commit is contained in:
2
test/user/.gitignore
vendored
2
test/user/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
local
|
||||
backup
|
||||
@@ -10,7 +10,6 @@ services:
|
||||
- docker-volume-backup.archive-pre.user=testuser
|
||||
- docker-volume-backup.archive-pre=/bin/sh -c 'whoami > /tmp/whoami.txt'
|
||||
|
||||
|
||||
backup:
|
||||
image: offen/docker-volume-backup:${TEST_VERSION:-canary}
|
||||
deploy:
|
||||
@@ -21,10 +20,10 @@ services:
|
||||
BACKUP_CRON_EXPRESSION: 0 0 5 31 2 ?
|
||||
EXEC_FORWARD_OUTPUT: "true"
|
||||
volumes:
|
||||
- ./local:/archive
|
||||
- ${LOCAL_DIR:-./local}:/archive
|
||||
- app_data:/backup/data:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
|
||||
volumes:
|
||||
app_data:
|
||||
archive:
|
||||
archive:
|
||||
|
||||
18
test/user/run.sh
Normal file → Executable file
18
test/user/run.sh
Normal file → Executable file
@@ -6,25 +6,25 @@ cd $(dirname $0)
|
||||
. ../util.sh
|
||||
current_test=$(basename $(pwd))
|
||||
|
||||
docker compose up -d --quiet-pull
|
||||
export LOCAL_DIR=$(mktemp -d)
|
||||
export TMP_DIR=$(mktemp -d)
|
||||
|
||||
echo "LOCAL_DIR $LOCAL_DIR"
|
||||
echo "TMP_DIR $TMP_DIR"
|
||||
|
||||
docker compose up -d --quiet-pull
|
||||
user_name=testuser
|
||||
docker exec user-alpine-1 adduser --disabled-password "$user_name"
|
||||
|
||||
docker compose exec backup backup
|
||||
|
||||
tar -xvf ./local/test.tar.gz
|
||||
if [ ! -f ./backup/data/whoami.txt ]; then
|
||||
tar -xvf "$LOCAL_DIR/test.tar.gz" -C "$TMP_DIR"
|
||||
if [ ! -f "$TMP_DIR/backup/data/whoami.txt" ]; then
|
||||
fail "Could not find file written by pre command."
|
||||
fi
|
||||
pass "Found expected file."
|
||||
|
||||
tar -xvf ./local/test.tar.gz
|
||||
if [ "$(cat ./backup/data/whoami.txt)" != "$user_name" ]; then
|
||||
if [ "$(cat $TMP_DIR/backup/data/whoami.txt)" != "$user_name" ]; then
|
||||
fail "Could not find expected user name."
|
||||
fi
|
||||
pass "Found expected user."
|
||||
|
||||
docker compose down --volumes
|
||||
sudo rm -rf ./local
|
||||
|
||||
|
||||
Reference in New Issue
Block a user