The reason why there are 2 postgres instances spinned up is, because Quarkus also does that for you automatically when you’re running in the test and dev profiles.
You don’t need to explicitly create a QuarkusTestResourceLifecycleManager
. As a matter of fact, you don’t need to specify your db url and do anything with Testcontainers.
Just write your test and a db is automatically spinned up for you. You don’t have to configure anything, this is all handled.
So you can remove all your code, except your test class and then it should look something like this:
quarkus:
http:
test-port: 9300
datasource:
db-kind: postgresql
hibernate-orm:
database:
generation: none <--> drop-and-create is going to conflict with liquibase
liquibase:
enabled: true
migrate-at-start: true
change-log: classpath:db/dbChangelog-test.yaml
default-schema-name: x
validate-on-migrate: true
// quarkus will spin up postgres automatically from here
@QuarkusTest
@TestHTTPEndpoint(YourRestController.class) ---> this will automatically add the rootpath to RestAssured
class MyTest {
...
}
For more info check these links: