Skip to content

JobMonitor: use test-run tags instead of name parsing - #17047

Merged
premun merged 1 commit into
dotnet:mainfrom
mmitche:jobmonitor-tags-migration
Jun 25, 2026
Merged

premun merged 1 commit into
dotnet:mainfrom
mmitche:jobmonitor-tags-migration

Conversation

@mmitche

@mmitche mmitche commented Jun 24, 2026

Copy link
Copy Markdown
Member

Fixes #17045

What

The Helix Job Monitor previously worked around an Azure DevOps bug — test-run tags posted when a run was created were silently dropped — by encoding the Helix job name into the test-run name as [HelixJob:<guid>] and parsing it back to deduplicate test-result uploads across monitor reruns.

The tags API now persists tags correctly when they are posted as objects at run completion, so this change replaces name parsing with real test-run tags.

How

  • Tag on completion. When the monitor completes a test run it tags it with the Helix job name, encoded as an alphanumeric helixjob<guid-without-dashes> tag (AzDO tags must be alphanumeric and ≤ 50 chars). Tagging at completion (not creation) preserves crash resilience: a tag exists iff the run completed and its results finished uploading.
  • Recover via the build-scoped endpoint. Already-uploaded jobs are discovered through the build-scoped test results tags endpoint on the vstmr host (GET /_apis/testresults/tags?buildId=...), which returns the union of tags across the build.
  • No backward compatibility. The legacy [HelixJob:...] name-marker read/write path is removed entirely — the new runner is not used against older test runs.

Verified behavior (live, against a dnceng-public build)

  • Tags persist only when posted as objects ({ "name": "..." }); the string form is silently dropped.
  • Tags must be alphanumeric, ≤ 50 chars, and are not returned inline on a run — only via the build-scoped vstmr tags endpoint.

Tests

  • Rewrote AzureDevOpsServiceTests and the fakes to model the verified production tag behavior.
  • Made FakeAzureDevOpsService faithfully model the real service (every create = a new run; no reuse), fixing a latent fake/real mismatch.
  • Full Microsoft.DotNet.Helix.Sdk.Tests suite: 146 passed, 0 failed.

The Helix Job Monitor previously worked around an Azure DevOps bug (test-run
tags posted at creation were silently dropped) by encoding the Helix job name
into the test-run *name* as `[HelixJob:<guid>]` and parsing it back to
deduplicate uploads across monitor reruns.

The tags API now works when tags are posted as objects at run completion, so
the monitor now:
- Tags each completed test run with the Helix job name, encoded as an
  alphanumeric `helixjob<guid-without-dashes>` tag (<=50 chars).
- Recovers already-uploaded jobs via the build-scoped test results tags
  endpoint on the vstmr host.

The legacy name-marker read/write path is removed entirely; the new runner is
not used against older test runs. Docs and tests are updated accordingly.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings June 24, 2026 21:45

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.

Pull request overview

Updates Helix Job Monitor’s Azure DevOps test-result deduplication strategy to rely on persisted test-run tags (applied at completion) instead of embedding/parsing [HelixJob:...] markers in test-run names. This aligns the monitor with current AzDO tag behavior while preserving crash-resilient reruns.

Changes:

  • Switch processed-job discovery to the build-scoped vstmr testresults tags endpoint and encode Helix job GUIDs into alphanumeric helixjob<guid-without-dashes> tags.
  • Apply the Helix-job tag when completing the run (PATCH), not when creating it (POST), and remove name-marker logic.
  • Rewrite/expand tests and fakes to model observed AzDO tag persistence/visibility behavior and “every create makes a new run” semantics.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Microsoft.DotNet.Helix/Sdk/Readme.md Updates SDK documentation to describe tag-based deduplication.
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/JobMonitorRunnerTests.cs Adjusts runner retry expectations to reflect orphaned runs on failed uploads.
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/Fakes/FakeAzureDevOpsTestRunsHandler.cs Updates fake HTTP handler to model tag persistence and build-scoped tag retrieval.
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/Fakes/FakeAzureDevOpsService.cs Aligns fake service behavior with “always create a new run” semantics and new method signatures.
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/AzureDevOpsServiceTests.cs Rewrites tests around completion-time tagging, build-scoped tag discovery, and encoding/rewriting helpers.
src/Microsoft.DotNet.Helix/JobMonitor/TestResultUploadQueue.cs Updates calls to create/complete run to match new tag-based API.
src/Microsoft.DotNet.Helix/JobMonitor/Services/AzureDevOpsService.cs Implements tag encoding/decoding, vstmr host rewriting, build-scoped tag discovery, and completion-time tagging.
src/Microsoft.DotNet.Helix/JobMonitor/MonitorState.cs Updates comment to reflect tag-based seeding of processed jobs.
src/Microsoft.DotNet.Helix/JobMonitor/JobMonitorRunner.Design.md Updates design doc to describe tag-based durable state and recovery path.
src/Microsoft.DotNet.Helix/JobMonitor/Interfaces/IAzureDevOpsService.cs Updates interface contract for create/complete run to support tag-based deduplication.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +312 to +314
The upload sequence per job is: create (or reuse) a test run with the plain
`{TestRunName}`, download results, upload them, complete the test run and tag
it with the Helix job name (`helixjob<guid>`).
@mmitche
mmitche requested a review from premun June 24, 2026 21:59
@premun premun changed the title JobMonitor: use test-run tags instead of name parsing (#17045) JobMonitor: use test-run tags instead of name parsing Jun 25, 2026
@premun
premun merged commit b076228 into dotnet:main Jun 25, 2026
15 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jun 26, 2026
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.

Update Job monitor to use tags instead of name parsing

3 participants