Repository navigation
Handshake from test host orchestrator in dotnet test pipe protocol (#6179) #9215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Amaury Levé (Evangelink)
merged 7 commits into
main
from
dev/copilot/issue-6179-orchestrator-handshake
Jun 17, 2026
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7f6b852
Extract duplicate banner logic into OutputDeviceBannerHelper
Evangelink 74ffea6
Refactor TrxReportGeneratorCommandLine to extend ReportGeneratorComma…
Evangelink 58e97b7
Merge remote-tracking branch 'origin/main' into dev/amauryleve/issue-…
b681600
Handshake from test host orchestrator in dotnet test pipe protocol (#…
6c6d7c8
Address PR review: dispose pipe stream on cancellation; link changelo…
5ab7010
Refactor pipe accept loop to satisfy missing-dispose analyzer
Evangelink 1b3ed86
Reuse SDK version negotiation and own pipe stream lifetime via await …
Evangelink File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
123 changes: 123 additions & 0 deletions
123
...rm.Acceptance.IntegrationTests/DotnetTestPipe/DotnetTestPipeOrchestratorHandshakeTests.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| namespace Microsoft.Testing.Platform.Acceptance.IntegrationTests.DotnetTestPipe; | ||
|
|
||
| /// <summary> | ||
| /// Verifies that, under the <c>--server dotnettestcli</c> pipe protocol, the test host orchestrator | ||
| /// (here the retry orchestrator) performs the handshake as well — not only the test hosts it spawns. | ||
| /// This locks down <a href="https://github.com/microsoft/testfx/issues/6179">microsoft/testfx#6179</a>: | ||
| /// the orchestrator handshakes with <c>HostType=TestHostOrchestrator</c> and advertises the | ||
| /// orchestration feature responsible for the run via the <c>OrchestratorFeature</c> property. | ||
| /// </summary> | ||
| [TestClass] | ||
| public class DotnetTestPipeOrchestratorHandshakeTests : AcceptanceTestBase<DotnetTestPipeOrchestratorHandshakeTests.TestAssetFixture> | ||
| { | ||
| private const string AssetName = "DotnetTestPipeOrchestratorHandshake"; | ||
|
|
||
| // Mirrors HandshakeMessageHostTypes.TestHostOrchestrator on the testfx side. Kept as a literal | ||
| // here so the black-box harness stays decoupled from internal testfx types. | ||
| private const string TestHostOrchestratorHostType = "TestHostOrchestrator"; | ||
| private const string TestHostHostType = "TestHost"; | ||
|
|
||
| // The retry orchestrator extension Uid, sent as the OrchestratorFeature value. | ||
| private const string RetryOrchestratorFeature = "RetryOrchestrator"; | ||
|
|
||
| public TestContext TestContext { get; set; } = null!; | ||
|
|
||
| [TestMethod] | ||
| public async Task DotnetTestPipe_Orchestrator_HandshakesWithFeature() | ||
| { | ||
| var testHost = TestInfrastructure.TestHost.LocateFrom( | ||
| AssetFixture.TargetAssetPath, AssetName, TargetFrameworks.NetCurrent); | ||
|
|
||
| string resultDirectory = Path.Combine(testHost.DirectoryName, Guid.NewGuid().ToString("N")); | ||
|
|
||
| FakeDotnetTestSdkMultiConnectionResult result = await FakeDotnetTestSdkMultiConnection.RunAsync( | ||
| testHost, | ||
| extraArguments: $"--retry-failed-tests 3 --results-directory {resultDirectory}", | ||
| environmentVariables: new() { { EnvironmentVariableConstants.TESTINGPLATFORM_TELEMETRY_OPTOUT, "1" } }, | ||
| cancellationToken: TestContext.CancellationToken); | ||
|
|
||
| // The orchestrator process and the single (passing) test host it spawned should both have | ||
| // connected and handshaked. | ||
| Dictionary<byte, string> orchestratorHandshake = Assert.ContainsSingle(result.HandshakesWithHostType(TestHostOrchestratorHostType)); | ||
|
|
||
| Assert.IsTrue( | ||
| orchestratorHandshake.TryGetValue(DotnetTestPipeProtocol.HandshakeProperties.OrchestratorFeature, out string? feature), | ||
| "Orchestrator handshake is missing the OrchestratorFeature property."); | ||
| Assert.AreEqual(RetryOrchestratorFeature, feature); | ||
|
|
||
| // The actual test host (spawned by the orchestrator) handshakes as a plain TestHost and must | ||
| // NOT carry an orchestrator feature. | ||
| Dictionary<byte, string> testHostHandshake = Assert.ContainsSingle(result.HandshakesWithHostType(TestHostHostType)); | ||
| Assert.IsFalse( | ||
| testHostHandshake.ContainsKey(DotnetTestPipeProtocol.HandshakeProperties.OrchestratorFeature), | ||
| "Test host handshake should not carry the OrchestratorFeature property."); | ||
| } | ||
|
|
||
| public sealed class TestAssetFixture() : TestAssetFixtureBase() | ||
| { | ||
| private const string AssetCode = """ | ||
| #file DotnetTestPipeOrchestratorHandshake.csproj | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFrameworks>$TargetFrameworks$</TargetFrameworks> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| <OutputType>Exe</OutputType> | ||
| <UseAppHost>true</UseAppHost> | ||
| <LangVersion>preview</LangVersion> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.Testing.Platform" Version="$MicrosoftTestingPlatformVersion$" /> | ||
| <PackageReference Include="Microsoft.Testing.Extensions.Retry" Version="$MicrosoftTestingPlatformVersion$" /> | ||
| </ItemGroup> | ||
| </Project> | ||
|
|
||
| #file Program.cs | ||
| using Microsoft.Testing.Extensions; | ||
| using Microsoft.Testing.Platform.Builder; | ||
| using Microsoft.Testing.Platform.Capabilities.TestFramework; | ||
| using Microsoft.Testing.Platform.Extensions.TestFramework; | ||
|
|
||
| public class Program | ||
| { | ||
| public static async Task<int> Main(string[] args) | ||
| { | ||
| ITestApplicationBuilder builder = await TestApplication.CreateBuilderAsync(args); | ||
| builder.RegisterTestFramework(_ => new TestFrameworkCapabilities(), (_, __) => new DummyTestFramework()); | ||
| builder.AddRetryProvider(); | ||
| using ITestApplication app = await builder.BuildAsync(); | ||
| return await app.RunAsync(); | ||
| } | ||
| } | ||
|
|
||
| public class DummyTestFramework : ITestFramework | ||
| { | ||
| public string Uid => nameof(DummyTestFramework); | ||
| public string Version => "2.0.0"; | ||
| public string DisplayName => nameof(DummyTestFramework); | ||
| public string Description => nameof(DummyTestFramework); | ||
| public Task<bool> IsEnabledAsync() => Task.FromResult(true); | ||
| public Task<CreateTestSessionResult> CreateTestSessionAsync(CreateTestSessionContext context) | ||
| => Task.FromResult(new CreateTestSessionResult() { IsSuccess = true }); | ||
| public Task<CloseTestSessionResult> CloseTestSessionAsync(CloseTestSessionContext context) | ||
| => Task.FromResult(new CloseTestSessionResult() { IsSuccess = true }); | ||
| public Task ExecuteRequestAsync(ExecuteRequestContext context) | ||
| { | ||
| context.Complete(); | ||
| return Task.CompletedTask; | ||
| } | ||
| } | ||
| """; | ||
|
|
||
| public string TargetAssetPath => GetAssetPath(AssetName); | ||
|
|
||
| public override (string ID, string Name, string Code) GetAssetsToGenerate() => (AssetName, AssetName, | ||
| AssetCode | ||
| .PatchTargetFrameworks(TargetFrameworks.NetCurrent) | ||
| .PatchCodeWithReplace("$MicrosoftTestingPlatformVersion$", MicrosoftTestingPlatformVersion)); | ||
| } | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.