# This scripts tests health-checks for PostgreSQL application, enabled using
# "option pgsql-check" line. A intermediate listener is used to validate
# the request because it is impossible with VTEST to read and match raw
# text.
server s1 {
recv 23
sendhex "520000000800000000"
} -start
server s2 {
recv 23
sendhex "450000000B53464154414C00"
} -start
server s3 {
recv 23
send "Not a PostgreSQL response"
} -start
syslog S1 -level notice {
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded, reason: Layer7 check passed.+info: \"PostgreSQL server is ok\".+check duration: [[:digit:]]+ms, status: 1/1 UP."
} -start
syslog S2 -level notice {
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be2/srv failed, reason: Layer7 invalid response.+info: \"FATAL\".+check duration: [[:digit:]]+ms, status: 0/1 DOWN."
} -start
syslog S3 -level notice {
recv
expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be3/srv failed, reason: Layer7 wrong status.+info: \"PostgreSQL unknown error\".+check duration: [[:digit:]]+ms, status: 0/1 DOWN."