summaryrefslogtreecommitdiff
path: root/src/test/regression/libs.sh
blob: 7c5a0c1821191a572430b658d80ab34554110363 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#-------------------------------------------
# wait for pgpool comes up
#-------------------------------------------
function wait_for_pgpool_startup {
	timeout=20

	while [ $timeout -gt  0 ]
	do
		$PGBIN/psql -p $PGPOOL_PORT -c "show pool_nodes" test >/dev/null 2>&1
		if [ $? = 0 ];then
			break;
		fi
		timeout=`expr $timeout - 1`
		sleep 1
	done
}

#-------------------------------------------
# wait for primary/main 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|main">/dev/null 2>&1
		    if [ $? = 0 ];then
			break;
		    fi
		fi
		timeout=`expr $timeout - 1`
		echo "timeout: $timeout"
		sleep 1
	done
}

#-------------------------------------------
# clean remaining processes and sockets
#-------------------------------------------
function clean_all {
	pgrep pgpool | xargs kill -9 > /dev/null 2>&1
	pgrep postgres | xargs kill -9 > /dev/null 2>&1
	rm -f $PGSOCKET_DIR/.s.PGSQL.*
	netstat -t -p 2>/dev/null|grep pgpool
}

#-------------------------------------------
# check segmentation fault
#-------------------------------------------
function check_segfault {
	egrep -i "segmentation fault|segfault" log/pgpool.log >/dev/null 2>&1
}