简体   繁体   English

在 Heroku CI 期间启动应用程序

[英]Start application during Heroku CI

I want to implement integration/e2e tests during Heroku CI phase (which runs for each PR).我想在 Heroku CI 阶段(为每个 PR 运行)期间实施集成/e2e 测试。 Tests are connecting to a running server by REST API.测试通过 REST API 连接到正在运行的服务器。

How can I do the DB migration and server startup during CI run (something similar to a review app)?在 CI 运行期间如何进行数据库迁移和服务器启动(类似于审查应用程序)? I am using an in-dyno postgres .我正在使用in-dyno postgres

I've tried setting the following in app.json :我尝试在app.json中设置以下内容:

  "environments": {
    "test": {
      "addons": ["heroku-postgresql:in-dyno"],
      "scripts": {
        "test-setup": "mvn package -P no-tests && bash migrate.sh",
        "test": "bash server.sh && mvn test"
      }
    }
  }

This works, but the CI instance does not close, as the server is still running, timing out after 2 hours.这可行,但 CI 实例不会关闭,因为服务器仍在运行,2 小时后超时。 Not cost efficient, so I ended up embedding the server instantiation in the integration tests, which is automatically closed once the tests finish.没有成本效益,所以我最终将服务器实例嵌入到集成测试中,一旦测试完成,它就会自动关闭。

Final app.json :最终app.json

  "environments": {
    "test": {
      "addons": ["heroku-postgresql:in-dyno"],
      "scripts": {
        "test-setup": "mvn package -P no-tests && bash migrate.sh",
        "test": "mvn test"
      }
    }
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM