You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use testcontainer for SQL Server tests by default #33267
The version of LocalDb that ships with Visual Studio is currently, and is usually, an older version.
This doesn't help people on non-Windows machines
Manual installation and configuration of dependencies is error prone, with better solutions now available.
We should therefore start using a SQL Server testcontainer by default. I understand that this will not work on the C.I., so we should ensure that the C.I. continues to work either in the old way, or in some other way that is supported by the C.I. system.
Yeah, FWIW in our local development workflow, we likely want to continue using a persistent SQL Server anyway, to be able to inspect it easily while testing, have faster startup times etc. So I think testcontainers here would in any case be a default that's overridable via an environment variable - both for devs which choose to do that and probably also for CI (though it may be worth checking if we can make things work there).
I'm curious what prevents you from using testcontainers in CI? Is it some limitation of the test suite/test setup? I'm genuinely interested as we've been running testcontainers in CI without a hitch and I might have some ideas depending on what the blockers are.
@pinkfloydx33 the problem isn't CI in general, but the specific images used in our own CI system, where we're not sure whether we can run docker etc. We haven't actually looked into it, but if there's an issue, It's really specific to our platform.
Ah I see. I'd be surprised if you couldn't. Assuming github runners or azure devops, the public microsoft images have docker installed on them. You can see their definitions in the runner-images repo.
(We actually ended up forking that repo and building our own slimmed down/customized vm image with a larger set of docker images pre-pulled, but they all start with docker on them)
Another possible reason for this is for agents to spin up their own testcontainer for their private use; this can be important now that we're running multiple agents in parallel, who might each be running tests and might step over each other's toes in the database.
This might also help with sandboxed agents, where configuring them to access the machine-wide SQL Server might be difficult/unfeasible (not yet sure exactly how that works). But in any case the parallel work of agents makes this desirable in any case.
Activity
roji commentedon Mar 7, 2024
Yeah, FWIW in our local development workflow, we likely want to continue using a persistent SQL Server anyway, to be able to inspect it easily while testing, have faster startup times etc. So I think testcontainers here would in any case be a default that's overridable via an environment variable - both for devs which choose to do that and probably also for CI (though it may be worth checking if we can make things work there).
pinkfloydx33 commentedon Mar 7, 2024
I'm curious what prevents you from using testcontainers in CI? Is it some limitation of the test suite/test setup? I'm genuinely interested as we've been running testcontainers in CI without a hitch and I might have some ideas depending on what the blockers are.
roji commentedon Mar 7, 2024
@pinkfloydx33 the problem isn't CI in general, but the specific images used in our own CI system, where we're not sure whether we can run docker etc. We haven't actually looked into it, but if there's an issue, It's really specific to our platform.
pinkfloydx33 commentedon Mar 7, 2024
Ah I see. I'd be surprised if you couldn't. Assuming github runners or azure devops, the public microsoft images have docker installed on them. You can see their definitions in the runner-images repo.
(We actually ended up forking that repo and building our own slimmed down/customized vm image with a larger set of docker images pre-pulled, but they all start with docker on them)
roji commentedon Mar 7, 2024
I'm pretty sure these aren't public images.
roji commentedon Feb 26, 2026
Another possible reason for this is for agents to spin up their own testcontainer for their private use; this can be important now that we're running multiple agents in parallel, who might each be running tests and might step over each other's toes in the database.
This might also help with sandboxed agents, where configuring them to access the machine-wide SQL Server might be difficult/unfeasible (not yet sure exactly how that works). But in any case the parallel work of agents makes this desirable in any case.
Default to using SQL Server testcontainer in tests