Skip to content

Commit 92ee9cf

Browse files
committed
Revert "Try to fix test"
This reverts commit ebe560d.
1 parent ebe560d commit 92ee9cf

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

tests/SharedInputs/postgres_wrapper.sh

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,38 @@
44
# `postgresql://pgtest@localhost:9100` to connect to the server.
55
#
66
# Example:
7-
# ./postgres_wrapper.sh /tmp/myinstance 'createdb --maintenance-db=postgresql://pgtest@localhost:9100/postgres mydb; psql postgresql://pgtest@localhost:9100/mydb -c \"CREATE TABLE foo (id integer);\"'
7+
# ./postgres_wrapper /tmp/myinstance 'createdb --maintenance-db=postgresql://pgtest@localhost:9100/postgres mydb; psql postgresql://pgtest@localhost:9100/mydb -c \"CREATE TABLE foo (id integer);\"'
88
#
99
# Inspired by https://github.com/tk0miya/testing.postgresql
10-
1110
set -u
12-
1311
TEST_DIR=$1
1412
shift
13+
DB_DIR="$(mktemp -d -t lnt)"
1514
if [ -d "${TEST_DIR}" ]; then
1615
echo 1>&2 "${TEST_DIR} already exists"
1716
exit 1
1817
fi
1918

20-
mkdir -p "${TEST_DIR}/db"
19+
mkdir -p "${TEST_DIR}"
20+
ln -s ${TEST_DIR}/db_root ${DB_DIR}
2121

22-
INITDB_FLAGS+=" --pgdata=${TEST_DIR}/db"
23-
INITDB_FLAGS+=" --waldir=${TEST_DIR}/db"
22+
INITDB_FLAGS+=" --pgdata=${DB_DIR}/db"
23+
INITDB_FLAGS+=" --waldir=${DB_DIR}/db"
2424
INITDB_FLAGS+=" --nosync"
2525
INITDB_FLAGS+=" --no-locale"
2626
INITDB_FLAGS+=" --auth=trust"
2727
INITDB_FLAGS+=" --username=pgtest"
28-
echo "$ initdb $INITDB_FLAGS >& ${TEST_DIR}/initdb_log.txt"
29-
initdb ${INITDB_FLAGS} >& ${TEST_DIR}/initdb_log.txt
28+
echo "$ initdb $INITDB_FLAGS >& ${DB_DIR}/initdb_log.txt"
29+
initdb ${INITDB_FLAGS} >& ${DB_DIR}/initdb_log.txt
3030

3131
POSTGRES_FLAGS+=" -p 9100"
32-
POSTGRES_FLAGS+=" -D ${TEST_DIR}/db"
33-
POSTGRES_FLAGS+=" -k ${TEST_DIR}/db"
32+
POSTGRES_FLAGS+=" -D ${DB_DIR}/db"
33+
POSTGRES_FLAGS+=" -k ${DB_DIR}/db"
3434
POSTGRES_FLAGS+=" -h 127.0.0.1"
3535
POSTGRES_FLAGS+=" -F"
3636
POSTGRES_FLAGS+=" -c logging_collector=off"
37-
echo "$ postgres $POSTGRES_FLAGS >& ${TEST_DIR}/server_log.txt"
38-
postgres ${POSTGRES_FLAGS} >& ${TEST_DIR}/server_log.txt &
37+
echo "$ postgres $POSTGRES_FLAGS >& ${DB_DIR}/server_log.txt"
38+
postgres ${POSTGRES_FLAGS} >& ${DB_DIR}/server_log.txt &
3939
PG_PID=$!
4040
sleep 1 # Give the server time to start.
4141

@@ -47,4 +47,5 @@ RC=$?
4747
kill -15 ${PG_PID}
4848
[ $? -ne 0 ] && (echo 1>&1 "Error: Could not kill postgres server"; exit 1)
4949
wait ${PG_PID}
50+
[ ${RC} -ne 0 ] && (rm -rf ${DB_DIR})
5051
exit ${RC}

0 commit comments

Comments
 (0)