I want to implement integration/e2e tests during Heroku CI phase (which runs for each PR). Tests are connecting to a running server by REST API.
How can I do the DB migration and server startup during CI run (something similar to a review app)? I am using an in-dyno postgres .
I've tried setting the following in 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. 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
:
"environments": {
"test": {
"addons": ["heroku-postgresql:in-dyno"],
"scripts": {
"test-setup": "mvn package -P no-tests && bash migrate.sh",
"test": "mvn test"
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.