testcontainers / testcontainers/testcontainers-java
Implement withDatabase() in MSSQLServerContainer
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 1.9k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 9
Description
Hello,
First of all, thanks for your great work!
I have a requirement to set READ_COMMITED_SNAPSHOT ON in the MSSQLServer database, and due to a MSSQLServer limitation that can't be applied to the default master database:
ALTER DATABASE master SET READ_COMMITTED_SNAPSHOT ON
throws
SQL Error [5058] [S0002]: Option 'READ_COMMITTED_SNAPSHOT' cannot be set in database 'master'.
This setting prevents read locks from being created and is the default setting in AzureSQL DB - in my case with testContainers my integration tests intermittently fail with CouldNotAquireLockException because of that.
For this to work OOTB for me I think the MSSQLServerContainer class would have to have the withDatabaseName() method implemented, and add the logic for creating the database before letting the application code connect to it.
I managed to get by by subclassing the MSSQLServerContainer, but it would be great to have it OOTB.
I can provide a PR if that's helpful.
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading MSSQLServerContainer and looking for existing database-name configuration patterns. Trace how the container is initialized before application connections and run the relevant integration tests. Done means withDatabaseName() creates and uses a non-master database with the requested setting available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java
- Domain
- databases, testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100