org.testcontainers.containers.wait.strategy.WaitAllStrategy Java Examples
The following examples show how to use
org.testcontainers.containers.wait.strategy.WaitAllStrategy.
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: Neo4jContainer.java From testcontainers-java with MIT License | 6 votes |
/** * Creates a Testcontainer using a specific docker image. * * @param dockerImageName The docker image to use. */ public Neo4jContainer(String dockerImageName) { super(dockerImageName); WaitStrategy waitForBolt = new LogMessageWaitStrategy() .withRegEx(String.format(".*Bolt enabled on 0\\.0\\.0\\.0:%d\\.\n", DEFAULT_BOLT_PORT)); WaitStrategy waitForHttp = new HttpWaitStrategy() .forPort(DEFAULT_HTTP_PORT) .forStatusCodeMatching(response -> response == HTTP_OK); this.waitStrategy = new WaitAllStrategy() .withStrategy(waitForBolt) .withStrategy(waitForHttp) .withStartupTimeout(Duration.ofMinutes(2)); addExposedPorts(DEFAULT_BOLT_PORT, DEFAULT_HTTP_PORT, DEFAULT_HTTPS_PORT); }
Example #2
Source File: OrientDBContainer.java From testcontainers-java with MIT License | 6 votes |
public OrientDBContainer(@NonNull String dockerImageName) { super(dockerImageName); serverPassword = DEFAULT_SERVER_PASSWORD; databaseName = DEFAULT_DATABASE_NAME; WaitStrategy waitForHttp = new HttpWaitStrategy() .forPort(DEFAULT_HTTP_PORT) .forStatusCodeMatching(response -> response == HTTP_OK); waitStrategy = new WaitAllStrategy() .withStrategy(Wait.forListeningPort()) .withStrategy(waitForHttp) .withStartupTimeout(Duration.ofMinutes(2)); addExposedPorts(DEFAULT_BINARY_PORT, DEFAULT_HTTP_PORT); }
Example #3
Source File: DockerSwiftContainer.java From james-project with Apache License 2.0 | 6 votes |
public DockerSwiftContainer() { this.swiftContainer = new GenericContainer<>(SWIFT_DOCKER_IMAGE); this.swiftContainer .withExposedPorts(KEYSTONE_ADMIN_PORT) .withExposedPorts(SWIFT_PORT) .withLogConsumer(DockerSwiftContainer::displayDockerLog) .waitingFor( new WaitAllStrategy() .withStrategy( forHttp("/v3") .forPort(KEYSTONE_ADMIN_PORT) .forStatusCode(200) .withRateLimiter(RateLimiters.TWENTIES_PER_SECOND) ).withStrategy( forHttp("/info") .forPort(SWIFT_PORT) .forStatusCode(200) .withRateLimiter(RateLimiters.TWENTIES_PER_SECOND) ) ); }
Example #4
Source File: Standard.java From presto with Apache License 2.0 | 5 votes |
@SuppressWarnings("resource") private DockerContainer createTestsContainer() { DockerContainer container = new DockerContainer("prestodev/centos6-oj8:" + imagesVersion) .withCopyFileToContainer(forHostPath(dockerFiles.getDockerFilesHostPath()), "/docker/presto-product-tests") .withCommand("bash", "-xeuc", "echo 'No command provided' >&2; exit 69") .waitingFor(new WaitAllStrategy()) // don't wait .withStartupCheckStrategy(new IsRunningStartupCheckStrategy()); return container; }
Example #5
Source File: PulsarContainer.java From testcontainers-java with MIT License | 5 votes |
@Override protected void configure() { super.configure(); if (functionsWorkerEnabled) { withCommand("/pulsar/bin/pulsar", "standalone"); waitingFor( new WaitAllStrategy() .withStrategy(waitStrategy) .withStrategy(Wait.forLogMessage(".*Function worker service started.*", 1)) ); } }
Example #6
Source File: InfluxDBContainer.java From testcontainers-java with MIT License | 5 votes |
public InfluxDBContainer(final String version) { super(IMAGE_NAME + ":" + version); waitStrategy = new WaitAllStrategy() .withStrategy(Wait.forHttp("/ping").withBasicCredentials(username, password).forStatusCode(204)) .withStrategy(Wait.forListeningPort()); addExposedPort(INFLUXDB_PORT); }
Example #7
Source File: BrowserWebDriverContainer.java From testcontainers-java with MIT License | 5 votes |
/** */ public BrowserWebDriverContainer() { final WaitStrategy logWaitStrategy = new LogMessageWaitStrategy() .withRegEx(".*(RemoteWebDriver instances should connect to|Selenium Server is up and running).*\n") .withStartupTimeout(Duration.of(15, SECONDS)); this.waitStrategy = new WaitAllStrategy() .withStrategy(logWaitStrategy) .withStrategy(new HostPortWaitStrategy()) .withStartupTimeout(Duration.of(15, SECONDS)); this.withRecordingFileFactory(new DefaultRecordingFileFactory()); }
Example #8
Source File: CouchbaseContainer.java From testcontainers-java with MIT License | 5 votes |
@Override protected void configure() { super.configure(); WaitAllStrategy waitStrategy = new WaitAllStrategy(); // Makes sure that all nodes in the cluster are healthy. waitStrategy = waitStrategy.withStrategy( new HttpWaitStrategy() .forPath("/pools/default") .forPort(MGMT_PORT) .withBasicCredentials(username, password) .forStatusCode(200) .forResponsePredicate(response -> { try { return Optional.of(MAPPER.readTree(response)) .map(n -> n.at("/nodes/0/status")) .map(JsonNode::asText) .map("healthy"::equals) .orElse(false); } catch (IOException e) { logger().error("Unable to parse response {}", response); return false; } }) ); if (enabledServices.contains(CouchbaseService.QUERY)) { waitStrategy = waitStrategy.withStrategy( new HttpWaitStrategy() .forPath("/admin/ping") .forPort(QUERY_PORT) .withBasicCredentials(username, password) .forStatusCode(200) ); } waitingFor(waitStrategy); }
Example #9
Source File: DockerRabbitMQ.java From james-project with Apache License 2.0 | 5 votes |
private WaitStrategy waitStrategy() { return new WaitAllStrategy() .withStrategy(Wait.forHttp("").forPort(DEFAULT_RABBITMQ_ADMIN_PORT) .withRateLimiter(RateLimiters.TWENTIES_PER_SECOND) .withStartupTimeout(TEN_MINUTES_TIMEOUT)) .withStrategy(new RabbitMQWaitStrategy(this, TEN_MINUTES_TIMEOUT)) .withStartupTimeout(TEN_MINUTES_TIMEOUT); }
Example #10
Source File: DockerComposeContainer.java From testcontainers-java with MIT License | 4 votes |
private void waitUntilServiceStarted(String serviceName, ComposeServiceWaitStrategyTarget serviceInstance) { final WaitAllStrategy waitAllStrategy = waitStrategyMap.get(serviceName); if (waitAllStrategy != null) { waitAllStrategy.waitUntilReady(serviceInstance); } }
Example #11
Source File: DockerComposeContainer.java From testcontainers-java with MIT License | 4 votes |
private void addWaitStrategy(String serviceInstanceName, @NonNull WaitStrategy waitStrategy) { final WaitAllStrategy waitAllStrategy = waitStrategyMap.computeIfAbsent(serviceInstanceName, __ -> new WaitAllStrategy(WaitAllStrategy.Mode.WITH_MAXIMUM_OUTER_TIMEOUT).withStartupTimeout(Duration.ofMinutes(30))); waitAllStrategy.withStrategy(waitStrategy); }