Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to run integration tests on many spring boot applications at the same time?

I have a gradle project with 3 modules which use spring-boot. These 3 spring-boot applications are running in parallel and interact with each other.

For example, MODULE1 saves data in MODULE2 and MODULE3 retrieves data from MODULE2 via Rest APIs.

I would like to implement integration tests regarding the interactions between these 3 spring boot applications (ie. have each of them run separately on a different port). Is it possible? how?

I know we can do it for a single spring boot application. (as explained here)

like image 989
yohm Avatar asked May 29 '15 19:05

yohm


People also ask

Does spring support integration testing?

The Spring Framework provides first-class support for integration testing in the spring-test module. The name of the actual JAR file might include the release version and might also be in the long org. springframework.


1 Answers

Have you ever considered using Docker? Like you I've had problem trying to do this and my current solution is to use docker-compose to stand up a container per application. I run each spring boot app in a simple container (example):

FROM openjdk:8-jdk-alpine

VOLUME /tmp
ADD target/module1.jar app.jar
ENV JAVA_OPTS=""
ENTRYPOINT exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar

Then I use docker-compose to put it all together:

version: '3'
services:
  module1:
    build: ./path/to/module1/Dockerfile
    ports:
     - "8080:8080"
    links:
     - module2
  module2:
    build: ./path/to/module2/Dockerfile
    ports:
     - "8081:8081"

Please note that I haven't tested any of this config as I'm not on a dev machine just now and I've simplified the config to what I think is the bare minimum.

like image 191
raven-king Avatar answered Oct 04 '22 21:10

raven-king