This feature is currently in incubating state, i.e. exact semantics, configuration options, APIs etc. may change in future revisions, based on the feedback we receive.
Please let us know if you encounter any problems will using this extension.
====
== Overview
When setting up change data capture pipelines with Debezium,
it's a good idea to also have some automated testing in place, in order to make sure that
* the source database is set up so changes can be streamed off of it
* your connectors are configured correctly
The Debezium extension for https://www.testcontainers.org/[Testcontainers] aims at simplying such tests,
by running all the required infrastructure (Apache Kafka, Kafka Connect etc.)
via Linux containers and making it easily accessible to Java-based tests.
It applies sensible defaults as far as possible
(e.g. database credentials for connectors can be obtained from the configured database container),
allowing you to focus on the essential logic of your tests.
== Getting Started
In order to use Debezium's Testcontainers integration, add the following dependency to your project:
<!-- Add the TC dependency matching your database -->
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
----
Depending on your testing strategy, you may also need the JDBC driver of your database and a client for Apache Kafka, so you can insert some test data and assert the corresponding change events in Kafka.
== Test Set-Up
When writing an integration test for a Debezium connector configuration,
you'll also need to set up Apache Kafka and a database which should be the source of change events.
The existing Testcontainers support for https://www.testcontainers.org/modules/kafka/[Apache Kafka] and https://www.testcontainers.org/modules/databases/[databases] can be used for that.
Together with Debezium's `DebeziumContainer` class, a typical set-up will look like this:
<1> Create a table in the Postgres database and insert two records
<2> Register an instance of the Debezium Postgres connector; the connector type as well as properties such as database host, database name, user etc. are derived from the database container
<3> Read two records from the change event topic in Kafka and assert their attributes