Search code examples
javamavenapple-m1testcontainers

testcontainers fails to start with maven on mac m1


I am trying to create testcontainers and they are failing with below errors

Inside the container

[2022-08-16 07:22:52,694] INFO 172.29.0.1 - - [16/Aug/2022:07:22:52 +0000] "GET /info HTTP/1.1" 404 49  21 (io.confluent.rest-utils.requests)
[2022-08-16 07:22:53,708] ERROR Request Failed with exception  (io.confluent.rest.exceptions.DebuggableExceptionMapper)
javax.ws.rs.NotFoundException: HTTP 404 Not Found

On the logs

12:41:07.851 [main] ERROR 🐳 [confluentinc/cp-schema-registry:5.5.0] - Could not start container
org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (localhost ports: [57338] should be listening)
    at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:90)

This is my implementation

public class SchemaRegistryContainer extends GenericContainer<SchemaRegistryContainer> {
  private static final int SCHEMA_PORT = 8081;

  public SchemaRegistryContainer(String version) {
    super("confluentinc/cp-schema-registry:" + version);
    withExposedPorts(8081);
    waitStrategy = Wait
        .forHttp("/info")
        .forStatusCode(200)
        .withStartupTimeout(Duration.ofMinutes(5));
  }
}

Here is environment details

OS : MacBook Air (M1, 2020) Version 12.1 Apple M1

Java version : openjdk version "13.0.2" 2020-01-14

<testcontainers.version>1.17.2</testcontainers.version>

<testcontainers.junit-jupiter.version>1.17.2</testcontainers.junit-jupiter.version>


Solution

  • Please check if schema registry service from confluent platform has /info endpoint.

    Reference : https://docs.confluent.io/platform/current/schema-registry/develop/api.html