Project

General

Profile

Actions

Defect #44668

open

PatchesTest fails intermittently when tests are run in parallel

Added by Go MAEDA about 14 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Resolution:
Affected version:

Description

The tests for Propshaft::Assembly#manifest_outdated? and #needs_precompile? in test/unit/initializers/patches_test.rb, added in #44240, fail intermittently when the tests are run with multiple workers, such as PARALLEL_WORKERS=8 bin/rails test:

Errno::ENOENT: No such file or directory @ rb_sysopen - /path/to/redmine/public/assets/.manifest.json
    config/initializers/10-patches.rb:150:in 'Pathname#read'
    config/initializers/10-patches.rb:150:in 'manifest_outdated?'

The cause is that these tests temporarily overwrite and delete the actual manifest file, public/assets/.manifest.json, which is shared by all workers. As a result, a worker can fail when another worker deletes the file just before it is read, and a stale or invalid manifest can be left behind after the run.

The attached patch makes the tests point Rails.application.assets.config.manifest_path to a file in a temporary directory and restore the original value afterwards. The tested methods read config.manifest_path on every call, so they are still exercised in the same way. Only the test file is changed.

With PARALLEL_WORKERS=8, running PatchesTest together with other tests failed in every attempt without the patch, and passed in every attempt with it.


Files


Related issues

Related to Redmine - Defect #44240: Automatic asset precompilation (redmine_detect_update) fails to detect new assets whose files have older mtimes than the existing manifestClosedMarius BĂLTEANUActions
Actions

Also available in: Atom PDF