On Wed, Mar 18, 2015 at 11:26:02AM +0530, Anoop C S wrote: > Trash translator creates the original file inside .trashcan directory on > receiving a truncate/ftruncate call and then truncates the file. During > the above mentioned procedure, whether a truncate/ftruncate call is > issued internally? The kernel sends SETATTR with new file size, and glusterfs turns this into a truncate call. I have to dig deeper to tell how. > We have started looking into the failures. And I see many instances of > the following error: > du: unknown option -- b Yes, I had to fix a few shell portability problems - The -p option for mkdir must be before the directory name - du -b is not portable. Use ls -l instead. - test -e file* fails if file* expands to multiple files. I introduced wildcard_exists() and wildcard_not_exists() to work this around. Attached patch adresses the three points. -- Emmanuel Dreyfus manu@xxxxxxxxxx
diff --git a/tests/features/trash.t b/tests/features/trash.t index e0b85da..bdb56f3 100755 --- a/tests/features/trash.t +++ b/tests/features/trash.t @@ -37,29 +37,35 @@ unlink_op() { sleep 2 test ! -e $M0/$1 - test -e $M0/.trashcan/$1* + wildcard_exists $M0/.trashcan/$1* # remove from trashcan rm -f $M0/.trashcan/$1* - test ! -e $M0/.trashcan/$1* + wildcard_not_exists $M0/.trashcan/$1* } truncate_op() { - truncate -s 2 $M0/$1 ls $M0/.trashcan/1/2/3 &> /dev/null sleep 2 test -e $M0/$1 - test $(du -b $M0/$1 | awk '{print $1}') -eq 2 &>/dev/null - test -e $M0/.trashcan/$1* - test $(du -b $M0/.trashcan/$1*|awk '{print $1}') -eq $2 &>/dev/null + test $(ls -l $M0/$1 | awk '{print $5}') -eq 2 &>/dev/null + wildcard_exists $M0/.trashcan/$1* + test $(ls -l $M0/.trashcan/$1*|awk '{print $5}') -eq $2 &>/dev/null # truncate from trashcan truncate -s 1 $M0/.trashcan/$1* test $(ls $M0/.trashcan/$1* | wc -l) -eq 1 } +wildcard_exists() { + test -e $1 +} + +wildcard_not_exists() { + test ! -e $1 +} # testing glusterd [1-3] TEST glusterd @@ -94,7 +100,7 @@ TEST unlink_op file1 TEST truncate_op file2 4 # create files directory hierarchy and check [16] -mkdir $M0/1/2/3 -p +mkdir -p $M0/1/2/3 create_files $M0/1/2/3/foo1 $M0/1/2/3/foo2 TEST file_exists 1/2/3/foo1 1/2/3/foo2 @@ -117,13 +123,13 @@ TEST file_exists a/test1 a/test2 # remove from eliminate pattern [22] rm -f $M0/a/test1 -TEST [ ! -e $M0/.trashcan/a/test1* ] +TEST wildcard_not_exists $M0/.trashcan/a/test1* # truncate from eliminate path [23-25] truncate -s 2 $M0/a/test2 TEST [ -e $M0/a/test2 ] -TEST [ `du -b $M0/a/test2 | awk '{print $1}'` -eq 2 ] -TEST [ ! -e $M0/.trashcan/a/test2* ] +TEST [ `ls -l $M0/a/test2 | awk '{print $5}'` -eq 2 ] +TEST wildcard_not_exists $M0/.trashcan/a/test2* # set internal op on [26-27] TEST $CLI volume set $V0 features.trash-internal-op on @@ -157,7 +163,7 @@ sleep 3 # check whether rebalance was succesful [38-40] TEST [ -e $B0/${V0}3/rebal2 ] -TEST [ -e $B0/${V0}1/.trashcan/internal_op/rebal2* ] +TEST wildcard_exists $B0/${V0}1/.trashcan/internal_op/rebal2* TEST stop_vol # create a replicated volume [41] @@ -190,21 +196,21 @@ TEST [ -e $B0/${V1}1/self -a -e $B0/${V1}2/self ] kill `ps aux| grep glusterfsd | awk '{print $2}' | head -1` sleep 2 rm -f $M1/self -TEST [ -e $M1/.trashcan/self* ] +TEST wildcard_exists $M1/.trashcan/self* # force start the volume and trigger the self-heal manually [56] TEST $CLI volume start $V1 force sleep 3 # check for the removed file in trashcan [57] -TEST [ -e $B0/${V1}1/.trashcan/internal_op/self* -o -e $B0/${V1}2/.trashcan/internal_op/self* ] +TEST [ wildcard_exists $B0/${V1}1/.trashcan/internal_op/self* -o wildcard_exists $B0/${V1}2/.trashcan/internal_op/self* ] # check renaming of trash directory through cli [58-62] TEST $CLI volume set $V0 trash-dir abc TEST $CLI volume start $V0 TEST glusterfs -s $H0 --volfile-id $V0 $M0 --attribute-timeout=0 TEST [ -e $M0/abc -a ! -e $M0/.trashcan ] -TEST [ -e $B0/${V0}1/abc/internal_op/rebal2* ] +TEST wildcard_exists $B0/${V0}1/abc/internal_op/rebal2* sleep 2 # ensure that rename and delete operation on trash directory fails [63-65]
_______________________________________________ Gluster-devel mailing list Gluster-devel@xxxxxxxxxxx http://www.gluster.org/mailman/listinfo/gluster-devel