0

I am trying to configure a Test container as described on this website. testcontainers

I am having trouble configuring it with DockerCompose. I am looking at the docs and I don't see what I am doing wrong. What is the correct way to configure DockerComposeContainer for the sake of junit testing?

Right now I keep getting an error

org.testcontainers.containers.ContainerLaunchException

Which is happening because the timeout expires. This is what the code looks like.

private final DockerComposeContainer environment = new DockerComposeContainer(new File(path))
        .withLogConsumer("localstack", logConsumer)
        .waitingFor("localstack", Wait.forHttp("http://localhost:4572")
                .forStatusCode(200)
                .withStartupTimeout(Duration.ofSeconds(90)));

If I sit there with postman while it is starting, I can hit that endpoint and get a 200 response with postman indicating that localstack has started up correctly. But DockerComposeContainer doesn't seem to pick it up. What's wrong here? What is the right way to do this?

slipperypete
  • 5,358
  • 17
  • 59
  • 99

1 Answers1

0

Are you calling environment.start() somewhere? I see you added a log consumer, are you able to see what is going on inside the container?

Also, would you like to try using local-compose mode?

@Container
public static DockerComposeContainer docker = new DockerComposeContainer(
        new File("src/test/resources/compose-mysql-test.yml")
)
        .withLocalCompose(true);
Vitaly Chura
  • 704
  • 8
  • 13