playtikaoss/testcontainers-spring-boot

repository·develop·Indexed 21 days ago

https://github.com/playtikaoss/testcontainers-spring-boot

Spring Boot integration testing utilities using Testcontainers. Provides specialized modules for embedded services including Aerospike (Standard and Enterprise), Artifactory, Azurite, Cassandra, ClickHouse, and Apache Kafka Native (GraalVM) using KRaft for Zookeeper-free setups.

Tokens
45.8K
Snippets
157
Records
208
Agent score
74%

What's inside testcontainers-spring-boot

  1. Configure Redis Client Drivers (Jedis vs Lettuce)

    develop

    The module supports both Jedis and Lettuce drivers. Spring Boot will automatically configure the connection factory based on which driver is present on your classpath:

    1. Jedis: Synchronous client. Selected by default if Jedis is on the classpath.
    2. Lettuce: Asynchronous/reactive client. Supports cluster mode.

    To explicitly force the use of Lettuce, set the following property: spring.data.redis.client-type=lettuce.

    The module ensures that LettuceConnectionFactory and JedisConnectionFactory beans are correctly ordered to depend on the embedded Redis container startup.

    spring.data.redis.client-type=lettuce
  2. How Durable Deletes work in embedded-aerospike-enterprise

    develop

    This module enforces the use of Durable Deletes to prevent 'zombie records' (records that reappear after a reboot because they were removed from the index but not from the disk).

    To achieve this, the module configures the Aerospike server with the disallow-expunge option.

    Consequence for Developers: If your client code attempts a delete operation without explicitly setting WritePolicy.durableDeletes to true, the operation will fail with Aerospike Error 22 (forbidden).

  3. Use ToxiProxy with embedded-mariadb

    develop

    If you enable embedded.toxiproxy.proxies.mariadb.enabled, the module will create a ToxiProxy TCP proxy for the MariaDB container. This allows you to simulate network latency, jitter, or connection failures in your tests.

    In addition to the properties listed in the reference guide, the module provides a Spring Bean of type ToxiproxyClientProxy named mariadbContainerProxy which you can inject into your tests to manipulate the proxy.

  4. Enable JetStream or Authentication in embedded-nats

    develop

    By default, NATS runs without security. To enable features like JetStream or specific authentication, you have two options:

    1. Via Properties: Use embedded.nats.command to pass flags directly to the NATS binary (e.g., embedded.nats.command=--jetstream).
    2. Via Bean Customization: Inject the NatsContainer bean and configure it before the Spring context starts.
  5. Use Toxiproxy with embedded-db2

    develop

    If you enable embedded.toxiproxy.proxies.db2.enabled, the library will create a container with a ToxiProxy TCP proxy and provide a proxy to the embedded-db2 container. This allows you to simulate network latency or failures.

    In addition to the properties listed above, a bean of type ToxiproxyClientProxy named db2ContainerProxy will be available in the Spring context.

  6. Provision custom Grafana datasources and dashboards

    develop

    Use embedded.grafana.filesToInclude to copy classpath resources into the container at startup. This is the standard way to provision custom datasources, dashboards, or alert rules.

    Each entry requires a classpathResource (the source in your project) and a containerPath (the destination inside the Grafana container).

    embedded:
      grafana:
        filesToInclude:
          - classpathResource: /embedded/grafana/provisioning/datasources/my-datasource.yml
            containerPath: /etc/grafana/provisioning/datasources/my-datasource.yml