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

The following examples show how to use org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy. 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: SyndesisS2iAssemblyContainer.java    From syndesis with Apache License 2.0 6 votes vote down vote up
public SyndesisS2iAssemblyContainer(String integrationName, Path projectDir, String imageTag) {
    super(new ImageFromDockerfile(integrationName + "-s2i", true)
        .withFileFromPath(SRC_DIR, projectDir)
        .withDockerfileFromBuilder(builder -> builder.from(String.format("syndesis/syndesis-s2i:%s", imageTag))
            .withStatement(new MultiArgsStatement("ADD", SRC_DIR, SRC_DIR))
            .user("0")
            .run("chown", "-R", "1000", SRC_DIR)
            .user("1000")
            .cmd(S2I_ASSEMBLE_SCRIPT)
            .build()));

    final WaitStrategy onLogDone = new LogMessageWaitStrategy()
        .withRegEx(".*\\.\\.\\. done.*\\s")
        .withStartupTimeout(SyndesisTestEnvironment.getContainerStartupTimeout());

    setWaitStrategy(onLogDone);
}
 
Example #2
Source File: Neo4jContainer.java    From testcontainers-java with MIT License 6 votes vote down vote up
/**
 * 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 #3
Source File: Db2Container.java    From testcontainers-java with MIT License 5 votes vote down vote up
public Db2Container(String imageName) {
    super(imageName);
    withPrivilegedMode(true);
    this.waitStrategy = new LogMessageWaitStrategy()
            .withRegEx(".*Setup has completed\\..*")
            .withStartupTimeout(Duration.of(10, ChronoUnit.MINUTES));

    addExposedPort(DB2_PORT);
}
 
Example #4
Source File: BrowserWebDriverContainer.java    From testcontainers-java with MIT License 5 votes vote down vote up
/**
 */
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 #5
Source File: PostgreSQLContainer.java    From testcontainers-java with MIT License 5 votes vote down vote up
public PostgreSQLContainer(final String dockerImageName) {
    super(dockerImageName);
    this.waitStrategy = new LogMessageWaitStrategy()
            .withRegEx(".*database system is ready to accept connections.*\\s")
            .withTimes(2)
            .withStartupTimeout(Duration.of(60, SECONDS));
    this.setCommand("postgres", "-c", FSYNC_OFF_OPTION);

    addExposedPort(POSTGRESQL_PORT);
}
 
Example #6
Source File: PrestoContainer.java    From testcontainers-java with MIT License 5 votes vote down vote up
public PrestoContainer(final String dockerImageName) {
    super(dockerImageName);
    this.waitStrategy = new LogMessageWaitStrategy()
        .withRegEx(".*io.prestosql.server.PrestoServer\\s+======== SERVER STARTED ========.*")
        .withStartupTimeout(Duration.of(60, SECONDS));

    addExposedPort(PRESTO_PORT);
}
 
Example #7
Source File: SolrContainer.java    From testcontainers-java with MIT License 5 votes vote down vote up
public SolrContainer(final String dockerImageName) {
    super(dockerImageName);
    this.waitStrategy = new LogMessageWaitStrategy()
        .withRegEx(".*o\\.e\\.j\\.s\\.Server Started.*")
        .withStartupTimeout(Duration.of(60, SECONDS));
    this.configuration = new SolrContainerConfiguration();
}
 
Example #8
Source File: VncRecordingContainer.java    From testcontainers-java with MIT License 5 votes vote down vote up
/**
 * Create a sidekick container and attach it to another container. The VNC output of that container will be recorded.
 */
public VncRecordingContainer(@NonNull Network network, @NonNull String targetNetworkAlias) throws IllegalStateException {
    super(TestcontainersConfiguration.getInstance().getVncRecordedContainerImage());

    this.targetNetworkAlias = targetNetworkAlias;
    withNetwork(network);
    waitingFor(new LogMessageWaitStrategy()
        .withRegEx(".*Connected.*")
        .withStartupTimeout(Duration.of(15, SECONDS)));
}
 
Example #9
Source File: LogMessageWaitStrategyTest.java    From testcontainers-java with MIT License 5 votes vote down vote up
@NotNull
@Override
protected LogMessageWaitStrategy buildWaitStrategy(AtomicBoolean ready) {

    return new LogMessageWaitStrategy() {
        @Override
        protected void waitUntilReady() {
            super.waitUntilReady();
            ready.set(true);
        }
    }.withRegEx(pattern).withTimes(2);
}
 
Example #10
Source File: DatabaseContainers.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
	super.configure();
	this.waitStrategy = new LogMessageWaitStrategy().withRegEx(".*DATABASE IS READY TO USE!.*\\s")
			.withStartupTimeout(Duration.of(10, ChronoUnit.MINUTES));
	setShmSize(1024L * 1024L * 1024L);
	addEnv("ORACLE_PWD", getPassword());
}