Repository navigation
Run the SQL Server integration tests on Testcontainers, with a CI job - #390
Merged
Merged
Conversation
Adds the shared SqlServerTestEnvironment (a linked source file) that starts a pinned SQL Server 2022 container, or uses the server named by SPRING_TEST_SQLSERVER, runs the database scripts and publishes SPRING_TEST_SQLSERVER_* environment variables. Spring.Data.Integration.Tests reads its connection strings from them instead of the hard-coded SPRINGQA host. The _database.sql scripts were mangled by a formatter (identifiers split across lines) and are rewritten. The two MSDTC tests are Explicit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGkLQuAuUjvRjrU1AcTsmk Signed-off-by: Marko Lahma <marko.lahma@gmail.com>
…Testcontainers Connection strings come from the SPRING_TEST_SQLSERVER_* environment variables. The mangled creditdebit.sql, testObject.sql and RecreateDatabases.sql are replaced by one clean script that also creates the springqa2 login. DbProviderTemplateTests.UserCredentialsDbProvider runs again (its mapping resource name had trailing whitespace). MultipleDbTests.MultipleDBAccess is Explicit (MSDTC), the other test of the fixture is ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGkLQuAuUjvRjrU1AcTsmk Signed-off-by: Marko Lahma <marko.lahma@gmail.com>
…on SQL Server with Testcontainers The App.config connection string is the SPRING_TEST_SQLSERVER_CS_SPRING environment variable (PropertyPlaceholderConfigurer, EnvironmentVariableMode Fallback). The mapping resource name had leading whitespace and is fixed. CanSuspendTransactionOnNotSupportedWithNestedRequired is Explicit (MSDTC). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGkLQuAuUjvRjrU1AcTsmk Signed-off-by: Marko Lahma <marko.lahma@gmail.com>
…h Testcontainers Creates a quartz database with the Quartz 3.22.9 SQL Server tables (vendored tables_sqlServer.sql), resolves the connection string from SPRING_TEST_SQLSERVER_CS_QUARTZ, and replaces the 20 second sleep in the formerly Explicit test with an assertion that the scheduler ran the job. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGkLQuAuUjvRjrU1AcTsmk Signed-off-by: Marko Lahma <marko.lahma@gmail.com>
…s, update the docs IntegrationTest runs the four Docker-backed SQL Server projects with TRX reporting (net10.0 off Windows, both TFMs on Windows). Test --test-integration-data now includes those projects (the .Integration filter used to run first and exclude them), and --test-integration-nms matches Spring.Messaging.Nms.Integration.Tests. CI gets an integration-linux job. docker-compose.yml and docker-compose-ci.yml are removed; README and AGENTS.md describe the Testcontainers recipe and the SPRING_TEST_SQLSERVER override. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGkLQuAuUjvRjrU1AcTsmk Signed-off-by: Marko Lahma <marko.lahma@gmail.com>
Produced by running the build, not edited by hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGkLQuAuUjvRjrU1AcTsmk Signed-off-by: Marko Lahma <marko.lahma@gmail.com>
Run the modules of a project one at a time when SPRING_TEST_SQLSERVER is set (--max-parallel-test-modules 1), because Microsoft.Testing.Platform otherwise starts the net10.0 and net472 builds together and they recreate the same databases under each other. Drop the quartz database before creating it. MultipleDbTests.MultipleDBAccessUsingMultipleSessionScopes is Explicit (MSDTC), not Ignore. Keep the setup exception when disposing the container also throws. Upload the TRX with always(). Convert the Data scripts to UTF-8, drop the redundant EnvironmentVariableMode lines, and tighten the README override section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LGkLQuAuUjvRjrU1AcTsmk Signed-off-by: Marko Lahma <marko.lahma@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The SQL Server-backed integration suites now start their own database through Testcontainers for .NET. All they need is a running Docker daemon: no local SQL Server, no docker-compose, no hosts entry, no hand-run scripts. A new CI job runs them. This follows the Testcontainers setup that already works in Quartz.NET.
How it works
test/Shared/SqlServerTestEnvironment.csis linked into each integration project.[SetUpFixture]starts onemcr.microsoft.com/mssql/server:2022-CU27-ubuntu-22.04container per test assembly, with a random port, so projects can run in parallel.build-support/create-integration-test-databases-and-users.sqland the project's ownData/*_database.sql, splitting onGOand using the same SqlClient path for every script.SPRING_TEST_SQLSERVER_HOST,_USERand_PASSWORD, plusSPRING_TEST_SQLSERVER_CS_<DATABASE>for each database.${SPRING_TEST_SQLSERVER_CS_*}throughVariablePlaceholderConfigurer/EnvironmentVariableSource, or through the existingPropertyPlaceholderConfigurers, where an environment variable is the fallback. C# tests callSqlServerTestEnvironment.GetConnectionString("Spring").SPRINGQAor(local)hosts.SPRING_TEST_SQLSERVERto an admin connection string runs the same, now idempotent, scripts against an existing server instead of a container. In that mode the build runs one test module at a time, because Microsoft.Testing.Platform otherwise runs the net472 and net10.0 modules at once.Testcontainers.MsSql4.16.0.Projects
Rot fixed along the way
_database.sqlscript and the NHibernate5 SQL scripts, splitting identifiers across lines ([\n decimal]), so SQL Server rejected them. These suites could not have passed for years.Data/.mapping-resourcevalues broke resource lookup.[Ignore]/[Explicit]attributes are removed.[Explicit("Requires MSDTC: …")]:DTCTestsandDTCTestsNoInterfaces.DeclarativeWithAttributes;MultipleDbTests.MultipleDBAccessand.MultipleDBAccessUsingMultipleSessionScopes;NotSupportedtest.Build and CI
IntegrationTestruns just those four projects, with TRX output. Off Windows it runs net10.0 only and skips the net472-only project. It works locally as well as on CI.Test --test-integration-datanow includes them. Before, the flag had no effect without--test-full.--test-integration-nmsnow matches the realSpring.Messaging.Nms.Integration.Testsname.integration-linuxjob inci.yml(ubuntu-latest, 30 min) runs./build.sh Compile IntegrationTestand always uploadsartifacts/TestResults.publish.ymlis untouched.docker-compose.ymland the unuseddocker-compose-ci.yml. README "Running tests" and AGENTS.md "Integration tests" describe the new recipe.Not in this PR: NMS/ActiveMQ integration on Testcontainers comes next. MSMQ tests stay Windows-only.
Spring.Web.Conversation.NHibernate5.Testsuses SQLite and needs no container.Verification
./build.cmd Compile IntegrationTestpasses locally, net10.0 and net472.SPRING_TEST_SQLSERVER(14 database setups on the same server), green both times../build.cmd Testpasses. The only failure isFormatUsingDefaults, which depends on this machine's regional settings.spring-revieweraccepted it with follow-ups, which are in the last commit.🤖 Generated with Claude Code
https://claude.ai/code/session_01LGkLQuAuUjvRjrU1AcTsmk