#3098 Make tests faster
Merged by pingou. Opened by abompard.
abompard/pagure faster-tests  into  master

Download 3098.patch

This PR aims at reducing the duration of the unit tests. It's a big PR but composed of multiple topical commits, so it will be easier to look at each commit in order than the whole diff.

The improvements come from the following changes:

  • reducing the number of subprocess.call() calls (mostly in test_pagure_admin),
  • using only one DB session, emptying the DB in test tearDowns (it's surprisingly much faster than copying the DB file and recreating a session for each test, I tested both techniques)
  • running the tasks synchronously, which removes the need to start a worker process for each test.

With this changes, running the whole test suite takes about 15 minutes.

It would be possible to bring that duration down but only by doing much more invasive changes, like mocking out components that the test is not aimed at testing, so I think I can stop there for now (it's still 3 times faster after all ;-) ). Some tests are reaaaally long, several seconds, and I have yet to identify those. But that's a good start.

Some of these changes make me think I must have been really tired when I changed them...

I'm loving this, thank you so much for this :)

I'm waiting for the local run to finish and I'll merge!

Ran 912 tests in 1229.271s
OK (SKIP=1)
./runtests.sh  1106.89s user 16.12s system 91% cpu 20:31.11 total

Pull-Request has been merged by pingou

Metadata