fix(test): serialize tests that mutate CORTEX_MAX_TOPOLOGY_BYTES#5
Merged
Conversation
`topology_size_limit_enforced` sets the env var to 16 to force the
size guard to fire, then unsets it. `cargo test` runs tests in
parallel by default, so a sibling test (`topology_round_trips_on_disk`)
that calls `read_topology` while the limit is in effect spuriously
fails with `TopologyTooLarge { bytes: 209, limit: 16 }`. Local runs
happened to schedule the tests in an order that avoided the race;
fresh CI hit it.
Fix is a module-level `Mutex` that both env-touching tests acquire.
The lock is poison-safe via `unwrap_or_else(|e| e.into_inner())` so
one test panicking can't permanently wedge the suite.
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.
Summary
CI failed on
disk::tests::topology_round_trips_on_diskwith:Root cause
topology_size_limit_enforcedmutates process-global state — it setsCORTEX_MAX_TOPOLOGY_BYTES=16to force the size guard to fire, then unsets it.cargo testruns tests in parallel by default, so whentopology_round_trips_on_diskhappens to callread_topologyduring that window it observes the 16-byte limit and trips the guard against the real ~209-byte topology file.Local runs happened to schedule the tests in an order that avoided the race; fresh CI hit it.
Fix
Module-level
Mutex<()>that both env-touching tests acquire before reading or writing the env var. Lock is poison-safe viaunwrap_or_else(|e| e.into_inner())so a panic in one test can't permanently wedge the rest.No production code change — the env var contract and the production read path are unchanged.
Test plan
cargo test -p hebb --features disk— green