Repository navigation
test(bootstrap): isolate reset/0 tests from concurrent VM builds - #448
Merged
Merged
Conversation
The reset/0 tests assert that the node-global :persistent_term keys are
absent right after a reset. Under async: true any other test calling
Lua.new/1 between the reset and the assertion re-memoizes the default
template, so the suite failed intermittently with "reset/0 left
{Lua, :default_lua} behind", most often when machine load widened the
window. Move them to their own async: false module, which ExUnit runs only
after every async module has finished.
Test-only: reset/0 is documented as safe against concurrent fetch/2.
Five tests wrote under fixed or per-VM-unique names in System.tmp_dir!/0. Two mix test runs on one machine (parallel worktrees) shared those paths, and one run's cleanup deleted the other's files mid-test, failing SuiteRunnerTest and Mix.Tasks.Lua.SuiteTest with File.Error. Add the OS pid to each path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a flake seen locally and on CI (PR 440, job "Build and test (1.19.0 / OTP 28.1)", run 46663403944, seed 973823):
reset/0 left {Lua, :default_lua} behind after a concurrent cold startinLua.VM.BootstrapTest, which passes alone and on rerun.Cause
The memoized templates live in
:persistent_term, which is node-global.Lua.VM.BootstrapTestwasasync: true, and itsreset/0tests assert that the keys are absent right afterBootstrap.reset(). Any other async test that callsLua.new/1in that window cold-starts and re-puts{Lua, :default_lua}(and:base_state), so the assertion sees the key. With several thousand tests across 8 cases (and more on a loaded machine) the window gets hit now and then.Deterministic reproduction: a test that calls
reset/0, runsLua.new()in another process, then asserts the key is missing fails every time (probe kept outside the repo).Test-only
reset/0is documented as safe to call concurrently withfetch/2; concurrent callers just rebuild. No library change.Changes
reset/0tests intoLua.VM.BootstrapResetTestwithasync: false; ExUnit runs it only after every async module finishes, so nothing can repopulate the keys mid-test.mix testruns: five tests wrote to fixed (or per-VMunique_integer) paths underSystem.tmp_dir!/0, so a second run's cleanup deleted the first run's files (File.ErrorinSuiteRunnerTestandMix.Tasks.Lua.SuiteTest). Add the OS pid to those paths.Verification
mix format --check-formatted,mix compile --warnings-as-errors,mix test: 2794 tests, 0 failures. 20 full runs with random seeds, 5 of them overlapping a secondmix testin another worktree: all green. An earlier 20-run pass without the tmp-path change had 1 failure, in an overlapped run, from the tmp-path collision, never from the bootstrap test.