Skip to content

Fix flaky RestoreFromBackupAsync test: replace Progress<T> with synchronous IProgress<T> - #3

Merged
lukislp merged 2 commits into
mainfrom
copilot/fix-test-unit-job-failure
Aug 6, 2026
Merged

Fix flaky RestoreFromBackupAsync test: replace Progress<T> with synchronous IProgress<T>#3
lukislp merged 2 commits into
mainfrom
copilot/fix-test-unit-job-failure

Conversation

Copilot AI commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

The RestoreFromBackupAsync_ValidUnencryptedBackup_RunsImportButFailsAtRelationalOnlyTallyStep test was failing non-deterministically in CI. The root cause: it used new Progress<RestoreProgress>(...), which dispatches its callback asynchronously on the ThreadPool (no SynchronizationContext in xUnit). The first progress event (RestoreStep.Validating) is reported before any await, so its callback races the test's assertion and can miss the list.

Changes

  • DatabaseRestoreServiceTests.cs — replace the Progress<T> instance with SyncProgress<T>, a minimal file-scoped IProgress<T> that invokes the handler synchronously on the calling thread, making event capture deterministic:
// Before — async dispatch, racy
var progress = new Progress<RestoreProgress>(p => progressEvents.Add(p));

// After — synchronous, deterministic
IProgress<RestoreProgress> progress = new SyncProgress<RestoreProgress>(p => progressEvents.Add(p));

// Helper added at bottom of file
file sealed class SyncProgress<T>(Action<T> handler) : IProgress<T>
{
    public void Report(T value) => handler(value);
}

No production code was changed.

Co-authored-by: lukislp <155678024+lukislp@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing GitHub Actions job 'test-unit' Fix flaky RestoreFromBackupAsync test: replace Progress<T> with synchronous IProgress<T> Aug 6, 2026
Copilot AI requested a review from lukislp August 6, 2026 13:28
@lukislp
lukislp marked this pull request as ready for review August 6, 2026 13:31
@lukislp
lukislp merged commit f698937 into main Aug 6, 2026
5 of 6 checks passed
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.2.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@lukislp
lukislp deleted the copilot/fix-test-unit-job-failure branch August 6, 2026 13:44
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.

2 participants