-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: RedPandaContainer does not allow for container to container Kafka communication #6395
Comments
quick workaround in class CustomRedpandaContainer(imageName: DockerImageName) : RedpandaContainer(imageName) {
override fun containerIsStarting(containerInfo: InspectContainerResponse?, reused: Boolean) {
super.containerIsStarting(containerInfo)
val hostname = "kafka"
var command = "#!/bin/bash\n"
command += "/usr/bin/rpk redpanda start --mode dev-container "
command += "--kafka-addr PLAINTEXT://0.0.0.0:29092,OUTSIDE://0.0.0.0:9092 "
command += "--advertise-kafka-addr PLAINTEXT://$hostname:29092,OUTSIDE://${this.host}:${getMappedPort(9092)}"
this.copyFileToContainer(Transferable.of(command, 511), "/testcontainers_start.sh")
}
} usage: val kafka = CustomRedpandaContainer(DockerImageName.parse("docker.redpanda.com/vectorized/redpanda:v22.3.11")).apply {
withNetwork(Network.SHARED)
withNetworkAliases("kafka")
} |
i'd recommend testing the latest 22.3.10 as the redpanda version fyi. |
The issue is still present with The testcontainer needs to allow for setting a network alias, that is then used in the startup script (to set |
While testcontainers are super for testing in the build pipeline, we want to use the same tests and build while developing locally, and that means we sometimes need to debug tests. With Kafka, that unfortunately often means looking at the data, just like you might with mysql console or similar. So spinning up the redpandaconsole makes sense imho. workaround:
|
Hi, There is currently some limitation in order to add new listeners in redpanda and kafka module. However, there is a workaround for this, see custom redpanda implementation in order to add dynamic listeners as you can see here The same applies to local development. See my setup using spring boot testcontainers integration this is the redpanda console config We are making some improvements to make this possible OOTB. See #7320 |
Module
Core
Testcontainers version
1.17.6
Using the latest Testcontainers version?
Yes
Host OS
Linux (Ubuntu 22.04.1 LTS)
Host Arch
x86
Docker version
What happened?
Cannot connect a Kafka Connect TestContainer instance to the RedpandaContainer.
It seems that this is due to the unfortunate nature of advertised addresses/listeners in the Kafka architecture.
Quarkus
RedPandaKafkaContainer
solved this by not having a static advertised addresses/listenersSee https://github.com/quarkusio/quarkus/blob/e47a267e13819cf5ebd4322ad2b2c88b06209a34/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/RedPandaKafkaContainer.java#L86
vs.
https://github.com/testcontainers/testcontainers-java/blob/0bb6925fb7d420/modules/redpanda/src/main/java/org/testcontainers/redpanda/RedpandaContainer.java#L55
My setup:
Relevant log output
Additional Information
Indeed, after overriding the command from
to
it works in my desired setup (should be dynamic of course)
The text was updated successfully, but these errors were encountered: