Skip to content

Serialize environment access between concurrent tests - #949

Merged
jonesbusy merged 2 commits into
oras-project:mainfrom
jonesbusy:fix/test-env-resource-lock
Oct 31, 2026
Merged

jonesbusy merged 2 commits into
oras-project:mainfrom
jonesbusy:fix/test-env-resource-lock

Conversation

@jonesbusy

@jonesbusy jonesbusy commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Tests mutating the process environment (HOME via TestUtils.withHome, REGISTRY_AUTH_FILE/XDG_RUNTIME_DIR in AuthStoreTest) raced with concurrently running tests building a Registry, which reads HOME to locate registries.conf. This caused random CI failures such as ContainerRefTest.shouldReadRegistriesConfig and
OCILayoutTest.shouldPushToOciLayoutWithoutTag.

  • Add EnvironmentLock: a SYSTEM_ENVIRONMENT resource lock key and a ResourceLocksProvider granting a READ lock to non-writer methods
  • Annotate env-mutating test methods with an exclusive lock
  • Cap the JUnit fork-join pool size to the configured parallelism to avoid compensation threads starting too many containers at once

Description

Testing done

Submitter checklist

  • I have read and understood the CONTRIBUTING guide
  • I have run mvn license:update-file-header, mvn spotless:apply, pre-commit run -a, mvn clean install before opening the PR

@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.60%. Comparing base (60b7dec) to head (e82c543).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #949      +/-   ##
============================================
+ Coverage     87.19%   87.60%   +0.41%     
  Complexity     1284     1284              
============================================
  Files            51       51              
  Lines          4131     4131              
  Branches        569      569              
============================================
+ Hits           3602     3619      +17     
+ Misses          309      292      -17     
  Partials        220      220              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Valentin Delaye <jonesbusy@users.noreply.github.com>
@jonesbusy
jonesbusy force-pushed the fix/test-env-resource-lock branch from 2999928 to 0ca73de Compare October 31, 2026 07:51
@jonesbusy
jonesbusy marked this pull request as ready for review October 31, 2026 08:21
@jonesbusy
jonesbusy merged commit 5f7a0a8 into oras-project:main Oct 31, 2026
9 checks passed
@jonesbusy
jonesbusy deleted the fix/test-env-resource-lock branch October 31, 2026 08:32
@jonesbusy jonesbusy changed the title test: serialize environment access between concurrent tests Serialize environment access between concurrent tests Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant