Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/Changelog-Platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ See full log [of v4.4.1...main](https://github.com/microsoft/testfx/compare/v4.4

### Added

* Introduce an experimental `ITestHostExecutionOrchestratorMiddleware` composed around exactly one existing `ITestHostExecutionOrchestrator` invocation, as a v1 single-invocation composition boundary. Register middleware via the new `AddTestHostExecutionOrchestratorMiddleware` extension method on `ITestHostOrchestratorManager`. This is not a typed multi-run retry/stress/shard engine: middleware cannot repeat, shard, or rewrite the wrapped orchestrator's result, must propagate downstream exceptions and cancellation unchanged, and the existing `--retry-failed-tests` orchestrator is unaffected.
* Enable native Microsoft.Testing.Platform execution for UWP and AppContainer Windows test hosts through a full-trust sidecar controller, including exact package-SID authorization for controller and extension pipes, LocalState artifact recovery, and multi-host Retry activation.

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,22 @@ await LogTestHostCreatedAsync(
private async Task<IHost?> TryBuildTestHostOrchestratorHostAsync(BuildContext context)
{
TestHostOrchestratorConfiguration testHostOrchestratorConfiguration = await _testHostOrchestratorManager.BuildAsync(context.ServiceProvider).ConfigureAwait(false);
if (testHostOrchestratorConfiguration.TestHostOrchestrators.Length == 0

// Middleware only wraps an existing orchestrator invocation (see
// ITestHostExecutionOrchestratorMiddleware); it does not stand in for one. Registering middleware
// without also registering exactly one orchestrator is a misconfiguration, not silently ignored.
bool hasActiveMiddleware = testHostOrchestratorConfiguration.Middleware.Length > 0;

if ((testHostOrchestratorConfiguration.TestHostOrchestrators.Length == 0 && !hasActiveMiddleware)
|| context.CommandLineHandler.IsOptionSet(PlatformCommandLineProvider.DiscoverTestsOptionKey))
{
return null;
}

ValidateTestHostOrchestratorMiddlewareConfiguration(
testHostOrchestratorConfiguration.TestHostOrchestrators.Length,
testHostOrchestratorConfiguration.Middleware.Length);

if (testHostOrchestratorConfiguration.TestHostOrchestrators.Any(
static orchestrator => orchestrator is ITestHostControllerConnectionAuthorizationConsumer))
{
Expand All @@ -156,6 +166,18 @@ await context.ServiceProvider.ResolveTestHostControllerAuthorizedSecurityIdentit
return new TestHostOrchestratorHost(testHostOrchestratorConfiguration, context.ServiceProvider);
}

internal static void ValidateTestHostOrchestratorMiddlewareConfiguration(int orchestratorCount, int middlewareCount)
{
if (middlewareCount > 0 && orchestratorCount != 1)
{
throw new InvalidOperationException(
string.Format(
CultureInfo.InvariantCulture,
PlatformResources.TestHostExecutionOrchestratorMiddlewareRequiresExactlyOneOrchestratorErrorMessage,
orchestratorCount));
}
}

private async Task<IHost?> TryBuildTestHostControllersHostAsync(BuildContext context)
{
if (ShouldSkipTestHostControllersHost(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public async Task<int> RunAsync()
ITestHostExecutionOrchestrator testHostOrchestrator = _testHostOrchestratorConfiguration.TestHostOrchestrators[0];
ITestApplicationCancellationTokenSource applicationCancellationToken = _serviceProvider.GetTestApplicationCancellationTokenSource();

// When connected to dotnet test through the pipe protocol, handshake from the orchestrator too
// When connected to dotnet test through the pipe protocol, handshake from the orchestrator too.
// This identifies the participating orchestrator mode for the whole session; middleware that
// short-circuits still leaves the session in orchestrator mode and reports a non-success result.
// (test hosts and test host controllers already do). This lets the SDK know that an orchestrator
// (e.g. retry) is participating in the run, identified by the OrchestratorFeature property.
IPushOnlyProtocol? pushOnlyProtocol = _serviceProvider.GetService<IPushOnlyProtocol>();
Expand Down Expand Up @@ -71,7 +73,13 @@ await pushOnlyProtocol.StartServerControlChannelAsync(_ =>
await orchestratorLifetime.BeforeRunAsync(applicationCancellationToken.CancellationToken).ConfigureAwait(false);
}

exitCode = await testHostOrchestrator.OrchestrateTestHostExecutionAsync(applicationCancellationToken.CancellationToken).ConfigureAwait(false);
exitCode = _testHostOrchestratorConfiguration.Middleware.Length == 0
? await testHostOrchestrator.OrchestrateTestHostExecutionAsync(applicationCancellationToken.CancellationToken).ConfigureAwait(false)
: await TestHostExecutionOrchestratorMiddlewarePipeline.RunAsync(
_testHostOrchestratorConfiguration.Middleware,
testHostOrchestrator.OrchestrateTestHostExecutionAsync,
logger,
applicationCancellationToken.CancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException) when (applicationCancellationToken.CancellationToken.IsCancellationRequested)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,14 @@ static Microsoft.Testing.Platform.Hosts.TestHostControllersTestHost.TerminateTes
static Microsoft.Testing.Platform.Hosts.TestHostControllersTestHost.RunWithCancellationTeardownAsync(System.Func<System.Threading.Tasks.Task!>! runAsync, System.Threading.CancellationToken applicationCancellationToken, Microsoft.Testing.Platform.Helpers.IProcess! testHostProcess, System.Action! requestCancellation, Microsoft.Testing.Platform.Logging.ILogger! logger, System.TimeSpan cooperativeShutdownTimeout, System.TimeSpan terminationTimeout) -> System.Threading.Tasks.Task!
static Microsoft.Testing.Platform.Hosts.TestHostControllersTestHost.WaitForTestHostControllerConnectionAsync(System.Func<System.Threading.CancellationToken,System.Threading.Tasks.Task>! waitConnectionAsync, double timeoutSeconds, System.Threading.CancellationToken applicationCancellationToken, System.Func<System.Threading.Tasks.Task>! onTimeoutAsync) -> System.Threading.Tasks.Task<bool>
Microsoft.Testing.Platform.Hosts.TestHostControllersTestHost.TestHostCooperativeShutdownTimeout.get -> System.TimeSpan
static Microsoft.Testing.Platform.Hosts.TestHostBuilder.ValidateTestHostOrchestratorMiddlewareConfiguration(int orchestratorCount, int middlewareCount) -> void
Microsoft.Testing.Platform.IPC.NamedPipeServer.WaitForDisconnectAsync(System.TimeSpan timeout) -> System.Threading.Tasks.Task<bool>!
static Microsoft.Testing.Platform.Messages.ShutdownTimeouts.GetCanceledConsumerCompletion(string? value) -> System.TimeSpan
Microsoft.Testing.Platform.TestHostOrchestrator.TestHostOrchestratorConfiguration.TestHostOrchestratorConfiguration(Microsoft.Testing.Platform.Extensions.TestHostOrchestrator.ITestHostExecutionOrchestrator![]! testHostOrchestrators, Microsoft.Testing.Platform.Extensions.TestHostOrchestrator.ITestHostExecutionOrchestratorMiddleware![]! middleware) -> void
Comment thread
Evangelink marked this conversation as resolved.
Resolved
Microsoft.Testing.Platform.TestHostOrchestrator.TestHostOrchestratorConfiguration.Middleware.get -> Microsoft.Testing.Platform.Extensions.TestHostOrchestrator.ITestHostExecutionOrchestratorMiddleware![]!
Microsoft.Testing.Platform.TestHostOrchestrator.TestHostOrchestratorManager.AddTestHostExecutionOrchestratorMiddleware(System.Func<System.IServiceProvider!, Microsoft.Testing.Platform.Extensions.TestHostOrchestrator.ITestHostExecutionOrchestratorMiddleware!>! factory) -> void
Microsoft.Testing.Platform.TestHostOrchestrator.TestHostExecutionOrchestratorMiddlewarePipeline
static Microsoft.Testing.Platform.TestHostOrchestrator.TestHostExecutionOrchestratorMiddlewarePipeline.RunAsync(System.Collections.Generic.IReadOnlyList<Microsoft.Testing.Platform.Extensions.TestHostOrchestrator.ITestHostExecutionOrchestratorMiddleware!>! middlewareOutermostFirst, System.Func<System.Threading.CancellationToken, System.Threading.Tasks.Task<int>!>! innermost, Microsoft.Testing.Platform.Logging.ILogger! logger, System.Threading.CancellationToken rootToken) -> System.Threading.Tasks.Task<int>!
*REMOVED*Microsoft.Testing.Platform.ServerMode.ClientCapabilities.ClientCapabilities(bool DebuggerProvider, bool IsStateful) -> void
*REMOVED*Microsoft.Testing.Platform.ServerMode.ClientCapabilities.Deconstruct(out bool DebuggerProvider, out bool IsStateful) -> void
*REMOVED*Microsoft.Testing.Platform.ServerMode.ClientCapabilities.IsStateful.get -> bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
[TPEXP]Microsoft.Testing.Platform.Extensions.TestFramework.TestExecution.RunAsync<T>(System.Func<System.Threading.Tasks.Task<T>!>! callback) -> System.Threading.Tasks.Task<T>!
[TPEXP]Microsoft.Testing.Platform.Services.ClientCapabilitiesExtensions
[TPEXP]static Microsoft.Testing.Platform.Services.ClientCapabilitiesExtensions.GetIsStateful(this Microsoft.Testing.Platform.Services.IClientCapabilities! capabilities) -> bool?
[TPEXP]Microsoft.Testing.Platform.Extensions.TestHostOrchestrator.ITestHostExecutionOrchestratorMiddleware
[TPEXP]Microsoft.Testing.Platform.Extensions.TestHostOrchestrator.ITestHostExecutionOrchestratorMiddleware.OrchestrateTestHostExecutionAsync(System.Func<System.Threading.CancellationToken, System.Threading.Tasks.Task<int>!>! next, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<int>!
[TPEXP]Microsoft.Testing.Platform.TestHostOrchestrator.ITestHostExecutionOrchestratorMiddlewareManager
[TPEXP]Microsoft.Testing.Platform.TestHostOrchestrator.ITestHostExecutionOrchestratorMiddlewareManager.AddTestHostExecutionOrchestratorMiddleware(System.Func<System.IServiceProvider!, Microsoft.Testing.Platform.Extensions.TestHostOrchestrator.ITestHostExecutionOrchestratorMiddleware!>! factory) -> void
[TPEXP]Microsoft.Testing.Platform.TestHostOrchestrator.TestHostOrchestratorManagerExtensions
[TPEXP]static Microsoft.Testing.Platform.TestHostOrchestrator.TestHostOrchestratorManagerExtensions.AddTestHostExecutionOrchestratorMiddleware(this Microsoft.Testing.Platform.TestHostOrchestrator.ITestHostOrchestratorManager! manager, System.Func<System.IServiceProvider!, Microsoft.Testing.Platform.Extensions.TestHostOrchestrator.ITestHostExecutionOrchestratorMiddleware!>! factory) -> void
Microsoft.Testing.Platform.Builder.TestApplicationOptions.CancellationToken.get -> System.Threading.CancellationToken
Microsoft.Testing.Platform.Builder.TestApplicationOptions.CancellationToken.set -> void
[TPEXP]Microsoft.Testing.Platform.Extensions.TestHostControllers.ITestHostHandleExitCodePolicy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@
<value>The factory for composite extension '{0}' returned a null instance.</value>
<comment>{0} is the extension type name.</comment>
</data>
<data name="TestHostExecutionOrchestratorMiddlewareNextReturnedNullErrorMessage" xml:space="preserve">
<value>The test host execution orchestrator middleware continuation returned a null task.</value>
</data>
<data name="ConfigurationManagerCannotFindDefaultJsonConfigurationErrorMessage" xml:space="preserve">
<value>Could not find the default json configuration</value>
</data>
Expand Down Expand Up @@ -1053,6 +1056,30 @@ Valid values are 'allow-skipped' (the default) which counts skipped tests as run
<value>Test host controller extensions that require process restart are not supported on browser/WebAssembly platforms.</value>
<comment>{Locked="WebAssembly"}</comment>
</data>
<data name="TestHostExecutionOrchestratorMiddlewareRequiresExactlyOneOrchestratorErrorMessage" xml:space="preserve">
<value>One or more 'ITestHostExecutionOrchestratorMiddleware' instances are registered, but exactly one 'ITestHostExecutionOrchestrator' must also be registered for middleware to wrap. Found {0} orchestrator(s) instead.</value>
<comment>{0} is the number of registered orchestrators (0 or more than 1). {Locked="ITestHostExecutionOrchestratorMiddleware"} {Locked="ITestHostExecutionOrchestrator"}</comment>
</data>
<data name="TestHostExecutionOrchestratorMiddlewareNextInvokedMoreThanOnceErrorMessage" xml:space="preserve">
<value>The 'next' delegate passed to an 'ITestHostExecutionOrchestratorMiddleware' can be invoked at most once. It was invoked again after already being invoked, concurrently with another invocation, or after the middleware's own call already returned or threw.</value>
<comment>{Locked="next"} {Locked="ITestHostExecutionOrchestratorMiddleware"}</comment>
</data>
<data name="TestHostExecutionOrchestratorMiddlewareFabricatedSuccessErrorMessage" xml:space="preserve">
<value>Middleware '{0}' short-circuited the test host execution orchestrator pipeline (it did not invoke 'next') but returned the success exit code. Short-circuiting middleware must return an explicit non-success exit code so skipped execution cannot be reported as if tests actually ran and passed.</value>
<comment>{0} is the middleware's Uid. {Locked="next"}</comment>
</data>
<data name="TestHostExecutionOrchestratorMiddlewareSwallowedDownstreamFailureErrorMessage" xml:space="preserve">
<value>Middleware '{0}' returned successfully after the downstream execution it started with 'next' actually faulted. The failure was not observed or propagated by the middleware, so it cannot be allowed to look like success.</value>
<comment>{0} is the middleware's Uid. {Locked="next"}</comment>
</data>
<data name="TestHostExecutionOrchestratorMiddlewareRewroteDownstreamResultErrorMessage" xml:space="preserve">
<value>Middleware '{0}' changed the downstream exit code from {1} to {2}. This version of the test host execution orchestrator pipeline does not allow middleware to rewrite the downstream result.</value>
<comment>{0} is the middleware's Uid. {1} is the exit code the downstream execution actually produced. {2} is the exit code the middleware returned instead.</comment>
</data>
<data name="TestHostOrchestratorManagerDoesNotSupportMiddlewareErrorMessage" xml:space="preserve">
<value>Test host orchestrator manager of type '{0}' does not support 'ITestHostExecutionOrchestratorMiddleware' registration. Implement 'ITestHostExecutionOrchestratorMiddlewareManager' on the manager type to support it.</value>
<comment>{0} is the concrete manager type name. {Locked="ITestHostExecutionOrchestratorMiddleware"} {Locked="ITestHostExecutionOrchestratorMiddlewareManager"}</comment>
</data>
<data name="SyncFlushNotSupportedInBrowserErrorMessage" xml:space="preserve">
<value>Synchronous flush is not supported in browser environments.</value>
</data>
Expand Down
Loading
Loading