diff options
author | Anuradha <atalur@redhat.com> | 2014-09-03 19:04:02 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2014-09-18 11:05:47 -0700 |
commit | acc0b3f93e74e914ee345e9e89619c8411596bdf (patch) | |
tree | 14a35cd56cae70fbe433cb5b4e073dce5065d0eb /tests | |
parent | 8f4c223c5f7a7a06c3b73dbb94e85d271bd84fb5 (diff) |
cluster/afr : Mark pending changelog xattrs for new creations
Backport of: http://review.gluster.org/8555
Based on type of file, set appropriate pending changelogs
for new entries.
Change-Id: Icf9af866fe9a9e511210e8ad097e968e2307d8ee
BUG: 1141787
Reviewed-on: http://review.gluster.org/8555
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Signed-off-by: Anuradha <atalur@redhat.com>
Reviewed-on: http://review.gluster.org/8748
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/afr.rc | 68 | ||||
-rw-r--r-- | tests/bugs/bug-1130892.t | 60 |
2 files changed, 128 insertions, 0 deletions
diff --git a/tests/afr.rc b/tests/afr.rc index 60ea1b7f123..938f9c07ab2 100644 --- a/tests/afr.rc +++ b/tests/afr.rc @@ -1,5 +1,73 @@ #!/bin/bash +function diff_dirs { + diff <(ls $1 | sort) <(ls $2 | sort) +} + +function heal_status { + local f1_path="${1}/${3}" + local f2_path="${2}/${3}" + local zero_xattr="000000000000000000000000" + local insync="" + diff_dirs $f1_path $f2_path + if [ $? -eq 0 ]; + then + insync="Y" + else + insync="N" + fi + local xattr11=$(get_hex_xattr trusted.afr.$V0-client-0 $f1_path) + local xattr12=$(get_hex_xattr trusted.afr.$V0-client-1 $f1_path) + local xattr21=$(get_hex_xattr trusted.afr.$V0-client-0 $f2_path) + local xattr22=$(get_hex_xattr trusted.afr.$V0-client-1 $f2_path) + local dirty1=$(get_hex_xattr trusted.afr.dirty $f1_path) + local dirty2=$(get_hex_xattr trusted.afr.dirty $f2_path) + if [ -z $xattr11 ]; then xattr11="000000000000000000000000"; fi + if [ -z $xattr12 ]; then xattr12="000000000000000000000000"; fi + if [ -z $xattr21 ]; then xattr21="000000000000000000000000"; fi + if [ -z $xattr22 ]; then xattr22="000000000000000000000000"; fi + if [ -z $dirty1 ]; then dirty1="000000000000000000000000"; fi + if [ -z $dirty2 ]; then dirty2="000000000000000000000000"; fi + echo ${insync}${xattr11}${xattr12}${xattr21}${xattr22}${dirty1}${dirty2} +} +# Check if given dir's self-heal is done +function is_dir_heal_done { + local zero_xattr="000000000000000000000000" + if [ "$(heal_status $@)" == "Y${zero_xattr}${zero_xattr}${zero_xattr}${zero_xattr}${zero_xattr}${zero_xattr}" ]; + then + echo "Y" + else + echo "N" + fi +} +# Check if the given file's self-heal is done +function is_file_heal_done { + local f1_path="${1}/${3}" + local f2_path="${2}/${3}" + local zxattr="000000000000000000000000" + local size1=$(stat -c "%s" $f1_path) + local size2=$(stat -c "%s" $f2_path) + local diff=$((size1-size2)) + local x11=$(get_hex_xattr trusted.afr.$V0-client-0 $f1_path) + local x12=$(get_hex_xattr trusted.afr.$V0-client-1 $f1_path) + local x21=$(get_hex_xattr trusted.afr.$V0-client-0 $f2_path) + local x22=$(get_hex_xattr trusted.afr.$V0-client-1 $f2_path) + local dirty1=$(get_hex_xattr trusted.afr.dirty $f1_path) + local dirty2=$(get_hex_xattr trusted.afr.dirty $f2_path) + if [ -z $x11 ]; then x11="000000000000000000000000"; fi + if [ -z $x12 ]; then x12="000000000000000000000000"; fi + if [ -z $x21 ]; then x21="000000000000000000000000"; fi + if [ -z $x22 ]; then x22="000000000000000000000000"; fi + if [ -z $dirty1 ]; then dirty1="000000000000000000000000"; fi + if [ -z $dirty2 ]; then dirty2="000000000000000000000000"; fi + if [ "${diff}${x11}${x12}${x21}${x22}${dirty1}${dirty2}" == "0${zxattr}${zxattr}${zxattr}${zxattr}${zxattr}${zxattr}" ]; + then + echo "Y" + else + echo "N" + fi +} + #count the number of entries marked for self-heal #in brick $1's index diff --git a/tests/bugs/bug-1130892.t b/tests/bugs/bug-1130892.t new file mode 100644 index 00000000000..438e795d571 --- /dev/null +++ b/tests/bugs/bug-1130892.t @@ -0,0 +1,60 @@ +#!/bin/bash +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../afr.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info; + +# Create a 1X2 replica +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}-{0,1} +EXPECT 'Created' volinfo_field $V0 'Status'; + +# Disable self-heal daemon +TEST gluster volume set $V0 self-heal-daemon off + +# Disable all perf-xlators +TEST $CLI volume set $V0 performance.quick-read off +TEST $CLI volume set $V0 performance.io-cache off +TEST $CLI volume set $V0 performance.write-behind off +TEST $CLI volume set $V0 performance.stat-prefetch off +TEST $CLI volume set $V0 performance.read-ahead off + +# Volume start +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status'; + +# FUSE Mount +TEST glusterfs -s $H0 --volfile-id $V0 $M0 + +# Create files and dirs +TEST mkdir -p $M0/one/two/ +TEST `echo "Carpe diem" > $M0/one/two/three` + +# Simulate disk-replacement +TEST kill_brick $V0 $H0 $B0/${V0}-1 +TEST rm -rf $B0/${V0}-1/one +TEST rm -rf $B0/${V0}-1/.glusterfs + +# Start force +TEST $CLI volume start $V0 force + +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 1 + +TEST stat $M0/one + +# Check pending xattrs +EXPECT "00000000" afr_get_specific_changelog_xattr $B0/${V0}-0/one trusted.afr.$V0-client-1 data +EXPECT_NOT "00000000" afr_get_specific_changelog_xattr $B0/${V0}-0/one trusted.afr.$V0-client-1 entry +EXPECT_NOT "00000000" afr_get_specific_changelog_xattr $B0/${V0}-0/one trusted.afr.$V0-client-1 metadata + +TEST gluster volume set $V0 self-heal-daemon on +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status +EXPECT_WITHIN $HEAL_TIMEOUT "Y" is_dir_heal_done $B0/${V0}-0 $B0/${V0}-1 one +EXPECT_WITHIN $HEAL_TIMEOUT "Y" is_dir_heal_done $B0/${V0}-0 $B0/${V0}-1 one/two +EXPECT_WITHIN $HEAL_TIMEOUT "Y" is_file_heal_done $B0/${V0}-0 $B0/${V0}-1 one/two/three + +cleanup; |