kopia lustrzana https://github.com/kartoza/docker-postgis
revert tests
rodzic
8380b45580
commit
d414b4a340
|
@ -0,0 +1,151 @@
|
|||
version: '2.1'
|
||||
volumes:
|
||||
default-pg-data-dir:
|
||||
new-pg-data-dir:
|
||||
new-pg-data-dir-2:
|
||||
new-pg-data-dir-3:
|
||||
recreate-pg-data-dir:
|
||||
init-waldir:
|
||||
services:
|
||||
pg-default:
|
||||
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: "pg_isready"
|
||||
|
||||
pg-new:
|
||||
image: 'kartoza/postgis:${TAG:-manual-build}'
|
||||
volumes:
|
||||
# Mount to new locations where there are no initial data
|
||||
- new-pg-data-dir:/opt/mypostgis/data
|
||||
- ./tests:/tests
|
||||
- ../utils:/lib/utils
|
||||
environment:
|
||||
# Tell the new location
|
||||
TEST_CLASS: TestNew
|
||||
DATADIR: /opt/mypostgis/data
|
||||
POSTGRES_PASS: 'docker'
|
||||
RUN_AS_ROOT: false
|
||||
healthcheck:
|
||||
interval: 60s
|
||||
timeout: 30s
|
||||
retries: 3
|
||||
test: "pg_isready"
|
||||
|
||||
pg-recreate:
|
||||
image: 'kartoza/postgis:${TAG:-manual-build}'
|
||||
volumes:
|
||||
- recreate-pg-data-dir:/var/lib/postgresql
|
||||
- ./tests:/tests
|
||||
- ../utils:/lib/utils
|
||||
environment:
|
||||
# Tell that you are going to perform cluster reinitialization
|
||||
TEST_CLASS: TestRecreate
|
||||
RECREATE_DATADIR: "True"
|
||||
DEFAULT_ENCODING: ${DEFAULT_ENCODING:-UTF-8}
|
||||
DEFAULT_COLLATION: ${DEFAULT_COLLATION:-id_ID.utf8}
|
||||
DEFAULT_CTYPE: ${DEFAULT_COLLATION:-id_ID.utf8}
|
||||
POSTGRES_PASS: 'docker'
|
||||
RUN_AS_ROOT: false
|
||||
healthcheck:
|
||||
interval: 60s
|
||||
timeout: 30s
|
||||
retries: 3
|
||||
test: "pg_isready"
|
||||
|
||||
pg-custom-waldir-wrong:
|
||||
image: 'kartoza/postgis:${TAG:-manual-build}'
|
||||
volumes:
|
||||
# Mount to a locations where there are initial data
|
||||
- new-pg-data-dir-2:/opt/mypostgis/data
|
||||
# Specify different waldir location
|
||||
- init-waldir:/opt/mypostgis/data/waldir
|
||||
- ./tests:/tests
|
||||
- ../utils:/lib/utils
|
||||
environment:
|
||||
TEST_CLASS: TestCustomWALdir
|
||||
DATADIR: /opt/mypostgis/data
|
||||
POSTGRES_INITDB_WALDIR: /opt/mypostgis/data/waldir
|
||||
POSTGRES_PASS: 'docker'
|
||||
RUN_AS_ROOT: false
|
||||
healthcheck:
|
||||
interval: 60s
|
||||
timeout: 30s
|
||||
retries: 3
|
||||
test: "pg_isready"
|
||||
|
||||
pg-custom-waldir-correct:
|
||||
image: 'kartoza/postgis:${TAG:-manual-build}'
|
||||
volumes:
|
||||
# Mount to new locations where there are no initial data
|
||||
- new-pg-data-dir-3:/opt/mypostgis/data
|
||||
# Specify different waldir location
|
||||
- init-waldir:/opt/mypostgis/waldir
|
||||
- ./tests:/tests
|
||||
- ../utils:/lib/utils
|
||||
environment:
|
||||
TEST_CLASS: TestCustomWALdir
|
||||
DATADIR: /opt/mypostgis/data
|
||||
POSTGRES_INITDB_WALDIR: /opt/mypostgis/waldir
|
||||
POSTGRES_PASS: 'docker'
|
||||
RUN_AS_ROOT: false
|
||||
healthcheck:
|
||||
interval: 60s
|
||||
timeout: 30s
|
||||
retries: 3
|
||||
test: "pg_isready"
|
||||
|
||||
pg-custom-waldir-not-match-1:
|
||||
image: 'kartoza/postgis:${TAG:-manual-build}'
|
||||
volumes:
|
||||
# Mount to a locations where there are initial data
|
||||
- new-pg-data-dir-3:/opt/mypostgis/data
|
||||
# Specify different waldir location
|
||||
- init-waldir:/opt/mypostgis/waldir
|
||||
- ./tests:/tests
|
||||
- ../utils:/lib/utils
|
||||
environment:
|
||||
TEST_CLASS: TestCustomWALdirNotMatch
|
||||
DATADIR: /opt/mypostgis/data
|
||||
POSTGRES_INITDB_WALDIR: /opt/waldir
|
||||
POSTGRES_PASS: 'docker'
|
||||
RUN_AS_ROOT: false
|
||||
healthcheck:
|
||||
interval: 60s
|
||||
timeout: 30s
|
||||
retries: 3
|
||||
test: "pg_isready"
|
||||
|
||||
pg-custom-waldir-not-match-2:
|
||||
image: 'kartoza/postgis:${TAG:-manual-build}'
|
||||
volumes:
|
||||
# Mount to a locations where there are initial data
|
||||
- new-pg-data-dir-2:/opt/mypostgis/data
|
||||
# Specify different waldir location
|
||||
- init-waldir:/opt/waldir
|
||||
- ./tests:/tests
|
||||
- ../utils:/lib/utils
|
||||
environment:
|
||||
TEST_CLASS: TestCustomWALdirNotMatch
|
||||
DATADIR: /opt/mypostgis/data
|
||||
POSTGRES_INITDB_WALDIR: /opt/waldir
|
||||
POSTGRES_PASS: 'docker'
|
||||
RUN_AS_ROOT: false
|
||||
healthcheck:
|
||||
interval: 60s
|
||||
timeout: 30s
|
||||
retries: 3
|
||||
test: "pg_isready"
|
||||
|
|
@ -6,12 +6,6 @@ volumes:
|
|||
new-pg-data-dir-3:
|
||||
recreate-pg-data-dir:
|
||||
init-waldir:
|
||||
default-pg-data-dir-gs:
|
||||
new-pg-data-dir-gs:
|
||||
new-pg-data-dir-2-gs:
|
||||
new-pg-data-dir-3-gs:
|
||||
recreate-pg-data-dir-gs:
|
||||
init-waldir-gs:
|
||||
services:
|
||||
pg-default:
|
||||
image: 'kartoza/postgis:${TAG:-manual-build}'
|
||||
|
@ -155,145 +149,3 @@ services:
|
|||
retries: 3
|
||||
test: "pg_isready"
|
||||
|
||||
# Custom user
|
||||
pg-default-gosu:
|
||||
image: 'kartoza/postgis:${TAG:-manual-build}'
|
||||
volumes:
|
||||
# By default persisted volumes should be in /var/lib/postgresql
|
||||
- default-pg-data-dir-gs:/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: "pg_isready"
|
||||
|
||||
pg-new-gosu:
|
||||
image: 'kartoza/postgis:${TAG:-manual-build}'
|
||||
volumes:
|
||||
# Mount to new locations where there are no initial data
|
||||
- new-pg-data-dir-gs:/opt/mypostgis/data
|
||||
- ./tests:/tests
|
||||
- ../utils:/lib/utils
|
||||
environment:
|
||||
# Tell the new location
|
||||
TEST_CLASS: TestNew
|
||||
DATADIR: /opt/mypostgis/data
|
||||
POSTGRES_PASS: 'docker'
|
||||
RUN_AS_ROOT: false
|
||||
healthcheck:
|
||||
interval: 60s
|
||||
timeout: 30s
|
||||
retries: 3
|
||||
test: "pg_isready"
|
||||
|
||||
pg-recreate-gosu:
|
||||
image: 'kartoza/postgis:${TAG:-manual-build}'
|
||||
volumes:
|
||||
- recreate-pg-data-dir-gs:/var/lib/postgresql
|
||||
- ./tests:/tests
|
||||
- ../utils:/lib/utils
|
||||
environment:
|
||||
# Tell that you are going to perform cluster reinitialization
|
||||
TEST_CLASS: TestRecreate
|
||||
RECREATE_DATADIR: "True"
|
||||
DEFAULT_ENCODING: ${DEFAULT_ENCODING:-UTF-8}
|
||||
DEFAULT_COLLATION: ${DEFAULT_COLLATION:-id_ID.utf8}
|
||||
DEFAULT_CTYPE: ${DEFAULT_COLLATION:-id_ID.utf8}
|
||||
POSTGRES_PASS: 'docker'
|
||||
RUN_AS_ROOT: false
|
||||
healthcheck:
|
||||
interval: 60s
|
||||
timeout: 30s
|
||||
retries: 3
|
||||
test: "pg_isready"
|
||||
|
||||
pg-custom-waldir-wrong-gosu:
|
||||
image: 'kartoza/postgis:${TAG:-manual-build}'
|
||||
volumes:
|
||||
# Mount to a locations where there are initial data
|
||||
- new-pg-data-dir-2-gs:/opt/mypostgis/data
|
||||
# Specify different waldir location
|
||||
- init-waldir-gs:/opt/mypostgis/data/waldir
|
||||
- ./tests:/tests
|
||||
- ../utils:/lib/utils
|
||||
environment:
|
||||
TEST_CLASS: TestCustomWALdir
|
||||
DATADIR: /opt/mypostgis/data
|
||||
POSTGRES_INITDB_WALDIR: /opt/mypostgis/data/waldir
|
||||
POSTGRES_PASS: 'docker'
|
||||
RUN_AS_ROOT: false
|
||||
healthcheck:
|
||||
interval: 60s
|
||||
timeout: 30s
|
||||
retries: 3
|
||||
test: "pg_isready"
|
||||
|
||||
pg-custom-waldir-correct-gosu:
|
||||
image: 'kartoza/postgis:${TAG:-manual-build}'
|
||||
volumes:
|
||||
# Mount to new locations where there are no initial data
|
||||
- new-pg-data-dir-3-gs:/opt/mypostgis/data
|
||||
# Specify different waldir location
|
||||
- init-waldir-gs:/opt/mypostgis/waldir
|
||||
- ./tests:/tests
|
||||
- ../utils:/lib/utils
|
||||
environment:
|
||||
TEST_CLASS: TestCustomWALdir
|
||||
DATADIR: /opt/mypostgis/data
|
||||
POSTGRES_INITDB_WALDIR: /opt/mypostgis/waldir
|
||||
POSTGRES_PASS: 'docker'
|
||||
RUN_AS_ROOT: false
|
||||
healthcheck:
|
||||
interval: 60s
|
||||
timeout: 30s
|
||||
retries: 3
|
||||
test: "pg_isready"
|
||||
|
||||
pg-custom-waldir-not-match-1-gosu:
|
||||
image: 'kartoza/postgis:${TAG:-manual-build}'
|
||||
volumes:
|
||||
# Mount to a locations where there are initial data
|
||||
- new-pg-data-dir-3-gs:/opt/mypostgis/data
|
||||
# Specify different waldir location
|
||||
- init-waldir-gs:/opt/mypostgis/waldir
|
||||
- ./tests:/tests
|
||||
- ../utils:/lib/utils
|
||||
environment:
|
||||
TEST_CLASS: TestCustomWALdirNotMatch
|
||||
DATADIR: /opt/mypostgis/data
|
||||
POSTGRES_INITDB_WALDIR: /opt/waldir
|
||||
POSTGRES_PASS: 'docker'
|
||||
RUN_AS_ROOT: false
|
||||
healthcheck:
|
||||
interval: 60s
|
||||
timeout: 30s
|
||||
retries: 3
|
||||
test: "pg_isready"
|
||||
|
||||
pg-custom-waldir-not-match-2-gosu:
|
||||
image: 'kartoza/postgis:${TAG:-manual-build}'
|
||||
volumes:
|
||||
# Mount to a locations where there are initial data
|
||||
- new-pg-data-dir-2-gs:/opt/mypostgis/data
|
||||
# Specify different waldir location
|
||||
- init-waldir-gs:/opt/waldir
|
||||
- ./tests:/tests
|
||||
- ../utils:/lib/utils
|
||||
environment:
|
||||
TEST_CLASS: TestCustomWALdirNotMatch
|
||||
DATADIR: /opt/mypostgis/data
|
||||
POSTGRES_INITDB_WALDIR: /opt/waldir
|
||||
POSTGRES_PASS: 'docker'
|
||||
RUN_AS_ROOT: false
|
||||
healthcheck:
|
||||
interval: 60s
|
||||
timeout: 30s
|
||||
retries: 3
|
||||
test: "pg_isready"
|
|
@ -5,36 +5,30 @@ set -e
|
|||
|
||||
source ../test-env.sh
|
||||
|
||||
if [[ $(dpkg -l | grep "docker-compose") > /dev/null ]];then
|
||||
VERSION='docker-compose'
|
||||
else
|
||||
VERSION='docker compose'
|
||||
fi
|
||||
|
||||
# Run service
|
||||
${VERSION} up -d pg-default pg-new pg-recreate pg-default-gosu pg-new-gosu pg-recreate-gosu
|
||||
docker-compose up -d pg-default pg-new pg-recreate
|
||||
|
||||
if [[ -n "${PRINT_TEST_LOGS}" ]]; then
|
||||
${VERSION} logs -f &
|
||||
docker-compose logs -f &
|
||||
fi
|
||||
|
||||
sleep 60
|
||||
|
||||
services=("pg-default" "pg-new" "pg-recreate" "pg-default-gosu" "pg-new-gosu" "pg-recreate-gosu")
|
||||
services=("pg-default" "pg-new" "pg-recreate")
|
||||
|
||||
for service in "${services[@]}"; do
|
||||
|
||||
# Execute tests
|
||||
until ${VERSION} exec -T $service pg_isready; do
|
||||
until docker-compose exec -T $service pg_isready; do
|
||||
sleep 5
|
||||
echo "Wait service to be ready"
|
||||
done;
|
||||
echo "Execute test for $service"
|
||||
${VERSION} exec -T $service /bin/bash /tests/test.sh
|
||||
docker-compose exec -T $service /bin/bash /tests/test.sh
|
||||
|
||||
done
|
||||
|
||||
# special meta test to check the setup
|
||||
bash ./test_custom_waldir.sh
|
||||
|
||||
${VERSION} down -v
|
||||
docker-compose down -v
|
||||
|
|
|
@ -4,120 +4,107 @@
|
|||
set -e
|
||||
|
||||
source ../test-env.sh
|
||||
if [[ $(dpkg -l | grep "docker-compose") > /dev/null ]];then
|
||||
VERSION='docker-compose'
|
||||
else
|
||||
VERSION='docker compose'
|
||||
fi
|
||||
|
||||
# This test is special
|
||||
# It is used to check the meta level of the setup.
|
||||
|
||||
# Print logs
|
||||
if [[ -n "${PRINT_TEST_LOGS}" ]]; then
|
||||
${VERSION} logs -f &
|
||||
docker-compose logs -f &
|
||||
fi
|
||||
|
||||
# Recreate containers with the same setup as pg-new and pg-default
|
||||
# Try to make sure that container recreation is successful
|
||||
echo "### Checking Container Recreation"
|
||||
${VERSION} down
|
||||
${VERSION} up -d pg-default pg-new pg-recreate pg-default-gosu pg-new-gosu pg-recreate-gosu
|
||||
docker-compose down
|
||||
docker-compose up -d pg-default pg-new pg-recreate
|
||||
|
||||
sleep 60
|
||||
|
||||
services=("pg-default" "pg-new" "pg-recreate" "pg-default-gosu" "pg-new-gosu" "pg-recreate-gosu")
|
||||
services=("pg-default" "pg-new" "pg-recreate")
|
||||
|
||||
for service in "${services[@]}"; do
|
||||
|
||||
# Execute tests
|
||||
until ${VERSION} exec -T $service pg_isready; do
|
||||
until docker-compose exec -T $service pg_isready; do
|
||||
sleep 5
|
||||
echo "Wait service to be ready"
|
||||
done;
|
||||
echo "Execute test for $service"
|
||||
${VERSION} exec -T $service /bin/bash /tests/test.sh
|
||||
docker-compose exec -T $service /bin/bash /tests/test.sh
|
||||
|
||||
done
|
||||
|
||||
# Check the wrong setup must have warned that nested custom pg_wal location
|
||||
# is prevented
|
||||
echo "### Checking Error Message on nested pg_wal location"
|
||||
services=("pg-custom-waldir-wrong" "pg-custom-waldir-wrong-gosu")
|
||||
${VERSION} up -d pg-custom-waldir-wrong pg-custom-waldir-wrong-gosu
|
||||
service="pg-custom-waldir-wrong"
|
||||
docker-compose up -d pg-custom-waldir-wrong
|
||||
|
||||
sleep 60
|
||||
|
||||
# Loop until we found error message
|
||||
for service in "${services[@]}"; do
|
||||
while true; do
|
||||
if [[ -n "$(${VERSION} logs $service | grep 'Error')" && \
|
||||
-n "$(${VERSION} logs $service | grep 'POSTGRES_INITDB_WALDIR should not be set to be inside DATADIR or PGDATA.')" ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 5
|
||||
done;
|
||||
done
|
||||
while true; do
|
||||
if [[ -n "$(docker-compose logs $service | grep 'Error')" && \
|
||||
-n "$(docker-compose logs $service | grep 'POSTGRES_INITDB_WALDIR should not be set to be inside DATADIR or PGDATA.')" ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 5
|
||||
done;
|
||||
|
||||
${VERSION} down
|
||||
docker-compose down
|
||||
|
||||
# Check that the correct custom initdb waldir works, twice after container restart.
|
||||
echo "### Checking custom POSTGRES_INITDB_WALDIR should work"
|
||||
services=("pg-custom-waldir-correct" "pg-custom-waldir-correct-gosu")
|
||||
for service in "${services[@]}"; do
|
||||
for ((i=1;i<=2;i++)); do
|
||||
echo "attempt $i"
|
||||
${VERSION} up -d $service
|
||||
sleep 60
|
||||
until ${VERSION} exec -T $service pg_isready; do
|
||||
sleep 5
|
||||
echo "Wait service to be ready"
|
||||
done;
|
||||
echo "Execute test for $service"
|
||||
${VERSION} exec -T $service /bin/bash /tests/test.sh
|
||||
${VERSION} down
|
||||
done
|
||||
service="pg-custom-waldir-correct"
|
||||
for ((i=1;i<=2;i++)); do
|
||||
echo "attempt $i"
|
||||
docker-compose up -d $service
|
||||
sleep 60
|
||||
until docker-compose exec -T $service pg_isready; do
|
||||
sleep 5
|
||||
echo "Wait service to be ready"
|
||||
done;
|
||||
echo "Execute test for $service"
|
||||
docker-compose exec -T $service /bin/bash /tests/test.sh
|
||||
docker-compose down
|
||||
done
|
||||
|
||||
# Check that if the variable POSTGRES_INITBD_WALDIR doesn't match with pg_wal symlink,
|
||||
# then give warning, but proceeds if the the mount is still correct
|
||||
echo "### Checking raise warning if custom POSTGRES_INITDB_WALDIR does not match"
|
||||
services=("pg-custom-waldir-not-match-1" "pg-custom-waldir-not-match-1-gosu")
|
||||
${VERSION} up -d pg-custom-waldir-not-match-1 pg-custom-waldir-not-match-1-gosu
|
||||
service="pg-custom-waldir-not-match-1"
|
||||
docker-compose up -d $service
|
||||
sleep 60
|
||||
# Loop until we found warning message
|
||||
for service in "${services[@]}"; do
|
||||
while true; do
|
||||
if [[ -n "$(${VERSION} logs $service | grep 'Warning')" && \
|
||||
-n "$(${VERSION} logs $service | grep 'POSTGRES_INITDB_WALDIR is not the same as what pg_wal is pointing to.')" ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 5
|
||||
done;
|
||||
until ${VERSION} exec -T $service pg_isready; do
|
||||
sleep 5
|
||||
echo "Wait service to be ready"
|
||||
done;
|
||||
echo "Execute test for $service"
|
||||
${VERSION} exec -T $service /bin/bash /tests/test.sh
|
||||
done
|
||||
${VERSION} down
|
||||
while true; do
|
||||
if [[ -n "$(docker-compose logs $service | grep 'Warning')" && \
|
||||
-n "$(docker-compose logs $service | grep 'POSTGRES_INITDB_WALDIR is not the same as what pg_wal is pointing to.')" ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 5
|
||||
done;
|
||||
until docker-compose exec -T $service pg_isready; do
|
||||
sleep 5
|
||||
echo "Wait service to be ready"
|
||||
done;
|
||||
echo "Execute test for $service"
|
||||
docker-compose exec -T $service /bin/bash /tests/test.sh
|
||||
docker-compose down
|
||||
|
||||
# Check that if the pg_wal is empty, then something is wrong and we should exit
|
||||
echo "### Checking Error and Exit if pg_wal is empty"
|
||||
services=("pg-custom-waldir-not-match-2 pg-custom-waldir-not-match-2-gosu")
|
||||
${VERSION} up -d pg-custom-waldir-not-match-2 pg-custom-waldir-not-match-2-gosu
|
||||
service="pg-custom-waldir-not-match-2"
|
||||
docker-compose up -d $service
|
||||
sleep 60
|
||||
# Loop until we found warning message
|
||||
for service in "${services[@]}"; do
|
||||
warning_text="Can't proceed because \"/opt/mypostgis/data/pg_wal\" directory is empty."
|
||||
while true; do
|
||||
if [[ -n "$(${VERSION} logs $service | grep 'Error')" && \
|
||||
-n "$(${VERSION} logs $service | grep "$warning_text")" ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 5
|
||||
done;
|
||||
done
|
||||
warning_text="Can't proceed because \"/opt/mypostgis/data/pg_wal\" directory is empty."
|
||||
while true; do
|
||||
if [[ -n "$(docker-compose logs $service | grep 'Error')" && \
|
||||
-n "$(docker-compose logs $service | grep "$warning_text")" ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 5
|
||||
done;
|
||||
|
||||
${VERSION} down -v
|
||||
docker-compose down -v
|
||||
|
|
Ładowanie…
Reference in New Issue