Skip to content

v3: speedup tests

luna requested to merge v3-speedup-tests into v3

In my machine, the test suite went from ~140s to ~85s, bundling up with the DNS/IPv6 fixes on the gitlab runner @ laserjet, we went from 400-200s to ~150s.

Most of those optimizations were found by hand, cProfile + snakeviz did not help due to the amount of things pytest runs on top. The data was way, way too noisey for me to make any conclusions. --duration=N did help, though: tox -- tests --duration=30.

The main changes here are:

  • Instead of creating a new test user per test, we use one for the entire test suite run, this removes the overhead of creating and deleting a user
  • To prevent tests that are destructive from breaking other tests, the test user is reset (active set to true, passwords being updated, token being regenned), on every test. This is still faster than the create/delete overhead.
  • Because of that, upload tests that use png_data() had to be accounted for later, as deduplication doesn't happen between separate users. By changing all tests to use the same user, deduplication happens. png_data() now appends 10 random bytes per call.
  • Job queues are forced to have their workers run every second instead of whichever they set, speeding up tests that wait_job() on those queues.
  • Tests that assumed the test user will always be clean and have 0 files / 0 shortens were fixed.

Happy!!!!!!

Merge request reports