tests: Fix spurious failure in tests/bugs/bug-830665.t

Problem with script:
EXPECT_WITHIN fails the test if the command it executes fails.
There is a possibility that the file script tries to 'cat' may not exist.
In those cases it would fail leading to spurious failures.

Fix:
Add a function which returns empty string when the file doesn't exist
and 'cat' file when it does exist.

Change-Id: I0abfb343f2fce1034ee4b5b680e3783c4f6e8486
BUG: 1092850
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/8057
Reviewed-by: Sachin Pandit <spandit@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
This commit is contained in:
Pranith Kumar K 2014-06-13 11:26:28 +05:30 committed by Vijay Bellur
parent 333d2a60eb
commit 4d656f9008

View File

@ -2,6 +2,7 @@
. $(dirname $0)/../include.rc
. $(dirname $0)/../nfs.rc
. $(dirname $0)/../volume.rc
cleanup;
@ -26,6 +27,16 @@ function volinfo_field()
$CLI volume info $vol | grep "^$field: " | sed 's/.*: //';
}
#EXPECT_WITHIN fails the test if the command it executes fails. This function
#returns "" when the file doesn't exist
function friendly_cat {
if [ ! -f $1 ];
then
echo "";
else
cat $1;
fi
}
## Verify volume is created
EXPECT "$V0" volinfo_field $V0 'Volume Name';
@ -81,7 +92,9 @@ sleep 5;
## Force entry self-heal.
TEST $CLI volume set $V0 cluster.self-heal-daemon on
sleep 1
EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status
EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0
EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1
TEST gluster volume heal $V0 full
#ls -lR $N0 > /dev/null;
@ -89,8 +102,8 @@ TEST gluster volume heal $V0 full
## check, but we want to test whether self-heal already happened.
## Make sure everything's in order on the recreated brick.
EXPECT_WITHIN $HEAL_TIMEOUT 'test_data' cat $B0/${V0}-0/a_file;
EXPECT_WITHIN $HEAL_TIMEOUT 'more_test_data' cat $B0/${V0}-0/a_dir/another_file;
EXPECT_WITHIN $HEAL_TIMEOUT 'test_data' friendly_cat $B0/${V0}-0/a_file;
EXPECT_WITHIN $HEAL_TIMEOUT 'more_test_data' friendly_cat $B0/${V0}-0/a_dir/another_file;
if [ "$EXIT_EARLY" = "1" ]; then
exit 0;