Skip to content

Commit bcdaf3b

Browse files
authored
make valgrind-session. (#691)
This runs in a docker container where we have valgrind installed and allows to check for some memory leaks.
1 parent fb8c529 commit bcdaf3b

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ RUN make -s clean && make -s install -j8
5858

5959
COPY ./tests/ ./tests
6060

61+
COPY ./valgrind ./valgrind
62+
RUN chmod a+w ./valgrind
63+
6164
USER docker
6265
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/postgresql/${PGVERSION}/bin
6366
ENV PG_AUTOCTL_DEBUG 1

Makefile

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the PostgreSQL License.
33

4+
TOP := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
5+
46
CONTAINER_NAME = pg_auto_failover
57
TEST_CONTAINER_NAME = pg_auto_failover_test
68
DOCKER_RUN_OPTS = --privileged -ti --rm
@@ -60,7 +62,7 @@ ifeq ($(VALGRIND),)
6062
BINPATH = ./src/bin/pg_autoctl/pg_autoctl
6163
PG_AUTOCTL = PG_AUTOCTL_DEBUG=1 ./src/bin/pg_autoctl/pg_autoctl
6264
else
63-
BINPATH = $(abspath $(PWD))/src/tools/pg_autoctl.valgrind
65+
BINPATH = $(abspath $(TOP))/src/tools/pg_autoctl.valgrind
6466
PG_AUTOCTL = PG_AUTOCTL_DEBUG=1 PG_AUTOCTL_DEBUG_BIN_PATH="$(BINPATH)" ./src/tools/pg_autoctl.valgrind
6567
endif
6668

@@ -157,7 +159,6 @@ build-test:
157159
run-test: build-test
158160
docker run \
159161
--name $(TEST_CONTAINER_NAME) \
160-
$(DOCKER_RUN_OPTS) \
161162
$(TEST_CONTAINER_NAME) \
162163
make -C /usr/src/pg_auto_failover test \
163164
TEST='${TEST}'
@@ -200,7 +201,7 @@ tmux-clean:
200201
--first-pgport $(FIRST_PGPORT) \
201202
--nodes $(NODES)
202203

203-
cluster: install tmux-clean
204+
tmux-session:
204205
$(PG_AUTOCTL) do tmux session \
205206
--root $(TMUX_TOP_DIR) \
206207
--first-pgport $(FIRST_PGPORT) \
@@ -212,6 +213,24 @@ cluster: install tmux-clean
212213
--binpath $(BINPATH) \
213214
--layout $(TMUX_LAYOUT)
214215

216+
cluster: install tmux-clean tmux-session ;
217+
218+
valgrind-session: build-test
219+
docker run \
220+
--name $(TEST_CONTAINER_NAME) \
221+
$(DOCKER_RUN_OPTS) \
222+
$(TEST_CONTAINER_NAME) \
223+
make -C /usr/src/pg_auto_failover \
224+
VALGRIND=1 \
225+
TMUX_TOP_DIR=/tmp/tmux \
226+
NODES=$(NODES) \
227+
NODES_ASYNC=$(NODES_ASYNC) \
228+
NODES_PRIOS=$(NODES_PRIOS) \
229+
NODES_SYNC_SB=$(NODES_SYNC_SB) \
230+
CLUSTER_OPTS=$(CLUSTER_OPTS) \
231+
TMUX_EXTRA_COMMANDS=$(TMUX_EXTRA_COMMANDS) \
232+
TMUX_LAYOUT=$(TMUX_LAYOUT) \
233+
tmux-session
215234

216235
azcluster: all
217236
$(PG_AUTOCTL) do azure create \

valgrind/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore everything in this directory
2+
*
3+
# Except this file
4+
!.gitignore

0 commit comments

Comments
 (0)