本文整理了Java中org.testcontainers.containers.wait.strategy.WaitStrategyTarget.getContainerId()
方法的一些代码示例,展示了WaitStrategyTarget.getContainerId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WaitStrategyTarget.getContainerId()
方法的具体详情如下:
包路径:org.testcontainers.containers.wait.strategy.WaitStrategyTarget
类名称:WaitStrategyTarget
方法名:getContainerId
暂无
代码示例来源:origin: testcontainers/testcontainers-java
@Override
protected void waitUntilReady() {
WaitingConsumer waitingConsumer = new WaitingConsumer();
LogUtils.followOutput(DockerClientFactory.instance().client(), waitStrategyTarget.getContainerId(), waitingConsumer);
Predicate<OutputFrame> waitPredicate = outputFrame ->
// (?s) enables line terminator matching (equivalent to Pattern.DOTALL)
outputFrame.getUtf8String().matches("(?s)" + regEx);
try {
waitingConsumer.waitUntil(waitPredicate, startupTimeout.getSeconds(), TimeUnit.SECONDS, times);
} catch (TimeoutException e) {
throw new ContainerLaunchException("Timed out waiting for log output matching '" + regEx + "'");
}
}
代码示例来源:origin: Playtika/testcontainers-spring-boot
@Override
protected void waitUntilReady() {
long seconds = startupTimeout.getSeconds();
try {
Unreliables.retryUntilTrue((int) seconds, TimeUnit.SECONDS,
() -> getRateLimiter().getWhenReady(this::isReady));
} catch (TimeoutException e) {
throw new ContainerLaunchException(
format("[%s] notifies that container[%s] is not ready after [%d] seconds, container cannot be started.",
getContainerType(), waitStrategyTarget.getContainerId(), seconds));
}
}
代码示例来源:origin: Playtika/testcontainers-spring-boot
protected boolean isReady() {
String commandName = getContainerType();
String containerId = waitStrategyTarget.getContainerId();
log.debug("{} execution of command {} for container id: {} ", commandName, containerId);
ExecCmdResult healthCheckCmdResult =
ContainerUtils.execCmd(DockerClientFactory.instance().client(), containerId, getCheckCommand());
log.debug("{} executed with exitCode: {}, output: {}",
commandName, healthCheckCmdResult.getExitCode(), healthCheckCmdResult.getOutput());
if (healthCheckCmdResult.getExitCode() != 0) {
log.debug("{} executed with exitCode !=0, considering status as unknown", commandName);
return false;
}
log.debug("{} command executed, considering container {} successfully started", commandName, containerId);
return true;
}
}
代码示例来源:origin: org.testcontainers/testcontainers
@Override
protected void waitUntilReady() {
WaitingConsumer waitingConsumer = new WaitingConsumer();
LogUtils.followOutput(DockerClientFactory.instance().client(), waitStrategyTarget.getContainerId(), waitingConsumer);
Predicate<OutputFrame> waitPredicate = outputFrame ->
// (?s) enables line terminator matching (equivalent to Pattern.DOTALL)
outputFrame.getUtf8String().matches("(?s)" + regEx);
try {
waitingConsumer.waitUntil(waitPredicate, startupTimeout.getSeconds(), TimeUnit.SECONDS, times);
} catch (TimeoutException e) {
throw new ContainerLaunchException("Timed out waiting for log output matching '" + regEx + "'");
}
}
代码示例来源:origin: etcd-io/jetcd
@Override
protected void waitUntilReady() {
final DockerClient client = DockerClientFactory.instance().client();
final WaitingConsumer waitingConsumer = new WaitingConsumer();
LogUtils.followOutput(client, waitStrategyTarget.getContainerId(), waitingConsumer);
try {
waitingConsumer.waitUntil(
f -> f.getUtf8String().contains("ready to serve client requests"),
startupTimeout.getSeconds(),
TimeUnit.SECONDS,
1
);
} catch (TimeoutException e) {
throw new ContainerLaunchException("Timed out");
}
}
};
代码示例来源:origin: com.github.mxsm/jetcd-launcher
@Override
protected void waitUntilReady() {
final DockerClient client = DockerClientFactory.instance().client();
final WaitingConsumer waitingConsumer = new WaitingConsumer();
LogUtils.followOutput(client, waitStrategyTarget.getContainerId(), waitingConsumer);
try {
waitingConsumer.waitUntil(
f -> f.getUtf8String().contains("ready to serve client requests"),
startupTimeout.getSeconds(),
TimeUnit.SECONDS,
1
);
} catch (TimeoutException e) {
throw new ContainerLaunchException("Timed out");
}
}
};
代码示例来源:origin: io.etcd/jetcd-launcher
@Override
protected void waitUntilReady() {
final DockerClient client = DockerClientFactory.instance().client();
final WaitingConsumer waitingConsumer = new WaitingConsumer();
LogUtils.followOutput(client, waitStrategyTarget.getContainerId(), waitingConsumer);
try {
waitingConsumer.waitUntil(
f -> f.getUtf8String().contains("ready to serve client requests"),
startupTimeout.getSeconds(),
TimeUnit.SECONDS,
1
);
} catch (TimeoutException e) {
throw new ContainerLaunchException("Timed out");
}
}
};
代码示例来源:origin: Playtika/testcontainers-spring-boot
@Override
protected boolean isReady() {
String containerId = waitStrategyTarget.getContainerId();
log.debug("Check Aerospike container {} status", containerId);
InspectContainerResponse containerInfo = waitStrategyTarget.getContainerInfo();
if (containerInfo == null) {
log.debug("Aerospike container[{}] doesn't contain info. Abnormal situation, should not happen.", containerId);
return false;
}
int port = getMappedPort(containerInfo.getNetworkSettings(), properties.port);
String host = DockerClientFactory.instance().dockerHostIpAddress();
//TODO: Remove dependency to client https://www.aerospike.com/docs/tools/asmonitor/common_tasks.html
try (AerospikeClient client = new AerospikeClient(host, port)) {
return client.isConnected();
} catch (AerospikeException.Connection e) {
log.debug("Aerospike container: {} not yet started. {}", containerId, e.getMessage());
}
return false;
}
代码示例来源:origin: jurmous/etcd4j
@Override
protected void waitUntilReady() {
final DockerClient client = DockerClientFactory.instance().client();
final WaitingConsumer waitingConsumer = new WaitingConsumer();
LogUtils.followOutput(client, waitStrategyTarget.getContainerId(), waitingConsumer);
try {
waitingConsumer.waitUntil(
f -> f.getUtf8String().contains("etcdserver: published"),
startupTimeout.getSeconds(),
TimeUnit.SECONDS,
1
);
} catch (TimeoutException e) {
throw new ContainerLaunchException("Timed out");
}
}
};
内容来源于网络,如有侵权,请联系作者删除!