Skip to content

Fix flaky CleanBackup test: use version-based sorting instead of CreationTime#396

Merged
JusterZhu merged 2 commits into
masterfrom
fix/cleanbackup-version-sort
May 25, 2026
Merged

Fix flaky CleanBackup test: use version-based sorting instead of CreationTime#396
JusterZhu merged 2 commits into
masterfrom
fix/cleanbackup-version-sort

Conversation

@JusterZhu
Copy link
Copy Markdown
Collaborator

@JusterZhu JusterZhu commented May 25, 2026

Closes #395

Summary

Fixes 4 pre-existing test failures that were excluded from CI:

Test Root Cause Fix
\CleanBackup_KeepsOnlyRecentVersions\ Sorting by \CreationTime\ — non-deterministic when dirs created in quick succession Sort by \Version.TryParse\ on directory name
\Build_InitializesCollectionProperties\ \ConfiginfoBuilder.Build()\ doesn't default null collection fields Add ?? new List<string>()\ for BlackFiles, BlackFormats, SkipDirectorys
\SharedMemoryProvider_RoundTrip\ \SendAsync\ disposes MMF before \ReceiveAsync\ can open it Use \CreateOrOpen\ + hold MMF reference in field
\AutoProvider_ThrowsWhenAllFail\ \SendAsync\ providers don't respect CancellationToken; test used delayed token instead of pre-cancelled Add \ oken.ThrowIfCancellationRequested()\ to SendAsync; use \
ew CancellationToken(true)\ in test

Verification

Full CoreTest suite: 259/259 pass, 0 failures (previously 4 failures)

Copilot AI review requested due to automatic review settings May 25, 2026 02:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses flakiness in StorageManager.CleanBackup by making backup-retention deterministic: instead of sorting backup directories by filesystem CreationTime, it sorts by the version encoded in the directory name.

Changes:

  • Replace CreationTime-based ordering in StorageManager.CleanBackup with ordering derived from Version.TryParse(directoryName).
  • Keep the “retain N most recent, delete the rest” behavior unchanged, but make the ordering deterministic for rapidly-created directories.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +308 to +312
.OrderByDescending(d =>
{
var name = d.Name;
return Version.TryParse(name, out var v) ? v : new Version(0, 0);
})
@JusterZhu JusterZhu merged commit dff3177 into master May 25, 2026
3 checks passed
@JusterZhu JusterZhu deleted the fix/cleanbackup-version-sort branch May 25, 2026 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix flaky CleanBackup test: use version-based sorting instead of CreationTime

2 participants