Skip to content

Commit

Permalink
Display Ryuk logs when it fails to start (#4842)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergei Egorov <bsideup@gmail.com>
Co-authored-by: Vincent MIJOULE (contractor) <vincent.mijoule@amadeus.com>
Co-authored-by: Richard North <rich.north@gmail.com>
  • Loading branch information
4 people committed Jan 5, 2022
1 parent e597f4a commit 3c30a26
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions core/src/main/java/org/testcontainers/utility/ResourceReaper.java
Expand Up @@ -34,7 +34,6 @@
import java.net.Socket;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -133,25 +132,31 @@ public void onNext(Frame frame) {
}
});

ContainerState containerState = new ContainerState() {

InspectContainerResponse inspectedContainer;
try {
// inspect container response might initially not contain the mapped port
final InspectContainerResponse inspectedContainer = await()
inspectedContainer = await()
.atMost(5, TimeUnit.SECONDS)
.pollInterval(DynamicPollInterval.ofMillis(50))
.pollInSameThread()
.until(
() -> client.inspectContainerCmd(ryukContainerId).exec(),
inspectContainerResponse -> {
return inspectContainerResponse
.getNetworkSettings()
.getPorts()
.getBindings()
.values()
.stream()
.anyMatch(Objects::nonNull);
.getNetworkSettings()
.getPorts()
.getBindings()
.values()
.stream()
.anyMatch(Objects::nonNull);
}
);
} catch (Exception e) {
log.warn("Ryuk container cannot be inspected and probably had a problem starting. Ryuk's logs:\n{}", ryukLog);
throw new IllegalStateException("Ryuk failed to start", e);
}

ContainerState containerState = new ContainerState() {

@Override
public List<Integer> getExposedPorts() {
Expand Down

0 comments on commit 3c30a26

Please sign in to comment.