glusterfs

Форк
0
247 строк · 6.2 Кб
1
#!/bin/bash
2

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

7
cleanup
8

9
test_mount() {
10
        volume=$1
11
        mount=$2
12
        test_dir=$3
13
        RETVAL=0
14
        glusterfs -s $H0 --volfile-id $volume $mount --attribute-timeout=0
15

16
        if [ "x$test_dir" = "x" ] ; then return $RETVAL; fi
17

18
        timeout=0
19
        while [ $timeout -lt $PROCESS_UP_TIMEOUT ] ; do
20
                timeout=$(( $timeout + 1 ))
21
                test -d $test_dir
22
                RETVAL=$?
23
                if [ $RETVAL -eq 0 ] ; then break ; fi
24
                sleep 1
25
        done
26

27
        return $RETVAL
28
}
29

30
start_vol() {
31
        volume=$1
32
        mount=$2
33
        test_dir=$3
34
        $CLI volume start $volume
35
        test_mount $volume $mount $test_dir
36
        RETVAL=$?
37
        return $RETVAL
38
}
39

40
create_files() {
41
        echo 'Hi' > $1
42
        echo 'Hai' > $2
43
}
44

45
file_exists () {
46
        vol=$1
47
        shift
48
        for file in `ls $B0/${vol}1/$@ 2> /dev/null` ; do
49
                test -e ${file} && return 0
50
        done
51
        for file in `ls $B0/${vol}2/$@ 2> /dev/null` ; do
52
                test -e ${file} && return 0
53
        done
54

55
        return 1
56
}
57

58
unlink_op() {
59

60
        rm -f $M0/$1
61
        ls $M0/.trashcan/1/2/3 &> /dev/null
62
        sleep 2
63

64
        test ! -e $M0/$1
65
        wildcard_exists $M0/.trashcan/$1*
66

67
        # remove from trashcan
68
        rm -f $M0/.trashcan/$1*
69
        wildcard_not_exists $M0/.trashcan/$1*
70
}
71

72
truncate_op() {
73
        truncate -s 2 $M0/$1
74
        ls $M0/.trashcan/1/2/3 &> /dev/null
75
        sleep 2
76

77
        test -e $M0/$1
78
        test $(ls -l $M0/$1 | awk '{print $5}') -eq 2 &> /dev/null
79
        wildcard_exists $M0/.trashcan/$1*
80
        test $(ls -l $M0/.trashcan/$1*|awk '{print $5}') -eq $2 &> /dev/null
81

82
        # truncate from trashcan
83
        truncate -s 1 $M0/.trashcan/$1*
84
        test $(ls $M0/.trashcan/$1* | wc -l) -eq 1
85
}
86

87
wildcard_exists() {
88
        test -e $1
89
        if [ $? -eq 0 ]; then echo "Y"; else echo "N"; fi
90
}
91

92
wildcard_not_exists() {
93
        test ! -e $1
94
        if [ $? -eq 0 ]; then echo "Y"; else echo "N"; fi
95
}
96

97
# testing glusterd
98
TEST glusterd
99
TEST pidof glusterd
100
TEST $CLI volume info
101

102
# creating distributed volume
103
TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2}
104

105
# checking volume status
106
EXPECT "$V0" volinfo_field $V0 'Volume Name'
107
EXPECT 'Created' volinfo_field $V0 'Status'
108
EXPECT '2' brick_count $V0
109

110
# test without enabling trash translator
111
TEST start_vol $V0 $M0
112

113
# test on enabling trash translator
114
TEST $CLI volume set $V0 features.trash on
115
EXPECT 'on' volinfo_field $V0 'features.trash'
116

117
# files directly under mount point
118
create_files $M0/file1 $M0/file2
119
TEST file_exists $V0 file1 file2
120

121
# perform unlink
122
TEST unlink_op file1
123

124
# perform truncate
125
TEST truncate_op file2 4
126

127
# create files directory hierarchy and check
128
mkdir -p $M0/1/2/3
129
create_files $M0/1/2/3/foo1 $M0/1/2/3/foo2
130
TEST file_exists $V0 1/2/3/foo1 1/2/3/foo2
131

132
# perform unlink
133
TEST unlink_op 1/2/3/foo1
134

135
# perform truncate
136
TEST truncate_op 1/2/3/foo2 4
137

138
# create a directory for eliminate pattern
139
mkdir $M0/a
140

141
# set the eliminate pattern
142
TEST $CLI volume set $V0 features.trash-eliminate-path /a
143
EXPECT '/a' volinfo_field $V0 'features.trash-eliminate-path'
144

145
# create two files and check
146
create_files $M0/a/test1 $M0/a/test2
147
TEST file_exists $V0 a/test1 a/test2
148

149
# remove from eliminate pattern
150
rm -f $M0/a/test1
151
EXPECT "Y" wildcard_not_exists $M0/.trashcan/a/test1*
152

153
# truncate from eliminate path
154
truncate -s 2 $M0/a/test2
155
TEST [ -e $M0/a/test2 ]
156
TEST [ `ls -l $M0/a/test2 | awk '{print $5}'` -eq 2 ]
157
EXPECT "Y" wildcard_not_exists $M0/.trashcan/a/test2*
158

159
# set internal op on
160
TEST $CLI volume set $V0 features.trash-internal-op on
161
EXPECT 'on' volinfo_field $V0 'features.trash-internal-op'
162

163
# again create two files and check
164
create_files $M0/inop1 $M0/inop2
165
TEST file_exists $V0 inop1 inop2
166

167
# perform unlink
168
TEST unlink_op inop1
169

170
# perform truncate
171
TEST truncate_op inop2 4
172

173
# remove one brick and restart the volume
174
TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}2 force
175
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
176
TEST $CLI volume stop $V0
177
TEST start_vol $V0 $M0 $M0/.trashcan
178

179
# again create two files and check
180
create_files $M0/rebal1 $M0/rebal2
181
TEST file_exists $V0 rebal1 rebal2
182

183
# add one brick
184
TEST $CLI volume add-brick $V0 $H0:$B0/${V0}3
185
TEST [ -d $B0/${V0}3 ]
186

187

188
# perform rebalance
189
TEST $CLI volume rebalance $V0 start force
190
EXPECT_WITHIN $REBALANCE_TIMEOUT "0" rebalance_completed
191

192
#Find out which file was migrated to the new brick
193
file_name=$(ls $B0/${V0}3/rebal*| xargs basename)
194

195
# check whether rebalance was succesful
196
EXPECT "Y" wildcard_exists $B0/${V0}3/$file_name*
197
EXPECT "Y" wildcard_exists $B0/${V0}1/.trashcan/internal_op/$file_name*
198

199
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
200

201
# force required in case rebalance is not over
202
TEST $CLI volume stop $V0 force
203

204
# create a replicated volume
205
TEST $CLI volume create $V1 replica 2 $H0:$B0/${V1}{1,2}
206

207
# checking volume status
208
EXPECT "$V1" volinfo_field $V1 'Volume Name'
209
EXPECT 'Replicate' volinfo_field $V1 'Type'
210
EXPECT 'Created' volinfo_field $V1 'Status'
211
EXPECT '2' brick_count $V1
212

213
# enable trash with options and start the replicate volume by disabling automatic self-heal
214
TEST $CLI volume set $V1 features.trash on
215
TEST $CLI volume set $V1 features.trash-internal-op on
216
EXPECT 'on' volinfo_field $V1 'features.trash'
217
EXPECT 'on' volinfo_field $V1 'features.trash-internal-op'
218
TEST start_vol $V1 $M1 $M1/.trashcan
219

220
# mount and check for trash directory
221
TEST [ -d $M1/.trashcan/internal_op ]
222

223
# create a file and check
224
touch $M1/self
225
TEST [ -e $B0/${V1}1/self -a -e $B0/${V1}2/self ]
226

227
# kill one brick and delete the file from mount point
228
kill_brick $V1 $H0 $B0/${V1}1
229
EXPECT_WITHIN ${PROCESS_UP_TIMEOUT} "1" online_brick_count
230
rm -f $M1/self
231
EXPECT "Y" wildcard_exists $B0/${V1}2/.trashcan/self*
232

233
# check renaming of trash directory through cli
234
TEST $CLI volume set $V0 trash-dir abc
235
TEST start_vol $V0 $M0 $M0/abc
236
TEST [ -e $M0/abc -a ! -e $M0/.trashcan ]
237
EXPECT "Y" wildcard_exists $B0/${V0}1/abc/internal_op/rebal*
238

239
# ensure that rename and delete operation on trash directory fails
240
rm -rf $M0/abc/internal_op
241
TEST [ -e $M0/abc/internal_op ]
242
rm -rf $M0/abc/
243
TEST [ -e $M0/abc ]
244
mv $M0/abc $M0/trash
245
TEST [ -e $M0/abc ]
246

247
cleanup
248

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

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

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

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