Project

General

Profile

Actions

Patch #44116

open

Enable parallel test execution by default

Added by Katsuya HIDAKA about 2 hours ago. Updated about 2 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Code cleanup/refactoring
Target version:
-

Description

This patch enables parallel tests by default.

  • Enable parallel tests by default.
  • Keep system tests single-process because they are not stable in parallel yet.
  • The worker count can still be changed by setting PARALLEL_WORKERS.
  • Adjust test code and configuration so tests run correctly and reliably in parallel.
  • Fix several flaky tests exposed by parallel test execution.

Why enable Parallel Testing by default?

  • Redmine's test workflow has gradually become slower. Fast and reliable test execution is essential for continuous development.
  • As the test suite grows, Parallel Testing becomes essential for keeping test execution fast.
  • Reliable parallel test execution requires test code and configuration that work correctly under parallel execution. To make this possible, we need to shift development to a workflow based on Parallel Testing.
  • Rails has long enabled Parallel Testing by default.

Performance

Before After
Test workflow runtime on GitHub Actions 12m32s (average for 2026-04) 5m29s (average of 5 runs)
bin/rails test runtime on MacBook Air M4 (10 processors) 2m29s 1m07s

Details

Enable parallel tests by default

  • Isolate attachment and thumbnail directories per worker to avoid filesystem interference between parallel tests.
  • Isolate generator test destination directories per worker to avoid cleanup conflicts between parallel tests.

Fix flaky IssueNestedSetConcurrencyTest

This stabilizes IssueNestedSetConcurrencyTest by initializing Active Record connections before running concurrent issue updates. This avoids random failures like the one below, which was exposed by parallel test execution.

Error:
IssueNestedSetConcurrencyTest#test_concurrent_subtask_removal:
RuntimeError: can't add a new key into hash during iteration
    test/unit/issue_nested_set_concurrency_test.rb:90:in `block (3 levels) in test_concurrent_subtask_removal'

bin/rails test test/unit/issue_nested_set_concurrency_test.rb:76

Fix flaky tests caused by locale leakage

This stabilizes tests affected by two locale-related test isolation problems.

First, a locale set by one test can leak to a later test in the same worker. For example, TimeEntryTest#test_should_not_accept_closed_issue failed because the locale remained Italian:

Failure:
TimeEntryTest#test_should_not_accept_closed_issue [test/unit/time_entry_test.rb:186]:
--- expected
+++ actual
@@ -1 +1 @@
-"Cannot log time on a closed issue" 
+"Impossibile registrare il tempo su una segnalazione chiusa" 

bin/rails test test/unit/time_entry_test.rb:178

Second, resetting the locale through set_language_if_valid 'en' in teardown can populate Redmine::I18n's language lookup cache while valid_languages is stubbed. This can make later tests unable to resolve non-English locales. For example, Redmine::I18nTest#test_french_locale failed because French could not be resolved and the locale stayed English:

Failure:
Redmine::I18nTest#test_french_locale [test/unit/lib/redmine/i18n_test.rb:256]:
Expected: "French (Français)" 
  Actual: "English" 

bin/rails test test/unit/lib/redmine/i18n_test.rb:254

To avoid these problems, this patch resets I18n.locale to I18n.default_locale before each test, and removes teardown code that reset the locale through set_language_if_valid 'en'.

These problems can happen even without parallel test execution because tests in the same process share locale-related global state. Parallel test execution can expose them more often.

Testing

  • Confirmed that all tests pass at least 10 times on GitHub Actions and locally.

Files

Actions #1

Updated by Katsuya HIDAKA about 2 hours ago

You can also find the details, code diff, and test results for this patch at https://github.com/hidakatsuya/redmine/pull/43.

Actions

Also available in: Atom PDF