Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Issue with Docker Timeout During Testcontainers Integration #1244

Closed
asos-grainnemeyer opened this issue Aug 29, 2024 · 6 comments
Closed
Labels
question Have you tried our Slack workspace (https://testcontainers.slack.com)?

Comments

@asos-grainnemeyer
Copy link

Testcontainers version

3.9.0

Using the latest Testcontainers version?

Yes

Host OS

Windows

Host arch

64-bit

.NET version

8.0

Docker version

Client:
 Cloud integration: v1.0.24
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:09:02 2022
 OS/Arch:           windows/amd64
 Context:           default
 Experimental:      true

Server: Docker Desktop 4.10.1 (82475)
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:01:23 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.6
  GitCommit:        10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc:
  Version:          1.1.2
  GitCommit:        v1.1.2-0-ga916309
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.11.2)
  compose: Docker Compose (Docker Inc., v2.22.0)
  extension: Manages Docker extensions (Docker Inc., v0.2.7)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 1
 Server Version: 20.10.17
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc version: v1.1.2-0-ga916309
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.102.1-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 15.49GiB
 Name: docker-desktop
 ID: TWCV:742T:43ZL:VWVJ:3BP3:SYR2:I6OM:P6YM:QCUK:H4VW:N22Z:EBXV
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5000
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support

What happened?

I'm currently facing an issue while running tests using Testcontainers in my .NET project. The test in question is designed to validate an endpoint that should return a 400 status code when provided with an invalid information. However, I'm encountering a Docker-related exception that prevents the test from executing as expected.

The docker container is successfully running, but the tests never complete.

Any suggestions on how to troubleshoot or resolve this problem would be greatly appreciated!

Relevant log output

Docker.DotNet.DockerApiException : Docker API responded with status code=InternalServerError, response={"message":"Get \"https://mcr.microsoft.com/v2/\": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"}

Stack Trace:
DockerClient.HandleIfErrorResponseAsync(HttpStatusCode statusCode, HttpResponseMessage response)
DockerClient.MakeRequestForRawResponseAsync(HttpMethod method, String path, IQueryString queryString, IRequestContent body, IDictionary`2 headers, CancellationToken token)
StreamUtil.MonitorResponseForMessagesAsync[T](Task`1 responseTask, DockerClient client, CancellationToken cancel, IProgress`1 progress)
DockerImageOperations.CreateAsync(IImage image, IDockerRegistryAuthenticationConfiguration dockerRegistryAuthConfig, CancellationToken ct) line 74
TestcontainersClient.PullImageAsync(IImage image, CancellationToken ct) line 375
TestcontainersClient.RunAsync(IContainerConfiguration configuration, CancellationToken ct) line 303
DockerContainer.UnsafeCreateAsync(CancellationToken ct) line 413
DockerContainer.StartAsync(CancellationToken ct) line 277
ApiFactory`1.InitializeAsync() line 33

Additional information

No response

@asos-grainnemeyer asos-grainnemeyer added the bug Something isn't working label Aug 29, 2024
@HofmeisterAn
Copy link
Collaborator

The docker container is successfully running, but the tests never complete.

The stack trace does not align with this comment. It indicates that Testcontainers/Docker is failing to pull the image (cannot connect to the Docker registry). Are you using a private registry or a proxy? What image are you trying to pull? Could you try pulling the image manually using the command docker pull <image_name>?

@asos-grainnemeyer
Copy link
Author

Thanks - I'm using a public registry and the image is sheyenrath/wiremock.net. When I manually pulled the image it was successful but when running the tests, they never complete.

@HofmeisterAn
Copy link
Collaborator

but when running the tests, they never complete.

This sounds very much like a misconfigured wait strategy. If the wait strategy never indicates success, Testcontainers for .NET will keep retrying. What kind of wait strategy are you using?

Usually, it helps to debug the wait strategy to determine why it is failing. You can also set a timeout to check whether the issue lies with the wait strategy. For example:

WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged(/* Or any other wait strategy. */, o => o.WithTimeout(TimeSpan.FromSeconds(30))))

@HofmeisterAn HofmeisterAn added question Have you tried our Slack workspace (https://testcontainers.slack.com)? and removed bug Something isn't working labels Aug 29, 2024
@asos-grainnemeyer
Copy link
Author

Thanks - I added your suggestion for wait strategy and the tests time out.

The strange thing is that the tests are running and passing for my colleague so it seems to be a problem with my environment

@HofmeisterAn
Copy link
Collaborator

As I mentioned, it's probably best to debug the wait strategy (the UntilAsync(IContainer) method) and see why it's not working. I can't really help without more info — sorry. I at least need the details on the builder configuration, including the wait strategy.

@HofmeisterAn
Copy link
Collaborator

Unfortunately, without further information, I cannot help. I will close the issue for now. If you have additional details that can help us triage the issue, please do not hesitate to reopen it.

@HofmeisterAn HofmeisterAn closed this as not planned Won't fix, can't repro, duplicate, stale Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Have you tried our Slack workspace (https://testcontainers.slack.com)?
Projects
None yet
Development

No branches or pull requests

2 participants