Skip to content

labianchin/docker-postgres-for-testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Docker Postgres For Testing

Docker Hub Docker Stars Docker Pulls Image Size Image Layers

This a docker image based in the official Postgres 9.4 docker image tweaked for database testing.

It basically configure things like turning off write ahead log (fsync=off) to make it faster. Notice that this can make the database more likely to be in an inconsistent state, if the case of a server crash. This is not a problem for database testing as we are more concerned with fast feedback and not about loosing data.

This is an alternative to H2, in memory SQLite and HyperSQL. You should consider this as it runs a real PostgreSQL server, that would be very close on what you have in production.

Check the file config.sh for all the configurations.

References:

Tips for writing tests

  • Do all schema setup (DDL) once before running the tests
  • Run the schema setup (DDL), as the DB migration that would run in production
  • Avoid DDL in each test, as that tent to be very slow
  • Before each test, truncate the tables and put some seed data (DML), that should be quick
  • Remember fasts tests are important, slow tests make you avoid refactoring code!

TODO

  • Tweak shared_buffers
  • Tweak work_mem

About

A postgres docker image tweaked for fast db testing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages