等待0.0.0.0:8080而不是localhost:8080

时间:2019-05-20 06:41:04

标签: java scala testcontainers

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("/") 它会超时。

如何告诉Testcontainer而不是0.0.0.0localhost? 我已经在这里描述了本地主机的问题:Why does the client can not connect to localhost:8080?

0 个答案:

没有答案