mirror of
https://github.com/ViViDboarder/docker-duplicity-cron.git
synced 2024-11-14 17:56:31 +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
|
||||
|
||||
.PHONY: default
|
||||
default: build-x86
|
||||
|
||||
.PHONY: test
|
||||
test: test-x86
|
||||
|
||||
.PHONY: build-x86
|
||||
build-x86:
|
||||
docker build -f ./Dockerfile.ubuntu -t $(DOCKER_TAG):ubuntu .
|
||||
|
||||
.PHONY: build-arm
|
||||
build-arm:
|
||||
docker build -f ./Dockerfile.raspbian -t $(DOCKER_TAG):raspbian .
|
||||
|
||||
.PHONY: build-all
|
||||
build-all: build-x86 build-arm
|
||||
|
||||
.PHONY: test-x86
|
||||
test-x86: build-x86
|
||||
./test.sh $(DOCKER_TAG) ubuntu
|
||||
|
||||
.PHONY: test-arm
|
||||
test-arm: build-arm
|
||||
./test.sh $(DOCKER_TAG) raspbian
|
||||
|
||||
.PHONY: test-all
|
||||
test-all: test-x86 test-arm
|
||||
|
||||
.PHONY: shell-x86
|
||||
shell-x86: build-x86
|
||||
docker run --rm -it $(DOCKER_TAG):ubuntu bash
|
||||
|
||||
.PHONY: shell-arm
|
||||
shell-arm: build-arm
|
||||
docker run --rm -it $(DOCKER_TAG):raspbian bash
|
||||
|
||||
.PHONY: shell
|
||||
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}"
|
||||
container_name="${image_name}-${tag}"
|
||||
|
||||
# Create backup container
|
||||
docker run -d -e SKIP_ON_START=true --name ${container_name} $full_image bash -c "/bin/sleep 20"
|
||||
# Create some test data
|
||||
docker exec $container_name sh -c "mkdir -p /data && echo Test > /data/test.txt"
|
||||
# Backup data
|
||||
echo "Making backup..."
|
||||
docker exec $container_name /backup.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
|
||||
# Run the test script within the container
|
||||
docker run --rm \
|
||||
-e SKIP_ON_START=true \
|
||||
-v "$(pwd)/itest.sh:/itest.sh" \
|
||||
--name ${container_name} \
|
||||
$full_image \
|
||||
bash -c "/itest.sh"
|
||||
|
Loading…
Reference in New Issue
Block a user