-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add a workaround for testcontainers/testcontainers-java#6441 (#152)
Adds a workaround for testcontainers/testcontainers-java#6441 issue. The issue happens when Docker was unavailable during the first attempt to start a container. All future attempts will fail, since `testcontainers` caches the connection attempt result in a static variable, so the state will persist while the class is loaded. The workaround is to reset the state through reflection each time before we start the container.
- Loading branch information
Showing
6 changed files
with
79 additions
and
21 deletions.
There are no files selected for viewing
20 changes: 9 additions & 11 deletions
20
artifact-tests/src/test/kotlin/dev/monosoul/jooq/artifact/GradleContainer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...s/src/test/kotlin/dev/monosoul/jooq/artifact/WorksAfterFailingToFindDockerArtifactTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package dev.monosoul.jooq.artifact | ||
|
||
import org.junit.jupiter.api.Test | ||
import org.testcontainers.utility.MountableFile.forClasspathResource | ||
import strikt.api.expect | ||
import strikt.assertions.contains | ||
import strikt.assertions.isSuccess | ||
|
||
class WorksAfterFailingToFindDockerArtifactTest { | ||
|
||
@Test | ||
fun `should be possible to generate jooq classes even after it failed on first attempt`() { | ||
// given | ||
val gradleContainer = GradleContainer(dockerSocketPath = "/var/run/docker-alt.sock").apply { | ||
withEnv("TESTCONTAINERS_RYUK_DISABLED", "true") | ||
withCopyToContainer(forClasspathResource("/testproject"), projectPath) | ||
withCopyToContainer(forClasspathResource("/gradle_run.sh"), "/gradle_run.sh") | ||
withCommand("/gradle_run.sh") | ||
} | ||
|
||
// when & then | ||
expect { | ||
catching { | ||
gradleContainer.start() | ||
gradleContainer.stop() | ||
}.isSuccess() | ||
|
||
that(gradleContainer.output).contains("BUILD SUCCESSFUL in ") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
gradle classes --info --stacktrace | ||
|
||
export DOCKER_HOST=unix:///var/run/docker-alt.sock | ||
export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker-alt.sock | ||
|
||
gradle classes --info --stacktrace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters