Skip to content

Add support for org.testcontainers.kafka.KafkaContainer #42014

Closed as not planned
@goatfryed

Description

@goatfryed

Currently, spring-boot-testcontainers supports only org.testcontainers.containers.KafkaContainer, but not org.testcontainers.containers.KafkaContainer.

The former is for use of confluentinc/cp-kafka derived images, the later is for use of apache/kafka derived images.

It's a bit confusing to me why testcontainers chose this specific package structure and didn't introduce a common interface, but it's also confusing that only one variant is supported at the moment, since the documentations exclude the import paths.

Versions

  • org.testcontainers:kafka:1.20.1
  • org.springframework.boot:spring-boot-testcontainers:3.3.1

Spring Dependency Management Plugin picks 1.19.8 by default. The issue is reproducible on that version as well.

I'd expect the following test to work

import org.testcontainers.kafka.KafkaContainer;

@SpringBootTest
@Testcontainers
class MyIntegrationTests {

    @Container
    @ServiceConnection
    static KafkaContainer kafkaContainer  = new KafkaContainer("apache/kafka:3.8.0");

    @Test
    void myTest() {
        // ...
    }

}

Currently I get

No ConnectionDetails found for source '@ServiceConnection source for MyIntegrationTests.kafkaContainer'
org.springframework.boot.autoconfigure.service.connection.ConnectionDetailsNotFoundException: No ConnectionDetails found for source '@ServiceConnection source for MyIntegrationTests.kafkaContainer'

Exception context added for people to find this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions