1

GenericContainer类中,它存在一个方法waitingFor,它等待状态码200作为来自服务器的响应。
我在容器中运行 Web 应用程序并0.0.0.0用作主机而不是localhost. 当我尝试运行时sbt test,我有以下超时:

[sweetsoft/sapmock:latest] - Could not start container
org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (localhost ports: [8080] should be listening)  

我正在使用测试容器如下:

final class MessageSpec extends BddSpec
  with ForAllTestContainer
  with BeforeAndAfterAll {


  override val container = FixedHostPortGenericContainer("sweetsoft/sapmock",
    waitStrategy = Wait.forHttp("/"),
    exposedHostPort = 8080,
    exposedContainerPort = 8080,
  )


  override def beforeAll(): Unit = {

  }


  feature("Process incoming messages") {
    info("As a user, I want that incoming messages is going to process appropriately.")
    info("A message should contain the following properties: `sap_id`, `sap_event`, `payload`")

当我删除waitStrategy = Wait.forHttp("/")时,它可以正常工作,但waitStrategy = Wait.forHttp("/") 会进入超时。

如何告诉Testcontainer0.0.0.0而不是听localhost?我在这里描述了 localhost 的问题:为什么客户端无法连接到 localhost:8080?

4

0 回答 0