Skip to content

Harden Helix test result publishing - #17460

Merged
mmitche merged 3 commits into
dotnet:mainfrom
mmitche:dev/helix-result-publishing-retries
Sep 1, 2026
Merged

mmitche merged 3 commits into
dotnet:mainfrom
mmitche:dev/helix-result-publishing-retries

Conversation

@mmitche

@mmitche mmitche commented Aug 31, 2026

Copy link
Copy Markdown
Member

Summary

  • process and observe test results before creating the Azure DevOps test run, so publication failures cannot hide failed tests
  • retry transient test-run creation failures and stop publication for the affected Helix job when creation retries are exhausted
  • separate local result parsing and aggregation from Azure DevOps payload publication
  • keep Azure DevOps authentication, retries, rate limiting, and metrics in the shared service while exposing a narrow result transport interface
  • keep result publication failures warning-only while preserving the observed test outcome for monitor exit behavior

Testing

  • eng\common\dotnet.ps1 test .\src\Microsoft.DotNet.Helix\Sdk.Tests\Microsoft.DotNet.Helix.Sdk.Tests\Microsoft.DotNet.Helix.Sdk.Tests.csproj --no-restore --configuration Debug --verbosity minimal (301 passed)

Process and observe test results before creating the Azure DevOps test run so publication failures cannot hide failed tests. Retry transient run creation failures, stop publication for the affected job when creation is exhausted, and keep upload failures warning-only.

Separate local result processing from Azure DevOps payload publication, while retaining the shared service for authenticated result transport, retries, rate limiting, and metrics.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 53128524-5f5d-453a-83c7-02d0302d83b0
Copilot AI lite review requested due to automatic review settings August 31, 2026 17:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR hardens Helix job monitor test-result publishing by separating local result parsing/aggregation from Azure DevOps publication, ensuring failing tests are observed before any Azure DevOps write operations can fail and mask outcomes.

Changes:

  • Introduces ITestResultProcessor + IAzureDevOpsResultPublisher to split local TRX processing from Azure DevOps publishing.
  • Observes/records test outcomes prior to test-run creation and publication, and retries transient test-run creation failures.
  • Refactors Azure DevOps result transport to include testRunId in the transport interface and centralize HTTP concerns in AzureDevOpsService.
File summaries
File Description
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/JobMonitorRunnerTests.cs Updates job monitor tests for the new observed-then-publish flow and renamed fake APIs.
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/Fakes/FakeHelixService.cs Adds download-test-results call counting for new behaviors asserted in tests.
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/Fakes/FakeAzureDevOpsService.cs Implements new processing/publishing interfaces used by the pipeline and updates counters/behavior.
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/AzureDevOpsServiceTests.cs Adjusts service tests for new transport surface and transient create retry behavior.
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/AzureDevOpsResultPublisherTests.cs Updates transport signatures and moves “all passed” computation coverage to the processor.
src/Microsoft.DotNet.Helix/JobMonitor/TestResultUploadPipeline.cs Reorders pipeline to prepare/observe results before creating runs and publishing; adds creation-failure single-reporting.
src/Microsoft.DotNet.Helix/JobMonitor/TestResults/TestResultProcessor.cs New local parsing/aggregation component that returns prepared results + computed pass/fail.
src/Microsoft.DotNet.Helix/JobMonitor/TestResults/PreparedTestResults.cs Replaces the old upload summary with prepared aggregated results + pass/fail outcome.
src/Microsoft.DotNet.Helix/JobMonitor/TestResults/ITestResultProcessor.cs New interface for local result preparation.
src/Microsoft.DotNet.Helix/JobMonitor/TestResults/IAzureDevOpsResultTransport.cs Updates transport to carry testRunId for result/attachment publication.
src/Microsoft.DotNet.Helix/JobMonitor/TestResults/IAzureDevOpsResultPublisher.cs New interface for publishing prepared results into an Azure DevOps run.
src/Microsoft.DotNet.Helix/JobMonitor/TestResults/AzureDevOpsResultPublisher.cs Refactors publisher to consume prepared results and publish via the updated transport.
src/Microsoft.DotNet.Helix/JobMonitor/Services/AzureDevOpsService.cs Implements the updated transport interface and enables transient retries for test run creation.
src/Microsoft.DotNet.Helix/JobMonitor/MonitorState.cs Updates state observation API to track pass/fail as a boolean rather than upload summary.
src/Microsoft.DotNet.Helix/JobMonitor/JobMonitorRunner.cs Wires processor/publisher into the runner and production dependency creation.
src/Microsoft.DotNet.Helix/JobMonitor/Interfaces/IAzureDevOpsService.cs Removes the old per-work-item upload method from the core service interface.
src/Microsoft.DotNet.Helix/JobMonitor/Design/Components/UploadPipeline.md Updates design doc to reflect the new prepare/observe/publish responsibilities and retry semantics.
Review details

Suppressed comments (1)

src/Microsoft.DotNet.Helix/JobMonitor/Services/AzureDevOpsService.cs:465

  • This call mixes a named argument (retryTransientFailures: true) followed by positional arguments. C# requires all arguments after the first named argument to also be named, so this will not compile.
                body.ToString(Formatting.None),
                AzureDevOpsRequestKind.Attachment,
                retryTransientFailures: true,
                ResultRequestAttemptCount,
                cancellationToken);
  • Files reviewed: 17/17 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +84 to +88
=> UploadTestResultsWithCountAsync(
results,
workItemName,
jobId,
testRunId: 0,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in a8bebfe. Removed the overload that hardcoded run 0; the tests now use the production PublishAsync path with an explicit test run ID and verify that ID reaches the transport.

@mmitche
mmitche requested a review from premun August 31, 2026 19:54
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copilot AI review requested due to automatic review settings September 1, 2026 14:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Review details

Suppressed comments (1)

src/Microsoft.DotNet.Helix/JobMonitor/TestResults/AzureDevOpsResultPublisher.cs:89

  • UploadTestResultsWithCountAsync defaults testRunId to 0, but IAzureDevOpsResultTransport now requires a real run id for both result publication and attachment upload. This overload can silently produce invalid requests (e.g., /runs/0/...) if it’s ever used with the production transport; consider removing it or requiring an explicit testRunId parameter (and updating the unit tests accordingly).
    public Task<long> UploadTestResultsWithCountAsync(
        IEnumerable<AggregatedResult> results,
        string workItemName,
        string jobId,
        CancellationToken cancellationToken = default)
        => UploadTestResultsWithCountAsync(
            results,
            workItemName,
            jobId,
            testRunId: 0,
            cancellationToken);
  • Files reviewed: 17/17 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Remove the test-only publishing overload that targeted run 0. Exercise the production PublishAsync path in publisher tests and verify the supplied run ID reaches the transport.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 53128524-5f5d-453a-83c7-02d0302d83b0
Copilot AI review requested due to automatic review settings September 1, 2026 14:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

src/Microsoft.DotNet.Helix/JobMonitor/Design/Components/UploadPipeline.md:45

  • This design doc says the result publisher uses “run-specific transports supplied by the service”, but the code now has AzureDevOpsService implement IAzureDevOpsResultTransport directly and the transport methods take an explicit testRunId. Updating this description will keep the design doc aligned with the current architecture.
`IAzureDevOpsService` owns authenticated Azure DevOps REST operations and the
test-run lifecycle. It does not read local result files. The result publisher
uses run-specific transports supplied by the service, keeping conversion and
batching separate from HTTP retry and authentication.
  • Files reviewed: 17/17 changed files
  • Comments generated: 1
  • Review effort level: Lite

@mmitche
mmitche enabled auto-merge (squash) September 1, 2026 15:46
@mmitche
mmitche merged commit 888b199 into dotnet:main Sep 1, 2026
12 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 2, 2026
@premun

premun commented Sep 2, 2026

Copy link
Copy Markdown
Member

/backport to release/10.0

@premun

premun commented Sep 2, 2026

Copy link
Copy Markdown
Member

/backport to release/11.0

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0 (link to workflow run)

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0 (link to workflow run)

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.

3 participants