Change container wait strategy

Instead of waiting for a log message, wait for the listening port becoming available. After a bugfix in Testcontainers 1.5.1, this is now possible.
This commit is contained in:
Reinhard Prechtl 2017-12-26 20:34:04 +01:00
parent 8bae171833
commit a696af771b

View file

@ -6,17 +6,13 @@ import org.infinispan.client.hotrod.RemoteCacheManager;
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.hotrod.exceptions.HotRodClientException; import org.infinispan.client.hotrod.exceptions.HotRodClientException;
import org.junit.runner.Description; import org.junit.runner.Description;
import org.rnorth.ducttape.Preconditions;
import org.testcontainers.containers.BindMode; import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.LogMessageWaitStrategy; import org.testcontainers.containers.wait.Wait;
import java.time.Duration;
import java.util.*; import java.util.*;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import static java.time.temporal.ChronoUnit.SECONDS;
/** /**
* An implementation of the {@link org.testcontainers.containers.GenericContainer} class that can be * An implementation of the {@link org.testcontainers.containers.GenericContainer} class that can be
* used to easily instantiate an Infinispan server for integration tests. * used to easily instantiate an Infinispan server for integration tests.
@ -77,9 +73,7 @@ public class InfinispanContainer extends GenericContainer<InfinispanContainer> {
this.withCommand(STANDALONE_MODE_CMD); this.withCommand(STANDALONE_MODE_CMD);
withExposedPorts(Arrays.stream(InfinispanEndpoints.values()).map(endpoint -> endpoint.protocolPort).toArray(Integer[]::new)); withExposedPorts(Arrays.stream(InfinispanEndpoints.values()).map(endpoint -> endpoint.protocolPort).toArray(Integer[]::new));
this.waitStrategy = new LogMessageWaitStrategy() this.waitStrategy = Wait.forListeningPort();
.withRegEx(".*Infinispan Server.*started in.*\\s")
.withStartupTimeout(Duration.of(60, SECONDS));
} }
/** /**