Skip to content

Commit a62ba2b

Browse files
author
Matthew Fisher
committed
feat(contrib): add recovery tests
While this test shows false negatives, it's still useful to test and make sure the database recovers from a restart.
1 parent 52b9630 commit a62ba2b

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

contrib/ci/test.sh

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ kill-containers() {
1818
# make sure we are in this dir
1919
CURRENT_DIR=$(cd $(dirname $0); pwd)
2020

21-
puts-step "creating fake database credentials"
21+
puts-step "creating fake postgres credentials"
2222

23-
# create fake database credentials
23+
# create fake postgres credentials
2424
mkdir -p $CURRENT_DIR/tmp/creds
2525
echo "testuser" > $CURRENT_DIR/tmp/creds/user
2626
echo "icanttellyou" > $CURRENT_DIR/tmp/creds/password
@@ -66,11 +66,11 @@ sleep 90s
6666
# display logs for debugging purposes
6767
puts-step "displaying minio logs"
6868
docker logs $MINIO_JOB
69-
puts-step "displaying database logs"
69+
puts-step "displaying postgres logs"
7070
docker logs $PG_JOB
7171

7272
# check if postgres is running
73-
puts-step "checking if database is running"
73+
puts-step "checking if postgres is running"
7474
docker exec $PG_JOB is_running
7575

7676
# check if minio has the 5 backups
@@ -80,3 +80,19 @@ if [[ ! "$NUM_BACKUPS" -eq "5" ]]; then
8080
puts-error "did not find 5 base backups, which is the default (found $NUM_BACKUPS)"
8181
exit 1
8282
fi
83+
84+
# kill off postgres, then reboot and see if it's running after recovering from backups
85+
puts-step "shutting off postgres, then rebooting to test data recovery"
86+
docker rm -f $PG_JOB
87+
PG_JOB=$(docker run -d --link $MINIO_JOB:minio -e BACKUP_FREQUENCY=1s -e DATABASE_STORAGE=minio -e DEIS_MINIO_SERVICE_HOST=minio -e DEIS_MINIO_SERVICE_PORT=9000 -v $CURRENT_DIR/tmp/creds:/var/run/secrets/deis/database/creds -v $CURRENT_DIR/tmp/aws-user:/var/run/secrets/deis/objectstore/creds $1)
88+
89+
# wait for postgres to boot
90+
puts-step "sleeping for 90s while postgres is recovering from backup..."
91+
sleep 90s
92+
93+
puts-step "displaying postgres logs"
94+
docker logs $PG_JOB
95+
96+
# check if postgres is running
97+
puts-step "checking if postgres is running"
98+
docker exec $PG_JOB is_running

0 commit comments

Comments
 (0)