Add elapsed-time telemetry to RunProcessAndGetOutput test helper#13829
Conversation
There was a problem hiding this comment.
Pull request overview
Adds elapsed-time telemetry to the RunnerUtilities.RunProcessAndGetOutput unit-test helper so test runs emit timing info even when they succeed, helping callers tune timeout budgets with real data.
Changes:
- Start a
Stopwatcharound process execution/waiting logic. - Emit a new
WriteOutputline that reports elapsed time, configured budget, and computed headroom.
Comments suppressed due to low confidence (1)
src/UnitTests.Shared/RunnerUtilities.cs:180
- In
DebugUnitTestsmode the timeout budget isn’t enforced (the code usesWaitForExit()with no timeout), but the telemetry line still reportsbudget/headroombased ontimeoutMilliseconds. This can produce misleading negative headroom for successful runs; consider either skipping the budget/headroom fields whenTraits.Instance.DebugUnitTestsis true or logging a distinct message indicating the run was unbounded.
Stopwatch sw = Stopwatch.StartNew();
if (Traits.Instance.DebugUnitTests)
{
p.WaitForExit();
}
else if (!p.WaitForExit(timeoutMilliseconds))
There was a problem hiding this comment.
Review Summary — PR #13829
Clean, low-risk change adding timing telemetry to test infrastructure (RunnerUtilities.cs).
| Status | Dimensions |
|---|---|
| ✅ LGTM (22) | Backwards Compat, ChangeWave, Performance, Test Coverage, Error Messages, Logging, String Comparison, API Surface, Target Authoring, Design, Cross-Platform, Code Simplification, Concurrency, Naming, SDK Integration, Idiomatic C#, File I/O, Build Infrastructure, Scope, Evaluation Model, Dependency Mgmt, Security |
| 📝 NIT (1) | Documentation Accuracy — phantom workflow reference |
| ⏭️ N/A (1) | Correctness — no edge case concerns for local Stopwatch in test code |
Assessment: The Stopwatch is a local variable with no concurrency/shared-state concerns. The System.Diagnostics using already exists. The arithmetic (timeoutMilliseconds - sw.ElapsedMilliseconds) correctly promotes int to long. Negative headroom in the DebugUnitTests path (no timeout enforcement) or when stream flushing exceeds budget is valid and useful information.
One minor nit filed inline about the comment referencing a non-existent workflow.
Note
🔒 Integrity filter blocked 1 item
The following item were blocked because they don't meet the GitHub integrity level.
- #13829
pull_request_read: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
To allow these resources, lower min-integrity in your GitHub frontmatter:
tools:
github:
min-integrity: approved # merged | approved | unapproved | noneGenerated by Expert Code Review (on open) for issue #13829 · ● 1.5M
823de5a to
1e89a6a
Compare
|
Thanks for the review. Addressed the legitimate concern; commented on the others. Addressed (force-pushed):
Not addressed:
This PR is test infra only ( |
1e89a6a to
e79c332
Compare
Replaces the global default-timeout bump (reviewed against on PR #45) with elapsed-time logging in the bootstrap-MSBuild test helper. The Stopwatch around WaitForExit lets callers see actual ms taken vs the budget, so when follow-up PRs add per-test timeout overrides (e.g. the unmerged NetTaskHostTest_FallbackToDotnet tests tracked in #41/#42), the author can pick a tight value based on data instead of guessing. Rationale for not bumping the default: the helper is called from 53 test sites across 11 files; a global bump would silently triple the worst-case budget for tests that today don't even use 30s, masking perf regressions. The two flaky tests cited in the original issues don't exist in main yet (they're on a feature branch), so per-call scoping isn't possible today; this PR makes the data available so it can be scoped correctly when they land. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
e79c332 to
34add7c
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Heads-up: auto-merge fired ~6 s before I checked, so this actually landed. Disregard the prior comment about #13836 — that PR is being closed as a duplicate. |
|
24h post-merge data from Aggregate across 5 414 process exits captured by the new telemetry (no
Useful signal:
Egregious cases — note that Not opening a follow-up PR for that here (out of scope for this telemetry PR), but flagging it as a worthwhile target for a separate cleanup — the helper now makes that kind of audit possible across all ~50 callers without extra instrumentation. |
The bootstrap-MSBuild test helper (
RunProcessAndGetOutputinsrc/UnitTests.Shared/RunnerUtilities.cs) currently surfaces wall-clock duration only when the process exceeds its timeout. On success the caller has no signal at all about how close to the budget it ran.This makes timeout tuning blind — both raising a budget (no data to justify the new value) and tightening one later (no data showing actual elapsed never approached the previous value).
Change
Wrap the existing
WaitForExitwith aStopwatchand logelapsedMs/budgetMs/headroomMson success via the existingWriteOutputpath. Pure additive — no behavior change.Risk
Test-only helper, single
WriteOutputline added. All ~50 callers benefit; none are affected.