Skip to content

Bug: quickfiler-tests-depend-on-wall-clock-timing #950

Description

@drmoisan
  • Work Mode: full-bug

Summary

Several QuickFiler.Test tests fail intermittently under load because they wait on real wall-clock time. Seen during parallel run bugs-2026-09-28:

Environment

  • OS/version: Windows 11 (local, with concurrent coverage runs) and windows-latest (CI)
  • Python version: n/a (C# / MSTest, parallel Workers=0, Scope=ClassLevel)
  • Command/flags used: Invoke-MSTestWithCoverage.ps1, and the CI MSTest-with-coverage required check
  • Data source or fixture: n/a

Steps to Reproduce

  1. Run QuickFiler.Test under the parallel regime while the machine is loaded, for example with a second coverage run.
  2. Observe intermittent failures in the tests named above.

Expected Behavior

The tests are deterministic regardless of machine load.

Actual Behavior

  • QuickFiler.Test/Controllers/QfcDatamodelLivenessTests.cs uses SpinWait.SpinUntil(condition, TimeSpan.FromSeconds(5)) (line ~56) and .Task.Wait(TimeSpan.FromSeconds(5)) (lines ~103 and ~173). A slow scheduler turns these into assertion failures.
  • QuickFiler.Test/Controllers/QfcItemController.UiThreadDispatcherFixtureTests.cs:206 fails intermittently. Its cause is not yet established.

Logs / Screenshots

Impact / Severity

  • Blocker
  • High
  • Medium
  • Low

Source

From: docs/features/potential/2026-09-30-quickfiler-tests-depend-on-wall-clock-timing.md

Activity

  1. drmoisan commented on Sep 30, 2026

    @drmoisan
    OwnerAuthor

    Restoring sections dropped by the promotion tooling.

    Suspected Cause / Notes

    Real-time bounded waits violate the repository determinism rules: no wall-clock waits in tests, and use of FakeTimeProvider or a controllable scheduler.

    • QfcDatamodelLivenessTests.cs uses SpinWait.SpinUntil(..., TimeSpan.FromSeconds(5)) (line ~56) and .Task.Wait(TimeSpan.FromSeconds(5)) (lines ~103 and ~173).
    • The transaction test (QfcItemController.UiThreadDispatcherFixtureTests.cs:206) may be a different root cause. Triage it first, and split it into its own issue if its cause is not timing.

    This hits a required check. #944 needed a one-time gate re-run because of it.

    Proposed Fix / Validation Ideas

    • Replace the bounded waits with deterministic completion signals (TaskCompletionSource or awaited handles) or an injected TimeProvider.
    • Use no retries, [DoNotParallelize], Workers=1 or longer timeouts, and find any raced static state.
    • Negative control: show that each rewritten test fails when the awaited signal is never set.
  2. drmoisan commented on Oct 1, 2026

    @drmoisan
    OwnerAuthor

    Scope note from the #950 preparation research.

    The same bounded wall-clock wait pattern also exists in:

    • QuickFiler.Test/Controllers/QfcDatamodelTeardownTests.cs
    • QuickFiler.Test/Controllers/QfcInitEmailQueueZeroBatchTests.cs

    Both waits come from the same cause: QfcDatamodel.InitEmailQueue starts its worker on a thread pool the test cannot control. Fix them with the same seam #950 introduces. They can be included in #950's scope, or taken on in a follow-up branch immediately after #950 merges.

    The research also found that the transaction test failure (Transaction_SecondCallerCannotInstallUntilTheFirstRestores) has a different cause: UiThreadDispatcherFixture.EnsureDispatcher() replaces the shared dispatcher without taking the lock that guards it, while QfcItemController_FocusAndThemeTests runs in parallel. The proposed fix changes only test code and stays within #950.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions