testcontainers / testcontainers/testcontainers-java

[Bug]: Cannot parse Date when deserializing com.github.dockerjava.api.model.Network object

Abierto
#9,542 21 comentarios 4 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

resolution/waiting-for-info type/bug
Lenguaje dominante
Java
Estrellas
8.7k
Forks
1.9k
Merge medio
2 d 17 h
PR fusionados (30 d)
9

Descripción

Module

Core

Testcontainers version

1.20.3

Using the latest Testcontainers version?

Yes

Host OS

Ubuntu 20.04

Host Arch

x86_64

Docker version
Client:
 Version:           24.0.7
 API version:       1.43
 Go version:        go1.21.1
 Git commit:        24.0.7-0ubuntu2~20.04.1
 Built:             Wed Mar 13 20:29:24 2024
 OS/Arch:           linux/amd64
 Context:           default

Server:
 Engine:
  Version:          24.0.7
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.21.1
  Git commit:       24.0.7-0ubuntu2~20.04.1
  Built:            Wed Mar 13 20:29:24 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.12
  GitCommit:        
 runc:
  Version:          1.1.12-0ubuntu2~20.04.1
  GitCommit:        
 docker-init:
  Version:          0.19.0
  GitCommit:
What happened?

We have some integration tests written in Junit5 brining up a GenericContainer for end-to-end tests between components. When the tests are run in a host process the GenericContainer object is created successfully, but when tests are run within a container (like in Jenkins) the GenericContainer fails to build, throwing the exception reported in the log pane.

Debugging the code, it seems the GenericContainer fails to deserialize dates in com.github.dockerjava.api.model.Network object when inspecting the docker network. The date format returned with docker network inspect is indeed "2024-11-13T21:04:48.309416219+0100", but apparently the BaseSettings initialized in ObjectMapper uses a StdDateFormat that is not able to parse it.

Reverting the dependency to testcontainers 1.17.6 made it work. I think this could be a regression.

Relevant log output
java.lang.RuntimeException: org.testcontainers.shaded.com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not deserialize value of type java.util.Date from String "2024-11-13T21:04:48.309416219+01:00": not a valid representation (error: Failed to parse Date value '2024-11-13T21:04:48.309416219+01:00': Can not parse date "2024-11-13T21:04:48.309416219+0100": while it seems to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSSZ', parsing fails (leniency? null))

 at [Source: N/A; line: -1, column: -1] (through reference chain: com.github.dockerjava.api.model.Network["Created"])
	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.get(DefaultInvocationBuilder.java:77) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.shaded.com.github.dockerjava.core.exec.InspectNetworkCmdExec.execute(InspectNetworkCmdExec.java:26) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.shaded.com.github.dockerjava.core.exec.InspectNetworkCmdExec.execute(InspectNetworkCmdExec.java:12) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.shaded.com.github.dockerjava.core.exec.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:21) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.shaded.com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:33) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.shaded.com.github.dockerjava.core.command.InpectNetworkCmdImpl.exec(InpectNetworkCmdImpl.java:7) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.dockerclient.DockerClientProviderStrategy.resolveDockerHostIpAddress(DockerClientProviderStrategy.java:453) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.dockerclient.DockerClientProviderStrategy.getDockerHostIpAddress(DockerClientProviderStrategy.java:424) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.DockerClientFactory.dockerHostIpAddress(DockerClientFactory.java:344) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.ContainerState.getHost(ContainerState.java:64) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:112) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:901) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:492) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:346) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81) ~[duct-tape-1.0.8.jar:?]
	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:336) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:322) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.PortForwardingContainer.createSSHSession(PortForwardingContainer.java:43) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.PortForwardingContainer.getSshConnection(PortForwardingContainer.java:38) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.PortForwardingContainer.exposeHostPort(PortForwardingContainer.java:69) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.containers.PortForwardingContainer.exposeHostPort(PortForwardingContainer.java:63) ~[testcontainers-1.20.3.jar:1.20.3]
	at org.testcontainers.Testcontainers.exposeHostPorts(Testcontainers.java:14) ~[testcontainers-1.20.3.jar:1.20.3]
Additional Information

No response

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comience por DockerClientProviderStrategy.resolveDockerHostIpAddress e InspectNetworkCmdExec.execute en el stack trace y, a continuación, inspeccione la configuración de BaseSettings ObjectMapper descrita en el informe. Reproduzca la deserialización de Network con el formato de fecha de Docker mostrado y verifique que el inicio de GenericContainer se realiza correctamente sin la InvalidFormatException.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
docker, java
Área
devtools, testing-qa
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.