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

Make MS SQLServer tests and connection handling more robust #790

Open
thadguidry opened this issue Nov 12, 2024 · 1 comment
Open

Make MS SQLServer tests and connection handling more robust #790

thadguidry opened this issue Nov 12, 2024 · 1 comment
Labels
bug Something isn't working MS SQLServer Microsoft SQLServer issues tests anything to do with Tests (resources, data, config, etc.)

Comments

@thadguidry
Copy link
Collaborator

thadguidry commented Nov 12, 2024

Sometimes during local testing, there is not enough of some kind of delay, in order to ensure that the MS SQLServer container is started, and the port and connection are available to use.

Warnings that should not be happening during testing:

2024-11-12T15:28:41.493+08:00  WARN 37996 --- [ main]
c.m.s.j.internals.SQLServerConnection    : 
ConnectionID:1 ClientConnectionId: e7f921ad-98a5-460e-8e9d-dffb9568e097
Prelogin error: host localhost port 51760
Unexpected end of prelogin response after 0 bytes read

Generally, we should make the Connection handling more robust and expect that sometimes there are delays reaching DB instances or containers due to intermittent networking issues.

For example, if during testing, there is no login actually needed, or it's implied or configured somehow, then we should ensure that it works without throwing these kinds of errors.

@thadguidry thadguidry added bug Something isn't working tests anything to do with Tests (resources, data, config, etc.) MS SQLServer Microsoft SQLServer issues labels Nov 12, 2024
@thadguidry
Copy link
Collaborator Author

thadguidry commented Nov 12, 2024

2024-11-12T15:44:33.834+08:00  INFO 29900 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 0 (http)
2024-11-12T15:44:33.834+08:00  INFO 29900 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2024-11-12T15:44:33.834+08:00  INFO 29900 --- [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.28]
2024-11-12T15:44:33.850+08:00  INFO 29900 --- [           main] o.a.c.c.C.[Tomcat-10].[localhost].[/]    : Initializing Spring embedded WebApplicationContext
2024-11-12T15:44:33.850+08:00  INFO 29900 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 229 ms
2024-11-12T15:44:33.868+08:00  INFO 29900 --- [           main] t.m.m.com/mssql/server:2022-latest       : Creating container for image: mcr.microsoft.com/mssql/server:2022-latest
2024-11-12T15:44:34.046+08:00  INFO 29900 --- [           main] o.t.utility.RegistryAuthLocator          
: Credential helper/store (docker-credential-desktop) does not have credentials for mcr.microsoft.com    
2024-11-12T15:44:34.104+08:00  INFO 29900 --- [           main] t.m.m.com/mssql/server:2022-latest       : Container mcr.microsoft.com/mssql/server:2022-latest is starting: 51453c2a7b6401eed334e30313f9af1b1bf7640e65c57cd6fd150e29a71c3b24
2024-11-12T15:44:34.398+08:00  INFO 29900 --- [           main] t.m.m.com/mssql/server:2022-latest       : Waiting for database connection to become available at jdbc:sqlserver://localhost:53304 using query 'SELECT 1'
2024-11-12T15:44:34.446+08:00  WARN 29900 --- [           main] c.m.s.j.internals.SQLServerConnection    : ConnectionID:1 ClientConnectionId: 0327816d-06ec-452d-bafd-e30588eed849 Prelogin error: host localhost port 53304 Unexpected end of prelogin response after 0 bytes read

Upon further investigation, it seems that SOMETIMES, the port that the container is created with is 0:1433 and other times it's something else like 53304 as shown in 4th to last line above? So what happens is a long timeout as expected.

We should look into figuring out why the MS SQLServer port for the container isn't consistent when a run with mvn verify is done that is testing against all the containers.

  • Maybe it might even be better to close the container resources AFTER each DB test suite it done, instead of closing them all at once after all tests have finished? Maybe that will get rid of the intermittent non-avail port for MS SQLServer testcontainer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working MS SQLServer Microsoft SQLServer issues tests anything to do with Tests (resources, data, config, etc.)
Projects
None yet
Development

No branches or pull requests

1 participant