testcontainers-dotnet: [Bug]: Working with MsSql Container getting `Initialization has been cancelled` exception
Testcontainers version
2.4.0
Using the latest Testcontainers version?
Yes
Host OS
Windows
Host arch
x64
.NET version
7.0.3
Docker version
Client:
Cloud integration: v1.0.29
Version: 20.10.22
API version: 1.41
Go version: go1.18.9
Git commit: 3a2c30b
Built: Thu Dec 15 22:36:18 2022
OS/Arch: windows/amd64
Context: default
Experimental: true
Server: Docker Desktop 4.16.3 (96739)
Engine:
Version: 20.10.22
API version: 1.41 (minimum version 1.12)
Go version: go1.18.9
Git commit: 42c8b31
Built: Thu Dec 15 22:26:14 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.14
GitCommit: 9ba4b250366a5ddde94bb7c9d1def331423aa323
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Docker info
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.10.0)
compose: Docker Compose (Docker Inc., v2.15.1)
dev: Docker Dev Environments (Docker Inc., v0.0.5)
extension: Manages Docker extensions (Docker Inc., v0.2.17)
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
scan: Docker Scan (Docker Inc., v0.23.0)
Server:
Containers: 5
Running: 0
Paused: 0
Stopped: 5
Images: 17
Server Version: 20.10.22
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: runc io.containerd.runc.v2 io.containerd.runtime.v1.linux
Default Runtime: runc
Init Binary: docker-init
containerd version: 9ba4b250366a5ddde94bb7c9d1def331423aa323
runc version: v1.1.4-0-g5fd4c4d
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: 12
Total Memory: 31.23GiB
Name: docker-desktop
ID: 4ISY:LGCG:5LYK:ITFR:XEMK:7OQS:4G7R:YW2W:VZJV:OECG:XLT3:GL6G
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 try to create a simple sample test. However I get an exception. DotNet.Testcontainers.Containers.ResourceReaperException : Initialization has been cancelled.
Docker logs not shown much information:
PS C:\Users\ismai> docker logs --follow testcontainers-ryuk-2780f9f8-55e4-4a1d-8d3a-efdc05c5a2ba
2023/02/19 19:37:20 Pinging Docker...
2023/02/19 19:37:20 Docker daemon is available!
2023/02/19 19:37:20 Starting on port 8080...
2023/02/19 19:37:20 Started!
panic: Timed out waiting for the first connection
goroutine 1 [running]:
main.main()
/go/src/github.com/testcontainers/moby-ryuk/main.go:53 +0x4da
Relevant log output
No response
Additional information
My all test code is here.
using DotNet.Testcontainers.Builders;
using DotNet.Testcontainers.Configurations;
using DotNet.Testcontainers.Containers;
using Microsoft.Data.SqlClient;
namespace TestProject1;
public sealed class MsSqlTest : IAsyncLifetime {
private static readonly ContainerBuilder<MsSqlTestcontainer> testcontainersBuilder = new ContainerBuilder<MsSqlTestcontainer>();
private static readonly MsSqlTestcontainer customUserEntityDatabase = testcontainersBuilder.WithDatabase(new MsSqlTestcontainerConfiguration {
Password = "localdevpassword#123",
Database = "TestDatabase"
}).WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(1433))
.Build();
public async Task DisposeAsync() {
await customUserEntityDatabase.DisposeAsync();
}
public async Task InitializeAsync() {
await customUserEntityDatabase.StartAsync();
}
[Fact]
public async Task ShouldUseDefaultImageWhenImageIsNotSpecifiedAsync() {
await InitContainerTestAsync();
}
private async Task InitContainerTestAsync() {
using (var connection = new SqlConnection($"{customUserEntityDatabase.ConnectionString}TrustServerCertificate=true;")) {
connection.Open();
using (SqlCommand command = new SqlCommand("SELECT '1'", connection)) {
using (SqlDataReader reader = command.ExecuteReader()) {
while (reader.Read()) {
Console.WriteLine("{0}", reader.GetString(0));
}
}
}
}
}
}
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 19
Since we now have the new release, I will close this issue. Let’s see if it reappears 🤞.