2

I have some testcontainers running for my junit intergration tests (Spring Boot, Junit 5)

public static PostgreSQLContainer<?> postgresContainer= new PostgreSQLContainer<>("postgres:13")
            .withDatabaseName("test")
            .withUsername("postgres")
            .withPassword("testIntegration")
            .withExposedPorts(5432)
            .withInitScript("test.sql")

And one for another postgrs database and one Generic one for ActiveMQ

    public static GenericContainer<?> aMQContainer= new GenericContainer<>("rmohr/activemq")
            .withExposedPorts(61616)
            .withEnv("DISABLE_SECURITY", "true")
            .withEnv("BROKER_CONFIG_GLOBAL_MAX_SIZE", "50000")
            .withEnv("BROKER_CONFIG_MAX_SIZE_BYTES", "50000")
            .withEnv("BROKER_CONFIG_MAX_DISK_USAGE", "100");
        postgresContainer.start();
        postgresContainer2.start();
        aMQContainer.start();

Locally everything work fine but when I run the tests in Jenkins which is set in a Linux environment (Raspberry Pi 4 4GB Model B) I get the following error:

    Caused by: org.testcontainers.containers.ContainerLaunchException: Container startup failed
    Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
    Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
    Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log  output   matching .*database systemt is ready to accept connections

I tried adding waiting conditions, or withStartupTimeoutSeconds(240) but to no avail.

Anyone with a similar problem?

Newboz
  • 69
  • 6

2 Answers2

0

The problem seems to be with PostgresSqlContainer, it can't understand if the image is running in docker or not. Changing PostgresSqlContainer.withStartupCheckStrategy() to new IsRunningStartupCheckStrategy() helped me

BluzSter
  • 76
  • 1
  • 4
  • Thank you very much for your answer an d sorry for my belated response. I managed in the end to make it work but i will implement your answer and observe the results. – Newboz Sep 01 '22 at 10:06
  • @Newboz In the end, I came up with this solution and it works stably for me: ```postgreSQLContainer.setWaitStrategy(new LogMessageWaitStrategy().withRegEx(".database system is ready to accept connections.\\s").withTimes(1).withStartupTimeout(Duration.of(60, SECONDS)));``` – BluzSter Oct 10 '22 at 11:38
0

In the end, I came up with this solution and it works stably for me:

postgreSQLContainer.setWaitStrategy(new LogMessageWaitStrategy()
.withRegEx(".database system is ready to accept connections.\\s")
.withTimes(1)
.withStartupTimeout(Duration.of(60, SECONDS)));
BluzSter
  • 76
  • 1
  • 4