genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0

CI Config

Working integration tests, using a postgres docker container in the
GitLab CI pipeline.
This commit is contained in:
Matthias Stock 2017-03-09 21:31:48 +00:00
commit 18eaa92eff
4 changed files with 22 additions and 8 deletions

View File

@ -37,7 +37,8 @@ test:
POSTGRES_DB: monolith POSTGRES_DB: monolith
POSTGRES_USER: monolith POSTGRES_USER: monolith
POSTGRES_PASSWORD: monolith_it POSTGRES_PASSWORD: monolith_it
LAB_MONOLITH_DB_IP: postgres LAB_MONOLITH_DB_HOST: postgres
LAB_MONOLITH_DB_PORT: "5432"
LAB_MONOLITH_DB_PASSWORD: monolith_it LAB_MONOLITH_DB_PASSWORD: monolith_it
script: script:
- ./gradlew -g /cache/.gradle check - ./gradlew -g /cache/.gradle check

View File

@ -1,7 +1,8 @@
# Getting Started # Getting Started
1. Install Docker. 1. Install Docker.
2. Set up an environment variable `LAB_MONOLITH_DB_IP` and assign the docker host's IP. 2. Set up an environment variable `LAB_MONOLITH_DB_HOST` and assign the docker host's IP,
set `LAB_MONOLITH_DB_PORT` to some free port, e.g. 5432.
For docker machine type `docker-machine env` and the value of `$DOCKER_HOST`, For docker machine type `docker-machine env` and the value of `$DOCKER_HOST`,
otherwise `localhost` is probably correct. otherwise `localhost` is probably correct.

View File

@ -1,6 +1,6 @@
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect
spring.datasource.driverClassName=org.postgresql.Driver spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://${LAB_MONOLITH_DB_IP}:15432/monolith spring.datasource.url=jdbc:postgresql://${LAB_MONOLITH_DB_HOST}:${LAB_MONOLITH_DB_PORT}/monolith
spring.datasource.username=monolith spring.datasource.username=monolith
spring.datasource.password=${LAB_MONOLITH_DB_PASSWORD} spring.datasource.password=${LAB_MONOLITH_DB_PASSWORD}

View File

@ -1,18 +1,30 @@
#!/bin/bash #!/bin/bash
[[ -n "$DOCKER_HOST" ]] && echo "DOCKER_HOST: $DOCKER_HOST" [[ -n "$DOCKER_HOST" ]] && echo "DOCKER_HOST: $DOCKER_HOST"
if [[ ! -n "$LAB_MONOLITH_DB_IP" ]]; then
echo 'ERROR: LAB_MONOLITH_DB_IP is not set.' if [[ ! -n "$LAB_MONOLITH_DB_HOST" ]]; then
echo 'ERROR: LAB_MONOLITH_DB_HOST is not set.'
exit 1 exit 1
else else
echo "LAB_MONOLITH_DB_IP: $LAB_MONOLITH_DB_IP" echo "LAB_MONOLITH_DB_HOST: $LAB_MONOLITH_DB_HOST"
fi fi
if [[ ! -n "$LAB_MONOLITH_DB_PORT" ]]; then
echo 'ERROR: LAB_MONOLITH_DB_PORT is not set.'
exit 1
else
echo "LAB_MONOLITH_DB_PORT: $LAB_MONOLITH_DB_PORT"
fi
if [[ ! -n "$LAB_MONOLITH_DB_PASSWORD" ]]; then if [[ ! -n "$LAB_MONOLITH_DB_PASSWORD" ]]; then
echo 'ERROR: LAB_MONOLITH_DB_PASSWORD is not set.' echo 'ERROR: LAB_MONOLITH_DB_PASSWORD is not set.'
exit 1 exit 1
fi fi
echo 'Starting database for integration tests...'
echo 'Starting database...'
docker run --rm --name monolith-postgres\ docker run --rm --name monolith-postgres\
-p 15432:5432\ -p $LAB_MONOLITH_DB_PORT:5432\
-e POSTGRES_USER=monolith\ -e POSTGRES_USER=monolith\
-e POSTGRES_PASSWORD=$LAB_MONOLITH_DB_PASSWORD\ -e POSTGRES_PASSWORD=$LAB_MONOLITH_DB_PASSWORD\
-d postgres:9 -d postgres:9