.Net runner with docker wrapper - running tests against SQL Server container
This is probably just me misunderstanding the docker wrapper purpose, but I'm trying to run integration tests (using dotnet test) against SQLServer LocalDb via Docker Wrapper.
LocalDb isn't installed on the default pool agents so my plan was to use Docker Wrapper to spin up SQLServer and then run dotnet test inside the container. This doesn't work as the container doesn't include the .Net SDK.
I can think of several solutions:-
1) Build my own image including SQL Server and .Net SDK
2) Crank up the SQL Server container in an earlier build step (not sure if this is supported?)
3) Crank up the container and run the tests within a PowerShell script using the PowerShell runner
Any advice welcome!
Please sign in to leave a comment.
Hi Russell,
your understanding is correct, TeamCity will basically wrap up the build step within a script, launch the docker container, then push the script to the container, map some folders and run it.
The most logical solution would be to build your own docker image to have both sql server and the dotnet sdk available. It's possible that there are some out there but we can't really recommend any right now.
If you have an SQL container elsewhere you might be able to boot it up earlier as you mentioned just fine, just remember to add an additional step to kill the container at the end of the build. This would be assuming that then your tests can connect to a separate container, of course.
I'm not sure what cranking up the container and running the tests in powershell would make as a difference with just running it normally.
Which option to choose would be your call, as it will depend on what you consider better. Having a docker image with both tools combined would allow you to use it outside of teamcity for custom tests, but would require a bit more work to get it set up, while setting up multiple already existing containers would be more complex in communicating your tests and the db and setting up on teamcity.
Thanks, Denis for your thoughtful reply, very helpful.
Yes, I think I'll create that docker with both tools included and see how that goes.
Thanks again
Russ