Browse Source

Clean test scripts

flock
ViViDboarder 11 months ago
parent
commit
707b8f304b
7 changed files with 68 additions and 68 deletions
  1. 2
    4
      .dockerignore
  2. 4
    4
      Makefile
  3. 0
    47
      itest.sh
  4. 0
    10
      test.sh
  5. 4
    3
      tests/docker-compose-test-s3.yml
  6. 0
    0
      tests/test-s3.sh
  7. 58
    0
      tests/test.sh

+ 2
- 4
.dockerignore View File

@@ -1,8 +1,6 @@
1
+.travis.yml
1 2
 Dockerfile.*
2 3
 Makefile
3 4
 Readme.md
4 5
 docker-compose.yaml
5
-docker-compose-test-s3.yml
6
-test.sh
7
-itest.sh
8
-test-s3.sh
6
+tests/

+ 4
- 4
Makefile View File

@@ -19,22 +19,22 @@ build-all: build-x86 build-arm
19 19
 
20 20
 .PHONY: test-x86
21 21
 test-x86: build-x86
22
-	./test.sh $(DOCKER_TAG):ubuntu
22
+	cd tests && ./test.sh $(DOCKER_TAG):ubuntu
23 23
 
24 24
 .PHONY: test-arm
25 25
 test-arm: build-arm
26
-	./test.sh $(DOCKER_TAG):raspbian
26
+	cd tests && .test.sh $(DOCKER_TAG):raspbian
27 27
 
28 28
 .PHONY: test-all
29 29
 test-all: test-x86 test-arm
30 30
 
31 31
 .PHONY: test-s3-x86
32 32
 test-s3-x86:
33
-	./test-s3.sh ubuntu
33
+	cd tests && ./test-s3.sh ubuntu
34 34
 
35 35
 .PHONY: test-s3-arm
36 36
 test-s3-arm:
37
-	./test-s3.sh raspbian
37
+	cd tests && ./test-s3.sh raspbian
38 38
 
39 39
 .PHONY: test-s3-all
40 40
 test-s3-all: test-s3-x86 test-s3-arm

+ 0
- 47
itest.sh View File

@@ -1,47 +0,0 @@
1
-#! /bin/bash
2
-set -e
3
-
4
-echo "Performing backup tests"
5
-
6
-echo "Verify cron and crontab exist"
7
-type cron
8
-type crontab
9
-
10
-echo "Create test data..."
11
-mkdir -p /data && echo Test > /data/test.txt
12
-
13
-echo "Making backup..."
14
-/backup.sh
15
-
16
-echo "Verify backup..."
17
-/verify.sh
18
-
19
-echo "Delete test data..."
20
-rm -fr /data/*
21
-
22
-echo "Verify deleted..."
23
-test -f /data/test.txt && exit 1 || echo "Gone"
24
-
25
-echo "Restore backup..."
26
-/restore.sh
27
-
28
-echo "Verify backup..."
29
-/verify.sh
30
-
31
-echo "Delete test data again..."
32
-rm -fr /data/*
33
-
34
-echo "Verify deleted..."
35
-test -f /data/test.txt && exit 1 || echo "Gone"
36
-
37
-echo "Simulate a restart with RESTORE_ON_EMPTY_START..."
38
-RESTORE_ON_EMPTY_START=true /entrypoint.sh
39
-
40
-echo "Verify restore happened..."
41
-test -f /data/test.txt
42
-
43
-echo "Verify restore with incorrect passphrase fails..."
44
-export PASSPHRASE=Incorrect.Mule.Solar.Paperclip
45
-
46
-echo "Fail to restore backup..."
47
-/restore.sh && exit 1 || echo "OK"

+ 0
- 10
test.sh View File

@@ -1,10 +0,0 @@
1
-#! /bin/bash
2
-
3
-image=$1
4
-
5
-# Run the test script within the container
6
-docker run --rm \
7
-    -e SKIP_ON_START=true \
8
-    -v "$(pwd)/itest.sh:/itest.sh" \
9
-    $image \
10
-    bash -c "/itest.sh"

docker-compose-test-s3.yml → tests/docker-compose-test-s3.yml View File

@@ -2,12 +2,13 @@ version: '2'
2 2
 services:
3 3
   duplicity:
4 4
     build:
5
-      context: .
5
+      context: ..
6 6
       dockerfile: Dockerfile.${DOCKER_BASE}
7 7
     entrypoint: "bash"
8
-    command: ["/itest.sh"]
8
+    command: ["/test.sh"]
9 9
     hostname: itest
10 10
     environment:
11
+      IN_CONTAINER: 'true'
11 12
       SKIP_ON_START: 'true'
12 13
       OPT_ARGUMENTS: '--s3-unencrypted-connection'
13 14
       BACKUP_DEST: s3://minio:9000/duplicity
@@ -15,7 +16,7 @@ services:
15 16
       AWS_ACCESS_KEY_ID: SUPER_SECRET_ACCESS_KEY
16 17
       AWS_SECRET_ACCESS_KEY: SUPER_SECRET_SECRET_KEY
17 18
     volumes:
18
-      - "./itest.sh:/itest.sh"
19
+      - "./test.sh:/test.sh"
19 20
     links:
20 21
       - minio
21 22
   minio:

test-s3.sh → tests/test-s3.sh View File


+ 58
- 0
tests/test.sh View File

@@ -0,0 +1,58 @@
1
+#! /bin/bash
2
+
3
+image=$1
4
+
5
+if [ "$IN_CONTAINER" != "true" ] ; then
6
+    # Run the test script within the container
7
+    docker run --rm \
8
+        -e IN_CONTAINER=true \
9
+        -e SKIP_ON_START=true \
10
+        -v "$(pwd)/test.sh:/test.sh" \
11
+        $image \
12
+        bash -c "/test.sh"
13
+else
14
+    echo "Performing backup tests"
15
+
16
+    echo "Verify cron and crontab exist"
17
+    type cron
18
+    type crontab
19
+
20
+    echo "Create test data..."
21
+    mkdir -p /data && echo Test > /data/test.txt
22
+
23
+    echo "Making backup..."
24
+    /backup.sh
25
+
26
+    echo "Verify backup..."
27
+    /verify.sh
28
+
29
+    echo "Delete test data..."
30
+    rm -fr /data/*
31
+
32
+    echo "Verify deleted..."
33
+    test -f /data/test.txt && exit 1 || echo "Gone"
34
+
35
+    echo "Restore backup..."
36
+    /restore.sh
37
+
38
+    echo "Verify backup..."
39
+    /verify.sh
40
+
41
+    echo "Delete test data again..."
42
+    rm -fr /data/*
43
+
44
+    echo "Verify deleted..."
45
+    test -f /data/test.txt && exit 1 || echo "Gone"
46
+
47
+    echo "Simulate a restart with RESTORE_ON_EMPTY_START..."
48
+    RESTORE_ON_EMPTY_START=true /entrypoint.sh
49
+
50
+    echo "Verify restore happened..."
51
+    test -f /data/test.txt
52
+
53
+    echo "Verify restore with incorrect passphrase fails..."
54
+    export PASSPHRASE=Incorrect.Mule.Solar.Paperclip
55
+
56
+    echo "Fail to restore backup..."
57
+    /restore.sh && exit 1 || echo "OK"
58
+fi

Loading…
Cancel
Save