use of org.testcontainers.containers.wait.internal.InternalCommandPortListeningCheck in project testcontainers-java by testcontainers.
the class HostPortWaitStrategy method waitUntilReady.
@Override
protected void waitUntilReady() {
final Set<Integer> externalLivenessCheckPorts = getLivenessCheckPorts();
if (externalLivenessCheckPorts.isEmpty()) {
log.debug("Liveness check ports of {} is empty. Not waiting.", waitStrategyTarget.getContainerInfo().getName());
return;
}
@SuppressWarnings("unchecked") List<Integer> exposedPorts = waitStrategyTarget.getExposedPorts();
final Set<Integer> internalPorts = getInternalPorts(externalLivenessCheckPorts, exposedPorts);
Callable<Boolean> internalCheck = new InternalCommandPortListeningCheck(waitStrategyTarget, internalPorts);
Callable<Boolean> externalCheck = new ExternalPortListeningCheck(waitStrategyTarget, externalLivenessCheckPorts);
try {
Unreliables.retryUntilTrue((int) startupTimeout.getSeconds(), TimeUnit.SECONDS, () -> getRateLimiter().getWhenReady(() -> internalCheck.call() && externalCheck.call()));
} catch (TimeoutException e) {
throw new ContainerLaunchException("Timed out waiting for container port to open (" + waitStrategyTarget.getContainerIpAddress() + " ports: " + externalLivenessCheckPorts + " should be listening)");
}
}
Aggregations