docs/modules/redpanda.md
Testcontainers can be used to automatically instantiate and manage Redpanda containers. More precisely Testcontainers uses the official Docker images for Redpanda
!!! note
This module uses features provided in docker.redpanda.com/redpandadata/redpanda.
Create a Redpanda to use it in your tests:
Creating a Redpanda inside_block:constructorWithVersion
<!--/codeinclude-->Now your tests or any other process running on your machine can get access to running Redpanda broker by using the following bootstrap server location:
<!--codeinclude-->Bootstrap Servers inside_block:getBootstrapServers
<!--/codeinclude-->Redpanda also provides a schema registry implementation. Like the Redpanda broker, you can access by using the following schema registry location:
<!--codeinclude-->Schema Registry inside_block:getSchemaRegistryAddress
<!--/codeinclude-->It is also possible to enable security capabilities of Redpanda by using:
<!--codeinclude-->Enable security inside_block:security
<!--/codeinclude-->Superusers can be created by using:
<!--codeinclude-->Register Superuser inside_block:createSuperUser
<!--/codeinclude-->Below is an example of how to create the AdminClient:
Create Admin Client inside_block:createAdminClient
<!--/codeinclude-->There are scenarios where additional listeners are needed because the consumer/producer can be another
container in the same network or a different process where the port to connect differs from the default
exposed port 9092. E.g Toxiproxy.
Register additional listener inside_block:registerListener
<!--/codeinclude-->Container defined in the same network:
<!--codeinclude-->Create kcat container inside_block:createKCatContainer
<!--/codeinclude-->Client using the new registered listener:
<!--codeinclude-->Produce/Consume via new listener inside_block:produceConsumeMessage
<!--/codeinclude-->The following examples shows how to register a proxy as a new listener in RedpandaContainer:
Use SocatContainer to create the proxy
Create Proxy inside_block:createProxy
<!--/codeinclude-->Register the listener and advertised listener
<!--codeinclude-->Register Listener inside_block:registerListenerAndAdvertisedListener
<!--/codeinclude-->Client using the new registered listener:
<!--codeinclude-->Produce/Consume via new listener inside_block:produceConsumeMessageFromProxy
<!--/codeinclude-->Add the following dependency to your pom.xml/build.gradle file:
=== "Gradle"
testImplementation "org.testcontainers:testcontainers-redpanda:{{latest_version}}"
=== "Maven"
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-redpanda</artifactId>
<version>{{latest_version}}</version>
<scope>test</scope>
</dependency>