Skip to content

Test framework overhaul (speed, reliability)

lain requested to merge cachex-test into develop

Contains parts of !3204 (closed).

mix test on current develop: Finished in 108.8 seconds

mix test on this branch: Finished in 89.0 seconds

This test contains an overhaul of how async and sync tests work, to improve both speed and reliability. It also shows a clear way to achieve more speedups in the future.

  1. Replaces sleeping with 'time travelling' the objects, that is, backdating them in the db.
  2. Replaces some Mocks with Mox. Mock / meck is quite slow, probably because it recompiles the modules twice. This also allows running tests in async mode that weren't possible before.
  3. Use Mox to stub Cachex either with a NullCache or the real cachex. Async tests must use the NullCache.
  4. Hunted down and fixed a few race conditions in several tests.

In general, tests that match these criteria can be made async:

  • Doesn't depend on real Cachex behavior.
  • Doesn't write to the Config / Application Environment.
  • Doesn't use Mock. Using Mox is fine.
  • Doesn't use the streamer.

Merge request reports