fix(test): replace flaky cache consistency assertion with independent invariants#42
Merged
Merged
Conversation
…variants The ConcurrentOperationsWithEviction test read EntryCount and CurrentSizeBytes in two non-atomic steps, then asserted exact equality. Under concurrent eviction, these properties can be observed at different points in time, causing intermittent failures. Replace with independent invariant checks: size >= 0, size <= capacity, size is a multiple of entry size (no partial leaks), and size == 0 when entry count is 0. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Test Results
SummarySummary
CoverageZipDrive - 2%
ZipDrive.Application - 85.4%
ZipDrive.Domain - 45.5%
ZipDrive.Infrastructure.Archives.Rar - 0%
ZipDrive.Infrastructure.Archives.Zip - 72.5%
ZipDrive.Infrastructure.Caching - 78.3%
ZipDrive.Infrastructure.FileSystem - 4.6%
ZipDrive.TestHelpers - 40.5%
|
There was a problem hiding this comment.
Pull request overview
This PR updates a flaky concurrency integration test in the caching subsystem by replacing an exact cross-property equality assertion with a set of invariant-based assertions that are intended to remain valid without requiring an atomic snapshot of multiple cache metrics.
Changes:
- Replaced
CurrentSizeBytes == EntryCount * entrySizewith invariant checks onCurrentSizeBytes. - Added assertions for non-negativity, capacity upper bound, and size alignment to entry size.
- Added a conditional empty-cache consistency assertion (
EntryCount == 0impliesCurrentSizeBytes == 0).
- Cast entrySize * cacheCapacity to long to prevent int overflow - Remove entryCount == 0 → size == 0 assertion (still cross-property) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
ConcurrentOperationsWithEvictiontest was intermittently failing in CI due to a non-atomic read ofEntryCountandCurrentSizeBytesfollowed by an exact equality assertionCurrentSizeBytes >= 0(never negative)CurrentSizeBytes <= capacity(never exceeds limit)CurrentSizeBytes % entrySize == 0(no partial entry size leaks)EntryCount == 0impliesCurrentSizeBytes == 0(empty cache has zero size)Test plan
🤖 Generated with Claude Code