- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想运行一个通过 Docker 运行 ES 镜像的容器测试。
经过一番研究,我发现 https://www.testcontainers.org/他们还有一个内置的 ES module .
因为我的开发环境在端口 9200 和 9300 中使用 ES,所以我更喜欢使用其他端口进行测试,比如 1200 和 1300。
因此,要从 CLI 运行 docker 镜像,我使用以下命令:docker run -p 1200:9200 -p 1300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.6.2
我尝试用 testcontainers 来做,例如:
static ElasticsearchContainer esContainer =
new ElasticsearchContainer("docker.elastic.co/elasticsearch/elasticsearch:7.6.2")
.withExposedPorts(1200, 9200)
.withExposedPorts(1300, 9300)
.withEnv("discovery.type", "single-node");
// .waitingFor(Wait.forHttp("/")); // Wait until elastic start – cause an error
@BeforeClass
public static void initEsDockerImage() {
esContainer.start();
esContainer.isRunning();
}
esContainer.getHttpHostAddress()
返回 localhost/127.0.0.1:32847 以及来自 docker 仪表板:
**waitingFor**
运行 start() 行命令抛出
Container startup failed
错误
最佳答案
如果你想指定一个端口而不是使用随机端口,你可以这样做:
static final MySQLContainer<?> mysql =
new MySQLContainer<>("mysql:5.6")
.withExposedPorts(34343)
.withCreateContainerCmdModifier(cmd -> cmd.withHostConfig(
new HostConfig().withPortBindings(new PortBinding(Ports.Binding.bindPort(34343), new ExposedPort(3306)))
));
关于java - 使用 testcontainers 使用自定义端口运行 ES docker 镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61913787/
我有服务器和客户端应用程序。服务器在 docker 容器内启动。我想测试服务器崩溃并恢复的场景。客户端在崩溃前连接到服务器,并在服务器恢复时自动连接到服务器。问题是测试容器随机映射端口,服务器回来后监
我正在使用此依赖项: org.testcontainers postgresql 1.5.1 test 这是容器,通过我的测试启动: @ClassRule publ
我正在部署两个 Testcontainer,一个带有 PostgreSQL (12.0) 镜像,另一个带有 Keycloak (8.0.0)。 PostgreSQL启动成功,但是当Keycloak尝试
问题陈述 我编写了一个程序,它利用 DynamoDb Streams 在发生更新时收到通知,此代码在使用 AWS 服务时工作正常,但似乎无法利用 Testcontainers/Localstack 进
您好,我正在尝试从我的单元测试类中启动一个测试容器。 在我的测试课上,我正在使用以下内容 @Container private static GenericContainer testC
如何在一个 mysql db 容器上创建多个数据库? 或者我是否必须为每个数据库创建 db 容器? 当我尝试从 sql 文件脚本创建它时: @ClassRule public static M
这里有一个在同一网络中创建Testcontainer的好例子:Can Testcontainers create docker network for me if it does not exist?
我使用 javax.mail 实现了一个 POP3 服务器和客户端,只是为了尝试与 Docker 进行集成测试。所以我基于 openjdk:8-jre 镜像创建了两个 Docker 镜像,并将我的 j
假设我的集成测试 (JUnit 5) 中有以下容器: @Container private static GenericContainer databaseContainer = ne
我有这个用于 IT 测试的抽象类: @RunWith(SpringRunner.class) @Import(DbUnitConfig.class) @SpringBootTest(classes =
我在 IDE 中遇到以下错误: Raw use of parameterized class 'GenericContainer' Inspection info: Reports any uses
我正在尝试针对 dockered 数据库运行 dropwizard 的集成测试。 Dropwizard Testcontainers 我试过的: @ClassRule public static fi
我在同一应用程序中同时使用 r2dbc 和 Liquibase。但是,Liquibase 无法使用 r2dbc 运行迁移,因此我需要为此使用单独的 jdbc 驱动程序。 我遵循了解决方案here ,并
我有一个使用MySQL Test容器的小型集成测试。 当我在本地构建时,运行简单的gradlew build命令,它将运行,测试并构建项目。但是,当我尝试使用正式的gradle docker镜像时,该
我正在尝试使用 Testcontainers 对我的 DAO 执行集成测试. 我的目标是在单独的容器中运行每个测试。为此,我添加了 @DirtiesContext注释 - 我的逻辑是,如果我注入(in
我正在使用 PostgreSQL TestContainer 来测试 Spring Boot 中的 Liquibase 架构迁移。我没有任何存储库。我想知道我是否可以查看/访问 TestContain
我正在使用 Testcontainers 通过 docker 启动一个 CockroachDB 实例。我需要通过将属性 sql.defaults.experimental_temporary_tabl
我尝试使用 testcontainers用于与 Oracle 集成测试的库。这是简单的测试: public class SimpleTest { @Rule public Oracle
我正在尝试使用 TestContainer 进行 Spring Boot 应用程序的集成测试。 此类应用程序的数据库驻留在自定义 PostgreSQL Docker 镜像中。 在集成测试中,Appli
我正在使用 Testcontainers 通过 docker 启动一个 CockroachDB 实例。我需要通过将属性 sql.defaults.experimental_temporary_tabl
我是一名优秀的程序员,十分优秀!