|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
3 | | -# TODO (bacongobbler): implement e2e tests |
4 | | -# https://github.com/deis/postgres/issues/41 |
5 | | -exit 0 |
| 3 | +set -eof pipefail |
| 4 | + |
| 5 | +puts-step() { |
| 6 | + echo "-----> $@" |
| 7 | +} |
| 8 | + |
| 9 | +# make sure we are in this dir |
| 10 | +CURRENT_DIR=$(cd $(dirname $0); pwd) |
| 11 | + |
| 12 | +puts-step "creating fake database credentials" |
| 13 | + |
| 14 | +# create fake database credentials |
| 15 | +mkdir -p $CURRENT_DIR/tmp/creds |
| 16 | +echo "testuser" > $CURRENT_DIR/tmp/creds/user |
| 17 | +echo "icanttellyou" > $CURRENT_DIR/tmp/creds/password |
| 18 | + |
| 19 | +puts-step "creating fake minio credentials" |
| 20 | + |
| 21 | +# create fake AWS credentials for minio admin credentials |
| 22 | +mkdir -p $CURRENT_DIR/tmp/aws-admin |
| 23 | +# needs to be 20 characters long |
| 24 | +echo "12345678901234567890" > $CURRENT_DIR/tmp/aws-admin/access-key-id |
| 25 | +# needs to be 40 characters long |
| 26 | +echo "1234567890123456789012345678901234567890" > $CURRENT_DIR/tmp/aws-admin/access-secret-key |
| 27 | + |
| 28 | +# create fake AWS credentials for minio user credentials |
| 29 | +mkdir -p $CURRENT_DIR/tmp/aws-user |
| 30 | +# needs to be 20 characters long |
| 31 | +echo "12345678901234567890" > $CURRENT_DIR/tmp/aws-user/access-key-id |
| 32 | +# needs to be 40 characters long |
| 33 | +echo "1234567890123456789012345678901234567890" > $CURRENT_DIR/tmp/aws-user/access-secret-key |
| 34 | + |
| 35 | +puts-step "creating fake kubernetes service account token" |
| 36 | + |
| 37 | +# create fake k8s serviceaccount token for minio to "discover" itself |
| 38 | +mkdir -p $CURRENT_DIR/tmp/k8s |
| 39 | +echo "token" > $CURRENT_DIR/tmp/k8s/token |
| 40 | +echo "cert" > $CURRENT_DIR/tmp/k8s/ca.crt |
| 41 | + |
| 42 | +# boot minio |
| 43 | +MINIO_JOB=$(docker run -dv $CURRENT_DIR/tmp/aws-admin:/var/run/secrets/deis/minio/admin -v $CURRENT_DIR/tmp/aws-user:/var/run/secrets/deis/minio/user -v $CURRENT_DIR/tmp/k8s:/var/run/secrets/kubernetes.io/serviceaccount quay.io/deisci/minio:v2-beta boot server /home/minio/) |
| 44 | + |
| 45 | +# boot postgres, linking the minio container and setting DEIS_MINIO_SERVICE_HOST and DEIS_MINIO_SERVICE_PORT |
| 46 | +PG_JOB=$(docker run -d --link $MINIO_JOB: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:/etc/wal-e.d/env $1) |
| 47 | + |
| 48 | +# wait for postgres to boot |
| 49 | +puts-step "sleeping for 1 minute while postgres is booting..." |
| 50 | +sleep 1m |
| 51 | + |
| 52 | +# display logs for debugging purposes |
| 53 | +puts-step "displaying minio logs" |
| 54 | +docker logs $MINIO_JOB |
| 55 | +puts-step "displaying database logs" |
| 56 | +docker logs $PG_JOB |
| 57 | + |
| 58 | +# check if postgres is running |
| 59 | +puts-step "checking if database is running" |
| 60 | +docker exec $PG_JOB is_running |
| 61 | + |
| 62 | +# success, kill off jobs |
| 63 | +puts-step "destroying containers" |
| 64 | +docker rm -f $MINIO_JOB |
| 65 | +docker rm -f $PG_JOB |
0 commit comments