Repository navigation
Extract shared experimental test output capture - #22716
Mitch Denny (mitchdenny) wants to merge 1 commit into
Conversation
Co-authored-by: Copilot App <[email protected]>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22716Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22716" |
Tests selector52 / 101 PR test projects · 4 PR jobs, from 20 changed files. Selected PR test projects (52 / 101)
Selected PR jobs (4)
How these were chosen — grouped by what changed
🧪 show 34
🔧 🧪 📦 affected project 📦 affected project 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 Job reasons
Selection computed for commit |
There was a problem hiding this comment.
🟡 Changes recommended
A pre-existing completion marker can remain visible after failed or cancelled capture leaves partial logs, and the tests do not cover the actual DCP log endpoint’s capture guarantees.
2 open issues
What changed in this PR
Extracts experimental raw test-output capture from the Go integration work into core Hosting, allowing language integrations to collect process output without depending on another hosting integration.
Changes:
- Adds shared
CaptureOutputAsync()support with separate stdout/stderr files, completion tracking, cancellation, and private file creation. - Connects collectors to DCP’s raw output streams and documents the supported execution contract.
- Adds capture and export tests, adapts coordinator construction, and updates generated SDK snapshots for five languages.
| File | Description |
|---|---|
| tests/Aspire.Hosting.TestUtilities/Utils/TestConsoleLogsService.cs | Adds configurable raw streams for tests. |
| tests/Aspire.Hosting.Tests/Cli/TestRunStreamingTests.cs | Supplies the coordinator’s logger dependency. |
| tests/Aspire.Hosting.Tests/Cli/TestRunCoordinatorTests.cs | Updates coordinator construction. |
| tests/Aspire.Hosting.Tests/Cli/TestOutputCaptureTests.cs | Tests capture, cancellation, artifacts, and safety checks. |
| tests/Aspire.Hosting.Tests/Cli/TestingCollectorTests.cs | Updates collector test setup. |
| tests/Aspire.Hosting.Dotnet.Tests/MsTestCollectorTests.cs | Adapts MSTest coordinator construction. |
| tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/TestOutputCaptureExportTests.cs | Tests Hosting-only experimental export. |
| tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts | Records TypeScript capture bindings. |
| tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TestOutputCaptureExportTests.GeneratesExperimentalCaptureOutputWithoutIntegrationAssemblies.verified.txt | Records the standalone capture export. |
| tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/MsTestExportTests.GeneratesOneAddMsTestMethodWithTypedOptionsAndExecutableCapabilities.verified.txt | Updates MSTest’s shared context projection. |
| tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs | Records the Rust capture binding. |
| tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py | Records the Python capture binding. |
| tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java | Records the Java capture binding. |
| tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go | Records the Go capture binding. |
| src/Aspire.Hosting/README.md | Documents experimental collection and artifact guarantees. |
| src/Aspire.Hosting/IConsoleLogsService.cs | Adds the raw-stream service contract. |
| src/Aspire.Hosting/Dcp/DcpResourceWatcher.cs | Opens separate timestamp-free DCP streams. |
| src/Aspire.Hosting/Cli/TestRunCoordinator.cs | Connects runtime collectors to capture. |
| src/Aspire.Hosting/Cli/TestOutputCapture.cs | Implements stream persistence and completion marking. |
| src/Aspire.Hosting/ApplicationModel/ResourceTestingContext.cs | Exposes and shares the capture task. |
| src/Aspire.Hosting/ApplicationModel/ResourceLoggerService.cs | Delegates raw-stream access to the console service. |
Review effort: Balanced
| // Open both destinations before draining either stream. CreateNew prevents reusing a stale | ||
| // report or following an existing file symlink. Mark completion only after both streams drain. | ||
| using var stop = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); | ||
| var stdout = CreateFile(context.OutputPath, "stdout.log"); |
| return _kubernetesService.GetLogStreamAsync(executable, | ||
| standardError ? Logs.StreamTypeStdErr : Logs.StreamTypeStdOut, | ||
| cancellationToken, follow: true, timestamps: false, lineNumbers: false); |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |


Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
55b3ffe76415044c2834e36d150c7f0aec0bf33a↑ 153 focused capture, cancellation, MSTest compatibility and SDK generation tests pass.
↓ Live DCP end-to-end capture and Windows/Linux execution were not validated; private-artifact behavior has not had independent security review.
Description
Test integrations need raw process output without depending on another language's hosting integration. This standalone prerequisite extracts the experimental
ResourceTestingContext.CaptureOutputAsync()capability from #21585 into core Hosting, against main rather than the integration stack.Collectors can await authoritative completion, including failed execution, and capture separate timestamp-free stdout/stderr streams into their private output directory. Both streams must reach EOF and both files must close before
output.completeis created. Repeated calls share the same capture task, including faults; collection cancellation and deadlines still apply. Ordinary run behavior is unchanged.The raw accessor, DCP durable-stream adapter, capture implementation, coordinator wiring, README contract and constructor adaptations match prepared Go revision
1a6812bafe33a93a036ec94a0659f7985aa7c38bexactly. Capture tests retain the same behavior, with inert executable names changed fromgototest-runner. The scanner/export regression scans only Hosting; no Go integration project reference was added. SDK snapshots were regenerated normally for all five language generators, including the original 35-line Go projection.No Go parser, resource, factory API, playground integration, language-specific testing integration, or stack metadata is included. Existing merged foundation and MSTest support are the only prerequisites. Extraction base:
d390bb0f5b6ef991e94f48222e9220b599324cb7.User-facing usage
Inside an experimental runtime test collector:
This supports one native, non-terminal executable invocation. Integrations must prevent replicas, restarts and retries before launch. Partial artifacts remain on failures without a completion marker.
Security considerations
Capture writes exclusively created files inside the existing private test output directory, uses Unix 0600 permissions, and rejects symlinked/reparse-point output directories and existing artifacts. Raw output may contain sensitive process data. No new listener or process launch is introduced. Independent threat modeling/security review and live cross-platform validation were not performed.
Validation
All final targeted runs passed on macOS arm64: 126 core Hosting tests, 20 MSTest collector tests, 3 TypeScript export/scanning tests, and one scanning test each for Go, Python, Rust and Java (153 total). Initial expected snapshot mismatches were regenerated, reviewed and rerun successfully. Live DCP capture, full repository suites, Windows and Linux were not run.
SDK restore — passed:
Raw capture, collector deadlines/cancellation, streaming and completion — passed, 126 tests:
Merged MSTest constructor/DI and collection compatibility — passed, 20 tests:
Hosting-only experimental export, MSTest projection and TypeScript scanning — passed, 3 tests:
Go shared SDK projection — passed, 1 test:
Remaining affected shared SDK projections — passed, 1 test per language:
Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?