shlogg · Early preview
Augusts Bautra @augustsbautra

Transactional Specs Reduce CI Run Time Spikes

Parallel RSpec runners on CI took 12-20min due to specs writing to DB & DatabaseCleaner cleanup. Switched from :truncation to :deletion, reducing spikes by 60s. Monitoring run times is key to preventing issues.

TL;DR

Make as many specs as possible be transactional (this can even be done for cucumbers!), especially for shared-example-using files where there are usually many examples. 
In those examples that actually write to DB for some reason, try switching from :truncation to :deletion. In our case, running postgres, oftentimes truncation randomly stalled for 2 minutes. Deletion sidesteps this.

  
  
  The Story

It somehow came to my attention that there's a huge variance in how long parallel RSpec runners take on CI, sometimes spiking from the 12min average to 20min and more, and routinely excee...