testcontainers / testcontainers-java

Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
https://testcontainers.org
MIT License
7.97k stars 1.64k forks source link

[Bug]: withStartupTimoutSeconds(int) not working #8590

Open eidottermihi opened 4 months ago

eidottermihi commented 4 months ago

Module

Oracle Free

Testcontainers version

1.19.7

Using the latest Testcontainers version?

Yes

Host OS

Windows

Host Arch

x86

Docker version

Client:
 Cloud integration: v1.0.35-desktop+001
 Version:           24.0.5
 API version:       1.43
 Go version:        go1.20.6
 Git commit:        ced0996
 Built:             Fri Jul 21 20:36:24 2023
 OS/Arch:           windows/amd64
 Context:           default

Server: Docker Desktop 4.22.0 (117440)
 Engine:
  Version:          24.0.5
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.6
  Git commit:       a61e2b4
  Built:            Fri Jul 21 20:35:45 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

What happened?

With OracleContainer (both oracle-free and oracle-xe) the default startup time is 60 seconds, which is not enough in some cases.

Configuring the container with withStartupTimeoutSeconds(180) still leads to an startup timeout after 60 seconds:

@Container
    private static final OracleContainer oracle = new OracleContainer("gvenzl/oracle-free:slim-faststart")
            .withDatabaseName("testDB")
            .withUsername("testUser")
            .withPassword("testPassword")
            .withStartupTimeoutSeconds(180);

Startup log:

2024-04-30 08:53:46.290  INFO   --- [           main] tc.gvenzl/oracle-free:slim-faststart     : Creating container for image: gvenzl/oracle-free:slim-faststart
2024-04-30 08:53:46.441  INFO   --- [           main] tc.gvenzl/oracle-free:slim-faststart     : Container gvenzl/oracle-free:slim-faststart is starting: a81f38a6d5ae6f76b5e54179f07a55f4d6982374b2b5a2bf1a9921501a26176f
2024-04-30 08:54:46.965 ERROR   --- [           main] tc.gvenzl/oracle-free:slim-faststart     : Could not start container

org.testcontainers.containers.ContainerLaunchException: Timed out waiting for log output matching '.*DATABASE IS READY TO USE!.*\s'

However, if I use withStartupTimeout(Duration.ofSeconds(180)) the startup timeout is overwritten correctly:

@Container
    private static final OracleContainer oracle = new OracleContainer("gvenzl/oracle-free:slim-faststart")
            .withDatabaseName("testDB")
            .withUsername("testUser")
            .withPassword("testPassword")
            .withStartupTimeout(Duration.ofSeconds(180));
2024-04-30 08:56:04.757  INFO   --- [           main] tc.gvenzl/oracle-free:slim-faststart     : Creating container for image: gvenzl/oracle-free:slim-faststart
2024-04-30 08:56:04.865  INFO   --- [           main] tc.gvenzl/oracle-free:slim-faststart     : Container gvenzl/oracle-free:slim-faststart is starting: f508df5cff9fd39a341708d1e2738030ae5b6adf7c2aa75bdd1515dcdfc662f5
2024-04-30 08:58:22.055  INFO   --- [           main] tc.gvenzl/oracle-free:slim-faststart     : Container gvenzl/oracle-free:slim-faststart started in PT2M17.2976617S
2024-04-30 08:58:22.056  INFO   --- [           main] tc.gvenzl/oracle-free:slim-faststart     : Container is started (JDBC URL: jdbc:oracle:thin:@localhost:65218/testDB)

Relevant log output

No response

Additional Information

No response

fokion commented 1 month ago

I can have a look :)

fmeheust commented 3 weeks ago

I was going to submit this pull request: https://github.com/fmeheust/testcontainers-java/pull/1. Maybe the new line of code bellow should be moved to JdbcDatabaseContainer instead.

this.waitStrategy.withStartupTimeout(Duration.ofSeconds(startupTimeoutSeconds));