Skip to content

Commit

Permalink
Fix DB name with hyphen and also add env for logging (#495)
Browse files Browse the repository at this point in the history
* Fix DB name with hyphen and also add env for logging and test creating database with hyphen

---------

Co-authored-by: Admire Nyakudya <[email protected]>
  • Loading branch information
NyakudyaA and Admire Nyakudya authored Dec 17, 2024
1 parent 711b968 commit 2d25521
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 3 deletions.
21 changes: 21 additions & 0 deletions scenario_tests/multiple_databases/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
volumes:
pg-db-data-dir:
pg-db-schema-dir:
pg-db-single-dir:


services:
Expand Down Expand Up @@ -45,4 +46,24 @@ services:
retries: 3
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"

pg-single-db:
image: 'kartoza/postgis:${TAG:-manual-build}'
restart: 'always'
# You can optionally mount to volume, to play with the persistence and
# observe how the node will behave after restarts.
volumes:
- pg-db-single-dir:/var/lib/postgresql
- ./tests:/tests
- ../utils:/lib/utils
environment:
POSTGRES_DB: 'name-with-hyphen'
POSTGRES_PASS: 'docker'
ALL_DATABASES: FALSE
SCHEMA_NAME: 'demo1,demo2'
healthcheck:
interval: 60s
timeout: 30s
retries: 3
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"


21 changes: 21 additions & 0 deletions scenario_tests/multiple_databases/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,24 @@ ${VERSION} exec -T pg-schema /bin/bash /tests/test_schemas.sh


${VERSION} down -v


# Run service for pg-schema
${VERSION} up -d pg-single-db

if [[ -n "${PRINT_TEST_LOGS}" ]]; then
${VERSION} logs -f &
fi

sleep 30

# Preparing all databases and single schema
until ${VERSION} exec -T pg-single-db pg_isready; do
sleep 1
done;

# Execute tests
${VERSION} exec -T pg-single-db /bin/bash /tests/test_schemas.sh


${VERSION} down -v
8 changes: 7 additions & 1 deletion scripts/env-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,12 @@ if [ -z "${SSL_KEY_FILE}" ]; then
SSL_KEY_FILE='/etc/ssl/private/ssl-cert-snakeoil.key'
fi

# controls all login params below, defaults to false
if [ -z "${LOGGING}" ]; then
LOGGING='FALSE'
fi
# log

if [ -z "${LOGGING_COLLECTOR}" ]; then
LOGGING_COLLECTOR='off'
fi
Expand Down Expand Up @@ -453,7 +458,8 @@ fi
IFS=','
read -a dbarr <<< "$POSTGRES_DBNAME"
SINGLE_DB=${dbarr[0]}
export ${SINGLE_DB}
echo ${SINGLE_DB} > /tmp/pg_dbname.txt


if [ -z "${TIMEZONE}" ]; then
TIMEZONE='Etc/UTC'
Expand Down
8 changes: 6 additions & 2 deletions scripts/setup-conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ cron.database_name = '${SINGLE_DB}'
password_encryption= '${PASSWORD_AUTHENTICATION}'
timezone='${TIMEZONE}'
cron.use_background_workers = on
EOF

echo "include 'postgis.conf'" >> "${CONF}"

if [[ "${LOGGING}" =~ [Tt][Rr][Uu][Ee] ]];then
cat > "${ROOT_CONF}"/logging.conf <<EOF
logging_collector='${LOGGING_COLLECTOR}'
log_directory='${LOG_DIRECTORY}'
log_filename='${LOG_FILENAME}'
Expand All @@ -54,10 +58,10 @@ log_connections='${LOG_CONNECTIONS}'
log_disconnections='${LOG_DISCONNECTS}'
log_line_prefix='${LOG_LINE_PREFIX}'
log_timezone='${LOG_TIMEZONE}'
EOF
echo "include 'logging.conf'" >> "${CONF}"

echo "include 'postgis.conf'" >> "${CONF}"
fi

# Create a config for logical replication
if [[ "${REPLICATION}" =~ [Tt][Rr][Uu][Ee] && "$WAL_LEVEL" == 'logical' ]]; then
Expand Down
1 change: 1 addition & 0 deletions scripts/setup-database.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash

source /scripts/env-data.sh
SINGLE_DB=$(cat /tmp/pg_dbname.txt)



Expand Down

0 comments on commit 2d25521

Please sign in to comment.