Skip to content

Commit 98f247f

Browse files
committed
monitor: add make installcheck target and fix regression test
Add a top-level 'make installcheck' target that builds the PG16 test Docker image and runs the monitor's SQL regression suite (pg_regress) inside a fresh container. Defaults to PGVERSION=16; override with INSTALLCHECK_PGVERSION=17 etc. Fix node_active_protocol.sql to work in the full regression sequence: - Pass number_sync_standbys to create_formation() (5-arg form) - Capture registered node IDs via \\gset after registration so the test is not sensitive to how many nodes prior tests (monitor, workers) created - Move node_active_protocol before dummy_update in REGRESS order to avoid running against a downgraded 'dummy' extension version Update expected/node_active_protocol.out from the actual pg_regress output.
1 parent baf3434 commit 98f247f

4 files changed

Lines changed: 107 additions & 85 deletions

File tree

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,26 @@ check: check-monitor ;
105105
check-monitor: install-monitor
106106
$(MAKE) -C src/monitor/ installcheck
107107

108+
# Run SQL regression tests (pg_regress installcheck) inside a Docker container.
109+
# Defaults to PG16; override with PGVERSION=17 etc.
110+
# Usage: make installcheck [PGVERSION=16]
111+
INSTALLCHECK_PGVERSION ?= 16
112+
.PHONY: installcheck
113+
installcheck: build-test-pg$(INSTALLCHECK_PGVERSION)
114+
docker run --rm \
115+
$(TEST_CONTAINER_NAME):pg$(INSTALLCHECK_PGVERSION) \
116+
bash -c ' \
117+
initdb --auth=trust --username=docker -D /tmp/pgdata && \
118+
printf "shared_preload_libraries = '"'"'pgautofailover'"'"'\n" \
119+
>> /tmp/pgdata/postgresql.conf && \
120+
pg_ctl start -D /tmp/pgdata -l /tmp/pgdata/pg.log -o "-k /tmp -p 5432" && \
121+
sudo chmod -R a+w /usr/src/pg_auto_failover/src/monitor && \
122+
make -C /usr/src/pg_auto_failover/src/monitor installcheck \
123+
PGHOST=/tmp PGPORT=5432 PGUSER=docker \
124+
|| { pg_ctl stop -D /tmp/pgdata; exit 1; } && \
125+
pg_ctl stop -D /tmp/pgdata \
126+
'
127+
108128
.PHONY: clean
109129
clean: clean-monitor clean-bin ;
110130

src/monitor/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ MODULE_big = $(EXTENSION)
1414
OBJS = $(patsubst ${SRC_DIR}%.c,%.o,$(wildcard ${SRC_DIR}*.c))
1515
PG_CPPFLAGS = -std=c99 -Wall -Werror -Wno-unused-parameter -Iinclude -I$(libpq_srcdir) -g
1616
SHLIB_LINK = $(libpq)
17-
REGRESS = create_extension monitor workers dummy_update node_active_protocol drop_extension upgrade
17+
REGRESS = create_extension monitor workers node_active_protocol dummy_update drop_extension upgrade
1818

1919
PG_CONFIG ?= pg_config
2020
PGXS = $(shell $(PG_CONFIG) --pgxs)

0 commit comments

Comments
 (0)