3
. $(dirname $0)/../include.rc
4
. $(dirname $0)/../volume.rc
5
. $(dirname $0)/../dht.rc
14
glusterfs -s $H0 --volfile-id $volume $mount --attribute-timeout=0
16
if [ "x$test_dir" = "x" ] ; then return $RETVAL; fi
19
while [ $timeout -lt $PROCESS_UP_TIMEOUT ] ; do
20
timeout=$(( $timeout + 1 ))
23
if [ $RETVAL -eq 0 ] ; then break ; fi
34
$CLI volume start $volume
35
test_mount $volume $mount $test_dir
48
for file in `ls $B0/${vol}1/$@ 2> /dev/null` ; do
49
test -e ${file} && return 0
51
for file in `ls $B0/${vol}2/$@ 2> /dev/null` ; do
52
test -e ${file} && return 0
61
ls $M0/.trashcan/1/2/3 &> /dev/null
65
wildcard_exists $M0/.trashcan/$1*
67
# remove from trashcan
68
rm -f $M0/.trashcan/$1*
69
wildcard_not_exists $M0/.trashcan/$1*
74
ls $M0/.trashcan/1/2/3 &> /dev/null
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
82
# truncate from trashcan
83
truncate -s 1 $M0/.trashcan/$1*
84
test $(ls $M0/.trashcan/$1* | wc -l) -eq 1
89
if [ $? -eq 0 ]; then echo "Y"; else echo "N"; fi
92
wildcard_not_exists() {
94
if [ $? -eq 0 ]; then echo "Y"; else echo "N"; fi
102
# creating distributed volume
103
TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2}
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
110
# test without enabling trash translator
111
TEST start_vol $V0 $M0
113
# test on enabling trash translator
114
TEST $CLI volume set $V0 features.trash on
115
EXPECT 'on' volinfo_field $V0 'features.trash'
117
# files directly under mount point
118
create_files $M0/file1 $M0/file2
119
TEST file_exists $V0 file1 file2
125
TEST truncate_op file2 4
127
# create files directory hierarchy and check
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
133
TEST unlink_op 1/2/3/foo1
136
TEST truncate_op 1/2/3/foo2 4
138
# create a directory for eliminate pattern
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'
145
# create two files and check
146
create_files $M0/a/test1 $M0/a/test2
147
TEST file_exists $V0 a/test1 a/test2
149
# remove from eliminate pattern
151
EXPECT "Y" wildcard_not_exists $M0/.trashcan/a/test1*
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*
160
TEST $CLI volume set $V0 features.trash-internal-op on
161
EXPECT 'on' volinfo_field $V0 'features.trash-internal-op'
163
# again create two files and check
164
create_files $M0/inop1 $M0/inop2
165
TEST file_exists $V0 inop1 inop2
171
TEST truncate_op inop2 4
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
179
# again create two files and check
180
create_files $M0/rebal1 $M0/rebal2
181
TEST file_exists $V0 rebal1 rebal2
184
TEST $CLI volume add-brick $V0 $H0:$B0/${V0}3
185
TEST [ -d $B0/${V0}3 ]
189
TEST $CLI volume rebalance $V0 start force
190
EXPECT_WITHIN $REBALANCE_TIMEOUT "0" rebalance_completed
192
#Find out which file was migrated to the new brick
193
file_name=$(ls $B0/${V0}3/rebal*| xargs basename)
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*
199
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
201
# force required in case rebalance is not over
202
TEST $CLI volume stop $V0 force
204
# create a replicated volume
205
TEST $CLI volume create $V1 replica 2 $H0:$B0/${V1}{1,2}
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
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
220
# mount and check for trash directory
221
TEST [ -d $M1/.trashcan/internal_op ]
223
# create a file and check
225
TEST [ -e $B0/${V1}1/self -a -e $B0/${V1}2/self ]
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
231
EXPECT "Y" wildcard_exists $B0/${V1}2/.trashcan/self*
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*
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 ]