Skip to content

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

@helpermethod

Description

@helpermethod

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!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions