testcontainers / testcontainers/testcontainers-java

[Bug]: withStartupTimoutSeconds(int) not working

Open
#8,590 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type/bug
Dominant language
Java
Stars
8.7k
Forks
1.9k
Avg merge
2d 17h
Merged PRs (30d)
9

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at OracleContainer and compare the implementation of withStartupTimeoutSeconds(int) with withStartupTimeout(Duration), using the reported 180-second examples as the reproduction. Add a regression test that verifies the integer overload permits startup beyond 60 seconds, and confirm the Oracle container startup completes without the premature timeout.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java
Domain
databases, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.