Skip to content

Commit 4e4d978

Browse files
committed
XFS tests
1 parent 984392d commit 4e4d978

File tree

3 files changed

+58
-33
lines changed

3 files changed

+58
-33
lines changed

README.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,12 @@ TODO:
2525
- check if xfs bug manifests after fallocate
2626
- check if xfs bug manifests via docker containers
2727
- check if '-o nouuid' works with ext4
28-
- add '-o nouuid'
29-
- add test that volume can be remounted after adding some data
30-
31-
create sparse ext4 volume of 1GiB on a 100 MiB disk - success
32-
create regular ext4 volume of 1GiB on a 100 Mib disk - fail
33-
34-
create sparse xfs volume of 1GiB on a 100 MiB disk - success
35-
create regular xfs volume of 1GiB on a 100 MiB disk - fail
28+
- add '-o nouuid'
3629

3730
on ext4/xfs vs ext3
3831

39-
not enough space - data file should be cleaned up
40-
4132
uid/gid - default & custom
4233

4334
mode - default & custom
4435

4536
inspect - should export status fields
46-

tests/test_ext4.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,6 @@
22

33
FS="ext4"
44

5-
testRegularVolumeDoesNotReserveDiskSpace() {
6-
local volume info allocated_size apparent_size
7-
# setup
8-
volume=$(docker volume create -d "${DRIVER}" -o fs=${FS} -o sparse=false)
9-
10-
info=$(ls --block-size=M -ls "/var/lib/${DRIVER}/${volume}.${FS}")
11-
allocated_size=$(echo ${info} | awk '{print $1}' | tr -dc '0-9')
12-
apparent_size=$(echo ${info} | awk '{print $6}' | tr -dc '0-9')
13-
14-
# checks
15-
assertTrue "Regular ${FS} volume of ${apparent_size} MiB should take less space: ${allocated_size} MiB" "[ ${allocated_size} -lt ${apparent_size} ]"
16-
17-
# cleanup
18-
docker volume rm "${volume}" > /dev/null
19-
}
20-
215
testRegularVolumeChecksDiskSpaceBeforeFormatting() {
226
local error result count
237
# setup
@@ -34,6 +18,22 @@ testRegularVolumeChecksDiskSpaceBeforeFormatting() {
3418
assertEquals "0" "${count}"
3519
}
3620

21+
testRegularVolumeDoesNotReserveDiskSpace() {
22+
local volume info allocated_size apparent_size
23+
# setup
24+
volume=$(docker volume create -d "${DRIVER}" -o fs=${FS} -o sparse=false)
25+
26+
info=$(ls --block-size=M -ls "/var/lib/${DRIVER}/${volume}.${FS}")
27+
allocated_size=$(echo ${info} | awk '{print $1}' | tr -dc '0-9')
28+
apparent_size=$(echo ${info} | awk '{print $6}' | tr -dc '0-9')
29+
30+
# checks
31+
assertTrue "Regular ${FS} volume of ${apparent_size} MiB should take less space: ${allocated_size} MiB" "[ ${allocated_size} -lt ${apparent_size} ]"
32+
33+
# cleanup
34+
docker volume rm "${volume}" > /dev/null
35+
}
36+
3737
testSparseVolumeDoesNotCheckAvailableDiskSpace() {
3838
local volume result info apparent_size
3939
# setup

tests/test_xfs.sh

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,66 @@
22

33
FS="xfs"
44

5-
testSparseVolumeDoesNotTakeDiskSpace() {
5+
testRegularVolumeChecksDiskSpaceBeforeFormatting() {
6+
local error result count
7+
# setup
8+
9+
## attempt creating 10 GiB volume while we have only 2 GiB of space
10+
error=$(docker volume create -d "${DRIVER}" -o fs=${FS} -o sparse=false -o size=10GiB 2>&1)
11+
result=$?
12+
13+
## because we shadow real data dir with our test volume we're sure there shouldn't be any volumes
14+
count=$(ls -1 "/var/lib/${DRIVER}/" | wc -l)
15+
16+
# checks
17+
assertEquals "1" "${result}"
18+
assertEquals "0" "${count}"
19+
}
20+
21+
testRegularVolumeReservesDiskSpace() {
622
local volume info allocated_size apparent_size
723
# setup
8-
local volume=$(docker volume create -d "${DRIVER}" -o fs=${FS} -o sparse=true)
24+
local volume=$(docker volume create -d "${DRIVER}" -o fs=${FS} -o sparse=false)
925
local info=$(ls --block-size=M -ls "/var/lib/${DRIVER}/${volume}.${FS}")
1026
local allocated_size=$(echo ${info} | awk '{print $1}' | tr -dc '0-9')
1127
local apparent_size=$(echo ${info} | awk '{print $6}' | tr -dc '0-9')
1228

1329
# checks
14-
assertTrue "Sparse ${FS} volume of ${apparent_size} MiB should take less space: ${allocated_size} MiB" "[ ${allocated_size} -lt ${apparent_size} ]"
30+
assertTrue "Regular ${FS} volume of ${apparent_size} MiB should take at least same space: ${allocated_size} MiB" "[ ${allocated_size} -ge ${apparent_size} ]"
1531

1632
# cleanup
1733
docker volume rm "${volume}" > /dev/null
1834
}
1935

20-
testRegularVolumeReservesDiskSpace() {
36+
testSparseVolumeDoesNotCheckAvailableDiskSpace() {
37+
local volume result info apparent_size
38+
# setup
39+
40+
## attempt creating 10 GiB volume while we have only 2 GiB of space
41+
volume=$(docker volume create -d "${DRIVER}" -o fs=${FS} -o sparse=true -o size=10GiB)
42+
result=$?
43+
44+
info=$(ls --block-size=M -ls "/var/lib/${DRIVER}/${volume}.${FS}")
45+
apparent_size=$(echo ${info} | awk '{print $6}' | tr -dc '0-9')
46+
47+
# checks
48+
assertEquals "0" "${result}"
49+
assertEquals "10240" "${apparent_size}"
50+
51+
# cleanup
52+
docker volume rm "${volume}" > /dev/null
53+
}
54+
55+
testSparseVolumeDoesNotTakeDiskSpace() {
2156
local volume info allocated_size apparent_size
2257
# setup
23-
local volume=$(docker volume create -d "${DRIVER}" -o fs=${FS} -o sparse=false)
58+
local volume=$(docker volume create -d "${DRIVER}" -o fs=${FS} -o sparse=true)
2459
local info=$(ls --block-size=M -ls "/var/lib/${DRIVER}/${volume}.${FS}")
2560
local allocated_size=$(echo ${info} | awk '{print $1}' | tr -dc '0-9')
2661
local apparent_size=$(echo ${info} | awk '{print $6}' | tr -dc '0-9')
2762

2863
# checks
29-
assertTrue "Regular ${FS} volume of ${apparent_size} MiB should take at least same space: ${allocated_size} MiB" "[ ${allocated_size} -ge ${apparent_size} ]"
64+
assertTrue "Sparse ${FS} volume of ${apparent_size} MiB should take less space: ${allocated_size} MiB" "[ ${allocated_size} -lt ${apparent_size} ]"
3065

3166
# cleanup
3267
docker volume rm "${volume}" > /dev/null

0 commit comments

Comments
 (0)