Skip to content

Commit

Permalink
[#3336] improvement(test): make docker detection failure error messag…
Browse files Browse the repository at this point in the history
…es more clear (#3538)

### What changes were proposed in this pull request?

 - clarify OrbStack status
 - check the docker env before IT start

### Why are the changes needed?

The previous detection logic was located in the constructor, and when
the test failed, it would throw an exception
`ExceptionInInitializerError`, causing the original error to be covered.

Fix: #3336 

### Does this PR introduce _any_ user-facing change?

no

### How was this patch tested?

Locally, by hand
  • Loading branch information
mchades authored and web-flow committed May 24, 2024
1 parent 5c7cf8b commit f5478ee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ fun printDockerCheckInfo() {
println("Docker server status ............................................ [${if (dockerRunning) "running" else "stop"}]")
if (OperatingSystem.current().isMacOsX()) {
println("mac-docker-connector status ..................................... [${if (macDockerConnector) "running" else "stop"}]")
println("OrbStack status ................................................. [${if (isOrbStack) "yes" else "no"}]")
println("OrbStack status ................................................. [${if (dockerRunning && isOrbStack) "yes" else "no"}]")
}

val docker_it_test = project.extra["docker_it_test"] as? Boolean ?: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public class ContainerSuite implements Closeable {

protected static final CloseableGroup closer = CloseableGroup.create();

private ContainerSuite() {
private static void init() {
try {
// Check if docker is available
// Check if docker is available and you should never close the global DockerClient!
DockerClient dockerClient = DockerClientFactory.instance().client();
Info info = dockerClient.infoCmd().exec();
LOG.info("Docker info: {}", info);
Expand All @@ -70,6 +70,7 @@ public static ContainerSuite getInstance() {
if (instance == null) {
synchronized (ContainerSuite.class) {
if (instance == null) {
init();
instance = new ContainerSuite();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
public class CloseContainerExtension implements BeforeAllCallback {
@Override
public void beforeAll(ExtensionContext extensionContext) {
// Ensure that the container suite is initialized before closing it
ContainerSuite.getInstance();
synchronized (CloseContainerExtension.class) {
extensionContext
.getRoot()
Expand Down

0 comments on commit f5478ee

Please sign in to comment.