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

Replace confluentinc/cp-kafka with apache/kafka-native #568

Open
helpermethod opened this issue Aug 9, 2024 · 1 comment
Open

Replace confluentinc/cp-kafka with apache/kafka-native #568

helpermethod opened this issue Aug 9, 2024 · 1 comment
Labels
good first issue Good for newcomers recipe Recipe request

Comments

@helpermethod
Copy link

What problem are you trying to solve?

  • replace org.testcontainers.container.KafkaContainer with the new implementation org.testcontainers.kafka.KafkaContainer
  • replace the Confluent Kafka Image with the much faster Apache Kafka Native Image

What precondition(s) should be checked before applying this recipe?

Requires Testcontainers 1.20.1

Describe the situation before applying the recipe

import org.testcontainers.containers.KafkaContainer;

@TestContainers
class KafkaTests {
    @Container
    KafkaContainer kafka = new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.5.3"));
}

Describe the situation after applying the recipe

import org.testcontainers.kafka.KafkaContainer;

@TestContainers
class KafkaTests {
    @Container
    KafkaContainer kafka = new KafkaContainer(DockerImageName.parse("apache/kafka-native:3.8.0"));
}

Have you considered any alternatives or workarounds?

No.

Any additional context

Docker image versions don't map 1:1.

Are you interested in contributing this recipe to OpenRewrite?

Yes!

@timtebeek
Copy link
Contributor

Thanks for logging an issue @helpermethod ! I'd been thinking of doing the same after doing this manually once before:

As seen there we could even remove the DockerImageName.parse, which might make a neat recipe in and of itself.

In terms of implementation we can reuse ChangeType; then we have to match the argument going into KafkaContainer, and in there any argument going into DockerImageName.parse to switch over to the new base image. Thanks for offering to help! Let us know if you'd need any more guidance.

@timtebeek timtebeek moved this to Recipes Wanted in OpenRewrite Aug 9, 2024
@timtebeek timtebeek added good first issue Good for newcomers recipe Recipe request labels Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers recipe Recipe request
Projects
Status: Recipes Wanted
Development

No branches or pull requests

2 participants