kopia lustrzana https://github.com/kartoza/docker-postgis
Backport from branch: 9.6-2.4
Fix default datadir - Change into default datadir - Add small unittestpull/105/head
rodzic
240f45414f
commit
6f30fba235
|
@ -0,0 +1,27 @@
|
||||||
|
sudo: required
|
||||||
|
|
||||||
|
language: python
|
||||||
|
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
virtualenv:
|
||||||
|
system_site_packages: true
|
||||||
|
|
||||||
|
python:
|
||||||
|
- '2.7'
|
||||||
|
|
||||||
|
script:
|
||||||
|
- ./build.sh
|
||||||
|
- pushd sample/replication
|
||||||
|
- make up
|
||||||
|
- make status
|
||||||
|
# Check for database status
|
||||||
|
- until make check-master-running; do echo "Retrying"; sleep 5; done
|
||||||
|
- until make check-slave-running; do echo "Retrying"; sleep 5; done
|
||||||
|
|
||||||
|
# Check replications
|
||||||
|
- until make check-master-replication; do echo "Retrying"; make master-log-tail; sleep 5; done
|
||||||
|
- sleep 60 # Wait replication finished
|
||||||
|
- until make check-slave-replication; do echo "Retrying"; make slave-log-tail; sleep 5; done
|
||||||
|
- popd
|
|
@ -24,3 +24,27 @@ master-log:
|
||||||
|
|
||||||
slave-log:
|
slave-log:
|
||||||
docker-compose logs -f --tail=30 pg-slave
|
docker-compose logs -f --tail=30 pg-slave
|
||||||
|
|
||||||
|
|
||||||
|
# These commands were used for travis
|
||||||
|
|
||||||
|
master-log-tail :
|
||||||
|
docker-compose logs --tail=30 pg-master
|
||||||
|
|
||||||
|
slave-log-tail:
|
||||||
|
docker-compose logs --tail=30 pg-slave
|
||||||
|
|
||||||
|
check-master-running:
|
||||||
|
@echo "Check master is running"
|
||||||
|
@docker-compose logs --tail=1 pg-master | grep 'database system is ready to accept connections' &> /dev/null
|
||||||
|
|
||||||
|
check-master-replication:
|
||||||
|
@docker-compose exec pg-master /bin/sh -c "su - postgres -c \"/tests/replication_test_master.sh\""
|
||||||
|
|
||||||
|
check-slave-running:
|
||||||
|
@echo "Check slave is running"
|
||||||
|
@docker-compose logs pg-slave | grep 'database system is ready to accept read only connections' &> /dev/null
|
||||||
|
@docker-compose logs pg-slave | grep 'started streaming WAL from primary' &> /dev/null
|
||||||
|
|
||||||
|
check-slave-replication:
|
||||||
|
@docker-compose exec pg-slave /bin/sh -c "su - postgres -c \"/tests/replication_test_slave.sh\""
|
||||||
|
|
|
@ -9,6 +9,7 @@ services:
|
||||||
# observe how the slave will behave after restarts.
|
# observe how the slave will behave after restarts.
|
||||||
volumes:
|
volumes:
|
||||||
- './pg-master:/var/lib/postgresql'
|
- './pg-master:/var/lib/postgresql'
|
||||||
|
- './tests:/tests'
|
||||||
environment:
|
environment:
|
||||||
# ALLOW_IP_RANGE option is used to specify additionals allowed domains
|
# ALLOW_IP_RANGE option is used to specify additionals allowed domains
|
||||||
# in pg_hba.
|
# in pg_hba.
|
||||||
|
@ -31,6 +32,7 @@ services:
|
||||||
# runtime
|
# runtime
|
||||||
volumes:
|
volumes:
|
||||||
- './pg-slave:/var/lib/postgresql'
|
- './pg-slave:/var/lib/postgresql'
|
||||||
|
- './tests:/tests'
|
||||||
environment:
|
environment:
|
||||||
# ALLOW_IP_RANGE option is used to specify additionals allowed domains
|
# ALLOW_IP_RANGE option is used to specify additionals allowed domains
|
||||||
# in pg_hba.
|
# in pg_hba.
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. /env-data.sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Check master replication"
|
||||||
|
|
||||||
|
# Create a new table
|
||||||
|
|
||||||
|
echo "Create new table"
|
||||||
|
psql -d ${POSTGRES_DBNAME} -c "CREATE TABLE test_replication_table ();"
|
||||||
|
|
||||||
|
# Check table exists in master
|
||||||
|
|
||||||
|
echo "Check table exists"
|
||||||
|
psql -d ${POSTGRES_DBNAME} -c "\dt" | grep test_replication_table
|
||||||
|
|
||||||
|
exit $?
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. /env-data.sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Check slave replication"
|
||||||
|
|
||||||
|
# Check table exists in slave
|
||||||
|
|
||||||
|
echo "Check table exists"
|
||||||
|
psql -d ${POSTGRES_DBNAME} -c "\dt" | grep test_replication_table
|
||||||
|
|
||||||
|
exit $?
|
|
@ -25,6 +25,7 @@ done
|
||||||
if [[ "$DESTROY_DATABASE_ON_RESTART" =~ [Tt][Rr][Uu][Ee] ]]; then
|
if [[ "$DESTROY_DATABASE_ON_RESTART" =~ [Tt][Rr][Uu][Ee] ]]; then
|
||||||
echo "Get initial database from master"
|
echo "Get initial database from master"
|
||||||
|
|
||||||
|
chown -R postgres:postgres $(getent passwd postgres | cut -d: -f6)
|
||||||
su - postgres -c "echo \"${REPLICATE_FROM}:${REPLICATE_PORT}:*:${POSTGRES_USER}:${POSTGRES_PASS}\" > ~/.pgpass"
|
su - postgres -c "echo \"${REPLICATE_FROM}:${REPLICATE_PORT}:*:${POSTGRES_USER}:${POSTGRES_PASS}\" > ~/.pgpass"
|
||||||
su - postgres -c "chmod 0600 ~/.pgpass"
|
su - postgres -c "chmod 0600 ~/.pgpass"
|
||||||
|
|
||||||
|
@ -32,6 +33,10 @@ if [[ "$DESTROY_DATABASE_ON_RESTART" =~ [Tt][Rr][Uu][Ee] ]]; then
|
||||||
do
|
do
|
||||||
echo "Waiting for master to connect..."
|
echo "Waiting for master to connect..."
|
||||||
sleep 1s
|
sleep 1s
|
||||||
|
if [ "$(ls -A $DATADIR)" ]; then
|
||||||
|
echo "Need empty folder. Cleaning directory..."
|
||||||
|
rm -rf $DATADIR/*
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue