[Enhancement]: Extending Testcontainers to support multiple container runtimes (Podman)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Tranquilla
- Stack tecnologico
- csharp, docker
- Ambito
- devops, infrastructure, testing
Direzione di ricerca
Inizia riproducendo i fallimenti non verificati di K3sContainer, LocalStackContainer e ResourceReaper con la configurazione del runtime indicata. Leggi DockerContainer.cs, ResourceReaper.cs, DockerClient.cs, il relativo DefaultResourceReaperTest.cs e i test di rete. Il lavoro è completo quando gli scenari non verificati elencati passano con i runtime dei container supportati senza introdurre regressioni nel comportamento di Docker.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
Since Testcontainers for Node has done an awesome job supporting multiple container runtimes (not just Docker), it makes perfect sense to continue this great work and look into implementing it for .NET. We can start by collecting a list of tasks, issues or incompabilities that are necessary to support other runtimes as well.
-
Docker.DotNet'sExtractArchiveToContainerAsync(string, ContainerPathStatParameters, Stream, CancellationToken)throwsSystem.Net.Sockets.SocketException : Connection reset by peer. - Running Testcontainers for .NET on macOS using Podman (brew installation) does not work well with the Resource Reaper. Testcontainers is incapable of mounting the daemon socket. It fails with different errors:
When attempting to use the daemon socket path from within the Podman virtual machine, the process is also unsuccessful. SettingDocker API responded with status code=InternalServerError, response={"cause":"operation not supported","message":"container create: statfs /Users/atomicjar/.local/share/containers/podman/machine/qemu/podman.sock: operation not supported","response":500}export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sockfails:
When running the Podman virtual machine with rootful privileges (Docker API responded with status code=InternalServerError, response={"cause":"permission denied","message":"container create: statfs /var/run/docker.sock: permission denied","response":500}podman machine set --rootful=true), the errors mentioned above do not occur. However, Testcontainers for .NET is either unable to establish a connection to the Resource Reaper or fails:Docker API responded with status code=NotFound, response={"cause":"no such container","message":"no container with name or ID \"b26ef6bf452c4d85051d7727a2f53b2dddcf0c55b824aa03a6dd20b203ebc6f1\" found: no such container","response":404}- ✅ To fix the issue, you need to run the Podman virtual machine with root privileges and set the environment variables
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sockandTESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED=true.
- ✅ To fix the issue, you need to run the Podman virtual machine with root privileges and set the environment variables
-
K3sContainerdoes not start (rancher/k3s:v1.26.2-k3s1)Failed to load kernel module br_netfilter with modprobe Failed to load kernel module iptable_nat with modprobe Failed to load kernel module iptable_filter with modprobe Failed to set sysctl: open /proc/sys/net/bridge/bridge-nf-call-iptables: no such file or directory Failed to set sysctl: open /proc/sys/net/netfilter/nf_conntrack_max: permission denied Failed to ApplyOOMScoreAdj" err="write /proc/self/oom_score_adj: permission denied Failed to set rlimit on max file handles" err="operation not permitted Failed to get the info of the filesystem with mountpoint" err="unable to find data in memory cache" mountpoint="/var/lib/rancher/k3s/agent/containerd/io.containerd.snapshotter.v1.overlayfs Failed to start ContainerManager" err="[open /proc/sys/vm/overcommit_memory: permission denied, open /proc/sys/kernel/panic: permission denied, open /proc/sys/kernel/panic_on_oops: permission denied] [...] -
LocalStackContainerdoes not start (localstack/localstack:1.4,localstack/localstack:2.0)2023-05-17T14:17:05.033 WARN --- [ asgi_gw_0] localstack.utils.archives : Attempt 1. Failed to download archive from https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.zip: MyHTTPSConnectionPool(host='s3-us-west-2.amazonaws.com', port=443): Max retries exceeded with url: /dynamodb-local/dynamodb_local_latest.zip (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xffff65444bb0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')) 2023-05-17T14:17:05.037 INFO --- [ asgi_gw_0] localstack.utils.archives : Unable to extract file, re-downloading ZIP archive /tmp/localstack.ddb.zip: ('Failed to download archive from %s: . Retries exhausted', 'https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.zip') 2023-05-17T14:17:25.079 WARN --- [ asgi_gw_0] localstack.utils.archives : Attempt 1. Failed to download archive from https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.zip: MyHTTPSConnectionPool(host='s3-us-west-2.amazonaws.com', port=443): Max retries exceeded with url: /dynamodb-local/dynamodb_local_latest.zip (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0xffff65444d00>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')) 2023-05-17T14:17:25.080 WARN --- [ asgi_gw_0] localstack.utils.functions : error calling function on_before_start: Installation of dynamodb-local failed. [...] - Failed test:
Failed DotNet.Testcontainers.ResourceReaper.Tests.DefaultResourceReaperTest.ContainerCleanUpStartsDefaultResourceReaper(resourceReaperEnabled: True) [1 ms] Error Message: Docker.DotNet.DockerApiException : Docker API responded with status code=InternalServerError, response={"cause":"no such container","message":"container 02bb9d49a7b7ecd0501c4e1035c544c5ba77cd90b5596415a06be7dfc0cdf50a does not exist in database: no such container","response":500} Stack Trace: at Docker.DotNet.DockerClient.HandleIfErrorResponseAsync(HttpStatusCode statusCode, HttpResponseMessage response, IEnumerable`1 handlers) in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Docker.DotNet/DockerClient.cs:line 447 at Docker.DotNet.DockerClient.MakeRequestAsync(IEnumerable`1 errorHandlers, HttpMethod method, String path, IQueryString queryString, IRequestContent body, IDictionary`2 headers, TimeSpan timeout, CancellationToken token) in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Docker.DotNet/DockerClient.cs:line 217 at Docker.DotNet.ContainerOperations.InspectContainerAsync(String id, CancellationToken cancellationToken) in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Docker.DotNet/Endpoints/ContainerOperations.cs:line 76 at DotNet.Testcontainers.Containers.DockerContainer.UnsafeStopAsync(CancellationToken ct) in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Testcontainers/Containers/DockerContainer.cs:line 442 at DotNet.Testcontainers.Containers.DockerContainer.DisposeAsyncCore() in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Testcontainers/Containers/DockerContainer.cs:line 311 at DotNet.Testcontainers.Resource.DisposeAsync() in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Testcontainers/Resource.cs:line 27 at DotNet.Testcontainers.Containers.ResourceReaper.DisposeAsync() in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Testcontainers/Containers/ResourceReaper.cs:line 170 at DotNet.Testcontainers.ResourceReaper.Tests.DefaultResourceReaperTest.InitializeAsync() in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/tests/Testcontainers.ResourceReaper.Tests/DefaultResourceReaperTest.cs:line 17 - Failed test:
Failed DotNet.Testcontainers.ResourceReaper.Tests.DefaultResourceReaperTest.ContainerCleanUpStartsDefaultResourceReaper(resourceReaperEnabled: False) [1 ms] Error Message: Docker.DotNet.DockerApiException : Docker API responded with status code=InternalServerError, response={"cause":"no such container","message":"container deca45c9a28733786162a3777bf145d0d00d37f335f7597d115a02186d5dd2a2 does not exist in database: no such container","response":500} Stack Trace: at Docker.DotNet.DockerClient.HandleIfErrorResponseAsync(HttpStatusCode statusCode, HttpResponseMessage response, IEnumerable`1 handlers) in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Docker.DotNet/DockerClient.cs:line 447 at Docker.DotNet.DockerClient.MakeRequestAsync(IEnumerable`1 errorHandlers, HttpMethod method, String path, IQueryString queryString, IRequestContent body, IDictionary`2 headers, TimeSpan timeout, CancellationToken token) in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Docker.DotNet/DockerClient.cs:line 217 at Docker.DotNet.ContainerOperations.InspectContainerAsync(String id, CancellationToken cancellationToken) in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Docker.DotNet/Endpoints/ContainerOperations.cs:line 76 at DotNet.Testcontainers.Containers.DockerContainer.UnsafeStopAsync(CancellationToken ct) in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Testcontainers/Containers/DockerContainer.cs:line 442 at DotNet.Testcontainers.Containers.DockerContainer.DisposeAsyncCore() in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Testcontainers/Containers/DockerContainer.cs:line 311 at DotNet.Testcontainers.Resource.DisposeAsync() in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Testcontainers/Resource.cs:line 27 at DotNet.Testcontainers.Containers.ResourceReaper.DisposeAsync() in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Testcontainers/Containers/ResourceReaper.cs:line 170 at DotNet.Testcontainers.ResourceReaper.Tests.DefaultResourceReaperTest.InitializeAsync() in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/tests/Testcontainers.ResourceReaper.Tests/DefaultResourceReaperTest.cs:line 17 - The test runs either with Docker or Podman if the
mtuinstead of thecom.docker.network.driver.mtukey is used. Is themtua valid key for Docker (it is probably not that important since we only test if TC sets the property)?Failed DotNet.Testcontainers.Tests.Unit.TestcontainerNetworkBuilderTest.CreateNetworkAssignsOptions [38 ms] Error Message: Assert.Contains() Failure Not found: com.docker.network.driver.mtu In value: KeyCollection<String, String> ["mtu"] Stack Trace: at DotNet.Testcontainers.Tests.Unit.TestcontainerNetworkBuilderTest.CreateNetworkAssignsOptions() in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/tests/Testcontainers.Tests/Unit/Networks/TestcontainerNetworkBuilderTest.cs:line 59 - Cannot ping containers by its hostname (
--hostname,WithHostname(string)), the ping commands fails withping: bad address '_container2'.
https://github.com/testcontainers/testcontainers-dotnet/blob/f0fef3ee3346665842426f1fe4bdead322c0097e/tests/Testcontainers.Tests/Unit/Networks/TestcontainersNetworkTest.cs#L47Failed DotNet.Testcontainers.Tests.Unit.TestcontainersNetworkTest.PingContainer(destination: "_testcontainer2") [85 ms] Error Message: Assert.Equal() Failure Expected: 0 Actual: 1 Stack Trace: at DotNet.Testcontainers.Tests.Unit.TestcontainersNetworkTest.PingContainer(String destination) in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/tests/Testcontainers.Tests/Unit/Networks/TestcontainersNetworkTest.cs:line 52 - Failed test:
- This looks like a race condition after the tests are finished (disposing the container).
Failed DotNet.Testcontainers.Tests.Unit.TestcontainersContainerCancellationTest+Cancel.Start [1 ms] Error Message: [Test Class Cleanup Failure (DotNet.Testcontainers.Tests.Unit.TestcontainersContainerCancellationTest+Cancel)]: Docker.DotNet.DockerApiException : Docker API responded with status code=InternalServerError, response={"cause":"no such container","message":"container 4c86760f485d02cb2fe7d1a20527fdc7c81fe6a9d24be63a3b16ea4884085310 does not exist in database: no such container","response":500} Stack Trace: at Docker.DotNet.DockerClient.HandleIfErrorResponseAsync(HttpStatusCode statusCode, HttpResponseMessage response, IEnumerable`1 handlers) in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Docker.DotNet/DockerClient.cs:line 447 at Docker.DotNet.DockerClient.MakeRequestAsync(IEnumerable`1 errorHandlers, HttpMethod method, String path, IQueryString queryString, IRequestContent body, IDictionary`2 headers, TimeSpan timeout, CancellationToken token) in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Docker.DotNet/DockerClient.cs:line 217 at Docker.DotNet.ContainerOperations.InspectContainerAsync(String id, CancellationToken cancellationToken) in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Docker.DotNet/Endpoints/ContainerOperations.cs:line 76 at DotNet.Testcontainers.Containers.DockerContainer.UnsafeStopAsync(CancellationToken ct) in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Testcontainers/Containers/DockerContainer.cs:line 442 at DotNet.Testcontainers.Containers.DockerContainer.DisposeAsyncCore() in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Testcontainers/Containers/DockerContainer.cs:line 311 at DotNet.Testcontainers.Resource.DisposeAsync() in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/src/Testcontainers/Resource.cs:line 27 - Podman can only set the mac address if the container is assigned to a network.
.DependsOn(new NetworkBuilder().Build())works. The Podman "workaround" does not work with Docker.This option can only be used if the <<container|pod>> is joined to only a single network
Failed DotNet.Testcontainers.Tests.Unit.TestcontainersContainerTest+WithConfiguration.MacAddress [899 ms] Error Message: Assert.Equal() Failure ↓ (pos 0) Expected: 92:95:5e:30:fe:6d Actual: ea:2c:b1:6c:16:c5 ↑ (pos 0) Stack Trace: at DotNet.Testcontainers.Tests.Unit.TestcontainersContainerTest.WithConfiguration.MacAddress() in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/tests/Testcontainers.Tests/Unit/Containers/Unix/TestcontainersContainerTest.cs:line 107 at DotNet.Testcontainers.Tests.Unit.TestcontainersContainerTest.WithConfiguration.MacAddress() in /home/runner/work/testcontainers-dotnet/testcontainers-dotnet/tests/Testcontainers.Tests/Unit/Containers/Unix/TestcontainersContainerTest.cs:line 108
Solution
-
Benefit
-
Alternatives
-
Would you like to help contributing this enhancement?
Yes
- Lingua principale
- C#
- Stelle
- 4.4k
- Fork
- 366
- Merge medio
- 2g 6h
- PR unite (30g)
- 19
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di testcontainers/testcontainers-dotnet
-
[Bug]: Container with port binding that exits during startup throws TimeoutException after 15 s instead of ContainerNotRunningExceptionForse già presa @seragAhmed l’ha presa 16 giorni fa. Apertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
testcontainers/testcontainers-dotnet#1819 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Enhancement]: Add .NET MiniStack moduleForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertaenhancement module
Difficoltà 4/5 3-5 giorni Idoneità per principianti 24/100
testcontainers/testcontainers-dotnet#1804 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: First builder access synchronously waits for Docker discovery and can starve the thread poolForse già presa @arnelirobles l’ha presa 24 giorni fa. Apertabug
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
testcontainers/testcontainers-dotnet#1777 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Enhancement]: Support for TUnitForse già presa @zcsizmadia l’ha presa 77 giorni fa. Apertaenhancement module
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
testcontainers/testcontainers-dotnet#1766 · 2 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
[Enhancement]: DuckDB nuget packageForse già presa @rosian22 l’ha presa 84 giorni fa. Apertaenhancement module
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
testcontainers/testcontainers-dotnet#1749 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di testcontainers/testcontainers-dotnet
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Forrest-Technologies/drover#1374 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
erkamyaman/rust-anything#1381 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
arastella625/DAORework#280 ·
I maintainer di solito rispondono entro 1 giorno