Git Product home page Git Product logo

testcontainers-spring-boot's Introduction

CircleCI codecov Codacy Badge Maven Central

Data services library

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.

Table of Contents

  1. How to use
  2. List of properties per data service
    1. embedded-mariadb
    2. embedded-couchbase
    3. embedded-kafka
    4. embedded-aerospike
    5. embedded-memsql
    6. embedded-redis
    7. embedded-neo4j
    8. embedded-zookeeper
  3. How to contribute

How to use

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>
            ...
        </dependency>
...
</project>

If you do not use spring cloud - make it work for tests only

<project>
...
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            ...
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter</artifactId>
            ...
            <scope>test</scope>
        </dependency>
...
</project>

Add data service library

<project>
...
        <dependency>
            <groupId>com.playtika.testcontainers</groupId>
            <artifactId>embedded-kafka</artifactId>
            <scope>test</scope>
        </dependency>
...
</project>

Use produced properties in your configuration

Example:

/src/test/resources/application.properties

spring.kafka.zookeeperHost=${embedded.zookeeper.zookeeperConnect}
spring.kafka.brokerList=${embedded.kafka.brokerList}

/src/test/resources/bootstrap.properties

embedded.kafka.topicsToCreate=some_topic

List of properties per data service

embedded-mariadb

Maven dependency
<dependency>
    <groupId>com.playtika.testcontainers</groupId>
    <artifactId>embedded-mariadb</artifactId>
    <scope>test</scope>
</dependency>
Consumes (via bootstrap.properties)
  • 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')
Produces
  • embedded.mariadb.port
  • embedded.mariadb.host
  • embedded.mariadb.schema
  • embedded.mariadb.user
  • embedded.mariadb.password

embedded-couchbase

Maven dependency
<dependency>
    <groupId>com.playtika.testcontainers</groupId>
    <artifactId>embedded-couchbase</artifactId>
    <scope>test</scope>
</dependency>
Consumes (via bootstrap.properties)
  • 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')
Produces
  • embedded.couchbase.bootstrapHttpDirectPort
  • embedded.couchbase.bootstrapCarrierDirectPort
  • embedded.couchbase.host
  • embedded.couchbase.bucket
  • embedded.couchbase.user
  • embedded.couchbase.password

embedded-kafka

Maven dependency
<dependency>
    <groupId>com.playtika.testcontainers</groupId>
    <artifactId>embedded-kafka</artifactId>
    <scope>test</scope>
</dependency>
Consumes (via bootstrap.properties)
  • embedded.zookeeper.enabled (true|false, default is 'true')
  • embedded.kafka.enabled (true|false, default is 'true')
  • embedded.kafka.topicsToCreate (comma separated list of topic names, default is empty)
  • embedded.kafka.dockerImage (default is set to kafka 0.11.x)
Produces
  • embedded.zookeeper.zookeeperConnect
  • embedded.kafka.brokerList

embedded-aerospike

Maven dependency
<dependency>
    <groupId>com.playtika.testcontainers</groupId>
    <artifactId>embedded-aerospike</artifactId>
    <scope>test</scope>
</dependency>
Consumes (via bootstrap.properties)
  • aerospike client library
  • embedded.aerospike.enabled (true|false, default is 'true')
  • embedded.aerospike.dockerImage (default is set to 'aerospike:3.15.0.1')
Produces
  • embedded.aerospike.host
  • embedded.aerospike.port
  • embedded.aerospike.namespace
  • AerospikeTimeTravelService
    • timeTravelTo
    • nextDay
    • addDays
    • addHours
    • rollbackTime

embedded-memsql

Maven dependency
<dependency>
    <groupId>com.playtika.testcontainers</groupId>
    <artifactId>embedded-memsql</artifactId>
    <scope>test</scope>
</dependency>
Consumes (via bootstrap.properties)
  • embedded.memsql.enabled (true|false, default is 'true')
  • embedded.memsql.dockerImage (default is set to 'memsql/quickstart:minimal-6.0.8')
Produces
  • embedded.memsql.port
  • embedded.memsql.host
  • embedded.memsql.schema
  • embedded.memsql.user
  • embedded.memsql.password
Notes
  • 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

embedded-redis

Maven dependency
<dependency>
    <groupId>com.playtika.testcontainers</groupId>
    <artifactId>embedded-redis</artifactId>
    <scope>test</scope>
</dependency>
Consumes (via bootstrap.properties)
  • embedded.redis.enabled (true|false, default is 'true')
  • embedded.redis.dockerImage (default is set to 'redis:4.0.2')
Produces
  • embedded.redis.host
  • embedded.redis.port
  • embedded.redis.user
  • embedded.redis.password

embedded-neo4j

Maven dependency
<dependency>
    <groupId>com.playtika.testcontainers</groupId>
    <artifactId>embedded-neo4j</artifactId>
    <scope>test</scope>
</dependency>
Consumes (via bootstrap.properties)
  • embedded.neo4j.enabled (true|false, default is 'true')
  • embedded.neo4j.dockerImage (default is set to 'neo4j:3.2.7')
Produces
  • embedded.neo4j.user
  • embedded.neo4j.password
  • embedded.neo4j.httpsPort
  • embedded.neo4j.httpPort
  • embedded.neo4j.boltPort

embedded-zookeeper

Consumes (via bootstrap.properties)
Produces

How to contribute

Flow

  • 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

testcontainers-spring-boot's People

Contributors

alekseibevzenko avatar aloren avatar jenkins-playtika avatar matveym avatar tdanylchuk avatar vasilievip avatar vmotolyzhenko avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.