Closed azan-n closed 1 month ago
This is not a bug. You need to configure your Colima environment properly. There are plenty of similar questions regarding this topic. Please use the search function. If you need further help, let me know. I can assist as soon as I am back from vacation.
Setting the CollectionDefinition with DisableParallelization = true
as suggested here leads to
rror Message:
System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
at DotNet.Testcontainers.Containers.DockerContainer.WaitUntilPortBindingsMapped.UntilAsync(IContainer _, CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 570
at DotNet.Testcontainers.Containers.DockerContainer.CheckReadinessAsync(WaitStrategy waitStrategy, CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 532
at DotNet.Testcontainers.Configurations.WaitStrategy.<>c__DisplayClass24_0.<<WaitUntilAsync>g__UntilAsync|0>d.MoveNext() in /_/src/Testcontainers/Configurations/WaitStrategies/WaitStrategy.cs:line 184
--- End of stack trace from previous location ---
at DotNet.Testcontainers.Configurations.WaitStrategy.WaitUntilAsync(Func`1 wait, TimeSpan interval, TimeSpan timeout, Int32 retries, CancellationToken ct) in /_/src/Testcontainers/Configurations/WaitStrategies/WaitStrategy.cs:line 213
at DotNet.Testcontainers.Containers.DockerContainer.CheckReadinessAsync(IEnumerable`1 waitStrategies, CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 550
at DotNet.Testcontainers.Containers.DockerContainer.UnsafeStartAsync(CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 467
at DotNet.Testcontainers.Containers.DockerContainer.StartAsync(CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 280
at DotNet.Testcontainers.Containers.ResourceReaper.GetAndStartNewAsync(Guid sessionId, IDockerEndpointAuthenticationConfiguration dockerEndpointAuthConfig, IImage resourceReaperImage, IMount dockerSocket, ILogger logger, Boolean requiresPrivilegedMode, TimeSpan initTimeout, CancellationToken ct) in /_/src/Testcontainers/Containers/ResourceReaper.cs:line 219
at DotNet.Testcontainers.Containers.ResourceReaper.GetAndStartNewAsync(Guid sessionId, IDockerEndpointAuthenticationConfiguration dockerEndpointAuthConfig, IImage resourceReaperImage, IMount dockerSocket, ILogger logger, Boolean requiresPrivilegedMode, TimeSpan initTimeout, CancellationToken ct) in /_/src/Testcontainers/Containers/ResourceReaper.cs:line 243
at DotNet.Testcontainers.Containers.ResourceReaper.GetAndStartDefaultAsync(IDockerEndpointAuthenticationConfiguration dockerEndpointAuthConfig, ILogger logger, Boolean isWindowsEngineEnabled, CancellationToken ct) in /_/src/Testcontainers/Containers/ResourceReaper.cs:line 135
at DotNet.Testcontainers.Clients.TestcontainersClient.RunAsync(IContainerConfiguration configuration, CancellationToken ct) in /_/src/Testcontainers/Clients/TestcontainersClient.cs:line 294
at DotNet.Testcontainers.Containers.DockerContainer.UnsafeCreateAsync(CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 413
at DotNet.Testcontainers.Containers.DockerContainer.StartAsync(CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 277
at CryptlexWebApi.IntegrationTests.CryptlexWebApiFactory.InitializeAsync()
I'm guessing I should try working with https://dotnet.testcontainers.org/examples/dind/
Unfortunately, I do not remember which steps are necessary, and I maybe mixed them up with the issues related to Podman. Nonetheless, using other container runtimes besides Docker requires additional configurations. Since I do not have access to a Mac, I am unable to update the documentation accordingly. However, the Testcontainers for Go docs (https://github.com/testcontainers/testcontainers-dotnet/discussions/689) might provide some guidance. Please refer to the documentation at:
If you're using an older version of Colima or have other applications that are unaware of Docker context the following workaround is available:
Testcontainers for .NET currently lacks the ability to resolve the context. Additionally, please note the following limitation with Colima: https://github.com/testcontainers/testcontainers-dotnet/issues/1085#issuecomment-1881561417. Hope that helps.
This was a part of an urgent POC. Switching from Colima to Docker Desktop worked.
Testcontainers version
3.9.0
Using the latest Testcontainers version?
Yes
Host OS
macOS
Host arch
arm64
.NET version
8.0
Docker version
Docker info
What happened?
Created a new project to try testcontainers for integration testing. The project has one test that only uses the WebApplicationFactory, a very minimal setup for it to be anything else.
The test suite does not error (at least not due to testcontainers) after calling the following:
Relevant log output
Additional information
The WebApplicationFactory is supposed to be used through a
ICollectionFixture
instead of the more conventionally usedIClassFixture
.