mirror of
https://github.com/ViViDboarder/docker-restic-cron.git
synced 2024-11-24 14:16:36 +00:00
Minor improvement on tests to make it quicker
This commit is contained in:
parent
bf795d2089
commit
ad2d5bdec9
13
Makefile
13
Makefile
@ -1,31 +1,40 @@
|
|||||||
.PHONY: build-x86 build-arm build-all test
|
|
||||||
|
|
||||||
DOCKER_TAG ?= docker-duplicity-cron
|
DOCKER_TAG ?= docker-duplicity-cron
|
||||||
|
|
||||||
|
.PHONY: default
|
||||||
default: build-x86
|
default: build-x86
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
test: test-x86
|
test: test-x86
|
||||||
|
|
||||||
|
.PHONY: build-x86
|
||||||
build-x86:
|
build-x86:
|
||||||
docker build -f ./Dockerfile.ubuntu -t $(DOCKER_TAG):ubuntu .
|
docker build -f ./Dockerfile.ubuntu -t $(DOCKER_TAG):ubuntu .
|
||||||
|
|
||||||
|
.PHONY: build-arm
|
||||||
build-arm:
|
build-arm:
|
||||||
docker build -f ./Dockerfile.raspbian -t $(DOCKER_TAG):raspbian .
|
docker build -f ./Dockerfile.raspbian -t $(DOCKER_TAG):raspbian .
|
||||||
|
|
||||||
|
.PHONY: build-all
|
||||||
build-all: build-x86 build-arm
|
build-all: build-x86 build-arm
|
||||||
|
|
||||||
|
.PHONY: test-x86
|
||||||
test-x86: build-x86
|
test-x86: build-x86
|
||||||
./test.sh $(DOCKER_TAG) ubuntu
|
./test.sh $(DOCKER_TAG) ubuntu
|
||||||
|
|
||||||
|
.PHONY: test-arm
|
||||||
test-arm: build-arm
|
test-arm: build-arm
|
||||||
./test.sh $(DOCKER_TAG) raspbian
|
./test.sh $(DOCKER_TAG) raspbian
|
||||||
|
|
||||||
|
.PHONY: test-all
|
||||||
test-all: test-x86 test-arm
|
test-all: test-x86 test-arm
|
||||||
|
|
||||||
|
.PHONY: shell-x86
|
||||||
shell-x86: build-x86
|
shell-x86: build-x86
|
||||||
docker run --rm -it $(DOCKER_TAG):ubuntu bash
|
docker run --rm -it $(DOCKER_TAG):ubuntu bash
|
||||||
|
|
||||||
|
.PHONY: shell-arm
|
||||||
shell-arm: build-arm
|
shell-arm: build-arm
|
||||||
docker run --rm -it $(DOCKER_TAG):raspbian bash
|
docker run --rm -it $(DOCKER_TAG):raspbian bash
|
||||||
|
|
||||||
|
.PHONY: shell
|
||||||
shell: shell-x86
|
shell: shell-x86
|
||||||
|
22
itest.sh
Executable file
22
itest.sh
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Performing backup tests"
|
||||||
|
|
||||||
|
echo "Create test data..."
|
||||||
|
mkdir -p /data && echo Test > /data/test.txt
|
||||||
|
|
||||||
|
echo "Making backup..."
|
||||||
|
/backup.sh
|
||||||
|
|
||||||
|
echo "Verify backup..."
|
||||||
|
/verify.sh
|
||||||
|
|
||||||
|
echo "Delete test data..."
|
||||||
|
rm -fr /data/*
|
||||||
|
|
||||||
|
echo "Restore backup..."
|
||||||
|
/restore.sh
|
||||||
|
|
||||||
|
echo "Verify backup..."
|
||||||
|
/verify.sh
|
30
test.sh
30
test.sh
@ -6,26 +6,10 @@ tag=$2
|
|||||||
full_image="${image_name}:${tag}"
|
full_image="${image_name}:${tag}"
|
||||||
container_name="${image_name}-${tag}"
|
container_name="${image_name}-${tag}"
|
||||||
|
|
||||||
# Create backup container
|
# Run the test script within the container
|
||||||
docker run -d -e SKIP_ON_START=true --name ${container_name} $full_image bash -c "/bin/sleep 20"
|
docker run --rm \
|
||||||
# Create some test data
|
-e SKIP_ON_START=true \
|
||||||
docker exec $container_name sh -c "mkdir -p /data && echo Test > /data/test.txt"
|
-v "$(pwd)/itest.sh:/itest.sh" \
|
||||||
# Backup data
|
--name ${container_name} \
|
||||||
echo "Making backup..."
|
$full_image \
|
||||||
docker exec $container_name /backup.sh
|
bash -c "/itest.sh"
|
||||||
# Verify the backup
|
|
||||||
echo "Verify backup..."
|
|
||||||
docker exec $container_name /verify.sh
|
|
||||||
# Remove test file
|
|
||||||
echo "Clear data..."
|
|
||||||
docker exec $container_name sh -c "rm /data/*"
|
|
||||||
# Restore the backup
|
|
||||||
echo "Restore backup..."
|
|
||||||
docker exec $container_name /restore.sh
|
|
||||||
# Verify the backup
|
|
||||||
echo "Verify backup..."
|
|
||||||
docker exec $container_name /verify.sh
|
|
||||||
# Stop the container
|
|
||||||
docker kill $container_name
|
|
||||||
# Remove the container
|
|
||||||
docker rm $container_name
|
|
||||||
|
Loading…
Reference in New Issue
Block a user