testcontainers-dotnet icon indicating copy to clipboard operation
testcontainers-dotnet copied to clipboard

[Bug]: MsSqlBuilder constructor broken in 3.9

Open Hamiller78 opened this issue 1 year ago • 1 comments

Testcontainers version

3.9

Using the latest Testcontainers version?

Yes

Host OS

Windows (but also occurs in Linux Build Agent)

Host arch

x86

.NET version

.NET 7

Docker version

Client:
 Cloud integration: v1.0.31
 Version:           20.10.24
 API version:       1.41
 Go version:        go1.19.7
 Git commit:        297e128
 Built:             Tue Apr  4 18:28:08 2023
 OS/Arch:           windows/amd64
 Context:           default
 Experimental:      true

Server: Docker Desktop 4.18.0 (104112)
 Engine:
  Version:          20.10.24
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.19.7
  Git commit:       5d6db84
  Built:            Tue Apr  4 18:18:42 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.18
  GitCommit:        2456e983eb9e37e47538f59ea18f2043c9a73640
 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.4)
  compose: Docker Compose (Docker Inc., v2.17.2)
  dev: Docker Dev Environments (Docker Inc., v0.1.0)
  extension: Manages Docker extensions (Docker Inc., v0.2.19)
  init: Creates Docker-related starter files for your project (Docker Inc., v0.1.0-beta.2)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.25.0)
  scout: Command line tool for Docker Scout (Docker Inc., v0.9.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 7
 Server Version: 20.10.24
 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: 2456e983eb9e37e47538f59ea18f2043c9a73640
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.16.3-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 12
 Total Memory: 15.51GiB
 Name: docker-desktop
 ID: ALNS:VWVK:HCLB:T4ZJ:SH23:44E2:VJ5L:ORCV:VZOD:GCDB:5K22:GMCY
 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:5555
  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?

Hi!

our integration test code breaks with 3.9.

We initialize our test container like this:

    private readonly MsSqlContainer _container = new MsSqlBuilder()
        .WithImage("mcr.microsoft.com/mssql/server:2022-CU12-ubuntu-22.04")
        .WithPassword("***")
        .WithLogger(NullLogger<ContainerFactory>.Instance)
        .Build();

In our Dependabot branch to update from Testcontainers 3.8 to 3.9 this breaks. During test execution (building the project works fine) we get the exception (see log for original, I formatted it a bit nicer here):

Method not found: 
'Void DotNet.Testcontainers.Configurations.ContainerConfiguration..ctor(
  DotNet.Testcontainers.Images.IImage,
  System.Func`2<Docker.DotNet.Models.ImageInspectResponse,Boolean>,
  System.String,
  System.String,
  System.String,
  System.String,
  System.Collections.Generic.IEnumerable`1<System.String>,
  System.Collections.Generic.IEnumerable`1<System.String>,
  System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>,
  System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>,
  System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>,
  System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Configurations.IResourceMapping>,
  System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Containers.IContainer>,
  System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Configurations.IMount>,
  System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Networks.INetwork>,
  System.Collections.Generic.IEnumerable`1<System.String>,
  System.Collections.Generic.IEnumerable`1<System.String>,
  DotNet.Testcontainers.Configurations.IOutputConsumer,
  System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Configurations.IWaitUntil>,
  System.Func`3<DotNet.Testcontainers.Containers.IContainer,System.Threading.CancellationToken,System.Threading.Tasks.Task>,
  System.Nullable`1<Boolean>,
  System.Nullable`1<Boolean>)

I checked in your code base: In DotNet.Testcontainers.Configurations the constructor for ContainerConfiguration now takes a parameter of type IEnumerable<WaitStrategy> instead of IEnumerable<IWaitUntil>. I would expect that this doesn't matter since the constructor is not called explicitly and the parameter has null as a default, but here we are.

Could you check the issue? Perhaps it just needs changing back to the more general IEnumerable<IWaitUntil>? We'd appreciate it it very much.

Kind regards, Torben

Relevant log output

Message: 
OneTimeSetUp: System.MissingMethodException : Method not found: 'Void DotNet.Testcontainers.Configurations.ContainerConfiguration..ctor(DotNet.Testcontainers.Images.IImage, System.Func`2<Docker.DotNet.Models.ImageInspectResponse,Boolean>, System.String, System.String, System.String, System.String, System.Collections.Generic.IEnumerable`1<System.String>, System.Collections.Generic.IEnumerable`1<System.String>, System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>, System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>, System.Collections.Generic.IReadOnlyDictionary`2<System.String,System.String>, System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Configurations.IResourceMapping>, System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Containers.IContainer>, System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Configurations.IMount>, System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Networks.INetwork>, System.Collections.Generic.IEnumerable`1<System.String>, System.Collections.Generic.IEnumerable`1<System.String>, DotNet.Testcontainers.Configurations.IOutputConsumer, **System.Collections.Generic.IEnumerable`1<DotNet.Testcontainers.Configurations.IWaitUntil>**, System.Func`3<DotNet.Testcontainers.Containers.IContainer,System.Threading.CancellationToken,System.Threading.Tasks.Task>, System.Nullable`1<Boolean>, System.Nullable`1<Boolean>)'.

  Stack Trace: 
MsSqlConfiguration.ctor(String database, String username, String password)
MsSqlBuilder.ctor() line 21
ContainerFactory.ctor() line 22

Additional information

No response

Hamiller78 avatar Jun 28 '24 11:06 Hamiller78

Do you use multiple modules? Please make sure you update all dependencies to version 3.9.0.

HofmeisterAn avatar Jun 28 '24 20:06 HofmeisterAn

My bad, you're right. Normally I get seperate pull requests for each module of a package and immediately see when I have to update them together. Somehow I didn't get a pull request for Testcontainers.MsSql and overlooked it in ther global packages.props.

Thanks a lot! The tests worked after I increased the version for both modules.

Hamiller78 avatar Jul 01 '24 11:07 Hamiller78

Yes, this is an unfortunate issue. I am still unsure how to bypass it or at least mitigate it. Since modules always depend on a base version of Testcontainers, it is usually necessary to update all of them.

HofmeisterAn avatar Jul 10 '24 09:07 HofmeisterAn