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
+}
--- /dev/null
+CREATE TEMP TABLE tmp (
+ node_id text,
+ hostname text,
+ port text,
+ status text,
+ lb_weight text,
+ role text,
+ select_cnt text,
+ load_balance_node text,
+ replication_delay text,
+ mode text);
+
+INSERT INTO tmp VALUES
+('0',:dir,'11002','down','0.500000','standby','0','false','0','s'),
+('1',:dir,'11003','up','0.500000','primary','0','false','0','s'),
+('0',:dir,'11002','down','0.500000','slave','0','false','0','r'),
+('1',:dir,'11003','up','0.500000','master','0','false','0','r');
+
+SELECT node_id,hostname,port,status,lb_weight,role,select_cnt,load_balance_node,replication_delay
+FROM tmp
+WHERE mode = :mode
$PSQL -c "show pool_nodes" test
- # trrigger failover
+ # trigger failover on node 1
$PG_CTL -D data1 -m f stop
wait_for_pgpool_startup
$PSQL -c "show pool_nodes" test |sed -e 's/true /false/'> result
./shutdownall
- cd ..
+ ./startall
+ wait_for_pgpool_startup
+ # trigger failover on node 0
+ $PG_CTL -D data0 -m f stop
+ wait_for_failover_done
+ $PSQL -c "show pool_nodes" test |sed -e 's/true /false/'> result
+ # check the output of "show pool_nodes".
+ LANG=C $PSQL -f ../create_expected_node0.sql -v mode="'$mode'" -v dir="'$PGSOCKET_DIR'" test | tail -n 6 > expected
+ cmp result expected > /dev/null 2>&1
+ if [ $? != 0 ];then
+ ./shutdownall
+ exit 1
+ fi
+
+ ./shutdownall
+
+ cd ..
done
exit 0