From 24796928e9306f20d51a5be6facec4e685da845c Mon Sep 17 00:00:00 2001 From: Frederik Ring Date: Fri, 10 Feb 2023 18:50:41 +0100 Subject: [PATCH] Add test case as per #187 --- test/order/docker-compose.yml | 28 ++++++++++++++++++++++++++++ test/order/fixture/test.txt | 1 + test/order/run.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 test/order/docker-compose.yml create mode 100644 test/order/fixture/test.txt create mode 100644 test/order/run.sh diff --git a/test/order/docker-compose.yml b/test/order/docker-compose.yml new file mode 100644 index 0000000..ce6b485 --- /dev/null +++ b/test/order/docker-compose.yml @@ -0,0 +1,28 @@ +version: "3" + +services: + rsync: + image: eeacms/rsync + tty: true + restart: unless-stopped + labels: + - docker-volume-backup.exec-label=order + - docker-volume-backup.archive-pre=sh -c "rsync -aAX --ignore-missing-args --delete-missing-args /data/ /bu/" + - docker-volume-backup.archive-post=sh -c "rm -rf /bu/*" + volumes: + - ./fixture:/data:ro + - bu:/bu + + backup: + image: offen/docker-volume-backup:${TEST_VERSION:-canary} + restart: always + environment: + BACKUP_FILENAME: backup.tar.gz + BACKUP_EXEC_LABEL: order + volumes: + - bu:/backup/order:ro + - ./local:/archive + - /var/run/docker.sock:/var/run/docker.sock + +volumes: + bu: diff --git a/test/order/fixture/test.txt b/test/order/fixture/test.txt new file mode 100644 index 0000000..9766475 --- /dev/null +++ b/test/order/fixture/test.txt @@ -0,0 +1 @@ +ok diff --git a/test/order/run.sh b/test/order/run.sh new file mode 100644 index 0000000..730c5e3 --- /dev/null +++ b/test/order/run.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) +. ../util.sh +current_test=$(basename $(pwd)) + +mkdir -p local + +docker compose up -d +sleep 10 + +docker compose exec backup backup + +if [ ! -f "./local/backup.tar.gz" ]; then + fail "Could not find expected backup file." +fi + +tmp_dir=$(mktemp -d) +tar -xvf ./local/backup.tar.gz -C $tmp_dir +if [ ! -f "$tmp_dir/backup/order/test.txt" ]; then + fail "Could not find expected file in untared archive." +fi + +docker compose down --volumes