Skip to content

Generic containers not starting #841

@darrenbeck-te

Description

@darrenbeck-te

Expected Behavior

In a gradle-kotlin project with version 4.4.5 of the io.micronaut.test-resources plugin, add a generic container definition to the application.properties config (wiremock in this case):

test-resources.containers.wiremock.image-name=wiremock/wiremock:3.1.0-1-alpine
test-resources.containers.wiremock.hostnames[0]=wiremock.host
test-resources.containers.wiremock.exposed-ports[0].wiremock.port=8080

Start the application with ./gradlew run and the defined wiremock container will start.

I can get the JDBC module working without issue, databases are started and the properties are resolved for the defined datasources, but generic containers don't seem to start.

I have tried to bind the resolved properties (wiremock.port and host in this case) to a component but that just causes startup to fail as they cannot be resolved.

I suspect I'm missing something here, but I can't work out what.

Actual Behaviour

The container does not start.

Enabling debug logging on the server shows the following output:

10:20:38.351 [main] INFO  i.m.c.DefaultApplicationContext$RuntimeConfiguredEnvironment - Established active environments: [test]
10:20:38.358 [ForkJoinPool.commonPool-worker-14] INFO  i.m.t.e.TestResourcesResolverLoader - Loaded 1 test resources resolvers: io.micronaut.testresources.testcontainers.GenericTestContainerProvider
10:20:38.397 [pool-1-thread-1] INFO  o.testcontainers.DockerClientFactory - Testcontainers version: 2.7.3
10:20:38.546 [pool-1-thread-1] INFO  o.t.d.DockerClientProviderStrategy - Loaded org.testcontainers.dockerclient.UnixSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first
10:20:38.705 [pool-1-thread-1] INFO  o.t.d.DockerClientProviderStrategy - Found Docker environment with local Unix socket (unix:///var/run/docker.sock)
10:20:38.707 [pool-1-thread-1] INFO  o.testcontainers.DockerClientFactory - Docker host IP address is localhost
10:20:38.724 [pool-1-thread-1] INFO  o.testcontainers.DockerClientFactory - Connected to docker: 
  Server Version: 28.0.0
  API Version: 1.48
  Operating System: Pop!_OS 22.04 LTS
  Total Memory: 31467 MB
10:20:38.735 [pool-1-thread-1] INFO  o.testcontainers.images.PullPolicy - Image pull policy will be performed by: DefaultPullPolicy()
10:20:38.736 [pool-1-thread-1] INFO  o.t.utility.ImageNameSubstitutor - Image name substitution will be performed by: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor')
10:20:38.750 [pool-1-thread-1] INFO  tc.testcontainers/ryuk:0.11.0 - Creating container for image: testcontainers/ryuk:0.11.0
10:20:38.890 [pool-1-thread-1] INFO  tc.testcontainers/ryuk:0.11.0 - Container testcontainers/ryuk:0.11.0 is starting: 152dfd99941a4fd83aebcbad872ced93d1e40494b26e6fb93ee1d30f2178fd42
10:20:39.083 [pool-1-thread-1] INFO  tc.testcontainers/ryuk:0.11.0 - Container testcontainers/ryuk:0.11.0 started in PT0.333488565S
10:20:39.087 [pool-1-thread-1] INFO  o.t.utility.RyukResourceReaper - Ryuk started - will monitor and terminate Testcontainers containers on JVM exit
10:20:39.087 [pool-1-thread-1] INFO  o.testcontainers.DockerClientFactory - Checking the system...
10:20:39.087 [pool-1-thread-1] INFO  o.testcontainers.DockerClientFactory - ✔︎ Docker server version should be at least 1.6.0
10:20:39.089 [main] DEBUG i.m.t.t.GenericTestContainerProvider - Properties which can be resolved by generic containers: []
10:20:39.090 [main] DEBUG i.m.t.t.GenericTestContainerProvider - Properties which can be resolved by generic containers: []
10:20:39.294 [scheduled-executor-thread-1] INFO  i.m.t.server.ExpiryManager - Test resources server will automatically be shutdown if it doesn't receive requests for 60 minutes
10:20:39.344 [main] INFO  io.micronaut.runtime.Micronaut - Startup completed in 1094ms. Server Running: http://localhost:43983
10:20:39.346 [main] DEBUG i.m.t.server.TestResourcesService - Wrote port 43983 to /home/darren/workspace/sandbox/micronaut/demo/.micronaut/test-resources/test-resources-port.txt
10:20:39.346 [main] INFO  i.m.t.server.TestResourcesService - A Micronaut Test Resources server is listening on port 43983, started in 1156ms
10:20:41.913 [virtual-executor2] DEBUG i.m.t.server.TestResourcesController - For configuration {containers.wiremock.image-name=wiremock/wiremock:3.1.0-1-alpine, containers.wiremock.exposed-ports[0].wiremock.port=8080, containers.wiremock.exposed-ports=[{wiremock.port=8080}], containers.wiremock.hostnames[0]=wiremock.host, containers.wiremock.hostnames=[wiremock.host]} and property entries {} , resolvable property: micronaut.test.resources.server.uri
10:20:41.915 [virtual-executor2] DEBUG i.m.t.t.GenericTestContainerProvider - Properties which can be resolved by generic containers: [wiremock.port, wiremock.host]
10:20:41.915 [virtual-executor2] DEBUG i.m.t.server.TestResourcesController - For configuration {containers.wiremock.image-name=wiremock/wiremock:3.1.0-1-alpine, containers.wiremock.exposed-ports[0].wiremock.port=8080, containers.wiremock.exposed-ports=[{wiremock.port=8080}], containers.wiremock.hostnames[0]=wiremock.host, containers.wiremock.hostnames=[wiremock.host]} and property entries {} , resolvable property: wiremock.port
10:20:41.915 [virtual-executor2] DEBUG i.m.t.server.TestResourcesController - For configuration {containers.wiremock.image-name=wiremock/wiremock:3.1.0-1-alpine, containers.wiremock.exposed-ports[0].wiremock.port=8080, containers.wiremock.exposed-ports=[{wiremock.port=8080}], containers.wiremock.hostnames[0]=wiremock.host, containers.wiremock.hostnames=[wiremock.host]} and property entries {} , resolvable property: wiremock.host
10:20:41.970 [virtual-executor3] DEBUG i.m.t.server.TestResourcesController - For configuration {} and property entries {} , resolvable property: micronaut.test.resources.server.uri
10:20:41.970 [virtual-executor3] DEBUG i.m.t.t.GenericTestContainerProvider - Properties which can be resolved by generic containers: []

Steps To Reproduce

Run the example application using:

./gradlew run

Environment Information

  • OS: Pop_OS 22.04
  • JDK: OpenJDK 21.0.4

Example Application

https://github.com/darrenbeck-te/micronaut-testresources-generic-test

Version

4.7.6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions