[Enhancement]: JdbcDatabaseContainer - Improve ``waitUntilContainerStarted``
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
Comienza en modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java, especialmente en waitUntilContainerStarted, y lee las API existentes de WaitStrategy y AbstractWaitStrategy. Añade la estrategia específica de JDBC y la estrategia combinada predeterminada descritas en el issue; se considera terminado cuando el inicio usa el rate limiter configurado y deja de realizar el antiguo comportamiento de polling o de sobrescritura hardcodeado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Module
Core
Proposal
Currently https://github.com/testcontainers/testcontainers-java/blob/7d8301903a6b45591605fd376702d24fc878a61d/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java#L176-L216 behaves very weird and this also impacts performance:
- It doesn't utilize
WaitStrategyand completely ignores/overrides it - It constantly tries to query if the container is running or builds database connections (these are very costly in terms of CPU usage)
- These attempts use a hardcoded throttling value of 100ms and completely ignore the RateLimiter of
WaitStrategy
- These attempts use a hardcoded throttling value of 100ms and completely ignore the RateLimiter of
I would propose that you use - as in all other containers - the WaitStrategy.
- Remove the override/method
JdbcDatabaseContainer#waitUntilContainerStarted - Create a custom WaitStrategy called
JDBCWaitStrategy. It could look like this:class JDBCWaitStrategy extends AbstractWaitStrategy { @Override protected void waitUntilReady() { if(!(this.waitStrategyTarget instanceof final JdbcDatabaseContainer<?> container)) { throw new IllegalArgumentException( "Container must implement JdbcDatabaseContainer"); } try { Unreliables.retryUntilTrue( (int)this.startupTimeout.getSeconds(), TimeUnit.SECONDS, () -> this.getRateLimiter().getWhenReady(() -> { try(final Connection connection = container.createConnection(""); final Statement statement = connection.createStatement()) { return statement.execute(container.getTestQueryString()); } }) ); } catch(final TimeoutException e) { throw new ContainerLaunchException( "JDBCContainer cannot be accessed by (JDBC URL: " + container.getJdbcUrl() + "), please check container logs"); } } } - Use the following default WaitStrategy for JDBCDatabaseContainer:
new WaitAllStrategy() .withStrategy(Wait.defaultWaitStrategy()) .withStrategy(new JDBCWaitStrategy())
Full example implementation:
- https://github.com/xdev-software/tci-base/blob/13ca7984f6a732981cbd1912d9535076969004fa/tci-advanced-demo/tci-db/src/main/java/software/xdev/tci/demo/tci/db/containers/WaitableJDBCContainer.java
- https://github.com/xdev-software/tci-base/blob/13ca7984f6a732981cbd1912d9535076969004fa/tci-advanced-demo/tci-db/src/main/java/software/xdev/tci/demo/tci/db/containers/DBContainer.java
- Lenguaje dominante
- Java
- Estrellas
- 8.8k
- Forks
- 2k
- Merge medio
- 5 d 21 h
- PR fusionados (30 d)
- 15
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de testcontainers/testcontainers-java
-
[Bug]: withStartupTimeout() changes the startup timeout of all containers that use the default wait strategyPosiblemente ocupada @aymenjamaaoui la tomó hace 1 día. Abiertotype/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
testcontainers/testcontainers-java#12171 ·
Los mantenedores suelen responder en 1 día
-
[Enhancement]: Document why singleton containers are required under Spring's test context cachingPosiblemente ocupada @zakaullah075 la tomó hace 95 días. Abiertotype/enhancement
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
testcontainers/testcontainers-java#11967 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Bug]: Cannot reuse Selenium BrowserWebDriverContainers under LinuxPosiblemente ocupada @kdelay la tomó hace 116 días. Abiertotype/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
testcontainers/testcontainers-java#11941 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: DockerDesktopClientProviderStrategy is always applicablePosiblemente ocupada @seonwooj0810 la tomó hace 165 días. Abiertotype/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
testcontainers/testcontainers-java#11829 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Enhancement]: cleanup document after removing junit4 supportPosiblemente ocupada @SJvaca30 la tomó hace 173 días. Abiertotype/enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
testcontainers/testcontainers-java#11578 ·
Los mantenedores suelen responder en 1 día
Todos los issues de testcontainers/testcontainers-java
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
yegor256/jping#122 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
SAP/ai-sdk-java#1206 ·
Los mantenedores suelen responder en 1 día
-
enhancement good first issue insight-module
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
sdlc-pro/spring-lens#606 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
apache/cloudstack#14719 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
apache/maven-surefire#3605 ·
Los mantenedores suelen responder en 1 día