testcontainers-dotnet-legacy
testcontainers-dotnet-legacy copied to clipboard
MS SQL Server Container
Description
This PR adds MS SQL Server as a test container.
Type of change
- [X] New feature (non-breaking change which adds functionality)
Hi @swissarmykirpan, would you or any of other contributors take a look at my PR please? Thanks
The code looks good to me.
I think we can merge this into develop first, and separate this out later. The new sqlclient dependency isn't big.
Hi @isen-ng , is there anything else pending?
@isen-ng @HofmeisterAn I've been thinking that we should drop Container Support for Windows. I don't really think there is much appetite for it and there is added complication especially around things like running linux + windows containers side by side (using hybrid mode). If anything, docker on windows can be setup to run linux containers, so I'm voting for dropping Windows support for now. We can obviously change that if there is actually a demand for it
I use most of the time Windows containers for native C++ components and Windows Desktop applications. But that’s certainly a special use case. In general, it’s not much extra work to support basic Docker operations on Windows containers too. In the case of modules, it is probably different.
But as you said, most things can be done with Unix containers. I think it is a good suggestion to start with Unix containers and add Windows support later.
I would like to drop support for linux containers too, but according to @martins-vds and @HofmeisterAn, there are real use cases for Windows containers. So .. for this library to be more wide adopted, I would like to support Windows. However, I do agree that we don't have to support Windows now. Windows containers may work, but we don't officially support them yet.
To support windows containers isn't difficult in code. However, I had a lot of trouble integrating them into CI and writing tests for them. If we could figure this out in a proper manner, we can officially support Windows.
What do you all think? The branch with all my changes assumes we only support linux for now, although it can be expanded to support Windows.
I'm fine with Unix support only for now. This will already help a lot. I'm also pretty sure that the most parts will work with Windows containers too, as you said @isen-ng. After a stable version we can think about Windows container.
I had a lot of trouble integrating them into CI and writing tests for them.
Maybe we can have a chat about your troubles. I got a pipeline running on Azure with Unix anx Windows.
Hello, this might help Recently I've been dealing with similar problems on running tests over linux/windows/azure ci-cd pipelines and the solution has been to create different images and stick them together within a docker manifest. Then, using same image name and tag pulls a different one based on the client requesting it.
You might find several multi-os multi-arch multi-build on docker hub. I needed to solve this same problem for running mysql containers and this was the solution
@Martins-vds if you want a Docker Integration testing API AND Windows support, just drop this PR and check out TestEnvironment.Docker instead.
@dgvives can you elaborate how that trick works?
@jzabroski sure
1 - Build and push the two images to docker hub. One using windows containers, other using linux containers: https://github.com/dgvives/base-mysql-windows-docker
docker image build . -t davidgarciavivesdn/base-mysql:windows
docker push davidgarciavivesdn/base-mysql:windows
https://github.com/dgvives/base-mysql-linux-docker
docker image build . -t davidgarciavivesdn/base-mysql:linux
docker push davidgarciavivesdn/base-mysql:linux
2 - Create a manifest and push to dockerhub
docker manifest create davidgarciavivesdn/base-mysql davidgarciavivesdn/base-mysql:linux davidgarciavivesdn/base-mysql:windows
docker manifest push davidgarciavivesdn/base-mysql:latest
3 - Reference image as davidgarciavivesdn/base-mysql and it should pull the proper one based on docker client requesting them. I used this as a sample:
https://github.com/Deffiss/testenvironment-docker/blob/master/samples/test-bll-with-nunit/BLLlWithNunitSample/BLLTests/TestBase.cs
private DockerEnvironment PrepareDockerEnvironment(DockerEnvironmentBuilder environmentBuilder)
{
return environmentBuilder
.UseDefaultNetwork()
.AddMariaDBContainer(
name: "dummyContainer",
rootPassword: "someDummyPassword",
imageName: "davidgarciavivesdn/base-mysql"
).Build();
}
Hope this helps