Test: stabilize 018.detach_primary.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Sun, 17 Apr 2022 12:48:51 +0000 (21:48 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Tue, 19 Apr 2022 06:45:52 +0000 (15:45 +0900)
The test occasionally failed with timeout. The cause seems the test
proceeds before watchdog are ready.  So wait till watchdog is ready
using pcp_watchdog_info.

src/test/regression/tests/018.detach_primary/test.sh

index 82b820061c4dda3cff31703f0cc56bf2e2c89550..aa310b255a5ed6b49f562fdde17404954a8d7844 100755 (executable)
@@ -83,7 +83,7 @@ wait_for_pgpool_startup
 
 # promote #3 node to create false primary
 $PG_CTL -D pgpool0/data2 promote
-sleep 10
+
 wait_for_pgpool_startup
 
 $PSQL -c "show pool_nodes" postgres|grep down
@@ -101,16 +101,36 @@ cd ..
 cd pgpool2
 ./startall
 cd ..
-sleep 10
-date
+
 wait_for_pgpool_startup
-date
+
 $PGPOOL_INSTALL_DIR/bin/pcp_watchdog_info -v -w -h localhost -p $PCP_PORT
 
-$PSQL -c "show pool_nodes" postgres
+date
+for i in {1..30}
+do
+    cnt=`$PGPOOL_INSTALL_DIR/bin/pcp_watchdog_info -v -w -h localhost -p $PCP_PORT|egrep "MASTER|LEADER|STANDBY"|wc -l`
+    if [ $cnt = 3 ];then
+       echo "watchdog is ready"
+       break
+    fi
+    sleep 1
+done
+date
 
-$PSQL -c "show pool_nodes" postgres|grep down
-if [ $? != 0 ];then
+ok=n
+for i in {1..10}
+do
+    $PSQL -c "show pool_nodes" postgres
+    $PSQL -c "show pool_nodes" postgres|grep down
+    if [ $? = 0 ];then
+       ok=y
+       break
+    fi
+    sleep 1
+done
+
+if [ $ok != 'y' ];then
     echo "node is not down despite that the quorum exists"
     ./shutdownall
     exit 1