-
Hi there thanks for such a great lib We have been using H2 for our test suite and we are planning to migrate to Doing so in H2 was pretty easy and fast using I was trying to do the same idea some stuff like
but was left facing locking problems and eliminating these locks will terminate the test context I also tried separate container per test but it takes alot of time Any idea how to overcome such a problem Note, This is not a bug in test container but it might be a feature request |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Hey @Youans, this is a great question and I just transferred it from issues to GitHub discussions. Let's try to come up with some ideas on how to best solve this for PostgreSQL. And who knows, maybe the community will have other good suggestions? I don't completely understand why your approach does not work, with which technology are you testing? And what do you mean with test context in this case? In the past, I personally used https://github.com/fastmonkeys/stellar, also in conjunction with Testcontainers, but it seems to not be actively maintained anymore. Another good alternative can be to use Flyway and run a |
Beta Was this translation helpful? Give feedback.
-
I'm not sure about the entire context and so I'm not sure about the best answer to this question.
|
Beta Was this translation helpful? Give feedback.
-
Sorry for late reply, Thanks for your great notes I managed to make my approach work but it was not an easy road But just to summarize the problem, I was trying to restore dump completely [structure + data] doing so requires to drop current opened database but this was not an option since I faced tons of Luckily, Here is a complete code in case anyone step on this problem in the future, I added some comments read them carefully `
` FYI this was done using Spring Boot v2.2.6.RELEASE & Postgres:9.6.24 |
Beta Was this translation helpful? Give feedback.
-
The way we handled this in my previous team, we first created a regular postegresql database and populated all of the tables with the required data. Then we went to the filesystem and got all of the table files and created a new docker image with those files using postgresql as base image. By copying over the schema files, that would initialize our database. Finally we used that image in our tests, that way each test had a fresh dataset to use no bothering with transactions and what not. The database would startup with all of the data already there and the tests just had to do their testing against it. Worked flawlessly and very quick, much faster than using insert into statements in a Before method call etc (edited) |
Beta Was this translation helpful? Give feedback.
Sorry for late reply, Thanks for your great notes
For the stack I use Spring Boot Test & JUnit Jupiter 5 and Liquibase for database migration
I managed to make my approach work but it was not an easy road
But just to summarize the problem,
I was trying to restore dump completely [structure + data] doing so requires to drop current opened database but this was not an option since I faced tons of
org.postgresql.util.PSQLException: FATAL: terminating connection due to administrator command
and
can not drop current opened database
errors so this was a no go optionLuckily,
There is an option to backup data only in postgres but when I tried to restore I faced the 1st problem the database locks…