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

The following examples show how to use org.testcontainers.containers.wait.strategy.HostPortWaitStrategy. 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: PulsarContainer.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public void start() {
    if (httpPort > 0 && servicePort < 0) {
        this.waitStrategy = new HttpWaitStrategy()
            .forPort(httpPort)
            .forStatusCode(200)
            .forPath(httpPath)
            .withStartupTimeout(Duration.of(300, SECONDS));
    } else if (httpPort > 0 || servicePort > 0) {
        this.waitStrategy = new HostPortWaitStrategy()
            .withStartupTimeout(Duration.of(300, SECONDS));
    }
    this.withCreateContainerCmdModifier(createContainerCmd -> {
        createContainerCmd.withHostName(hostname);
        createContainerCmd.withName(getContainerName());
        createContainerCmd.withEntrypoint(serviceEntryPoint);
    });

    beforeStart();
    super.start();
    log.info("Start pulsar service {} at container {}", serviceName, containerName);
}
 
Example #2
Source File: DockerJamesRule.java    From james-project with Apache License 2.0 6 votes vote down vote up
public DockerJamesRule(String image) {
    container = DockerContainer.fromName(image)
        .withExposedPorts(SMTP_PORT, IMAP_PORT)
        .waitingFor(new HostPortWaitStrategy())
        .withLogConsumer(frame -> {
            switch (frame.getType()) {
                case STDOUT:
                    LOGGER.info(frame.getUtf8String());
                    break;
                case STDERR:
                    LOGGER.error(frame.getUtf8String());
                    break;
                case END:
                    break; //Ignore
            }
        });
}
 
Example #3
Source File: DebeziumMySQLContainer.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    super.configure();
    this.withNetworkAliases(NAME)
        .withExposedPorts(PORTS)
        .withCreateContainerCmdModifier(createContainerCmd -> {
            createContainerCmd.withHostName(NAME);
            createContainerCmd.withName(getContainerName());
        })
        .waitingFor(new HostPortWaitStrategy());
}
 
Example #4
Source File: ElasticSearchContainer.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    super.configure();
    this.withNetworkAliases(NAME)
        .withExposedPorts(PORTS)
        .withEnv("discovery.type", "single-node")
        .withCreateContainerCmdModifier(createContainerCmd -> {
            createContainerCmd.withHostName(NAME);
            createContainerCmd.withName(clusterName + "-" + NAME);
        })
        .waitingFor(new HostPortWaitStrategy());
}
 
Example #5
Source File: RabbitMQContainer.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    super.configure();
    this.withNetworkAliases(networkAlias)
            .withExposedPorts(PORTS)
            .withCreateContainerCmdModifier(createContainerCmd -> {
                createContainerCmd.withHostName(NAME);
                createContainerCmd.withName(clusterName + "-" + NAME);
            })
            .waitingFor(new HostPortWaitStrategy());
}
 
Example #6
Source File: DebeziumPostgreSqlContainer.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    super.configure();
    this.withNetworkAliases(NAME)
        .withExposedPorts(PORTS)
        .withCreateContainerCmdModifier(createContainerCmd -> {
            createContainerCmd.withHostName(NAME);
            createContainerCmd.withName(getContainerName());
        })
        .waitingFor(new HostPortWaitStrategy());
}
 
Example #7
Source File: HdfsContainer.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Override
   protected void configure() {
	super.configure();
	this.withNetworkAliases(NAME)
       .withExposedPorts(PORTS)
       .withCreateContainerCmdModifier(createContainerCmd -> {
           createContainerCmd.withHostName(NAME);
           createContainerCmd.withName(clusterName + "-" + NAME);
       })
       .waitingFor(new HostPortWaitStrategy());
}
 
Example #8
Source File: DebeziumMongoDbContainer.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    super.configure();
    this.withNetworkAliases(NAME)
            .withExposedPorts(PORTS)
            .withCreateContainerCmdModifier(createContainerCmd -> {
                createContainerCmd.withHostName(NAME);
                createContainerCmd.withName(getContainerName());
            })
            .waitingFor(new HostPortWaitStrategy());
}
 
Example #9
Source File: CassandraContainer.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    super.configure();
    this.withNetworkAliases(NAME)
        .withExposedPorts(PORT)
        .withCreateContainerCmdModifier(createContainerCmd -> {
            createContainerCmd.withHostName(NAME);
            createContainerCmd.withName(clusterName + "-" + NAME);
        })
        .waitingFor(new HostPortWaitStrategy());
}
 
Example #10
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 #11
Source File: DockerElasticSearch.java    From james-project with Apache License 2.0 5 votes vote down vote up
static DockerContainer defaultContainer(String imageName) {
    return DockerContainer.fromName(imageName)
        .withTmpFs(ImmutableMap.of("/usr/share/elasticsearch/data", "rw,size=200m"))
        .withExposedPorts(ES_HTTP_PORT)
        .withEnv("discovery.type", "single-node")
        .withAffinityToContainer()
        .waitingFor(new HostPortWaitStrategy().withRateLimiter(RateLimiters.TWENTIES_PER_SECOND));
}
 
Example #12
Source File: LdapGenericContainer.java    From james-project with Apache License 2.0 5 votes vote down vote up
private DockerContainer createContainer() {
    return DockerContainer.fromDockerfile(
        new ImageFromDockerfile()
            .withFileFromClasspath("populate.ldif", dockerFilePrefix.orElse("") + "ldif-files/populate.ldif")
            .withFileFromClasspath("Dockerfile", dockerFilePrefix.orElse("") + "ldif-files/Dockerfile"))
        .withAffinityToContainer()
        .withEnv("SLAPD_DOMAIN", domain)
        .withEnv("SLAPD_PASSWORD", password)
        .withEnv("SLAPD_CONFIG_PASSWORD", password)
        .withExposedPorts(LdapGenericContainer.DEFAULT_LDAP_PORT)
        .waitingFor(new HostPortWaitStrategy().withRateLimiter(RateLimiters.TWENTIES_PER_SECOND));
}
 
Example #13
Source File: FakeSmtp.java    From james-project with Apache License 2.0 5 votes vote down vote up
private static DockerContainer fakeSmtpContainer() {
    return DockerContainer.fromName(Images.FAKE_SMTP)
        .withAffinityToContainer()
        .waitingFor(new HostPortWaitStrategy()
            .withRateLimiter(RateLimiters.TWENTIES_PER_SECOND)
            .withStartupTimeout(Duration.ofMinutes(1))
        );
}
 
Example #14
Source File: EmbeddedGraphiteBootstrapConfiguration.java    From kayenta with Apache License 2.0 4 votes vote down vote up
@Bean(name = "graphiteWaitStrategy")
public WaitStrategy graphiteWaitStrategy() {
  return new HostPortWaitStrategy();
}