Skip to content

Commit

Permalink
PGDATA added, netcat-openbsd installation
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Galkin committed Oct 24, 2022
1 parent 6ffc97c commit af155a8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
2 changes: 2 additions & 0 deletions docker/pg_tests/Dockerfile_daemon_test
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
FROM wal-g/docker_prefix:latest

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y netcat-openbsd && apt-get clean

CMD su - postgres /tmp/tests/daemon_test.sh
4 changes: 1 addition & 3 deletions docker/pg_tests/scripts/configs/daemon_test_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@
"WALG_USE_WAL_DELTA": "true",
"WALG_UPLOAD_CONCURRENCY": "1",
"WALG_UPLOAD_QUEUE": "1",
"WALG_UPLOAD_DISK_CONCURRENCY": "1"
"PGDATABASE": "postgres",
"PGHOST": "/var/run/postgresql",
"WALG_UPLOAD_DISK_CONCURRENCY": "1"
24 changes: 19 additions & 5 deletions docker/pg_tests/scripts/tests/daemon_test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
set -e -x

export PGDATA=/var/lib/postgresql/10/main

CONFIG_FILE="/tmp/configs/daemon_test_config.json"

COMMON_CONFIG="/tmp/configs/common_config.json"
Expand All @@ -11,16 +13,28 @@ echo "," >> ${TMP_CONFIG}
cat ${COMMON_CONFIG} >> ${TMP_CONFIG}
/tmp/scripts/wrap_config_file.sh ${TMP_CONFIG}

/usr/lib/postgresql/10/bin/initdb ${PGDATA}
/usr/lib/postgresql/10/bin/pg_ctl -D ${PGDATA} -w start
/tmp/scripts/wait_while_pg_not_ready.sh

wal-g --config=${TMP_CONFIG} delete everything FORCE --confirm

pgbench -i -s 50 postgres
du -hs ${PGDATA}
sleep 1
WAL=$(ls -l ${PGDATA}/pg_wal | head -n2 | tail -n1 | egrep -o "[0-9A-F]{24}")
SOCKET="/tmp/wal-daemon.sock"

wal-g --config=${TMP_CONFIG} daemon ${SOCKET}
SOCKET="${PGDATA}/wal-daemon.sock"
wal-g --config=${TMP_CONFIG} daemon ${SOCKET} &

if (echo -en "C\x0\x8"; echo -n "CHECK"; echo -en "F\x0\x1B"; echo -n "${WAL}") | nc -U ${SOCKET} | grep -q "OO"; then
if {
echo -en "C\x0\x8"
echo -n "CHECK"
echo -en "F\x0\x1B"
echo -n "${WAL}"
} | nc -U ${SOCKET} | grep -q "OO"; then
echo "WAL-G response is correct"
else
echo "Error in WAL-G response"
exit 1
fi

wal-g st ls ${WALE_S3_PREFIX}/wal_005/${WAL}.br
5 changes: 3 additions & 2 deletions internal/databases/postgres/daemon_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (h *CheckMessageHandler) Handle(messageBody []byte) error {
tracelog.ErrorLogger.Printf("Error on writing in socket: %v \n", err)
return err
}
tracelog.ErrorLogger.Println("Successful configuration check")
tracelog.InfoLogger.Println("Successful configuration check")
return nil
}

Expand All @@ -56,7 +56,8 @@ func (h *ArchiveMessageHandler) Handle(messageBody []byte) error {
tracelog.InfoLogger.Printf("wal file name: %s\n", string(messageBody))
PgDataSettingString, ok := internal.GetSetting(internal.PgDataSetting)
if !ok {
tracelog.InfoLogger.Print("\nPGDATA is not set in the conf.\n")
tracelog.ErrorLogger.Print("\nPGDATA is not set in the conf.\n")
return fmt.Errorf("PGDATA is not set in the conf")
}
pathToWal := path.Join(PgDataSettingString, "pg_wal")
fullPath := path.Join(pathToWal, string(messageBody))
Expand Down

0 comments on commit af155a8

Please sign in to comment.