-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest-minio.sh
More file actions
executable file
·75 lines (56 loc) · 2.45 KB
/
test-minio.sh
File metadata and controls
executable file
·75 lines (56 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
set -eof pipefail
cleanup() {
kill-containers "${MINIO_JOB}" "${PG_JOB}"
}
trap cleanup EXIT
TEST_ROOT=$(dirname "${BASH_SOURCE[0]}")/
# shellcheck source=/dev/null
source "${TEST_ROOT}/test.sh"
# make sure we are in this dir
CURRENT_DIR=$(cd "$(dirname "$0")"; pwd)
create-postgres-creds
puts-step "creating fake minio credentials"
mkdir -p "${CURRENT_DIR}"/tmp/aws-user
echo "us-east-1" > "${CURRENT_DIR}"/tmp/aws-user/region
echo "database-bucket" > "${CURRENT_DIR}"/tmp/aws-user/database-bucket
echo "1234567890123456789012345678901234567890" > "${CURRENT_DIR}"/tmp/aws-user/accesskey
echo "1234567890123456789012345678901234567890" > "${CURRENT_DIR}"/tmp/aws-user/secretkey
# boot minio
mkdir -p "${CURRENT_DIR}"/tmp/bin
echo "ls /home/minio/*/*/basebackups_005" > "${CURRENT_DIR}"/tmp/bin/backups.sh
MINIO_JOB=$(docker run -d \
-v "${CURRENT_DIR}"/tmp/bin:/tmp/bin \
-v "${CURRENT_DIR}"/tmp/aws-user:/var/run/secrets/drycc/objectstore/creds \
drycc/minio:v1.0.1 server /home/minio/)
puts-step "minio starting, wait 30s."
sleep 30
# boot postgres, linking the minio container and setting DRYCC_MINIO_SERVICE_HOST and DRYCC_MINIO_SERVICE_PORT
PG_CMD="docker run -d --link ${MINIO_JOB}:minio -e PGCTLTIMEOUT=1200 \
-e BACKUP_FREQUENCY=1s -e DATABASE_STORAGE=minio \
-e DRYCC_MINIO_SERVICE_HOST=minio -e DRYCC_MINIO_SERVICE_PORT=9000 \
-v ${CURRENT_DIR}/tmp/creds:/var/run/secrets/drycc/database/creds \
-v ${CURRENT_DIR}/tmp/aws-user:/var/run/secrets/drycc/objectstore/creds $1"
start-postgres "${PG_CMD}"
# display logs for debugging purposes
puts-step "displaying minio logs"
docker logs "${MINIO_JOB}"
check-postgres "${PG_JOB}"
# check if minio has the 5 backups
puts-step "checking if minio has 5 backups"
BACKUPS="$(docker exec "${MINIO_JOB}" sh /tmp/bin/backups.sh | grep json)"
NUM_BACKUPS="$(echo "${BACKUPS}" | wc -w)"
# NOTE (bacongobbler): the BACKUP_FREQUENCY is only 1 second, so we could technically be checking
# in the middle of a backup. Instead of failing, let's consider N+1 backups an acceptable case
if [[ "${NUM_BACKUPS}" -lt "5" ]]; then
puts-error "the number of backups is less than 5 (found $NUM_BACKUPS)"
puts-error "${BACKUPS}"
exit 1
fi
# kill off postgres, then reboot and see if it's running after recovering from backups
puts-step "shutting off postgres, then rebooting to test data recovery"
kill-containers "${PG_JOB}"
start-postgres "${PG_CMD}"
check-postgres "${PG_JOB}"
puts-step "tests PASSED!"
exit 0