Skip to content
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

Use new apache/kafka-native docker image for kafka module #2683

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

CTrando
Copy link

@CTrando CTrando commented Aug 5, 2024

What does this PR do?

Uses the new apache/kafka-native docker image instead of the confluent local docker image. The kafka native docker image is much faster (startup time is maybe a second once the image is downloaded).

Trying to see if there is a desire from the community to use this. I can also add support for authentication mechanisms like SASL_PLAINTEXT if desired.

A current limitation of this however is that the desired host port must be known at container creation time - unlike before where we could dynamically pick a port at runtime. The way it was done before was a bit strange, it was running a kafka instance after the container had already started up I believe, which allowed it to pick the right port to use. Here, when we start up the kafka container it must know the port already.

We can still support picking random ports with some tricks like this, but there's no guarantee there won't be collisions.

Also I realize some of these changes may cause unavoidable breaking changes, so I'm happy to make a v2 module.

Why is it important?

Related issues

Copy link

netlify bot commented Aug 5, 2024

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit b55139d
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/66b1153381aaf60008cdbc1f
😎 Deploy Preview https://deploy-preview-2683--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.


// validateKRaftVersion validates if the image version is compatible with KRaft mode,
// which is available since version 7.0.0.
func validateKRaftVersion(fqName string) error {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every apache/kafka-native image supports kraft


hostname := inspect.Config.Hostname

code, r, err := container.Exec(context.Background(), []string{"cat", "/usr/sbin/testcontainers_start.sh"})
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this script doesn't exist anymore in the kafka image - also I didn't think it was necessary to check advertisted listeners, considering if it's set incorrectly, the other tests would fail because kafka wouldn't work in the first place

@@ -17,7 +15,7 @@ func TestKafka(t *testing.T) {

ctx := context.Background()

kafkaContainer, err := kafka.Run(ctx, "confluentinc/confluent-local:7.5.0", kafka.WithClusterID("kraftCluster"))
kafkaContainer, err := kafka.Run(ctx, "apache/kafka-native:3.8.0", kafka.WithClusterID("kraftCluster"))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: need some more tests on the client side to demonstrate this works + add tests for setting host port

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant