SIZE_LIST="1048576 1000 12345 0"
LAST_BRICK=$(($DISPERSE - 1))
CHUNK_SIZE=512
function fragment_size
{
local fragments=$(($DISPERSE - $REDUNDANCY))
local block_size=$(($CHUNK_SIZE * $fragments))
local size=$(($1 + $block_size - 1))
echo $((( $size - ( $size ) % $block_size ) / $fragments))
}
cleanup
tmp=`mktemp -d -t ${0##*/}.XXXXXX`
if [ ! -d $tmp ]; then
exit 1
fi
TEST glusterd
TEST pidof glusterd
TEST $CLI volume create $V0 redundancy $REDUNDANCY $H0:$B0/${V0}{0..$LAST_BRICK}
EXPECT 'Created' volinfo_field $V0 'Status'
TEST $CLI volume start $V0
EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Started' volinfo_field $V0 'Status'
TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0
EXPECT_WITHIN $CHILD_UP_TIMEOUT "$DISPERSE" ec_child_up_count $V0 0
TEST dd if=/dev/urandom of=$tmp/small bs=1024 count=1
TEST dd if=/dev/urandom of=$tmp/big bs=1024 count=4096
cs_small=$(sha1sum $tmp/small | awk '{ print $1 }')
cs_big=$(sha1sum $tmp/big | awk '{ print $1 }')
cp $tmp/small $tmp/small1
for size in $SIZE_LIST; do
truncate -s $size $tmp/small1
eval cs_small_truncate[$size]=$(sha1sum $tmp/small1 | awk '{ print $1 }')
done
cp $tmp/big $tmp/big1
for size in $SIZE_LIST; do
truncate -s $size $tmp/big1
eval cs_big_truncate[$size]=$(sha1sum $tmp/big1 | awk '{ print $1 }')
done
TEST df -h $M0
TEST stat $M0
for idx in `seq 0 $LAST_BRICK`; do
brick[$idx]=$(gf_get_gfid_backend_file_path $B0/$V0$idx)
done
TEST stat $M0/
TEST mkdir $M0/dir1
TEST [ -d $M0/dir1 ]
TEST touch $M0/file1
TEST [ -f $M0/file1 ]
for dir in . dir1; do
TEST cp $tmp/small $M0/$dir/small
TEST [ -f $M0/$dir/small ]
fsize=$(fragment_size 1024)
EXPECT "1024" stat -c "%s" $M0/$dir/small
for idx in `seq 0 $LAST_BRICK`; do
EXPECT "$fsize" stat -c "%s" ${brick[$idx]}/$dir/small
done
EXPECT "$cs_small" echo $(sha1sum $M0/$dir/small | awk '{ print $1 }')
TEST cp $tmp/big $M0/$dir/big
TEST [ -f $M0/$dir/big ]
fsize=$(fragment_size 4194304)
EXPECT "4194304" stat -c "%s" $M0/$dir/big
for idx in `seq 0 $LAST_BRICK`; do
EXPECT "$fsize" stat -c "%s" ${brick[$idx]}/$dir/big
done
EXPECT "$cs_big" echo $(sha1sum $M0/$dir/big | awk '{ print $1 }')
# Give enough time for current operations to complete. Otherwise the
# following kill_brick can cause data corruption and self-heal will be
# needed, but this script is not prepared to handle self-healing.
sleep 2
for idx in `seq 0 $LAST_BRICK`; do
TEST kill_brick $V0 $H0 $B0/$V0$idx
EXPECT "1024" stat -c "%s" $M0/$dir/small
EXPECT "4194304" stat -c "%s" $M0/$dir/big
TEST $CLI volume start $V0 force
EXPECT_WITHIN $CHILD_UP_TIMEOUT "$DISPERSE" ec_child_up_count $V0 0
done
for size in $SIZE_LIST; do
TEST truncate -s $size $M0/$dir/small
TEST [ -f $M0/$dir/small ]
fsize=$(fragment_size $size)
EXPECT "$size" stat -c "%s" $M0/$dir/small
for idx in `seq 0 $LAST_BRICK`; do
EXPECT "$fsize" stat -c "%s" ${brick[$idx]}/$dir/small
done
EXPECT "${cs_small_truncate[$size]}" echo $(sha1sum $M0/$dir/small | awk '{ print $1 }')
TEST truncate -s $size $M0/$dir/big
TEST [ -f $M0/$dir/big ]
EXPECT "$size" stat -c "%s" $M0/$dir/big
for idx in `seq 0 $LAST_BRICK`; do
EXPECT "$fsize" stat -c "%s" ${brick[$idx]}/$dir/big
done
EXPECT "${cs_big_truncate[$size]}" echo $(sha1sum $M0/$dir/big | awk '{ print $1 }')
done
TEST rm -f $M0/$dir/small
TEST [ ! -e $M0/$dir/small ]
for idx in `seq 0 $LAST_BRICK`; do
TEST [ ! -e ${brick[$idx]}/$dir/small ]
done
TEST rm -f $M0/$dir/big
TEST [ ! -e $M0/$dir/big ]
for idx in `seq 0 $LAST_BRICK`; do
TEST [ ! -e ${brick[$idx]}/$dir/big ]
done
done
TEST rmdir $M0/dir1
TEST [ ! -e $M0/dir1 ]
for idx in `seq 0 $LAST_BRICK`; do
TEST [ ! -e ${brick[$idx]}/dir1 ]
done
TEST rm -f $M0/file1
TEST [ ! -e $M0/file1 ]
for idx in `seq 0 $LAST_BRICK`; do
TEST [ ! -e ${brick[$idx]}/file1 ]
done
rm -rf $tmp
cleanup