Add wait_for_failover_done function for test.
authorBo Peng <pengbo@sraoss.co.jp>
Tue, 20 Mar 2018 08:42:46 +0000 (17:42 +0900)
committerBo Peng <pengbo@sraoss.co.jp>
Tue, 20 Mar 2018 08:42:46 +0000 (17:42 +0900)
src/test/regression/libs.sh
src/test/regression/tests/003.failover/test.sh

index 646927892871763e5ff3e38a417dbc3547df2947..f7aeaad956035f43ea4b8da1ed5b28ddb8e4be98 100644 (file)
@@ -14,3 +14,24 @@ function wait_for_pgpool_startup {
                sleep 1
        done
 }
+
+#-------------------------------------------
+# wait for primary/master failover done
+#-------------------------------------------
+function wait_for_failover_done {
+       timeout=20
+
+       while [ $timeout -gt  0 ]
+       do
+               $PGBIN/psql -p $PGPOOL_PORT -c "show pool_nodes" test >/dev/null 2>&1
+               if [ $? = 0 ];then
+                   $PGBIN/psql -p $PGPOOL_PORT -c "show pool_nodes" test |egrep -i "primary|master">/dev/null 2>&1
+                   if [ $? = 0 ];then
+                       break;
+                   fi
+               fi
+               timeout=`expr $timeout - 1`
+               echo "timeout: $timeout"
+               sleep 1
+       done
+}
index 4b2a8f1828eb2125139729c98d83ce4a9b5e0a54..3a93ed13def2c0fa844ed7a5e97c2a7470e58ca6 100755 (executable)
@@ -44,7 +44,7 @@ do
 
        # trigger failover on node 0
        $PG_CTL -D data0 -m f stop
-       wait_for_pgpool_startup
+       wait_for_failover_done
        $PSQL -c "show pool_nodes" test | sed -e 's/true /false/' > result
        if [ ! -s result ];then
                ./shutdownall