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