deis / postgres

A PostgreSQL database used by Deis Workflow.
https://deis.com
MIT License
36 stars 22 forks source link

add integration tests for running postgres #41

Closed bacongobbler closed 8 years ago

bacongobbler commented 8 years ago

An example script that was originally implemented for #24, but can't seem to get postgres to talk to minio:

#!/usr/bin/env bash

set -eof pipefail
set -x

# make sure we are in this dir
CURRENT_DIR=$(cd $(dirname $0); pwd)

# create fake database credentials
mkdir -p $CURRENT_DIR/tmp/creds
echo "testuser" > $CURRENT_DIR/tmp/creds/user
echo "icanttellyou" > $CURRENT_DIR/tmp/creds/password

# create fake AWS credentials for minio admin credentials
mkdir -p $CURRENT_DIR/tmp/aws-admin
echo "access-key" > $CURRENT_DIR/tmp/aws-admin/access-key-id
echo "secret-key" > $CURRENT_DIR/tmp/aws-admin/access-secret-key

# create fake AWS credentials for minio user credentials
mkdir -p $CURRENT_DIR/tmp/aws-user
echo "access-key" > $CURRENT_DIR/tmp/aws-user/access-key-id
echo "secret-key" > $CURRENT_DIR/tmp/aws-user/access-secret-key

# create fake k8s serviceaccount token for minio to "discover" itself
mkdir -p $CURRENT_DIR/tmp/k8s
echo "token" > $CURRENT_DIR/tmp/k8s/token
echo "cert" > $CURRENT_DIR/tmp/k8s/ca.crt

# boot minio
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/)

# boot postgres, linking the minio container and setting DEIS_MINIO_SERVICE_HOST and DEIS_MINIO_SERVICE_PORT
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)

# wait for postgres to boot
sleep 10

# display logs for debugging purposes
docker logs $MINIO_JOB
docker logs $PG_JOB

# check if postgres is running
docker exec $PG_JOB is_master

# success, kill off jobs
docker rm -f $MINIO_JOB
docker rm -f $PG_JOB
arschles commented 8 years ago

@bacongobbler has minio started serving on a valid IP? As you mentioned in https://github.com/deis/charts/pull/142#issuecomment-192525656, the minio component assumes it's executing in a k8s pod (with access to the full suite of in-container env vars).

If it would help your testing, I can modify the component to be able to run outside k8s.

bacongobbler commented 8 years ago

@arschles looks like it's working now! I'll have to debug deis/charts#142 further.

arschles commented 8 years ago

glad to hear it. let me know how I can help on deis/charts#142