org.testcontainers.containers.wait.strategy.AbstractWaitStrategy Java Examples

The following examples show how to use org.testcontainers.containers.wait.strategy.AbstractWaitStrategy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EtcdContainer.java    From etcd4j with Apache License 2.0 6 votes vote down vote up
private WaitStrategy waitStrategy() {
    return new AbstractWaitStrategy() {
        @Override
        protected void waitUntilReady() {
            final DockerClient client = DockerClientFactory.instance().client();
            final WaitingConsumer waitingConsumer = new WaitingConsumer();

            LogUtils.followOutput(client, waitStrategyTarget.getContainerId(), waitingConsumer);

            try {
                waitingConsumer.waitUntil(
                    f -> f.getUtf8String().contains("etcdserver: published"),
                    startupTimeout.getSeconds(),
                    TimeUnit.SECONDS,
                    1
                );
            } catch (TimeoutException e) {
                throw new ContainerLaunchException("Timed out");
            }
        }
    };
}