Would adding a feature to "reset" the postgres container to a known schema be useful? #698
vinaysshenoy
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
I like the idea @vinaysshenoy, thanks for raising it. I'm aware that Docker are working on a checkpoint feature (https://docs.docker.com/engine/reference/commandline/checkpoint/), which would achieve a similar result but would work for all containers, not just postgres. I wonder if it'd be better to look into that instead. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For additional context, I use Flyway to handle database migrations in my app. For the test suite, it's mostly integration tests where I spin up and tear down the server between each test. As part of this, I also do the same with the app dependencies, which is a postgres database.
This essentially meant that between each test, I was:
I initially tried starting the container and migrating it once before running all the tests and then manually deleting the data in the tables, but that led to other issues because this is a script that needs to be maintained and constantly updated whenever new database changes happen, so I dropped it.
I also tried experimenting with tmpfs to speed things up, but had trouble setting it up with GItHub actions (where I run the CI) so I tried a different approach, which worked really well and sped up my CI times by over 50%! What I ended up doing was:
This had a massive performance benefit on the test suite, as you can see from the measurements below:
Before
After
I managed to get this into a fairly portable setup as part of the postgres container:
Would this be something that would make sense to get into the main repository? I would be happy to raise a PR if so.
Beta Was this translation helpful? Give feedback.
All reactions