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