testcontainers-java icon indicating copy to clipboard operation
testcontainers-java copied to clipboard

JDBC - MSSQL - getLivenessCheckPortNumbers() shouldn't that be the mapped port and not the internal?

Open npetzall opened this issue 3 years ago • 5 comments

https://github.com/testcontainers/testcontainers-java/blob/600d235d220d5e507405921b4e241aa73c067a2a/modules/mssqlserver/src/main/java/org/testcontainers/containers/MSSQLServerContainer.java#L64-L67

Mysql has the ports mapped https://github.com/testcontainers/testcontainers-java/blob/600d235d220d5e507405921b4e241aa73c067a2a/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainer.java#L56-L60

If the overrides are removed you would receive mapped ports of the exposedPorts.

npetzall avatar Apr 24 '22 03:04 npetzall

Hey @npetzall, thanks for raising this issue. Your observation seems correct. In which scenarios would this lead to issues for you?

kiview avatar Jul 11 '22 07:07 kiview

If I remember correctly I couldn't use the MSSQLServerContainer and had to extend it. Since it failed the liveliness check.

This was on Windows so testcontainers tried to connect to 1433 or something like that but it was reachable on a different port.

npetzall avatar Jul 11 '22 08:07 npetzall

I do also have a a custom wait strategy

@Override
    protected void waitUntilContainerStarted() {
        new WaitAllStrategy()
                .withStrategy(Wait.forListeningPort())
                .withStrategy(Wait.forLogMessage("(?s).*default collation was successfully changed.*",1))
                .waitUntilReady(this);
        super.waitUntilContainerStarted();
    }

So it might be related to changes done that affect what is exposed or how the strategies work.

npetzall avatar Jul 11 '22 08:07 npetzall

Thanks, this example makes sense.

kiview avatar Jul 11 '22 09:07 kiview

It's a bit tricky since the JavaDoc only says ports to check if ready, but Wait.forListeningPort seems to assume that it's a published port.

npetzall avatar Jul 11 '22 10:07 npetzall

Thank you all for your contributions. This issue should be closed now. It's in the 1.17.4 release

aidando73 avatar Oct 04 '22 07:10 aidando73