summaryrefslogtreecommitdiff
path: root/tests/test_runner
diff options
context:
space:
mode:
authorCeesjan Luiten <ceesjan@ytec.nl>2021-05-21 16:49:01 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-06-10 07:32:15 +0200
commitcb6c19749d342c3dc0f97d89ff6887b220cf45b8 (patch)
tree911c7a6913243e29751ac0a056be54a55febb034 /tests/test_runner
parented3af3ff4b3cfb72de598f1b39a1028ba3826efb (diff)
Refs #27734 -- Prevented creation of more parallel workers than TestCases.
The parallel test runner uses multiple workers to distribute the workload. These workers are assigned a worker ID using a globally incremented variable, which determines what test database to connect to. When the worker ID surpasses the test database IDs Django will crash. This reduce likelihood of crashing parallel tests because ParallelTestSuite will no longer create more workers than TestCases. It won't eliminate the problem completely though because there are other circumstances in which new workers can be created which can then be assigned an "illegal" worker ID.
Diffstat (limited to 'tests/test_runner')
-rw-r--r--tests/test_runner/test_discover_runner.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/test_runner/test_discover_runner.py b/tests/test_runner/test_discover_runner.py
index 4eff76c5fd..3f840ee049 100644
--- a/tests/test_runner/test_discover_runner.py
+++ b/tests/test_runner/test_discover_runner.py
@@ -348,6 +348,12 @@ class DiscoverRunnerTests(SimpleTestCase):
with self.assertRaisesMessage(ValueError, msg):
DiscoverRunner(pdb=True, parallel=2)
+ def test_number_of_parallel_workers(self):
+ """Number of processes doesn't exceed the number of TestCases."""
+ runner = DiscoverRunner(parallel=5, verbosity=0)
+ suite = runner.build_suite(['test_runner_apps.tagged'])
+ self.assertEqual(suite.processes, len(suite.subsuites))
+
def test_buffer_mode_test_pass(self):
runner = DiscoverRunner(buffer=True, verbose=0)
with captured_stdout() as stdout, captured_stderr() as stderr: