fix issue with host mounts (#419)

* fix issue with host mounts and add tests
pull/421/head
mazano 2023-03-30 07:08:30 +02:00 zatwierdzone przez GitHub
rodzic 6eb1043519
commit b70664d906
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
5 zmienionych plików z 61 dodań i 23 usunięć

Wyświetl plik

@ -7,6 +7,24 @@ volumes:
recreate-pg-data-dir:
init-waldir:
services:
pg-local:
image: 'kartoza/postgis:${TAG:-manual-build}'
volumes:
# By default persisted volumes should be in /var/lib/postgresql
- ./default-pg-data-dir:/var/lib/postgresql
- ./tests:/tests
- ../utils:/lib/utils
environment:
# Default usage, no datadir location defined
TEST_CLASS: TestDefault
POSTGRES_PASS: 'docker'
RUN_AS_ROOT: false
healthcheck:
interval: 60s
timeout: 30s
retries: 3
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"
pg-default:
image: 'kartoza/postgis:${TAG:-manual-build}'
volumes:
@ -23,7 +41,7 @@ services:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"
pg-new:
image: 'kartoza/postgis:${TAG:-manual-build}'
@ -42,7 +60,7 @@ services:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"
pg-recreate:
image: 'kartoza/postgis:${TAG:-manual-build}'
@ -63,7 +81,7 @@ services:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"
pg-custom-waldir-wrong:
image: 'kartoza/postgis:${TAG:-manual-build}'
@ -84,7 +102,7 @@ services:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"
pg-custom-waldir-correct:
image: 'kartoza/postgis:${TAG:-manual-build}'
@ -105,7 +123,7 @@ services:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"
pg-custom-waldir-not-match-1:
image: 'kartoza/postgis:${TAG:-manual-build}'
@ -126,7 +144,7 @@ services:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"
pg-custom-waldir-not-match-2:
image: 'kartoza/postgis:${TAG:-manual-build}'
@ -147,5 +165,5 @@ services:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"

Wyświetl plik

@ -7,6 +7,23 @@ volumes:
recreate-pg-data-dir:
init-waldir:
services:
pg-local:
image: 'kartoza/postgis:${TAG:-manual-build}'
volumes:
# By default persisted volumes should be in /var/lib/postgresql
- ./local-pg-data-dir:/var/lib/postgresql
- ./tests:/tests
- ../utils:/lib/utils
environment:
# Default usage, no datadir location defined
TEST_CLASS: TestDefault
POSTGRES_PASS: 'docker'
healthcheck:
interval: 60s
timeout: 30s
retries: 3
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"
pg-default:
image: 'kartoza/postgis:${TAG:-manual-build}'
volumes:
@ -22,7 +39,7 @@ services:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"
pg-new:
image: 'kartoza/postgis:${TAG:-manual-build}'
@ -40,7 +57,7 @@ services:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"
pg-recreate:
image: 'kartoza/postgis:${TAG:-manual-build}'
@ -60,7 +77,7 @@ services:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"
pg-custom-waldir-wrong:
image: 'kartoza/postgis:${TAG:-manual-build}'
@ -80,7 +97,7 @@ services:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"
pg-custom-waldir-correct:
image: 'kartoza/postgis:${TAG:-manual-build}'
@ -100,7 +117,7 @@ services:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"
pg-custom-waldir-not-match-1:
image: 'kartoza/postgis:${TAG:-manual-build}'
@ -120,7 +137,7 @@ services:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"
pg-custom-waldir-not-match-2:
image: 'kartoza/postgis:${TAG:-manual-build}'
@ -140,5 +157,5 @@ services:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"

Wyświetl plik

@ -13,7 +13,7 @@ fi
# Run service for root user
${VERSION} up -d pg-default pg-new pg-recreate
${VERSION} up -d pg-local pg-default pg-new pg-recreate
if [[ -n "${PRINT_TEST_LOGS}" ]]; then
${VERSION} logs -f &
@ -21,7 +21,7 @@ fi
sleep 30
services=("pg-default" "pg-new" "pg-recreate")
services=("pg-local" "pg-default" "pg-new" "pg-recreate")
for service in "${services[@]}"; do
@ -40,9 +40,11 @@ bash ./test_custom_waldir.sh
${VERSION} down -v
# Run service for none root user
${VERSION} -f docker-compose-gs.yml up -d pg-default pg-new pg-recreate
# Run service for none root user
mkdir default-pg-data-dir
${VERSION} -f docker-compose-gs.yml up -d pg-local pg-default pg-new pg-recreate
if [[ -n "${PRINT_TEST_LOGS}" ]]; then
${VERSION} -f docker-compose-gs.yml logs -f &
@ -50,7 +52,7 @@ fi
sleep 30
services=("pg-default" "pg-new" "pg-recreate")
services=("pg-local" "pg-default" "pg-new" "pg-recreate")
for service in "${services[@]}"; do
@ -67,4 +69,4 @@ done
# special meta test to check the setup
#bash ./test_custom_waldir_gs.sh
${VERSION} -f docker-compose-gs.yml down -v
${VERSION} -f docker-compose-gs.yml down -v

Wyświetl plik

@ -23,11 +23,11 @@ fi
# Try to make sure that container recreation is successful
echo "### Checking Container Recreation"
${VERSION} down
${VERSION} up -d pg-default pg-new pg-recreate
${VERSION} up -d pg-local pg-default pg-new pg-recreate
sleep 60
services=("pg-default" "pg-new" "pg-recreate")
services=("pg-local" "pg-default" "pg-new" "pg-recreate")
for service in "${services[@]}"; do

Wyświetl plik

@ -34,7 +34,7 @@ EOF
fi
create_dir "${WAL_ARCHIVE}"
non_root_permission postgres postgres
# test if DATADIR has content
# Do initialization if DATADIR directory is empty, or RECREATE_DATADIR is true
@ -74,6 +74,7 @@ EOF
fi
fi;
non_root_permission postgres postgres
# Set proper permissions
# needs to be done as root:
chown -R postgres:postgres ${DATADIR} ${WAL_ARCHIVE}