org.testcontainers.containers.wait.strategy.WaitAllStrategy类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(194)

本文整理了Java中org.testcontainers.containers.wait.strategy.WaitAllStrategy类的一些代码示例,展示了WaitAllStrategy类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WaitAllStrategy类的具体详情如下:
包路径:org.testcontainers.containers.wait.strategy.WaitAllStrategy
类名称:WaitAllStrategy

WaitAllStrategy介绍

暂无

代码示例

代码示例来源:origin: testcontainers/testcontainers-java

private void addWaitStrategy(String serviceInstanceName, @NonNull WaitStrategy waitStrategy) {
  final WaitAllStrategy waitAllStrategy = waitStrategyMap.computeIfAbsent(serviceInstanceName, __ ->
    (WaitAllStrategy) new WaitAllStrategy().withStartupTimeout(Duration.ofMinutes(30)));
  waitAllStrategy.withStrategy(waitStrategy);
}

代码示例来源:origin: testcontainers/testcontainers-java

private void waitUntilServiceStarted(String serviceName, ComposeServiceWaitStrategyTarget serviceInstance) {
  final WaitAllStrategy waitAllStrategy = waitStrategyMap.get(serviceName);
  if(waitAllStrategy != null) {
    waitAllStrategy.waitUntilReady(serviceInstance);
  }
}

代码示例来源:origin: testcontainers/testcontainers-java

public InfluxDBContainer(final String version) {
  super(IMAGE_NAME + ":" + version);
  waitStrategy = new WaitAllStrategy()
    .withStrategy(Wait.forHttp("/ping").withBasicCredentials(username, password).forStatusCode(204))
    .withStrategy(Wait.forListeningPort());
}

代码示例来源:origin: org.testcontainers/influxdb

public InfluxDBContainer(final String version) {
  super(IMAGE_NAME + ":" + version);
  waitStrategy = new WaitAllStrategy()
    .withStrategy(Wait.forHttp("/ping").withBasicCredentials(username, password).forStatusCode(204))
    .withStrategy(Wait.forListeningPort());
}

代码示例来源:origin: testcontainers/testcontainers-java

/**
 * 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));
}

代码示例来源:origin: org.apache.james/blob-objectstorage

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)
      )
    );
}

代码示例来源:origin: org.testcontainers/testcontainers

private void waitUntilServiceStarted(String serviceName, ComposeServiceWaitStrategyTarget serviceInstance) {
  final WaitAllStrategy waitAllStrategy = waitStrategyMap.get(serviceName);
  if (waitAllStrategy != null) {
    waitAllStrategy.waitUntilReady(serviceInstance);
  }
}

代码示例来源:origin: org.testcontainers/testcontainers

private void addWaitStrategy(String serviceInstanceName, @NonNull WaitStrategy waitStrategy) {
  if (waitStrategy == null) {
    throw new java.lang.NullPointerException("waitStrategy is marked @NonNull but is null");
  }
  final WaitAllStrategy waitAllStrategy = waitStrategyMap.computeIfAbsent(serviceInstanceName, __ -> (WaitAllStrategy) new WaitAllStrategy().withStartupTimeout(Duration.ofMinutes(30)));
  waitAllStrategy.withStrategy(waitStrategy);
}

代码示例来源:origin: Playtika/testcontainers-spring-boot

private static WaitStrategy getCompositeWaitStrategy(ElasticSearchProperties properties) {
    WaitAllStrategy strategy = new WaitAllStrategy()
        .withStrategy(new HostPortWaitStrategy());
    properties.indices.forEach(index -> strategy.withStrategy(new CreateIndex(properties, index)));
    return strategy
        .withStrategy(new WaitForGreenStatus(properties))
        .withStartupTimeout(DEFAULT_CONTAINER_WAIT_DURATION);
  }
}

代码示例来源:origin: Playtika/testcontainers-spring-boot

/**
   * https://developer.couchbase.com/documentation/server/current/rest-api/rest-node-provisioning.html
   */
  private static WaitStrategy getCompositeWaitStrategy(CouchbaseProperties properties) {
    return new WaitAllStrategy()
        .withStrategy(new SetupNodeStorage(properties))
        .withStrategy(new SetupRamQuotas(properties))
        .withStrategy(new SetupServices(properties))
        .withStrategy(new SetupIndexesType(properties))
        .withStrategy(new SetupAdminUserAndPassword(properties))
        .withStrategy(new CreateBucket(properties))
        .withStrategy(new CreatePrimaryIndex(properties))
        .withStrategy(new CreateBucketUser(properties))
        .withStartupTimeout(DEFAULT_CONTAINER_WAIT_DURATION);
  }
}

代码示例来源:origin: org.apache.james/apache-james-backends-rabbitmq

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);
}

代码示例来源:origin: Playtika/testcontainers-spring-boot

@Bean(name = AEROSPIKE_BEAN_NAME, destroyMethod = "stop")
public GenericContainer aerospike(AerospikeWaitStrategy aerospikeWaitStrategy,
                 ConfigurableEnvironment environment,
                 AerospikeProperties properties) {
  log.info("Starting aerospike server. Docker image: {}", properties.dockerImage);
  WaitStrategy waitStrategy = new WaitAllStrategy()
      .withStrategy(aerospikeWaitStrategy)
      .withStrategy(new HostPortWaitStrategy())
      .withStartupTimeout(Duration.of(60, SECONDS));
  GenericContainer aerospike =
      new GenericContainer<>(properties.dockerImage)
          .withExposedPorts(properties.port)
          .withLogConsumer(containerLogsConsumer(log))
          // see https://github.com/aerospike/aerospike-server.docker/blob/master/aerospike.template.conf
          .withEnv("NAMESPACE", properties.namespace)
          .withEnv("SERVICE_PORT", String.valueOf(properties.port))
          .withEnv("MEM_GB", String.valueOf(1))
          .withEnv("STORAGE_GB", String.valueOf(1))
          .withCreateContainerCmdModifier(cmd -> cmd.withCapAdd(Capability.NET_ADMIN))
          .waitingFor(waitStrategy)
          .withStartupTimeout(properties.getTimeoutDuration());
  aerospike.start();
  registerAerospikeEnvironment(aerospike, environment, properties);
  return aerospike;
}

相关文章