14f8ab
From 01bb17a0910a638e89a44a6da4b1359123940498 Mon Sep 17 00:00:00 2001
14f8ab
From: Hari Gowtham <hgowtham@redhat.com>
14f8ab
Date: Wed, 17 Apr 2019 12:17:27 +0530
14f8ab
Subject: [PATCH 130/141] tier/test: new-tier-cmds.t fails after a glusterd
14f8ab
 restart
14f8ab
14f8ab
Problem: new-tier-cmds.t does a restart of gluster processes and
14f8ab
after the restart the bricks and the tier process takes more
14f8ab
time than before to come online. This causes the detach start to
14f8ab
fail.
14f8ab
14f8ab
Fix: Give it enough time to come online after the restart.
14f8ab
14f8ab
label: DOWNSTREAM ONLY
14f8ab
14f8ab
Change-Id: I0f50b0bb77fe49ebd3a0292e190d0350d7994cfe
14f8ab
Signed-off-by: Hari Gowtham <hgowtham@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/168130
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
14f8ab
---
14f8ab
 tests/basic/tier/new-tier-cmds.t | 45 ++++++++++++++++++++++++++--------------
14f8ab
 tests/volume.rc                  |  8 +++++++
14f8ab
 2 files changed, 37 insertions(+), 16 deletions(-)
14f8ab
14f8ab
diff --git a/tests/basic/tier/new-tier-cmds.t b/tests/basic/tier/new-tier-cmds.t
14f8ab
index b9c9390..92881ac 100644
14f8ab
--- a/tests/basic/tier/new-tier-cmds.t
14f8ab
+++ b/tests/basic/tier/new-tier-cmds.t
14f8ab
@@ -19,14 +19,6 @@ function create_dist_tier_vol () {
14f8ab
         TEST $CLI_1 volume tier $V0 attach replica 2 $H1:$B1/${V0}_h1 $H2:$B2/${V0}_h2 $H3:$B3/${V0}_h3 $H1:$B1/${V0}_h4 $H2:$B2/${V0}_h5 $H3:$B3/${V0}_h6
14f8ab
 }
14f8ab
 
14f8ab
-function tier_daemon_status {
14f8ab
-        local _VAR=CLI_$1
14f8ab
-        local xpath_sel='//node[hostname="Tier Daemon"][path="localhost"]/status'
14f8ab
-        ${!_VAR} --xml volume status $V0 \
14f8ab
-                | xmllint --xpath "$xpath_sel" - \
14f8ab
-                | sed -n '/.*<status>\([0-9]*\).*/s//\1/p'
14f8ab
-}
14f8ab
-
14f8ab
 function detach_xml_status {
14f8ab
         $CLI_1 volume tier $V0 detach status --xml | sed -n \
14f8ab
         '/.*<opErrstr>Detach tier status successful/p' | wc -l
14f8ab
@@ -70,7 +62,20 @@ TEST $glusterd_2;
14f8ab
 EXPECT_WITHIN $PROBE_TIMEOUT 2 check_peers;
14f8ab
 
14f8ab
 #after starting detach tier the detach tier status should display the status
14f8ab
-sleep 2
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 1 $V0 $H1 $B1/${V0}_b1
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 1 $V0 $H1 $B1/${V0}_b4
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 1 $V0 $H1 $B1/${V0}_h1
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 1 $V0 $H1 $B1/${V0}_h4
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 2 $V0 $H2 $B2/${V0}_b2
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 2 $V0 $H2 $B2/${V0}_b5
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 2 $V0 $H2 $B2/${V0}_h2
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 2 $V0 $H2 $B2/${V0}_h5
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 3 $V0 $H3 $B3/${V0}_b3
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 3 $V0 $H3 $B3/${V0}_b6
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 3 $V0 $H3 $B3/${V0}_h3
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 3 $V0 $H3 $B3/${V0}_h6
14f8ab
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "3" get_shd_count
14f8ab
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "3" get_tierd_count
14f8ab
 $CLI_1 volume status
14f8ab
 TEST $CLI_1 volume tier $V0 detach start
14f8ab
 
14f8ab
@@ -91,13 +96,21 @@ EXPECT_WITHIN $PROBE_TIMEOUT 2 check_peers;
14f8ab
 EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 1 $V0 $H2 $B2/${V0}_b2
14f8ab
 EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 1 $V0 $H2 $B2/${V0}_h2
14f8ab
 
14f8ab
-# Parsing normal output doesn't work because of line-wrap issues on our
14f8ab
-# regression machines, and the version of xmllint there doesn't support --xpath
14f8ab
-# so we can't do it that way either.  In short, there's no way for us to detect
14f8ab
-# when we can stop waiting, so we just have to wait the maximum time every time
14f8ab
-# and hope any failures will show up later in the script.
14f8ab
-sleep $PROCESS_UP_TIMEOUT
14f8ab
-#XPECT_WITHIN $PROCESS_UP_TIMEOUT 1 tier_daemon_status 2
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 1 $V0 $H1 $B1/${V0}_b1
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 1 $V0 $H1 $B1/${V0}_b4
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 1 $V0 $H1 $B1/${V0}_h1
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 1 $V0 $H1 $B1/${V0}_h4
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 2 $V0 $H2 $B2/${V0}_b2
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 2 $V0 $H2 $B2/${V0}_b5
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 2 $V0 $H2 $B2/${V0}_h2
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 2 $V0 $H2 $B2/${V0}_h5
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 3 $V0 $H3 $B3/${V0}_b3
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 3 $V0 $H3 $B3/${V0}_b6
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 3 $V0 $H3 $B3/${V0}_h3
14f8ab
+EXPECT_WITHIN $CHILD_UP_TIMEOUT 1 cluster_brick_up_status 3 $V0 $H3 $B3/${V0}_h6
14f8ab
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "3" get_shd_count
14f8ab
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "0" get_tierd_count
14f8ab
+$CLI_1 volume status
14f8ab
 
14f8ab
 EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" tier_detach_status
14f8ab
 
14f8ab
diff --git a/tests/volume.rc b/tests/volume.rc
14f8ab
index 289b197..b326098 100644
14f8ab
--- a/tests/volume.rc
14f8ab
+++ b/tests/volume.rc
14f8ab
@@ -719,6 +719,14 @@ function get_snapd_count {
14f8ab
         ps auxww | grep glusterfs | grep snapd.pid | grep -v grep | wc -l
14f8ab
 }
14f8ab
 
14f8ab
+function get_tierd_count {
14f8ab
+        ps auxww | grep glusterfs | grep tierd.pid | grep -v grep | wc -l
14f8ab
+}
14f8ab
+
14f8ab
+function get_shd_count {
14f8ab
+        ps auxww | grep glusterfs | grep shd.pid | grep -v grep | wc -l
14f8ab
+}
14f8ab
+
14f8ab
 function drop_cache() {
14f8ab
 	case $OSTYPE in
14f8ab
 	Linux)
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab