Skip to content

Commit

Permalink
Adding scripts for postgres.
Browse files Browse the repository at this point in the history
  • Loading branch information
dartartem committed Nov 9, 2017
1 parent 71bbef2 commit ccbeffb
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 7 deletions.
34 changes: 34 additions & 0 deletions build-and-test-all-cdc-postgres.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

set -e

if [ -z "$DOCKER_COMPOSE" ]; then
echo setting DOCKER_COMPOSE
export DOCKER_COMPOSE="docker-compose -f docker-compose-postgres.yml -f docker-compose-cdc-postgres.yml"
else
echo using existing DOCKER_COMPOSE = $DOCKER_COMPOSE
fi

export GRADLE_OPTIONS="-P excludeCdcLibs=true"

./gradlew $GRADLE_OPTIONS $* :eventuate-tram-cdc-mysql-service:clean :eventuate-tram-cdc-mysql-service:assemble

. ./set-env-postgres.sh

$DOCKER_COMPOSE stop
$DOCKER_COMPOSE rm --force -v

$DOCKER_COMPOSE build
$DOCKER_COMPOSE up -d postgres

./wait-for-postgres.sh

$DOCKER_COMPOSE up -d

./gradlew $GRADLE_OPTIONS :eventuate-tram-mysql-kafka-integration-test:cleanTest :eventuate-tram-mysql-kafka-integration-test:test

$DOCKER_COMPOSE stop
$DOCKER_COMPOSE rm --force -v



3 changes: 1 addition & 2 deletions build-and-test-all-cdc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ $DOCKER_COMPOSE rm --force -v
$DOCKER_COMPOSE build
$DOCKER_COMPOSE up -d mysql

echo waiting for MySQL
sleep 10
./wait-for-mysql.sh

$DOCKER_COMPOSE up -d

Expand Down
15 changes: 15 additions & 0 deletions build-and-test-all-postgres.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /bin/bash

set -e

. ./set-env-postgres.sh

docker-compose -f docker-compose-postgres.yml down -v

docker-compose -f docker-compose-postgres.yml up -d

./wait-for-postgres.sh

./gradlew build

docker-compose -f docker-compose-postgres.yml down -v
2 changes: 2 additions & 0 deletions build-and-test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ docker-compose down -v

docker-compose up -d

./wait-for-mysql.sh

./gradlew build

docker-compose down -v
10 changes: 7 additions & 3 deletions docker-compose-cdc-postgres.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
cdcservice:
build: ./eventuate-tram-cdc-mysql-service
links:
- postgres
- kafka
- zookeeper
ports:
- "8099:8080"
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://172.17.0.1/eventuate
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres/eventuate
SPRING_DATASOURCE_USERNAME: eventuate
SPRING_DATASOURCE_PASSWORD: eventuate
SPRING_DATASOURCE_TEST_ON_BORROW: "true"
SPRING_DATASOURCE_VALIDATION_QUERY: SELECT 1
SPRING_DATASOURCE_DRIVER_CLASS_NAME: org.postgresql.Driver
EVENTUATELOCAL_KAFKA_BOOTSTRAP_SERVERS: 172.17.0.1:9092
EVENTUATELOCAL_ZOOKEEPER_CONNECTION_STRING: 172.17.0.1:2181
EVENTUATELOCAL_KAFKA_BOOTSTRAP_SERVERS: kafka:9092
EVENTUATELOCAL_ZOOKEEPER_CONNECTION_STRING: zookeeper:2181
EVENTUATELOCAL_CDC_POLLING_INTERVAL_IN_MILLISECONDS: 500
EVENTUATELOCAL_CDC_MAX_EVENTS_PER_POLLING: 1000
EVENTUATELOCAL_CDC_MAX_ATTEMPTS_FOR_POLLING: 100
Expand Down
3 changes: 3 additions & 0 deletions eventuate-tram-consumer-kafka/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ dependencies {
compile "io.eventuate.local.java:eventuate-local-java-kafka:$eventuateLocalVersion"
compile "org.springframework.boot:spring-boot-starter-jdbc:$springBootVersion"
compile 'mysql:mysql-connector-java:5.1.36'
compile ('org.postgresql:postgresql:9.4-1200-jdbc41') {
exclude group: "org.slf4j", module: "slf4j-simple"
}
compile "io.eventuate.client.java:eventuate-client-java-common-impl:$eventuateClientVersion"

testCompile "org.springframework.boot:spring-boot-starter-test:$springBootVersion"
Expand Down
4 changes: 2 additions & 2 deletions mysql-cli.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /bin/bash -e

docker run -it \
docker run $* \
--name mysqlterm --link $(echo ${PWD##*/} | sed -e 's/-//g')_mysql_1:mysql --rm mysql:5.7.13 \
sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" eventuate'
sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" -o eventuate'
5 changes: 5 additions & 0 deletions postgres-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /bin/bash -e

docker run $* \
--name postgresterm --link $(echo ${PWD##*/} | sed -e 's/-//g')_postgres_1:postgres --rm postgres:9.6.5 \
sh -c 'export PGPASSWORD="$POSTGRES_ENV_POSTGRES_PASSWORD"; exec psql -h postgres -U "$POSTGRES_ENV_POSTGRES_USER" '
7 changes: 7 additions & 0 deletions wait-for-mysql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/sh

until (echo select 1 from dual | ./mysql-cli.sh -i > /dev/null)
do
echo sleeping for mysql
sleep 5
done
7 changes: 7 additions & 0 deletions wait-for-postgres.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/sh

until (echo select 1 | ./postgres-cli.sh -i > /dev/null)
do
echo sleeping for postgres
sleep 5
done

0 comments on commit ccbeffb

Please sign in to comment.