Commit Graph

2 Commits

Author SHA1 Message Date
Adam Coldrick 6cdc6f4bfb Use one database per test class rather than per test
When running the test suite using MySQL, a lot of time is spent
creating the database, running the migrations, and then dropping
the database when the test finishes. Obviously we need a clean
database at the start of each test, but that doesn't mean we need
to run the migrations every single time.

Setting parallel_class to True in .stestr.conf makes all the tests
in a given class run in the same subprocess, whilst retaining
parallelisation when there is more than one test class discovered.

This commit moves the setup and cleanup of the database to the class
level rather than the test level, so that the slow migration step only
runs once per test class, rather than once per test. Cleaning the
database between tests is done by deleting everything from the tables
(excepting the tables that are populated by the migrations themselves),
and resetting any autoincrement counters.

This reduces the runtime of the individual tests by an order of
magnitude locally, from about 10 seconds per test to about 1 second per
test with this patch applied. There is still some overhead for each
class, but I can now run the test suite in about 15 minutes with MySQL
on my machine, as opposed to over an hour previously.

Change-Id: I1f38a3c4bf88cba8abfaa3f7d39d1403be6952b7
2019-03-18 15:24:05 +00:00
Matthew Treinish f7556744bb
Bump minimum os-testr requirement to 1.0.0
This commit bumps the os-testr version to use 1.0.0. 1.0.0 changes the
internals to use stestr instead of subprocessing testr. A bunch of
incorrect imports in the tests were updated as a well, relying on
relative import paths is finicky at the best of times so to make the
tests work this just points to the path based on the root of the package
instead.

Change-Id: I2aed3f6a9adeac2b7dbe58ee12c0a1485278d56f
2017-10-16 20:29:39 -04:00