A collection of Testcontainers modules for Confluent Platform components, designed to simplify integration testing of Kafka-based applications.
-
Supports all major Confluent Platform components
-
Easy setup of RBAC and MDS-enabled environments
-
Integration with Confluent Hub connectors
-
Compatible with Confluent Platform 7.8.0
-
Requires Java 17 or later
Start Kafka and Schema Registry:
final var factory = new CPTestContainerFactory();
// Create and start Kafka and Schema Registry
final KafkaContainer kafka = factory.createKafka();
final SchemaRegistryContainer schemaRegistry = factory.createSchemaRegistry(kafka);
schemaRegistry.start(); // implicitly starts kafka container
// Configure client properties
Properties properties = new Properties();
properties.put("bootstrap.servers", kafka.getBootstrapServers());
properties.put("schema.registry.url", schemaRegistry.getBaseUrl());
Start a single-node Kafka Connect cluster with connectors from Confluent Hub:
final var connect = factory.createCustomConnector(
Set.of(
"confluentinc/kafka-connect-s3:latest",
"confluentinc/kafka-connect-datagen:0.4.0"
),
kafka
);
connect.start();
Configure CP-Server and Schema Registry with RBAC:
final var factory = new CPTestContainerFactory(network);
final var ldap = factory.createLdap();
final var confluentServer = factory.createConfluentServer()
.enableRbac();
final var sr = factory.createSchemaRegistry(confluentServer)
.enableRbac();
sr.start();
Component | RBAC Support | Description |
---|---|---|
Confluent Server |
✅ |
Core Kafka component with enterprise features |
Schema Registry |
✅ |
Schema management and compatibility |
Kafka Connect |
✅ (without secret registry) |
Data integration framework |
ksqlDB |
✅ |
Stream processing engine |
REST Proxy |
✅ |
RESTful interface to Kafka |
Replicator |
❌ (investigating OOM issues) |
Cross-cluster data replication |
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
testImplementation 'com.github.testcontainers-all-things-kafka:cp-testcontainers:Tag'
}
See LocalStackIntTest for an example of setting up an S3 sink connector with LocalStack.
See MultiVersionTest for examples of testing against different Confluent Platform versions.
Status 404: {"message":"could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network"}
Solution: Clean up unused Docker networks:
docker network prune
See License