Skip to content

[Bug]: MockServerContainer Doesn't Get Reused #6084

@akefirad

Description

@akefirad

Module

MockServer

Testcontainers version

1.17.5

Using the latest Testcontainers version?

Yes

Host OS

macOS

Host Arch

x86

Docker version

Client:
 Cloud integration: v1.0.22
 Version:           20.10.12
 API version:       1.41
 Go version:        go1.16.12
 Git commit:        e91ed57
 Built:             Mon Dec 13 11:46:56 2021
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.12
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.12
  Git commit:       459d0df
  Built:            Mon Dec 13 11:43:56 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

What happened?

I've got two test-containers set up in my tests, LocalStack and MockServer. Both of them are configured withReuse(true) but for some reason MockServer container stops after tests are executed. I also noticed something else; when I start the containers in one process and run the tests in another process, LocalStack container works without any issue and stays running (next to Ryuk container) after tests are executed, but MockServer stops right after tests are done. I couldn't find anything helpful as to what could be the issue:

  1. I created the container using directly GenericContainer class, same behavior.
  2. I Replace MockServer with WireMock (via GenericContainer) and it behaves as expected (similar to LocalStack), stays running after tests are done in another process, and also respects the reuse flag.

Relevant log output

There's not much log, only one line (apart from the startup logs):
> 19:59:50.278 [,] [docker-java-stream--1211111146] INFO  w.infra.containers.MockServer - STDOUT: 2022-11-01 18:59:50 5.14.0 INFO stopped for port: 1080

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions