Itamar Turner-Trauring pythonspeed.com

10× faster database tests with Docker  ↦

Testing code that talks to the database can be slow. Fakes are fast but unrealistic. What to do? With a little help from Docker, you can write tests that run fast, use the real database, are easy to write and run.

I tried Itamar’s technique on changelog.com’s test suite and the 679 tests complete in ~17 seconds. The same tests run directly against Postgres complete in ~12 seconds.

A net loss for me, but that may have something to do with how Docker for Mac works? I’d love to hear other people’s experiences.


Discussion

Sign in or Join to comment or subscribe

 Itamar Turner-Trauring

Itamar Turner-Trauring

Helping Python software teams ship features faster.

2019-02-27T16:52:17Z ago

Apparently Docker for Mac does add a lot of filesystem I/O overhead, yeah.

The solution might be RAM disk, but the tmpfs method won’t work on Mac. You can use native Mac RAM disks, though, as documented here: https://devops.stackexchange.com/questions/4012/does-docker-on-macos-support-tmpfs

Can you try that and see if it speeds thing up?

Player art
  0:00 / 0:00