If you are writing services using spring boot (and maybe spring cloud) and you do medium sized tests during build process, then this set of spring boot auto-configurations might be handy. By adding module into classpath, you will get stateful service, like couchbase or kafka, auto-started and available for connection from your application service w/o wiring any additional code. Docker and TestContainers are used to bootstrap stateful service using spring cloud bootstrap phase. Usage of spring cloud in your production code is optional, but you will need it in tests. See "how to" below.
-
List of properties per data service
- embedded-mariadb
- embedded-couchbase
- embedded-kafka
- embedded-rabbitmq
- embedded-aerospike
- embedded-memsql
- embedded-redis
- embedded-neo4j
- embedded-zookeeper
- embedded-postgresql
- embedded-elasticsearch
- embedded-dynamodb
- embedded-minio
- embedded-mongodb
- embedded-google-pubsub
- embedded-keycloak
- embedded-influxdb
- embedded-vault
Make sure you have spring boot and spring cloud in classpath of your tests. In case if you need to pick version.
<project>
...
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
<version>PICK LATEST VERSION</version>
...
</dependency>
...
</project>
<project>
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>PICK LATEST VERSION</version>
...
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
<version>PICK LATEST VERSION</version>
...
<scope>test</scope>
</dependency>
...
</project>
<project>
...
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-kafka</artifactId>
<scope>test</scope>
</dependency>
...
</project>
/src/test/resources/application.properties
spring.kafka.bootstrap-servers=${embedded.kafka.brokerList}
/src/test/resources/bootstrap.properties
embedded.kafka.topicsToCreate=some_topic
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-mariadb</artifactId>
<scope>test</scope>
</dependency>
- embedded.mariadb.enabled
(true|false, default is 'true')
- embedded.mariadb.encoding
(default is 'utf8mb4')
- embedded.mariadb.collation
(default is 'utf8mb4_unicode_ci')
- embedded.mariadb.dockerImage
(default is set to 'mariadb:10.3.2')
- You can pick wanted version on dockerhub
- embedded.mariadb.waitTimeoutInSeconds
(default is 60 seconds)
- embedded.mariadb.port
- embedded.mariadb.host
- embedded.mariadb.schema
- embedded.mariadb.user
- embedded.mariadb.password
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-couchbase</artifactId>
<scope>test</scope>
</dependency>
- embedded.couchbase.enabled
(true|false, default is 'true')
- embedded.couchbase.services
(comma separated list, default is 'kv,index,n1ql,fts')
- embedded.couchbase.clusterRamMb
(default is set to '256')
- embedded.couchbase.bucketRamMb
(default is set to '100')
- embedded.couchbase.dockerImage
(default is set to 'couchbase:community-4.5.1')
- You can pick wanted version on dockerhub
- NOTE: Versions of couchbase 2.x/3.x are not functional via docker, consider use of CouchbaseMock
- embedded.couchbase.bucketType
(default is set to 'couchbase')
- Used for test bucket creation
- embedded.couchbase.waitTimeoutInSeconds
(default is 60 seconds)
- embedded.couchbase.bootstrapHttpDirectPort
- Please note that this also produced as System property for couchbase java client
- embedded.couchbase.bootstrapCarrierDirectPort
- Please note that this also produced as System property for couchbase java client
- embedded.couchbase.host
- embedded.couchbase.bucket
- embedded.couchbase.user
- embedded.couchbase.password
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-kafka</artifactId>
<scope>test</scope>
</dependency>
- embedded.zookeeper.enabled
(true|false, default is 'true')
- embedded.zookeeper.waitTimeoutInSeconds
(default is 60 seconds)
- embedded.zookeeper.dockerImage
(default : confluentinc/cp-zookeeper:4.1.2)
- To use another zookeper version pick corresponding docker image on dockerhub
- embedded.kafka.enabled
(true|false, default is 'true')
- embedded.kafka.topicsToCreate
(comma separated list of topic names, default is empty)
- embedded.kafka.dockerImage
(default: confluentinc/cp-kafka:4.1.2. Kafka version is 1.1.x.)
- To use another kafka version pick corresponding docker image on dockerhub
- Confluent Platform and Apache Kafka Compatibility
- embedded.kafka.waitTimeoutInSeconds
(default is 60 seconds)
Containers for embedded-kafka
and embedded-zookeper
bind their volumes to host filesystem. By default, to your projects target
folder. You can configure binding using properties:
- embedded.zookeeper.fileSystemBind.enabled
(true|false, default is 'true')
- embedded.zookeeper.fileSystemBind.dataFolder
(default : target/embedded-zk-data)
- embedded.zookeeper.fileSystemBind.txnLogsFolder
(default : target/embedded-zk-txn-logs)
- embedded.kafka.enabled
(true|false, default is 'true')
- embedded.kafka.fileSystemBind.dataFolder
(default : target/embedded-kafka-data)
- embedded.zookeeper.zookeeperConnect
- embedded.kafka.brokerList
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-rabbitmq</artifactId>
<scope>test</scope>
</dependency>
- embedded.rabbitmq.enabled
(true|false, default is 'true')
- embedded.rabbitmq.password
(default : rabbitmq)
- embedded.rabbitmq.vhost
(virtual host, default: '/')
- embedded.rabbitmq.dockerImage
(default: rabbitmq:3-alpine)
- You can pick wanted version on dockerhub
- embedded.rabbitmq.waitTimeoutInSeconds
(default is 60 seconds)
- embedded.rabbitmq.host
- embedded.rabbitmq.port
- embedded.rabbitmq.user
- embedded.rabbitmq.password
- embedded.rabbitmq.vhost
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-aerospike</artifactId>
<scope>test</scope>
</dependency>
- aerospike client library
- embedded.aerospike.enabled
(true|false, default is 'true')
- embedded.aerospike.dockerImage
(default is set to 'aerospike/aerospike-server:4.3.0.8')
- You can pick wanted version on dockerhub
- embedded.aerospike.waitTimeoutInSeconds
(default is 60 seconds)
- embedded.aerospike.host
- embedded.aerospike.port
- embedded.aerospike.namespace
- AerospikeTimeTravelService
- timeTravelTo
- nextDay
- addDays
- addHours
- rollbackTime
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-memsql</artifactId>
<scope>test</scope>
</dependency>
- embedded.memsql.enabled
(true|false, default is 'true')
- embedded.memsql.dockerImage
(default is set to 'memsql/quickstart:minimal-6.0.8')
- You can pick wanted version on dockerhub
- embedded.memsql.waitTimeoutInSeconds
(default is 60 seconds)
- embedded.memsql.port
- embedded.memsql.host
- embedded.memsql.schema
- embedded.memsql.user
- embedded.memsql.password
- Images without "minimal" tag do no start withing 30 secs, so they are unusable
- There should be at least 1.5 GB of RAM available for memsql to start
- You can enable debug logs for com.playtika.test category to troubleshoot issues
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-redis</artifactId>
<scope>test</scope>
</dependency>
- embedded.redis.enabled
(true|false, default is 'true')
- embedded.redis.dockerImage
(default is set to 'redis:4.0.12')
- You can pick wanted version on dockerhub
- embedded.redis.waitTimeoutInSeconds
(default is 60 seconds)
- embedded.redis.clustered
(default is 'false')
- If 'true' Redis is started in cluster mode
- embedded.redis.requirepass
(default is 'true')
- embedded.redis.host
- embedded.redis.port
- embedded.redis.user
- embedded.redis.password
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-neo4j</artifactId>
<scope>test</scope>
</dependency>
- embedded.neo4j.enabled
(true|false, default is 'true')
- embedded.neo4j.dockerImage
(default is set to 'neo4j:3.2.7')
- You can pick wanted version on dockerhub
- embedded.neo4j.waitTimeoutInSeconds
(default is 60 seconds)
- embedded.neo4j.user
- embedded.neo4j.password
- embedded.neo4j.httpsPort
- embedded.neo4j.httpPort
- embedded.neo4j.boltPort
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-postgresql</artifactId>
<scope>test</scope>
</dependency>
- embedded.postgresql.enabled
(true|false, default is 'true')
- embedded.postgresql.dockerImage
(default is set to 'postgres:10-alpine')
- You can pick wanted version on dockerhub
- embedded.postgresql.waitTimeoutInSeconds
(default is 60 seconds)
- embedded.postgresql.database
- embedded.postgresql.user
- embedded.postgresql.password
- embedded.postgresql.port
- embedded.postgresql.host
- embedded.postgresql.schema
- embedded.postgresql.user
- embedded.postgresql.password
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-elasticsearch</artifactId>
<scope>test</scope>
</dependency>
- embedded.elasticsearch.enabled
(true|false, default is 'true')
- embedded.elasticsearch.dockerImage
(default is set to 'docker.elastic.co/elasticsearch/elasticsearch:6.2.4')
- embedded.elasticsearch.indices
(indices to create, no indices are created by default)
- You can pick wanted version on docker.elastic.co
- embedded.elasticsearch.waitTimeoutInSeconds
(default is 60 seconds)
- embedded.elasticsearch.clusterName
- embedded.elasticsearch.host
- embedded.elasticsearch.httpPort
- embedded.elasticsearch.transportPort
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-dynamodb</artifactId>
<scope>test</scope>
</dependency>
- embedded.dynamodb.enabled
(true|false, default is 'true')
- embedded.dynamodb.dockerImage
(default is set to 'amazon/dynamodb-local:latest')
- You can pick wanted version on dockerhub
- embedded.dynamodb.host
- embedded.dynamodb.port
- embedded.dynamodb.accessKey
- embedded.dynamodb.secretKey
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-voltdb</artifactId>
<scope>test</scope>
</dependency>
- embedded.voltdb.enabled
(true|false, default is 'true')
- embedded.voltdb.dockerImage
(default is set to 'voltdb/voltdb-community:8.3.3')
- You can pick wanted version on dockerhub
- embedded.voltdb.host
- embedded.voltdb.port
VoltDB container has no security enabled, you can use any credentials.
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-minio</artifactId>
<scope>test</scope>
</dependency>
- embedded.minio.enabled
(true|false, default is 'true')
- embedded.minio.dockerImage
(default is set to 'minio/minio')
- You can pick wanted version on dockerhub
- embedded.minio.accessKey
(default is set to 'AKIAIOSFODNN7EXAMPLE")
- embedded.minio.secretKey
(default is set to 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY')
- embedded.minio.userName
(default is set to 'minio')
- embedded.minio.groupName
(default is set to 'minio')
- embedded.minio.region
(default is set to '')
- embedded.minio.worm
(on|off, default is set to 'off')
- embedded.minio.browser
(on|off, default is set to 'on')
- embedded.minio.directory
(default is set to '/data')
- embedded.minio.host
- embedded.minio.port
- embedded.minio.accessKey
- embedded.minio.secretKey
- embedded.minio.region
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-mongodb</artifactId>
<scope>test</scope>
</dependency>
- embedded.mongodb.enabled
(true|false, default is 'true')
- embedded.mongodb.dockerImage
(default is set to 'mongo:4.2.0-bionic')
- You can pick wanted version on dockerhub
- embedded.mongodb.host
(default is localhost)
- embedded.mongodb.port
(default is 27017)
- embedded.mongodb.username
- embedded.mongodb.password
- embedded.mongodb.database
(default is test)
- embedded.mongodb.host
- embedded.mongodb.port
(mapped port)
- embedded.mongodb.username
- embedded.mongodb.password
- embedded.mongodb.database
To auto-configure spring-data-mongodb use these properties in your test application.properties
:
spring.data.mongodb.uri=mongodb://${embedded.mongodb.host}:${embedded.mongodb.port}/${embedded.mongodb.database}
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-google-pubsub</artifactId>
<scope>test</scope>
</dependency>
- embedded.google.pubsub.enabled
(true|false, default is 'true')
- embedded.google.pubsub.dockerImage
(default is set to 'google/cloud-sdk:257.0.0')
- You can pick wanted version on dockerhub
- embedded.google.pubsub.host
(default is 0.0.0.0)
- embedded.google.pubsub.port
(default is 8089)
- embedded.google.pubsub.project-id
(default is my-project-id)
- Topics and Subscriptions:
- embedded.google.pubsub.topics-and-subscriptions[0].topic=topic0_name
- embedded.google.pubsub.topics-and-subscriptions[0].subscription=subscription0_name
- embedded.google.pubsub.topics-and-subscriptions[1].topic=topic0_name
- embedded.google.pubsub.topics-and-subscriptions[1].subscription=subscription0_name
- embedded.google.pubsub.host
- embedded.google.pubsub.port
(mapped port)
- embedded.google.pubsub.project-id
To auto-configure spring-cloud-gcp-starter-pubsub use these properties in your test application.properties
:
spring.cloud.gcp.project-id=${embedded.google.pubsub.project-id}
spring.cloud.gcp.pubsub.emulatorHost=${embedded.google.pubsub.host}:${embedded.google.pubsub.port}
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-keycloak</artifactId>
<scope>test</scope>
</dependency>
embedded.keycloak.enabled
(boolean, true|false, default is 'true')embedded.keycloak.dockerImage
(String, default is set to 'jboss/keycloak:8.0.1')- You can pick wanted version on dockerhub
embedded.keycloak.command
(String[], default is '["-c", "standalone.xml", "-Dkeycloak.profile.feature.upload_scripts=enabled"]')embedded.keycloak.admin-user
(String, default is 'admin')embedded.keycloak.admin-password
(String, default is 'letmein')embedded.keycloak.import-file
(String, default is '')
embedded.keycloak.host
embedded.keycloak.http-port
(mapped HTTP port)embedded.keycloak.auth-server-url
To configure for example the keycloak-spring-boot-starter
use these properties in your test application.yml
:
keycloak:
auth-server-url: ${embedded.keycloak.auth-server-url}
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-influxdb</artifactId>
<scope>test</scope>
</dependency>
embedded.influxdb.enabled
(boolean, true|false, default is 'true')embedded.influxdb.dockerImage
(String, default is set to 'influxdb:1.5-alpine')- You can pick wanted version on dockerhub
embedded.influxdb.admin-user
(String, default is 'admin')embedded.influxdb.admin-password
(String, default is 'admin')embedded.influxdb.user
(String, default is 'user')embedded.influxdb.password
(String, default is 'password')embedded.influxdb.enable-http-auth
(boolean true|false, default is 'true')embedded.influxdb.host
(String, default is 'localhost')embedded.influxdb.port
(int, default is '8086')embedded.influxdb.database
(String, default is 'db')
embedded.influxdb.database
embedded.influxdb.host
embedded.influxdb.password
embedded.influxdb.port
(mapped HTTP port)embedded.influxdb.user
There is currently no starter library for using InfluxDB server version 1.x because it uses basic HTTP protocol to communicate.
You can anyway create your own properties using those values for example in your test application.yml
:
influxdb:
url: http://${embedded.influxdb.host}:${embedded.influxdb.port}
user: ${embedded.influxdb.user}
password: ${embedded.influxdb.password}
database: ${embedded.influxdb.database}
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-vault</artifactId>
<scope>test</scope>
</dependency>
embedded.vault.enabled
(boolean, true|false, default is 'true')embedded.vault.dockerImage
(String, default is set to 'vault:1.4.0')- You can pick wanted version on dockerhub
embedded.vault.host
(String, default is 'localhost')embedded.vault.port
(int, default is 8200)embedded.vault.token
(String, default is '00000000-0000-0000-0000-000000000000')embedded.vault.path
(String, default is 'secret/application')embedded.vault.secrets
(Map, default is empty)
embedded.vault.host
embedded.vault.port
(mapped HTTP port)embedded.vault.token
To auto-configure spring-cloud-vault-config use these properties in your test bootstrap.properties
:
spring.cloud.vault:
scheme: http
host: ${embedded.vault.host}
port: ${embedded.vault.port}
token: ${embedded.vault.token}
kv:
enabled: true
- There is 2 branches in project: master and develop
- You need to fork project and create branch from develop
- You do not need to update project version in pom.xml files, this will be done by release job
- Once finished - create pull request to develop from your fork, pass review and wait for merge
- On release, ci job will merge develop into master and remove snapshot + publish artifacts into public maven repo
- Release build is done on using gitflow-maven-plugin
- Release is done per each major change, critical bug
- Release can be done by contributor request
- Contacts to start release: