gpt4 book ai didi

org.testcontainers.containers.wait.strategy.WaitStrategyTarget.getContainerIpAddress()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-27 08:11:05 27 4
gpt4 key购买 nike

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

WaitStrategyTarget.getContainerIpAddress介绍

暂无

代码示例

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

/**
 * Build the URI on which to check if the container is ready.
 *
 * @param livenessCheckPort the liveness port
 * @return the liveness URI
 */
private URI buildLivenessUri(int livenessCheckPort) {
  final String scheme = (tlsEnabled ? "https" : "http") + "://";
  final String host = waitStrategyTarget.getContainerIpAddress();
  final String portSuffix;
  if ((tlsEnabled && 443 == livenessCheckPort) || (!tlsEnabled && 80 == livenessCheckPort)) {
    portSuffix = "";
  } else {
    portSuffix = ":" + String.valueOf(livenessCheckPort);
  }
  return URI.create(scheme + host + portSuffix + path);
}

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

@Before
public void setUp() throws Exception {
  listeningSocket1 = new ServerSocket(0);
  listeningSocket2 = new ServerSocket(0);
  nonListeningSocket = new ServerSocket(0);
  nonListeningSocket.close();
  mockContainer = mock(WaitStrategyTarget.class);
  when(mockContainer.getContainerIpAddress()).thenReturn("127.0.0.1");
}

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

@Override
protected void waitUntilReady() {
  final Set<Integer> externalLivenessCheckPorts = getLivenessCheckPorts();
  if (externalLivenessCheckPorts.isEmpty()) {
    log.debug("Liveness check ports of {} is empty. Not waiting.", waitStrategyTarget.getContainerInfo().getName());
    return;
  }
  @SuppressWarnings("unchecked")
  List<Integer> exposedPorts = waitStrategyTarget.getExposedPorts();
  final Set<Integer> internalPorts = getInternalPorts(externalLivenessCheckPorts, exposedPorts);
  Callable<Boolean> internalCheck = new InternalCommandPortListeningCheck(waitStrategyTarget, internalPorts);
  Callable<Boolean> externalCheck = new ExternalPortListeningCheck(waitStrategyTarget, externalLivenessCheckPorts);
  try {
    Unreliables.retryUntilTrue((int) startupTimeout.getSeconds(), TimeUnit.SECONDS,
      () -> getRateLimiter().getWhenReady(() -> internalCheck.call() && externalCheck.call()));
  } catch (TimeoutException e) {
    throw new ContainerLaunchException("Timed out waiting for container port to open (" +
        waitStrategyTarget.getContainerIpAddress() +
        " ports: " +
        externalLivenessCheckPorts +
        " should be listening)");
  }
}

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

/**
 * Build the URI on which to check if the container is ready.
 *
 * @param livenessCheckPort the liveness port
 * @return the liveness URI
 */
private URI buildLivenessUri(int livenessCheckPort) {
  final String scheme = (tlsEnabled ? "https" : "http") + "://";
  final String host = waitStrategyTarget.getContainerIpAddress();
  final String portSuffix;
  if ((tlsEnabled && 443 == livenessCheckPort) || (!tlsEnabled && 80 == livenessCheckPort)) {
    portSuffix = "";
  } else {
    portSuffix = ":" + String.valueOf(livenessCheckPort);
  }
  return URI.create(scheme + host + portSuffix + path);
}

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

@Override
protected void waitUntilReady() {
  final Set<Integer> externalLivenessCheckPorts = getLivenessCheckPorts();
  if (externalLivenessCheckPorts.isEmpty()) {
    log.debug("Liveness check ports of {} is empty. Not waiting.", waitStrategyTarget.getContainerInfo().getName());
    return;
  }
  @SuppressWarnings("unchecked")
  List<Integer> exposedPorts = waitStrategyTarget.getExposedPorts();
  final Set<Integer> internalPorts = getInternalPorts(externalLivenessCheckPorts, exposedPorts);
  Callable<Boolean> internalCheck = new InternalCommandPortListeningCheck(waitStrategyTarget, internalPorts);
  Callable<Boolean> externalCheck = new ExternalPortListeningCheck(waitStrategyTarget, externalLivenessCheckPorts);
  try {
    Unreliables.retryUntilTrue((int) startupTimeout.getSeconds(), TimeUnit.SECONDS, () -> getRateLimiter().getWhenReady(() -> internalCheck.call() && externalCheck.call()));
  } catch (TimeoutException e) {
    throw new ContainerLaunchException("Timed out waiting for container port to open (" + waitStrategyTarget.getContainerIpAddress() + " ports: " + externalLivenessCheckPorts + " should be listening)");
  }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com