glusterfs

Форк
0
151 строка · 4.7 Кб
1
#!/bin/bash
2

3
. $(dirname $0)/../include.rc
4
. $(dirname $0)/../volume.rc
5

6
cleanup;
7

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

13
TEST glusterd
14
TEST pidof glusterd
15

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
21

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'
28

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

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'
35

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
39

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'
45

46
## don't use min-size, so any size will be compressed.
47
TEST $CLI volume set $V0 network.compression.min-size 0
48

49
## Start the volume
50
TEST $CLI volume start $V0;
51
EXPECT 'Started' volinfo_field $V0 'Status';
52

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

57
####################
58
## Testing writev ##
59
####################
60

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`
64

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`
68

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)
74

75
TEST rm -f /tmp/gzipfile.gz
76

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

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

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]}
85

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

89
###################
90
## Testing readv ##
91
###################
92

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`
96

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)
100

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

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]}
107

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

112
## Stop the volume
113
TEST $CLI volume stop $V0;
114
EXPECT 'Stopped' volinfo_field $V0 'Status';
115

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'
121

122
## Start the volume
123
TEST $CLI volume start $V0;
124
EXPECT 'Started' volinfo_field $V0 'Status';
125

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

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
133

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

138
## Stop the volume
139
TEST $CLI volume stop $V0;
140
EXPECT 'Stopped' volinfo_field $V0 'Status';
141

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
146

147
## Delete the volume
148
TEST $CLI volume delete $V0;
149
TEST ! $CLI volume info $V0;
150

151
cleanup;
152

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.