add tests for none root

pull/403/head
Admire Nyakudya 2022-12-26 16:43:48 +02:00
rodzic aadda8a904
commit 5b0e73b602
9 zmienionych plików z 252 dodań i 21 usunięć

Wyświetl plik

@ -19,25 +19,11 @@ services:
- ALLOW_IP_RANGE=0.0.0.0/0
# Add extensions you need to be enabled by default in the DB. Default are the five specified below
- POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology,postgis_raster,pgrouting
- RUN_AS_ROOT=false
- RUN_AS_ROOT=true
ports:
- "5432"
restart: on-failure
healthcheck:
test: "PGPASSWORD=docker pg_isready -h 127.0.0.1 -U docker -d gis"
dbbackups:
image: kartoza/pg-backup:15-3.3
hostname: pg-backups
volumes:
- dbbackups:/backups
environment:
- DUMPPREFIX=PG_db
- POSTGRES_USER=docker
- POSTGRES_PASS=docker
- POSTGRES_PORT=5432
- POSTGRES_HOST=db
restart: on-failure
depends_on:
db:
condition: service_healthy

Wyświetl plik

@ -4,6 +4,8 @@ version: '2.1'
volumes:
pg-data-dir:
new-pg-data-dir:
pg-data-dir-gs:
new-pg-data-dir-gs:
services:
pg:
@ -56,3 +58,54 @@ services:
timeout: 30s
retries: 3
test: "pg_isready"
pg-gosu:
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-data-dir-gs:/var/lib/postgresql
- ./tests:/tests
- ../utils:/lib/utils
environment:
DEFAULT_COLLATION: ${DEFAULT_COLLATION:-id_ID.utf8}
DEFAULT_CTYPE: ${DEFAULT_COLLATION:-id_ID.utf8}
ALLOW_IP_RANGE: '0.0.0.0/0'
TEST_CLASS: test_collation.TestCollationDefault
POSTGRES_PASS: 'docker'
RUN_AS_ROOT: false
ports:
- "7778:5432"
healthcheck:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
pg-new-gosu:
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:
- new-pg-data-dir-gs:/opt/data/postgis
- ./tests:/tests
- ../utils:/lib/utils
hostname: 'pg-new-gosu'
environment:
RECREATE_DATADIR: "True"
PGDATA: /opt/data/postgis
DEFAULT_COLLATION: ${DEFAULT_COLLATION:-id_ID.utf8}
DEFAULT_CTYPE: ${DEFAULT_COLLATION:-id_ID.utf8}
ALLOW_IP_RANGE: '0.0.0.0/0'
TEST_CLASS: test_collation.TestCollationInitialization
POSTGRES_PASS: 'docker'
RUN_AS_ROOT: true
ports:
- "7779:5432"
healthcheck:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"

Wyświetl plik

@ -20,7 +20,7 @@ fi
sleep 30
services=("pg" "pg-new")
services=("pg" "pg-new" "pg-gosu" "pg-new-gosu")
for service in "${services[@]}"; do

Wyświetl plik

@ -44,3 +44,46 @@ services:
timeout: 30s
retries: 3
test: "pg_isready"
pg-gosu:
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:
- ./tests:/tests
- ../utils:/lib/utils
environment:
ALLOW_IP_RANGE: '0.0.0.0/0'
TEST_CLASS: test_extensions.TestExtensions
POSTGRES_PASS: 'docker'
RUN_AS_ROOT: false
ports:
- "7778:5432"
healthcheck:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
pg-two-extensions-gosu:
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:
- ./tests:/tests
- ../utils:/lib/utils
environment:
ALLOW_IP_RANGE: '0.0.0.0/0'
TEST_CLASS: test_extensions.TestExtensions
POSTGRES_MULTIPLE_EXTENSIONS: postgis,pgcrypto:1.3
POSTGRES_PASS: 'docker'
RUN_AS_ROOT: false
ports:
- "7779:5432"
healthcheck:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"

Wyświetl plik

@ -21,7 +21,7 @@ fi
sleep 30
services=("pg" "pg-two-extensions")
services=("pg" "pg-two-extensions" "pg-gosu" "pg-two-extensions-gosu")
for service in "${services[@]}"; do

Wyświetl plik

@ -3,6 +3,9 @@ volumes:
default-pg-data-dir-md5:
new-pg-data-dir:
default-pg-data-dir-scram:
default-pg-data-dir-md5-gs:
new-pg-data-dir-gs:
default-pg-data-dir-scram-gs:
services:
pg-default-md5:
@ -59,4 +62,59 @@ services:
retries: 3
test: "pg_isready"
# Gosu settings
pg-default-md5-gosu:
image: 'kartoza/postgis:${TAG:-manual-build}'
volumes:
# By default persisted volumes should be in /var/lib/postgresql
- default-pg-data-dir-md5-gs:/var/lib/postgresql
- ./tests/init.sql:/docker-entrypoint-initdb.d/init.sql
- ./tests:/tests
- ../utils:/lib/utils
environment:
POSTGRES_PASS: 'docker'
PASSWORD_AUTHENTICATION: md5
RUN_AS_ROOT: false
healthcheck:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
pg-new-md5-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/init.sh:/docker-entrypoint-initdb.d/init.sh
- ./tests:/tests
- ../utils:/lib/utils
environment:
DATADIR: /opt/mypostgis/data
POSTGRES_PASS: 'docker'
PASSWORD_AUTHENTICATION: md5
RUN_AS_ROOT: false
healthcheck:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
pg-default-scram-gosu:
image: 'kartoza/postgis:${TAG:-manual-build}'
volumes:
# By default persisted volumes should be in /var/lib/postgresql
- default-pg-data-dir-scram-gs:/var/lib/postgresql
- ./tests/init.sql:/docker-entrypoint-initdb.d/init.sql
- ./tests:/tests
- ../utils:/lib/utils
environment:
POSTGRES_PASS: 'docker'
RUN_AS_ROOT: false
healthcheck:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"

Wyświetl plik

@ -13,7 +13,7 @@ fi
# Run service
${VERSION} up -d pg-default-md5 pg-new-md5 pg-default-scram
${VERSION} up -d pg-default-md5 pg-new-md5 pg-default-scram pg-default-md5-gosu pg-new-md5-gosu pg-default-scram-gosu
if [[ -n "${PRINT_TEST_LOGS}" ]]; then
${VERSION} logs -f &
@ -21,7 +21,7 @@ fi
sleep 60
services=("pg-default-md5" "pg-new-md5" "pg-default-scram")
services=("pg-default-md5" "pg-new-md5" "pg-default-scram" "pg-default-md5-gosu" "pg-new-md5-gosu" "pg-default-scram-gosu")
for service in "${services[@]}"; do

Wyświetl plik

@ -0,0 +1,63 @@
version: '2.1'
volumes:
pg-publisher-data-dir:
pg-subscriber-data-dir:
services:
pg-publisher:
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-publisher-data-dir:/var/lib/postgresql
- ./tests:/tests
- ../utils:/lib/utils
environment:
ALLOW_IP_RANGE: '0.0.0.0/0'
POSTGRES_PASS: 'docker'
REPLICATION_USER: 'replicator'
REPLICATION_PASS: 'replicator'
REPLICATION: 'true'
WAL_LEVEL: 'logical'
RUN_AS_ROOT: false
ports:
- "7777:5432"
healthcheck:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"
pg-subscriber:
image: 'kartoza/postgis:${TAG:-manual-build}'
restart: 'always'
# You can optionally mount to volume, but we're not able to scale it
# in that case.
# The node will always destroy its database and copy from master at
# runtime
volumes:
- pg-subscriber-data-dir:/var/lib/postgresql
- ./tests:/tests
- ../utils:/lib/utils
environment:
ALLOW_IP_RANGE: '0.0.0.0/0'
WAL_LEVEL: 'logical'
POSTGRES_PASS: 'docker'
REPLICATION_USER: 'replicator'
REPLICATION_PASS: 'replicator'
REPLICATION: 'true'
RUN_AS_ROOT: false
depends_on:
- pg-publisher
# You can expose the port to observe it in your local machine
# For this sample, it was disabled by default to allow scaling test
ports:
- "7776:5432"
healthcheck:
interval: 60s
timeout: 30s
retries: 3
test: "pg_isready"

Wyświetl plik

@ -11,7 +11,7 @@ if [[ $(dpkg -l | grep "docker-compose") > /dev/null ]];then
fi
# Run service
# Run service as root
${VERSION} up -d
if [[ -n "${PRINT_TEST_LOGS}" ]]; then
@ -37,3 +37,31 @@ done;
${VERSION} exec -T pg-subscriber /bin/bash /tests/test_subscriber.sh
${VERSION} down -v
# Run the service as none root
${VERSION} -f docker-compose-gs.yml up -d
if [[ -n "${PRINT_TEST_LOGS}" ]]; then
${VERSION} -f docker-compose-gs.yml logs -f &
fi
sleep 60
# Preparing publisher cluster
until ${VERSION} -f docker-compose-gs.yml exec -T pg-publisher pg_isready; do
sleep 1
done;
# Execute tests
${VERSION} -f docker-compose-gs.yml exec -T pg-publisher /bin/bash /tests/test_publisher.sh
# Preparing node cluster
until ${VERSION} -f docker-compose-gs.yml exec -T pg-subscriber pg_isready; do
sleep 1
done;
# Execute tests
${VERSION} -f docker-compose-gs.yml exec -T pg-subscriber /bin/bash /tests/test_subscriber.sh
${VERSION} down -v