Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JdbcDatabaseContainer ignores set WaitStrategy #2994

Open
MarcelHeckel opened this issue Jul 14, 2020 · 6 comments
Open

JdbcDatabaseContainer ignores set WaitStrategy #2994

MarcelHeckel opened this issue Jul 14, 2020 · 6 comments

Comments

@MarcelHeckel
Copy link

The JdbcDatabaseContainer overwirtes the method waitUntilContainerStarted() of GenericContainer but does not call super.waitUntilContainerStarted(). So the WaitStrategy set via waitingFor() is not applied. This is really confusing because you wonder why the set WaitStrategy is not called.

Please add super.waitUntilContainerStarted() at the beginning of waitUntilContainerStarted() in JdbcDatabaseContainer. E.g.:

@Override
protected void waitUntilContainerStarted() {
    super.waitUntilContainerStarted();

    logger().info("Waiting for database connection to become available at {} using query '{}'", getJdbcUrl(), getTestQueryString());

    // Repeatedly try and open a connection to the DB and execute a test query
    ....
@bademux
Copy link

bademux commented Sep 14, 2020

It is definitely the bug. It should either throw "Unimplemented" exception on JdbcDatabaseContainer#waitingFor or take into account custom wait strategy

Meanwhile I use hackfix below

 public class OracleContainer extends org.testcontainers.containers.OracleContainer {

    public OracleContainer(String dockerImageName) {
        super(dockerImageName);
    }

    @Override
    protected void waitUntilContainerStarted() {
        super.waitUntilContainerStarted();
        WaitStrategy waitStrategy = getWaitStrategy();
        if (waitStrategy != null) {
            waitStrategy.waitUntilReady(this);
        }
    }
}

@stale
Copy link

stale bot commented Dec 19, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

@stale stale bot added the stale label Dec 19, 2020
@MarcelHeckel
Copy link
Author

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

The issue is still valid.

@stale stale bot removed the stale label Dec 20, 2020
@anderso
Copy link

anderso commented Oct 27, 2023

I just spent two hours trying to figure out why waitStrategy is ignored before I found this. And the documentation on this doesn't really explain the relationship between wait strategy and startup strategy BTW, or atleast I don't understand it. I'm guessing startup strategy is applied first and then wait strategy?

@rissabekov-tyro
Copy link

Any update on this issue?

perlun added a commit to perlun/testcontainers-java that referenced this issue Jan 16, 2024
As pointed out in
testcontainers#2994, the
fact that `JdbcDatabaseContainer` ignores any `WaitStrategy` set on the
container is very confusing to the user. This change tries to make the
public API less confusing.
@perlun
Copy link
Contributor

perlun commented Jan 16, 2024

I second the opinion of others in this thread. Let's try to get this fixed: #8127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants