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