Repository navigation
Use TimeProvider for SealedSecret sync-wait budget to fix SealedSecretApplyStepTests flake - #21530
Merged
Mitch Denny (mitchdenny) merged 1 commit intoNov 7, 2026
Conversation
WaitForSealedSecretSyncedAsync and InvokeProbeWithRemainingBudgetAsync measured their remaining budget against DateTimeOffset.UtcNow and CancelAfter, so the StatusMatchesButSecretAbsent test raced the wall clock: a slow first iteration under CI load consumed the whole budget before the second poll and the loop timed out after a single Secret probe. Inject a TimeProvider (production uses TimeProvider.System) and drive the test with FakeTimeProvider plus an explicit second-probe signal, so the budget only elapses when the test advances it. Fixes #19662 Co-authored-by: Copilot <[email protected]>
Contributor
|
🚀 Dogfood this PR with:
Or
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change making SealedSecret sync-wait timeout progression deterministic.
No open issues 🎉
What changed in this PR
Addresses the flaky SealedSecret sync-wait test in #19662 by making timeout progression deterministic, while retaining TimeProvider.System for production behavior.
Changes:
- Threads
TimeProviderthrough remaining-budget calculations, probe cancellation, and polling delays. - Updates the regression test to advance fake time only after the second Secret probe starts, with bounded waits to guard against hangs.
- Adds the test project’s
Microsoft.Extensions.TimeProvider.Testingdependency.
| File | Description |
|---|---|
| tests/Aspire.Hosting.Radius.Tests/Secrets/SealedSecretApplyStepTests.cs | Uses fake time for the flaky scenario and supplies a time provider at existing call sites. |
| tests/Aspire.Hosting.Radius.Tests/Aspire.Hosting.Radius.Tests.csproj | References the fake-time testing package. |
| src/Aspire.Hosting.Radius/Publishing/SealedSecretApplyStep.cs | Uses the supplied time provider consistently for budgets, cancellation, and delays. |
Review effort: Balanced
David Fowler (davidfowl)
marked this pull request as ready for review
October 31, 2026 06:25
This was referenced Nov 5, 2026
Mitch Denny (mitchdenny)
approved these changes
Nov 7, 2026
14 tasks
Mitch Denny (mitchdenny)
pushed a commit
that referenced
this pull request
Nov 10, 2026
…tApplyStepTests flake (#21530) ## Description Fixes #19662 `SealedSecretApplyStepTests.WaitForSealedSecretSynced_StatusMatchesButSecretAbsent_KeepsWaitingThenTimesOut` is flaky on CI. ### Root cause `WaitForSealedSecretSyncedAsync` and `InvokeProbeWithRemainingBudgetAsync` measured their budget against the wall clock (`DateTimeOffset.UtcNow` and `CancelAfter`). #19555 raised the test budget from 10ms to 250ms, but the test still failed on main on 10-12: under CI load, a slow first iteration (cold JIT, thread-pool starvation) can use up the whole budget before the second poll, so the loop times out after observing the absent Secret only once. ### Fix Inject a `TimeProvider` into the budget calculation, the probe timeout (`CancellationTokenSource(remaining, timeProvider)`) and the poll delay. Production passes `TimeProvider.System`, so runtime behavior is unchanged. The test now uses `FakeTimeProvider`: it waits until the second probe signals that it started, then calls `Advance` to exhaust the budget. The budget therefore only elapses after the loop has demonstrably kept waiting, regardless of runner speed. `Microsoft.Extensions.TimeProvider.Testing` is already centrally versioned in `Directory.Packages.props`; the test project only references it. ### Evidence - **Fail-before / pass-after:** with a 300ms stall injected into the first iteration, the old code failed 3/3 with the CI signature and the fixed code passed 5/5. - **Under load:** the `SealedSecretApplyStepTests` class passed 30/30 under CPU load. - **Full project:** `Aspire.Hosting.Radius.Tests` passed 669 tests, 0 failed. ## Checklist - Is this feature complete? - [x] Yes. Ready to ship. - [ ] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] Yes - [ ] No - Did you add public API? - [ ] Yes - [x] No - Does the change make any security assumptions or guarantees? - [ ] Yes - [x] No **🤖 Posted by AspireAgent (AI Agent)** Co-authored-by: davidfowl <[email protected]> Co-authored-by: Copilot <[email protected]> (cherry picked from commit c37dfbe)
Mitch Denny (mitchdenny)
pushed a commit
that referenced
this pull request
Nov 10, 2026
…tApplyStepTests flake (#21530) ## Description Fixes #19662 `SealedSecretApplyStepTests.WaitForSealedSecretSynced_StatusMatchesButSecretAbsent_KeepsWaitingThenTimesOut` is flaky on CI. ### Root cause `WaitForSealedSecretSyncedAsync` and `InvokeProbeWithRemainingBudgetAsync` measured their budget against the wall clock (`DateTimeOffset.UtcNow` and `CancelAfter`). #19555 raised the test budget from 10ms to 250ms, but the test still failed on main on 10-12: under CI load, a slow first iteration (cold JIT, thread-pool starvation) can use up the whole budget before the second poll, so the loop times out after observing the absent Secret only once. ### Fix Inject a `TimeProvider` into the budget calculation, the probe timeout (`CancellationTokenSource(remaining, timeProvider)`) and the poll delay. Production passes `TimeProvider.System`, so runtime behavior is unchanged. The test now uses `FakeTimeProvider`: it waits until the second probe signals that it started, then calls `Advance` to exhaust the budget. The budget therefore only elapses after the loop has demonstrably kept waiting, regardless of runner speed. `Microsoft.Extensions.TimeProvider.Testing` is already centrally versioned in `Directory.Packages.props`; the test project only references it. ### Evidence - **Fail-before / pass-after:** with a 300ms stall injected into the first iteration, the old code failed 3/3 with the CI signature and the fixed code passed 5/5. - **Under load:** the `SealedSecretApplyStepTests` class passed 30/30 under CPU load. - **Full project:** `Aspire.Hosting.Radius.Tests` passed 669 tests, 0 failed. ## Checklist - Is this feature complete? - [x] Yes. Ready to ship. - [ ] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] Yes - [ ] No - Did you add public API? - [ ] Yes - [x] No - Does the change make any security assumptions or guarantees? - [ ] Yes - [x] No **🤖 Posted by AspireAgent (AI Agent)** Co-authored-by: davidfowl <[email protected]> Co-authored-by: Copilot <[email protected]> (cherry picked from commit c37dfbe)
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.
Description
Fixes #19662
SealedSecretApplyStepTests.WaitForSealedSecretSynced_StatusMatchesButSecretAbsent_KeepsWaitingThenTimesOutis flaky on CI.Root cause
WaitForSealedSecretSyncedAsyncandInvokeProbeWithRemainingBudgetAsyncmeasured their budget against the wall clock (DateTimeOffset.UtcNowandCancelAfter). #19555 raised the test budget from 10ms to 250ms, but the test still failed on main on 10-12: under CI load, a slow first iteration (cold JIT, thread-pool starvation) can use up the whole budget before the second poll, so the loop times out after observing the absent Secret only once.Fix
Inject a
TimeProviderinto the budget calculation, the probe timeout (CancellationTokenSource(remaining, timeProvider)) and the poll delay. Production passesTimeProvider.System, so runtime behavior is unchanged. The test now usesFakeTimeProvider: it waits until the second probe signals that it started, then callsAdvanceto exhaust the budget. The budget therefore only elapses after the loop has demonstrably kept waiting, regardless of runner speed.Microsoft.Extensions.TimeProvider.Testingis already centrally versioned inDirectory.Packages.props; the test project only references it.Evidence
SealedSecretApplyStepTestsclass passed 30/30 under CPU load.Aspire.Hosting.Radius.Testspassed 669 tests, 0 failed.Checklist
🤖 Posted by AspireAgent (AI Agent)