From d0da350a7aa859c230053e5c58b805e037733fe6 Mon Sep 17 00:00:00 2001 From: paunin Date: Sat, 27 Apr 2019 13:06:11 +0800 Subject: [PATCH] Add test for crosscheck of repmgr --- tests/repmgr-crosscheck/run.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 tests/repmgr-crosscheck/run.sh diff --git a/tests/repmgr-crosscheck/run.sh b/tests/repmgr-crosscheck/run.sh new file mode 100755 index 00000000..e3910edd --- /dev/null +++ b/tests/repmgr-crosscheck/run.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# https://github.com/paunin/PostDock/issues/225 +docker-compose up -d pgmaster pgslave1 pgslave3 +set -e + +docker-compose exec -T pgmaster wait_local_postgres +docker-compose exec -T pgslave1 wait_local_postgres +docker-compose exec -T pgslave3 wait_local_postgres +sleep 10 + +# Result matrix should look like this(5 rows, 3 rows with stars but with no question marks): +# +# Name | Id | 1 | 2 | 4 +# ------+----+----+----+---- +# node1 | 1 | * | * | * +# node2 | 2 | * | * | * +# node4 | 4 | * | * | * + +for CONTAINER in "pgmaster" "pgslave1" "pgslave3"; do + echo "Checking CONTAINER=$CONTAINER" + UNKNOWN_NUMBER=`docker-compose exec $CONTAINER bash -c 'gosu postgres repmgr cluster crosscheck 2>/dev/null' | grep -v '?' | grep '*' | wc -l | tr -d ' '` + if [[ "3" != "$UNKNOWN_NUMBER" ]]; then + echo ">>> CrossCheck failed for CONTAINER=$CONTAINER (UNKNOWN_NUMBER=$UNKNOWN_NUMBER)" + exit 1 + fi +done + + +