14f8ab
From b311385a3c4bd56d69d1fa7e9bd3d9a2ae5c344e Mon Sep 17 00:00:00 2001
14f8ab
From: Pranith Kumar K <pkarampu@redhat.com>
14f8ab
Date: Mon, 7 Oct 2019 12:27:01 +0530
14f8ab
Subject: [PATCH 403/449] Fix spurious failure in bug-1744548-heal-timeout.t
14f8ab
14f8ab
Script was assuming that the heal would have triggered
14f8ab
by the time test was executed, which may not be the case.
14f8ab
It can lead to following failures when the race happens:
14f8ab
14f8ab
...
14f8ab
18:29:45 not ok  14 [     85/      1] <  26> '[ 331 == 333 ]' -> ''
14f8ab
...
14f8ab
18:29:45 not ok  16 [  10097/      1] <  33> '[ 668 == 666 ]' -> ''
14f8ab
14f8ab
Heal on 3rd brick didn't start completely first time the command was executed.
14f8ab
So the extra count got added to the next profile info.
14f8ab
14f8ab
Fixed it by depending on cumulative stats and waiting until the count is
14f8ab
satisfied using EXPECT_WITHIN
14f8ab
14f8ab
> Upstream patch link:https://review.gluster.org/23523
14f8ab
>fixes: bz#1759002
14f8ab
>Change-Id: I3b410671c902d6b1458a757fa245613cb29d967d
14f8ab
>Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
14f8ab
14f8ab
BUG: 1764091
14f8ab
Change-Id: Ic4d16b6c8a1bbc35735567d60fd0383456b9f534
14f8ab
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/202369
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
14f8ab
---
14f8ab
 tests/bugs/replicate/bug-1744548-heal-timeout.t | 17 +++++++++++------
14f8ab
 1 file changed, 11 insertions(+), 6 deletions(-)
14f8ab
14f8ab
diff --git a/tests/bugs/replicate/bug-1744548-heal-timeout.t b/tests/bugs/replicate/bug-1744548-heal-timeout.t
14f8ab
index 3cb73bc..0aaa3ea 100644
14f8ab
--- a/tests/bugs/replicate/bug-1744548-heal-timeout.t
14f8ab
+++ b/tests/bugs/replicate/bug-1744548-heal-timeout.t
14f8ab
@@ -4,6 +4,11 @@
14f8ab
 . $(dirname $0)/../../volume.rc
14f8ab
 . $(dirname $0)/../../afr.rc
14f8ab
 
14f8ab
+function get_cumulative_opendir_count {
14f8ab
+#sed 'n:d' prints odd-numbered lines
14f8ab
+    $CLI volume profile $V0 info |grep OPENDIR|sed 'n;d' | awk '{print $8}'|tr -d '\n'
14f8ab
+}
14f8ab
+
14f8ab
 cleanup;
14f8ab
 
14f8ab
 TEST glusterd;
14f8ab
@@ -20,23 +25,23 @@ TEST ! $CLI volume heal $V0
14f8ab
 TEST $CLI volume profile $V0 start
14f8ab
 TEST $CLI volume profile $V0 info clear
14f8ab
 TEST $CLI volume heal $V0 enable
14f8ab
-TEST $CLI volume heal $V0
14f8ab
 # Each brick does 3 opendirs, corresponding to dirty, xattrop and entry-changes
14f8ab
-COUNT=`$CLI volume profile $V0 info incremental |grep OPENDIR|awk '{print $8}'|tr -d '\n'`
14f8ab
-TEST [ "$COUNT" == "333" ]
14f8ab
+EXPECT_WITHIN $HEAL_TIMEOUT "^333$" get_cumulative_opendir_count
14f8ab
 
14f8ab
 # Check that a change in heal-timeout is honoured immediately.
14f8ab
 TEST $CLI volume set $V0 cluster.heal-timeout 5
14f8ab
 sleep 10
14f8ab
-COUNT=`$CLI volume profile $V0 info incremental |grep OPENDIR|awk '{print $8}'|tr -d '\n'`
14f8ab
 # Two crawls must have happened.
14f8ab
-TEST [ "$COUNT" == "666" ]
14f8ab
+EXPECT_WITHIN $HEAL_TIMEOUT "^999$" get_cumulative_opendir_count
14f8ab
 
14f8ab
 # shd must not heal if it is disabled and heal-timeout is changed.
14f8ab
 TEST $CLI volume heal $V0 disable
14f8ab
+#Wait for configuration update and any opendir fops to complete
14f8ab
+sleep 10
14f8ab
 TEST $CLI volume profile $V0 info clear
14f8ab
 TEST $CLI volume set $V0 cluster.heal-timeout 6
14f8ab
-sleep 6
14f8ab
+#Better to wait for more than 6 seconds to account for configuration updates
14f8ab
+sleep 10
14f8ab
 COUNT=`$CLI volume profile $V0 info incremental |grep OPENDIR|awk '{print $8}'|tr -d '\n'`
14f8ab
 TEST [ -z $COUNT ]
14f8ab
 cleanup;
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab