summaryrefslogtreecommitdiffstats
path: root/tests/basic/cdc.t
blob: 8653a77207af9c83871d6425dbd4c1fb9a8aa873 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash

. $(dirname $0)/../include.rc
. $(dirname $0)/../volume.rc

cleanup;

function file_mime_type () {
    mime_type=$(file --mime $1 2>/dev/null | sed '/^[^:]*: /s///')
    echo $mime_type
}

TEST glusterd
TEST pidof glusterd

## Create a volume with one brick
TEST $CLI volume create $V0 $H0:$B0/${V0}1;
EXPECT "$V0" volinfo_field $V0 'Volume Name';
EXPECT 'Created' volinfo_field $V0 'Status';
EXPECT '1' brick_count $V0

## Turn off performance translators
## This is required for testing readv calls
TEST $CLI volume set $V0 performance.io-cache off
EXPECT 'off' volinfo_field $V0 'performance.io-cache'
TEST $CLI volume set $V0 performance.quick-read off
EXPECT 'off' volinfo_field $V0 'performance.quick-read'

TEST $CLI volume set $V0 performance.strict-write-ordering on
EXPECT 'on' volinfo_field $V0 'performance.strict-write-ordering'

## Turn on cdc xlator by setting network.compression to on
TEST $CLI volume set $V0 network.compression on
EXPECT 'on' volinfo_field $V0 'network.compression'

## Make sure that user cannot change network.compression.mode
## This would break the cdc xlator if allowed!
TEST ! $CLI volume set $V0 network.compression.mode client

## Turn on network.compression.debug option
## This will dump compressed data onto disk as gzip file
## This is used to check if compression actually happened
TEST $CLI volume set $V0 network.compression.debug on
EXPECT 'on' volinfo_field $V0 'network.compression.debug'

## Start the volume
TEST $CLI volume start $V0;
EXPECT 'Started' volinfo_field $V0 'Status';

sleep 2
## Mount FUSE with caching disabled
TEST $GFS -s $H0 --volfile-id $V0 $M0;

####################
## Testing writev ##
####################

## Create a 1K file locally and find the md5sum
TEST dd if=/dev/zero of=/tmp/cdc-orig count=1 bs=1k 2>/dev/null
checksum[original-file]=`md5sum /tmp/cdc-orig | cut -d' ' -f1`

## Copy the file to mountpoint and find its md5sum on brick
TEST dd if=/tmp/cdc-orig of=$M0/cdc-server count=1 bs=1k 2>/dev/null
checksum[brick-file]=`md5sum $B0/${V0}1/cdc-server | cut -d' ' -f1`

## Uncompress the gzip dump file and find its md5sum
# mime outputs for gzip are different for file version > 5.14
TEST touch /tmp/gzipfile
TEST gzip /tmp/gzipfile
GZIP_MIME_TYPE=$(file_mime_type /tmp/gzipfile.gz)

TEST rm -f /tmp/gzipfile.gz

EXPECT "$GZIP_MIME_TYPE" echo $(file_mime_type /tmp/cdcdump.gz)

TEST gunzip -f /tmp/cdcdump.gz
checksum[dump-file-writev]=`md5sum /tmp/cdcdump | cut -d' ' -f1`

## Check if all 3 checksums are same
TEST test ${checksum[original-file]} = ${checksum[brick-file]}
TEST test ${checksum[brick-file]} = ${checksum[dump-file-writev]}

## Cleanup files
TEST rm -f /tmp/cdcdump.gz

###################
## Testing readv ##
###################

## Copy file from mount point to client and find checksum
TEST dd if=$M0/cdc-server of=/tmp/cdc-client count=1 bs=1k 2>/dev/null
checksum[client-file]=`md5sum /tmp/cdc-client | cut -d' ' -f1`

## Uncompress the gzip dump file and find its md5sum
# mime outputs for gzip are different for file version > 5.14
EXPECT "$GZIP_MIME_TYPE" echo $(file_mime_type /tmp/cdcdump.gz)

TEST gunzip -f /tmp/cdcdump.gz
checksum[dump-file-readv]=`md5sum /tmp/cdcdump | cut -d' ' -f1`

## Check if all 3 checksums are same
TEST test ${checksum[brick-file]} = ${checksum[client-file]}
TEST test ${checksum[client-file]} = ${checksum[dump-file-readv]}

## Cleanup files and unmount
TEST rm -f /tmp/cdc* $M0/cdc*
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0

## Stop the volume
TEST $CLI volume stop $V0;
EXPECT 'Stopped' volinfo_field $V0 'Status';

## Turn on network.compression.min-size and set it to 100 bytes
## Compression should not take place if file size
## is less than 100 bytes
TEST $CLI volume set $V0 network.compression.min-size 100
EXPECT '100' volinfo_field $V0 'network.compression.min-size'

## Start the volume
TEST $CLI volume start $V0;
EXPECT 'Started' volinfo_field $V0 'Status';

## Mount FUSE with caching disabled
TEST $GFS -s $H0 --volfile-id $V0 $M0;

## Create a file of size 99 bytes on mountpoint
## This is should not be compressed
TEST dd if=/dev/zero of=$M0/cdc-small count=1 bs=99 2>/dev/null
TEST ! test -e /tmp/cdcdump.gz

## Cleanup files and unmount
TEST rm -f /tmp/cdc* $M0/cdc*
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0

## Stop the volume
TEST $CLI volume stop $V0;
EXPECT 'Stopped' volinfo_field $V0 'Status';

## Reset the network.compression options
TEST $CLI volume reset $V0 network.compression.debug
TEST $CLI volume reset $V0 network.compression.min-size
TEST $CLI volume reset $V0 network.compression

## Delete the volume
TEST $CLI volume delete $V0;
TEST ! $CLI volume info $V0;

cleanup;