diff --git a/.gitignore b/.gitignore index 5994cce6..28b661e5 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ build .project *.iml .idea +out/ \ No newline at end of file diff --git a/README.md b/README.md index 464b062d..7417c570 100644 --- a/README.md +++ b/README.md @@ -59,25 +59,21 @@ Usage Requires -------- -- Java 7 (8+ does not work) +- Java 7 or 8 (Java>8 does not work) - MySQL Client + Server - RabbitMQ -Setup (with Docker) -------------------- +Setup (with Docker Compose) +--------------------------- To make it easy to run the tests and it requirements, -the `startContainers.sh` script is provided. Which -will start a: +the `docker-compose.yml` Docker Compose configuration +file is provided. Which will start a: - MySQL Server container - RabbitMQ Server container - RabbitMQ Management container -If the `mysql` command is available, which is the mysql client, -also the required SQL scripts will be imported into the MySQL -Server. - -If you use the `startContainers.sh` script, you don't need +If you use Docker Compose, you don't need MySQL Server and RabbitMQ installed locally. Instead, Docker needs to be installed as the script will start MySQL and RabbitMQ in Docker containers. diff --git a/build.gradle b/build.gradle index 4706db34..e57de502 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,16 @@ +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.avast.gradle:gradle-docker-compose-plugin:0.8.12' + } +} allprojects { apply plugin: 'java' + + apply plugin: 'com.avast.gradle.docker-compose' } subprojects { @@ -25,7 +35,10 @@ project(':iddd_common') { compile group: 'com.google.code.gson', name: 'gson', version: '2.1' compile group: 'com.rabbitmq', name: 'amqp-client', version: '3.0.4' compile group: 'org.hibernate', name: 'hibernate', version: '3.2.7.ga' - compile group: 'org.springframework', name: 'spring', version: '2.5.6' + compile group: 'org.springframework', name: 'spring-core', version: '3.2.18.RELEASE' + compile group: 'org.springframework', name: 'spring-context', version: '3.2.18.RELEASE' + compile group: 'org.springframework', name: 'spring-tx', version: '3.2.18.RELEASE' + compile group: 'org.springframework', name: 'spring-hibernate3', version: '2.0.8' compile group: 'org.iq80.leveldb', name: 'leveldb', version: '0.5' compile group: 'org.aspectj', name: 'aspectjweaver', version: '1.7.2' compile group: 'javassist', name: 'javassist', version: '3.8.0.GA' @@ -40,7 +53,10 @@ project(':iddd_common') { project(':iddd_identityaccess') { dependencies { compile project(':iddd_common') - compile group: 'org.springframework', name: 'spring', version: '2.5.6' + compile group: 'org.springframework', name: 'spring-core', version: '3.2.18.RELEASE' + compile group: 'org.springframework', name: 'spring-context', version: '3.2.18.RELEASE' + compile group: 'org.springframework', name: 'spring-tx', version: '3.2.18.RELEASE' + compile group: 'org.springframework', name: 'spring-hibernate3', version: '2.0.8' compile group: 'javax.ws.rs', name: 'javax.ws.rs-api', version: '2.0-rc1' compile group: 'org.jboss.resteasy', name: 'resteasy-cache-core', version: '2.0.1.GA' @@ -71,4 +87,9 @@ project(':iddd_agilepm') { testCompile files(this.project(':iddd_common').sourceSets.test.output) } +} + +subprojects*.tasks*.withType(Test) { + dependsOn composeUp + finalizedBy composeDown } \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..5a57b53c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: '3.1' + +services: + iddd-mysql: + restart: always + image: mysql:5 + ports: + - "3306:3306" + volumes: + - ./iddd_common/src/main/mysql/test_common.sql:/docker-entrypoint-initdb.d/01_test_common.sql + - ./iddd_common/src/main/mysql/common.sql:/docker-entrypoint-initdb.d/02_common.sql + - ./iddd_identityaccess/src/main/mysql/iam.sql:/docker-entrypoint-initdb.d/03_iam.sql + - ./iddd_collaboration/src/main/mysql/collaboration.sql:/docker-entrypoint-initdb.d/04_collaboration.sql + environment: + MYSQL_ROOT_PASSWORD: root + rabbitmq: + restart: always + image: rabbitmq:3-management + ports: + - "5672:5672" + - "8080::15672" + environment: + RABBITMQ_NODENAME: iddd-rabbitmq-node diff --git a/iddd_collaboration/src/main/mysql/collaboration.sql b/iddd_collaboration/src/main/mysql/collaboration.sql index d996321b..8bf599d8 100644 --- a/iddd_collaboration/src/main/mysql/collaboration.sql +++ b/iddd_collaboration/src/main/mysql/collaboration.sql @@ -10,7 +10,7 @@ CREATE TABLE `tbl_dispatcher_last_event` ( CREATE TABLE `tbl_es_event_store` ( `event_id` bigint(20) NOT NULL auto_increment, - `event_body` varchar(65000) NOT NULL, + `event_body` text NOT NULL, `event_type` varchar(250) NOT NULL, `stream_name` varchar(250) NOT NULL, `stream_version` int(11) NOT NULL, @@ -123,7 +123,7 @@ CREATE TABLE `tbl_vw_post` ( `author_email_address` varchar(100) NOT NULL, `author_identity` varchar(50) NOT NULL, `author_name` varchar(200) NOT NULL, - `body_text` varchar(64000) NOT NULL, + `body_text` text NOT NULL, `changed_on` datetime NOT NULL, `created_on` datetime NOT NULL, `discussion_id` varchar(36) NOT NULL, diff --git a/startContainers.sh b/startContainers.sh deleted file mode 100755 index c2bcc348..00000000 --- a/startContainers.sh +++ /dev/null @@ -1,119 +0,0 @@ -#!/bin/bash - -host="0.0.0.0" - -mysqlUser="root" -mysqlPassword="root" -mysqlContainerName="iddd-mysql" -mysqlPort="3306" - -rabbitmqNodeName="$(hostname)" -rabbitmqContainerName="iddd-rabbitmq" -rabbitmqManagementHttpPort="8080" - -containers[0]="${mysqlContainerName}" -containers[1]="${rabbitmqContainerName}" - -function start() { - echo "Starting MySQL Server container..." - docker rm -f "${mysqlContainerName}" - docker run --name "${mysqlContainerName}" -p "${mysqlPort}":3306 -e MYSQL_ROOT_PASSWORD="${mysqlPassword}" -d mysql - - echo "Waiting for MySQL Server to be up and running..." - waitForContainer "${mysqlContainerName}" "mysqld: ready for connections." - - local testSqlFiles="$(find $(pwd) -name *.sql | grep -i "test")" - local sqlFiles="$(find $(pwd) -name *.sql | grep -vi "test")" - if which mysql > /dev/null; then - for sql in ${testSqlFiles}; do - echo "Importing [${sql}]" - $(mysql --host="${host}" --port=3306 --protocol=TCP --user="${mysqlUser}" --password="${mysqlPassword}" < ${sql}) - done - for sql in ${sqlFiles}; do - echo "Importing [${sql}]" - $(mysql --host="${host}" --port=3306 --protocol=TCP --user="${mysqlUser}" --password="${mysqlPassword}" < ${sql}) - done - else - echo -e - echo "!! mysql command not found" - echo "!! You need to import the following SQL files into MySQL Server, yourself:" - for sql in ${testSqlFiles}; do - echo ${sql} - done - for sql in ${sqlFiles}; do - echo ${sql} - done - echo -e - echo "You can find MySQL Server on [localhost] port [${mysqlPort}]" - echo -e - read -rsp "Press any key to continue..." - echo -e - fi - - echo "Starting RabbitMQ container..." - docker rm -f "${rabbitmqContainerName}" - docker run --name "${rabbitmqContainerName}" -p 5672:5672 -p "${rabbitmqManagementHttpPort}":15672 -e RABBITMQ_NODENAME="${rabbitmqNodeName}" -d rabbitmq:3-management - echo "Waiting for RabbitMQ to be up and running..." - waitForContainer "${rabbitmqContainerName}" "Server startup complete;" - - echo -e - echo "RabbitMQ Management available at [http://localhost:${rabbitmqManagementHttpPort}]" - echo "(Login with user/pass of [guest/guest])" -} - -function status() { - docker ps -a | head -1 - for name in ${containers[@]}; do - docker ps -a | grep "${name}" - done -} - -function stop() { - for name in ${containers[@]}; do - echo "Stopping container [${name}]..." - docker stop "${name}" > /dev/null 2>&1 - done -} - -function usage() { - echo "Usage: $(basename $0) []" - echo -e - echo "Available commands:" - echo " start Start external dependencies for this project in Docker containers" - echo " (incl. MySQL Server and RabbitMQ)" - echo " stop Stop the Docker containers" - echo -e -} - -function requires() { - local command=$1 - which ${command} > /dev/null 2>&1 || { echo "!! This script requires [${command}] to be installed" && exit 1; } -} - -function waitForContainer() { - local containerName="$1" - local logMsg="$2" - until docker logs ${containerName} 2>&1 | grep "${logMsg}" > /dev/null; do - sleep 1s - done -} - - -requires 'docker' - -command=$1; shift -case "${command}" in - start) - start - ;; - stop) - stop - ;; - status) - status - ;; - *) - usage - exit 1 - ;; -esac