File tree Expand file tree Collapse file tree 3 files changed +58
-5
lines changed Expand file tree Collapse file tree 3 files changed +58
-5
lines changed Original file line number Diff line number Diff line change @@ -21,10 +21,13 @@ go mod tidy
21
21
```
22
22
23
23
## Test
24
- on ext4/xfs vs ext3
25
-
26
24
uid/gid - default & custom
27
25
28
26
mode - default & custom
29
27
30
28
inspect - should export status fields
29
+
30
+ # Extra
31
+ if _ , err := exec.LookPath("mkfs.xfs"); err != nil {
32
+ logrus.Fatal("mkfs.xfs is not available, please install xfsprogs to continue")
33
+ }
Original file line number Diff line number Diff line change @@ -12,9 +12,23 @@ oneTimeSetUp() {
12
12
13
13
setUp () {
14
14
HANDLE=$( mktemp -u)
15
- truncate -s " ${1:- 2GiB} " " ${HANDLE} "
16
- mkfs.xfs " ${HANDLE} " & > /dev/null
17
- mount -o nouuid " ${HANDLE} " " ${DATA_DIR} "
15
+ truncate -s " ${BASE_SIZE:- 2G} " " ${HANDLE} "
16
+
17
+
18
+ case " ${BASE_FS:- xfs} " in
19
+ xfs)
20
+ mkfs.xfs " ${HANDLE} " & > /dev/null
21
+ mount -o nouuid " ${HANDLE} " " ${DATA_DIR} "
22
+ ;;
23
+ ext* )
24
+ mkfs.${BASE_FS} -F " ${HANDLE} " & > /dev/null
25
+ mount " ${HANDLE} " " ${DATA_DIR} "
26
+ ;;
27
+ * )
28
+ echo " Unsupported BASE fs"
29
+ exit 1
30
+ ;;
31
+ esac
18
32
}
19
33
20
34
tearDown () {
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ BASE_SIZE=" 100M"
4
+ BASE_FS=" ext3"
5
+
6
+ testFallbackToDdFromFallocateOnUnsupportedFs () {
7
+ local error result count
8
+ # setup
9
+
10
+ # # for sparse=false we use fallocate and fallback to dd if fallocate is not supported
11
+ error=$( docker volume create -d " ${DRIVER} " -o fs=xfs -o sparse=false -o size=50MiB 2>&1 )
12
+ result=$?
13
+
14
+ # # because we shadow real data dir with our test volume we're sure there shouldn't be any volumes
15
+ count=$( ls -1 " /var/lib/${DRIVER} /" | grep -v " lost+found" | wc -l)
16
+
17
+ assertEquals " 0" " ${result} "
18
+ assertEquals " 1" " ${count} "
19
+ }
20
+
21
+ testDdFailureScenarioWhenThereIsNotEnoughDiskSpace () {
22
+ local error result count
23
+ # setup
24
+
25
+ # # attempt creating 2 GiB volume while we have only 1 GiB of space
26
+ error=$( docker volume create -d " ${DRIVER} " -o fs=xfs -o sparse=false -o size=200MiB 2>&1 )
27
+ result=$?
28
+
29
+ # # because we shadow real data dir with our test volume we're sure there shouldn't be any volumes
30
+ count=$( ls -1 " /var/lib/${DRIVER} /" | grep -v " lost+found" | wc -l)
31
+
32
+ assertEquals " 1" " ${result} "
33
+ assertEquals " 0" " ${count} "
34
+ }
35
+
36
+ . test.sh
You can’t perform that action at this time.
0 commit comments