3
. $(dirname $0)/../include.rc
4
. $(dirname $0)/../volume.rc
8
function file_mime_type () {
9
mime_type=$(file --mime $1 2>/dev/null | sed '/^[^:]*: /s///')
16
## Create a volume with one brick
17
TEST $CLI volume create $V0 $H0:$B0/${V0}1;
18
EXPECT "$V0" volinfo_field $V0 'Volume Name';
19
EXPECT 'Created' volinfo_field $V0 'Status';
20
EXPECT '1' brick_count $V0
22
## Turn off performance translators
23
## This is required for testing readv calls
24
TEST $CLI volume set $V0 performance.io-cache off
25
EXPECT 'off' volinfo_field $V0 'performance.io-cache'
26
TEST $CLI volume set $V0 performance.quick-read off
27
EXPECT 'off' volinfo_field $V0 'performance.quick-read'
29
TEST $CLI volume set $V0 performance.strict-write-ordering on
30
EXPECT 'on' volinfo_field $V0 'performance.strict-write-ordering'
32
## Turn on cdc xlator by setting network.compression to on
33
TEST $CLI volume set $V0 network.compression on
34
EXPECT 'on' volinfo_field $V0 'network.compression'
36
## Make sure that user cannot change network.compression.mode
37
## This would break the cdc xlator if allowed!
38
TEST ! $CLI volume set $V0 network.compression.mode client
40
## Turn on network.compression.debug option
41
## This will dump compressed data onto disk as gzip file
42
## This is used to check if compression actually happened
43
TEST $CLI volume set $V0 network.compression.debug on
44
EXPECT 'on' volinfo_field $V0 'network.compression.debug'
46
## don't use min-size, so any size will be compressed.
47
TEST $CLI volume set $V0 network.compression.min-size 0
50
TEST $CLI volume start $V0;
51
EXPECT 'Started' volinfo_field $V0 'Status';
54
## Mount FUSE with caching disabled
55
TEST $GFS -s $H0 --volfile-id $V0 $M0;
61
## Create a 1K file locally and find the md5sum
62
TEST dd if=/dev/zero of=/tmp/cdc-orig count=1 bs=1k 2>/dev/null
63
checksum[original-file]=`md5sum /tmp/cdc-orig | cut -d' ' -f1`
65
## Copy the file to mountpoint and find its md5sum on brick
66
TEST dd if=/tmp/cdc-orig of=$M0/cdc-server count=1 bs=1k 2>/dev/null
67
checksum[brick-file]=`md5sum $B0/${V0}1/cdc-server | cut -d' ' -f1`
69
## Uncompress the gzip dump file and find its md5sum
70
# mime outputs for gzip are different for file version > 5.14
71
TEST touch /tmp/gzipfile
72
TEST gzip /tmp/gzipfile
73
GZIP_MIME_TYPE=$(file_mime_type /tmp/gzipfile.gz)
75
TEST rm -f /tmp/gzipfile.gz
77
EXPECT "$GZIP_MIME_TYPE" echo $(file_mime_type /tmp/cdcdump.gz)
79
TEST gunzip -f /tmp/cdcdump.gz
80
checksum[dump-file-writev]=`md5sum /tmp/cdcdump | cut -d' ' -f1`
82
## Check if all 3 checksums are same
83
TEST test ${checksum[original-file]} = ${checksum[brick-file]}
84
TEST test ${checksum[brick-file]} = ${checksum[dump-file-writev]}
87
TEST rm -f /tmp/cdcdump.gz
93
## Copy file from mount point to client and find checksum
94
TEST dd if=$M0/cdc-server of=/tmp/cdc-client count=1 bs=1k 2>/dev/null
95
checksum[client-file]=`md5sum /tmp/cdc-client | cut -d' ' -f1`
97
## Uncompress the gzip dump file and find its md5sum
98
# mime outputs for gzip are different for file version > 5.14
99
EXPECT "$GZIP_MIME_TYPE" echo $(file_mime_type /tmp/cdcdump.gz)
101
TEST gunzip -f /tmp/cdcdump.gz
102
checksum[dump-file-readv]=`md5sum /tmp/cdcdump | cut -d' ' -f1`
104
## Check if all 3 checksums are same
105
TEST test ${checksum[brick-file]} = ${checksum[client-file]}
106
TEST test ${checksum[client-file]} = ${checksum[dump-file-readv]}
108
## Cleanup files and unmount
109
TEST rm -f /tmp/cdc* $M0/cdc*
110
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
113
TEST $CLI volume stop $V0;
114
EXPECT 'Stopped' volinfo_field $V0 'Status';
116
## Turn on network.compression.min-size and set it to 100 bytes
117
## Compression should not take place if file size
118
## is less than 100 bytes
119
TEST $CLI volume set $V0 network.compression.min-size 100
120
EXPECT '100' volinfo_field $V0 'network.compression.min-size'
123
TEST $CLI volume start $V0;
124
EXPECT 'Started' volinfo_field $V0 'Status';
126
## Mount FUSE with caching disabled
127
TEST $GFS -s $H0 --volfile-id $V0 $M0;
129
## Create a file of size 99 bytes on mountpoint
130
## This is should not be compressed
131
TEST dd if=/dev/zero of=$M0/cdc-small count=1 bs=99 2>/dev/null
132
TEST ! test -e /tmp/cdcdump.gz
134
## Cleanup files and unmount
135
TEST rm -f /tmp/cdc* $M0/cdc*
136
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
139
TEST $CLI volume stop $V0;
140
EXPECT 'Stopped' volinfo_field $V0 'Status';
142
## Reset the network.compression options
143
TEST $CLI volume reset $V0 network.compression.debug
144
TEST $CLI volume reset $V0 network.compression.min-size
145
TEST $CLI volume reset $V0 network.compression
148
TEST $CLI volume delete $V0;
149
TEST ! $CLI volume info $V0;