Skip to content

Commit 81e6f16

Browse files
EvangelinkCopilot
andcommitted
Address orchestrator composition review feedback
Document process-wide child environment and discovery behavior, reject Repetition with Recovery on the dotnet test pipe, and harden acceptance paths. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent daf5f9a commit 81e6f16

19 files changed

Lines changed: 246 additions & 18 deletions

‎docs/decisions/multiple-test-orchestrators.md‎

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ These were the assumptions at design time; executed checks are recorded below.
6666

6767
### Constraints
6868

69-
- When exactly one orchestrator is enabled, behavior must not change: the
70-
process tree, handshake properties, exit codes, artifacts, and telemetry stay
71-
identical.
69+
- When exactly one orchestrator is enabled during normal execution, behavior
70+
must not change: the process tree, handshake properties, exit codes,
71+
artifacts, and telemetry stay identical. Discovery is an intentional
72+
exception, described below.
7273
- Handshake property ID 11 `OrchestratorFeature` is an exact-match contract with
7374
dotnet/sdk (see research). Changing its meaning is a cross-repository break.
7475
- Repository API rules apply: new public API must be experimental and carry the
@@ -311,7 +312,9 @@ Why this order:
311312
handshake. A violation produces a Phase 1 style error that names the Uids
312313
involved.
313314

314-
1. One enabled orchestrator: behavior is unchanged, and the stage is ignored.
315+
1. One enabled orchestrator during normal execution: behavior is unchanged, and
316+
the stage is ignored. Discovery is the intentional exception described in
317+
rule 5.
315318
2. More than one enabled orchestrator: each one must implement
316319
`IComposableTestHostExecutionOrchestrator`.
317320
3. At most one orchestrator per stage. Ordering therefore never depends on
@@ -320,7 +323,20 @@ involved.
320323
4. Each member's existing environment rejections still apply. For example,
321324
Retry rejects hot reload and server mode without the `dotnet test` pipe. If
322325
any member rejects the environment, the whole combination fails.
323-
5. `--list-tests` skips orchestrator and middleware composition.
326+
5. `--list-tests` bypasses orchestration before orchestrator factories are
327+
created or enablement is queried, and before orchestrators are initialized
328+
or middleware is built. This applies even when only one orchestrator is
329+
registered. It intentionally changes discovery behavior from before this
330+
change, when enabled orchestrators and middleware were initialized during
331+
discovery; the change avoids initializing execution components for test
332+
listing.
333+
6. `Repetition` and `Recovery` cannot be composed under the `dotnettestcli`
334+
named-pipe protocol. When an iteration retries, the next iteration starts
335+
again at attempt 1 for the same execution and test UID. The SDK progress
336+
consumer requires non-decreasing attempt numbers
337+
([`TestProgressState`](https://github.com/dotnet/sdk/blob/5db7f0f18d18c99acfa82e6663a84b1122195380/src/Cli/dotnet/Commands/Test/MTP/Terminal/TestProgressState.cs#L343)).
338+
Reject this combination until iteration identity is represented in the
339+
protocol. Other protocols are not restricted by this check.
324340

325341
**Child-launch contract for every stage except the innermost:**
326342

@@ -339,11 +355,16 @@ involved.
339355

340356
**Internal chain guard (not public API).** When composition is active, the
341357
platform sets an internal environment variable before running the active
342-
orchestrator. The variable holds the ordered list of consumed Uids, and children
343-
inherit it. At startup, every process reads the variable and removes it from its
344-
own environment, then skips the listed Uids before querying enablement. If a
345-
test host controller must restart an attempt, it forwards the chain explicitly
346-
in the child's launch environment. Test code does not inherit it. The guard has three uses:
358+
orchestrator. The variable holds the ordered list of consumed Uids. It is
359+
process-wide, so every child process started while the orchestrator is running
360+
inherits it, not only the intended child that continues the composition. This
361+
includes diagnostic/helper processes and custom launcher targets. An MTP process
362+
consumes and clears it at startup before skipping the listed Uids; unrelated
363+
launches must remove it if they must not continue the composition. If a test
364+
host controller must restart an attempt, it forwards the chain explicitly in
365+
the child's launch environment. Test code in the normal MTP test process does
366+
not inherit it because MTP startup has already cleared it. The guard has three
367+
uses:
347368

348369
- It prevents re-activation, even when an orchestrator was enabled by
349370
configuration rather than by a command-line option it can strip.
@@ -417,7 +438,9 @@ Each of these processes repeats platform initialization.
417438

418439
**Implementation:** `TestHostOrchestratorManager` validates the enabled set and
419440
selects the active stage before initializing composable orchestrators.
420-
`TestHostBuilder` consumes the chain and bypasses composition during discovery.
441+
`TestHostBuilder` consumes the chain and bypasses orchestration during
442+
discovery, including factory creation and enablement checks for single-
443+
orchestrator runs.
421444
`TestHostOrchestratorHost` publishes the child chain only around the selected
422445
orchestrator's execution, not around lifetime callbacks or short-circuiting
423446
middleware. Each extension remains responsible for its exit code and artifacts;
@@ -452,6 +475,7 @@ SDK. The generated `DotnetTestPipeOrchestratorHandshake` app references
452475
| Selection and lifecycle | 93 focused manager, builder and host cases passed on each of `net10.0`, `net11.0` and `net462`. These include discovery with incompatible orchestrators, pre-enablement duplicate-Uid rejection, stage ordering and selected-only initialization. |
453476
| Wire and restart | `DotnetTestPipe_Orchestrator_HandshakesWithFeature` and both rows of `DotnetTestPipe_ComposedOrchestrators_EachProcessHandshakesWithItsUid` passed. The composed rows check both feature Uids, one execution id, distinct instance ids, and attempts 1 and 2, with zero or two controller handshakes respectively. |
454477
| Counterfactual | With the original composition implementation, the direct row and Retry alone passed; the controller row failed: `The child reactivated the consumed Selection orchestrator.` The controller had dropped the consumed chain on relaunch. The same three cases passed after the fix (suite exit 2 → 0). This isolates a restart regression, not every aspect of composition. |
478+
| Repetition with Recovery | The packed `DotnetTestPipe_RepetitionAndRecoveryOrchestrators_AreRejectedBeforeExecution` case uses a two-iteration fixture whose first test attempt fails and retries. With the pipe-mode guard removed, both the fake named-pipe consumer and SDK `11.0.100` observed the attempt reset `[1, 2, 1]`; the SDK terminated with `UnreachableException: Unexpected test result for attempt '1' while the last attempt is '2'` (exit `-2146232797`). With the guard, the packed acceptance case passed without a test-host handshake. The real-SDK run is the unguarded counterfactual; the guard path itself is verified by the packed fake named-pipe test. |
455479
| Released SDKs | SDKs `10.0.404` and `11.0.100` each ran the packaged `net11.0` apphost with Selection, Retry and a controller restart. Both reported `FlakyTest` failed on try 1, passed on try 2, and returned 0 for one logical test. SDK 11 also reported `flaky: 1 (passed after retry)`. |
456480
| Mixed modules | SDK `11.0.100` ran the pre-fix and fixed apphosts in one invocation. The fixed module passed after retry, the previous module failed at its controller child, and the SDK returned 1. |
457481

@@ -484,6 +508,7 @@ claim that every proposed scenario has shipped or been executed.
484508
| Selection with Recovery | A Selection test asset plus Retry, with one flaky test inside the selected set. Assert exit 0, that attempt 2 runs only the failed UID, the handshake order, and the retry rendering in the SDK. | Terminal at 80 and 200 columns. The zero-selected path needs the real AffectedTests package, because the SDK recognizes only its Uids. |
485509
| Distribution with Recovery | A two-shard test asset with `--partition` and a flaky test in shard 1. Assert per-shard retry, distinct results directories and instance ids, attempt numbers, and the aggregated exit code. | No interleaved partial lines. SDK rendering of concurrent attempts remains a gap until it is run. |
486510
| Composition rules | Two orchestrators in the same stage, and an undeclared orchestrator combined with another. Assert errors that name the Uids. | Error text. |
511+
| Repetition with Recovery | The `dotnettestcli` pipe rejects Repetition + Recovery before any test-host handshake. The packed two-iteration counterfactual without the guard was run against SDK `11.0.100` and terminated on `[1, 2, 1]`; the guarded acceptance case verifies rejection before test-host execution. | No rendered change. The real-SDK run was the unguarded failure reproduction; the guarded path was validated with the packed fake named-pipe consumer, not a released SDK executable. |
487512
| Cancellation | Cancel during an inner attempt. Assert exit 3 in every process and no orphaned process ids. | Nonvisual. |
488513
| Lifetimes and middleware run once | Azure DevOps loopback publisher sees exactly one run created and finalized. A middleware marker file is written once. | The payload is proven; the live Azure DevOps UI remains a gap. |
489514
| Recursion guard | An outer orchestrator that does not strip its option. Assert the process count is bounded. | Nonvisual. |

‎src/MTP/Microsoft.Testing.Platform/Resources/PlatformResources.resx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,10 @@ Valid values are 'allow-skipped' (the default) which counts skipped tests as run
11021102
<value>Test host orchestrator '{0}' declares an unsupported stage value '{1}'.</value>
11031103
<comment>{0} is an orchestrator Uid. {1} is an invalid TestHostExecutionOrchestratorStage value.</comment>
11041104
</data>
1105+
<data name="TestHostExecutionOrchestratorRepetitionAndRecoveryUnsupportedOnDotnetTestPipeErrorMessage" xml:space="preserve">
1106+
<value>Test host orchestrators '{0}' cannot compose the 'Repetition' and 'Recovery' stages under the 'dotnettestcli' named-pipe protocol because a retry in one repeated iteration can make the next iteration report a lower attempt number to the SDK.</value>
1107+
<comment>{0} is the list of orchestrator Uids. {Locked="dotnettestcli"}</comment>
1108+
</data>
11051109
<data name="TestHostExecutionOrchestratorChainIsInvalidErrorMessage" xml:space="preserve">
11061110
<value>The internal test host orchestrator chain value is invalid.</value>
11071111
</data>

‎src/MTP/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.cs.xlf‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,11 @@ Přečtěte si další informace o telemetrii Microsoft Testing Platform: https:
13921392
<target state="translated">Middleware {0} se úspěšně vrátil, přestože následné provádění, které spustil pomocí „next“, ve skutečnosti selhalo. Middleware nezpozoroval ani nerozšířil selhání, takže nemůže vypadat jako úspěch.</target>
13931393
<note>{0} is the middleware's Uid. {Locked="next"}</note>
13941394
</trans-unit>
1395+
<trans-unit id="TestHostExecutionOrchestratorRepetitionAndRecoveryUnsupportedOnDotnetTestPipeErrorMessage">
1396+
<source>Test host orchestrators '{0}' cannot compose the 'Repetition' and 'Recovery' stages under the 'dotnettestcli' named-pipe protocol because a retry in one repeated iteration can make the next iteration report a lower attempt number to the SDK.</source>
1397+
<target state="new">Test host orchestrators '{0}' cannot compose the 'Repetition' and 'Recovery' stages under the 'dotnettestcli' named-pipe protocol because a retry in one repeated iteration can make the next iteration report a lower attempt number to the SDK.</target>
1398+
<note>{0} is the list of orchestrator Uids. {Locked="dotnettestcli"}</note>
1399+
</trans-unit>
13951400
<trans-unit id="TestHostExecutionOrchestratorStageIsInvalidErrorMessage">
13961401
<source>Test host orchestrator '{0}' declares an unsupported stage value '{1}'.</source>
13971402
<target state="new">Test host orchestrator '{0}' declares an unsupported stage value '{1}'.</target>

‎src/MTP/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.de.xlf‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,11 @@ Read more about Microsoft Testing Platform telemetry: https://aka.ms/testingplat
13921392
<target state="translated">Middleware „{0}“ wurde erfolgreich zurückgegeben, nachdem die Downstreamausführung mit dem Fehler „next“ gestartet wurde. Der Fehler wurde von der Middleware nicht erkannt oder weitergegeben, sodass es nicht aussehen kann, als wäre die Ausführung erfolgreich gewesen.</target>
13931393
<note>{0} is the middleware's Uid. {Locked="next"}</note>
13941394
</trans-unit>
1395+
<trans-unit id="TestHostExecutionOrchestratorRepetitionAndRecoveryUnsupportedOnDotnetTestPipeErrorMessage">
1396+
<source>Test host orchestrators '{0}' cannot compose the 'Repetition' and 'Recovery' stages under the 'dotnettestcli' named-pipe protocol because a retry in one repeated iteration can make the next iteration report a lower attempt number to the SDK.</source>
1397+
<target state="new">Test host orchestrators '{0}' cannot compose the 'Repetition' and 'Recovery' stages under the 'dotnettestcli' named-pipe protocol because a retry in one repeated iteration can make the next iteration report a lower attempt number to the SDK.</target>
1398+
<note>{0} is the list of orchestrator Uids. {Locked="dotnettestcli"}</note>
1399+
</trans-unit>
13951400
<trans-unit id="TestHostExecutionOrchestratorStageIsInvalidErrorMessage">
13961401
<source>Test host orchestrator '{0}' declares an unsupported stage value '{1}'.</source>
13971402
<target state="new">Test host orchestrator '{0}' declares an unsupported stage value '{1}'.</target>

‎src/MTP/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.es.xlf‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,11 @@ Más información sobre la telemetría de la Plataforma de pruebas de Microsoft:
13921392
<target state="translated">El middleware "{0}" se devolvió correctamente después de la ejecución de nivel inferior que se inició con el error "next". El middleware no observó ni propagó el error, por lo que no se puede permitir que parezca correcto.</target>
13931393
<note>{0} is the middleware's Uid. {Locked="next"}</note>
13941394
</trans-unit>
1395+
<trans-unit id="TestHostExecutionOrchestratorRepetitionAndRecoveryUnsupportedOnDotnetTestPipeErrorMessage">
1396+
<source>Test host orchestrators '{0}' cannot compose the 'Repetition' and 'Recovery' stages under the 'dotnettestcli' named-pipe protocol because a retry in one repeated iteration can make the next iteration report a lower attempt number to the SDK.</source>
1397+
<target state="new">Test host orchestrators '{0}' cannot compose the 'Repetition' and 'Recovery' stages under the 'dotnettestcli' named-pipe protocol because a retry in one repeated iteration can make the next iteration report a lower attempt number to the SDK.</target>
1398+
<note>{0} is the list of orchestrator Uids. {Locked="dotnettestcli"}</note>
1399+
</trans-unit>
13951400
<trans-unit id="TestHostExecutionOrchestratorStageIsInvalidErrorMessage">
13961401
<source>Test host orchestrator '{0}' declares an unsupported stage value '{1}'.</source>
13971402
<target state="new">Test host orchestrator '{0}' declares an unsupported stage value '{1}'.</target>

‎src/MTP/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.fr.xlf‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,11 @@ En savoir plus sur la télémétrie de la plateforme de tests Microsoft : https
13921392
<target state="translated">L’intergiciel « {0} » s’est effectué correctement alors que l’exécution en aval qu’il avait démarrée avec « next » a effectivement généré une erreur. L’intergiciel n’a ni détecté ni propagé l’échec. Il ne peut donc pas donner l’impression que l’opération a réussi.</target>
13931393
<note>{0} is the middleware's Uid. {Locked="next"}</note>
13941394
</trans-unit>
1395+
<trans-unit id="TestHostExecutionOrchestratorRepetitionAndRecoveryUnsupportedOnDotnetTestPipeErrorMessage">
1396+
<source>Test host orchestrators '{0}' cannot compose the 'Repetition' and 'Recovery' stages under the 'dotnettestcli' named-pipe protocol because a retry in one repeated iteration can make the next iteration report a lower attempt number to the SDK.</source>
1397+
<target state="new">Test host orchestrators '{0}' cannot compose the 'Repetition' and 'Recovery' stages under the 'dotnettestcli' named-pipe protocol because a retry in one repeated iteration can make the next iteration report a lower attempt number to the SDK.</target>
1398+
<note>{0} is the list of orchestrator Uids. {Locked="dotnettestcli"}</note>
1399+
</trans-unit>
13951400
<trans-unit id="TestHostExecutionOrchestratorStageIsInvalidErrorMessage">
13961401
<source>Test host orchestrator '{0}' declares an unsupported stage value '{1}'.</source>
13971402
<target state="new">Test host orchestrator '{0}' declares an unsupported stage value '{1}'.</target>

‎src/MTP/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.it.xlf‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,11 @@ Altre informazioni sulla telemetria della piattaforma di test Microsoft: https:/
13921392
<target state="translated">Il middleware '{0}' ha restituito il controllo correttamente dopo che l'esecuzione downstream avviata con 'next' ha effettivamente avuto esito negativo. Il middleware non ha rilevato né propagato l'errore, quindi non è consentito che l'esecuzione risulti completata correttamente.</target>
13931393
<note>{0} is the middleware's Uid. {Locked="next"}</note>
13941394
</trans-unit>
1395+
<trans-unit id="TestHostExecutionOrchestratorRepetitionAndRecoveryUnsupportedOnDotnetTestPipeErrorMessage">
1396+
<source>Test host orchestrators '{0}' cannot compose the 'Repetition' and 'Recovery' stages under the 'dotnettestcli' named-pipe protocol because a retry in one repeated iteration can make the next iteration report a lower attempt number to the SDK.</source>
1397+
<target state="new">Test host orchestrators '{0}' cannot compose the 'Repetition' and 'Recovery' stages under the 'dotnettestcli' named-pipe protocol because a retry in one repeated iteration can make the next iteration report a lower attempt number to the SDK.</target>
1398+
<note>{0} is the list of orchestrator Uids. {Locked="dotnettestcli"}</note>
1399+
</trans-unit>
13951400
<trans-unit id="TestHostExecutionOrchestratorStageIsInvalidErrorMessage">
13961401
<source>Test host orchestrator '{0}' declares an unsupported stage value '{1}'.</source>
13971402
<target state="new">Test host orchestrator '{0}' declares an unsupported stage value '{1}'.</target>

‎src/MTP/Microsoft.Testing.Platform/Resources/xlf/PlatformResources.ja.xlf‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,11 @@ Microsoft Testing Platform テレメトリの詳細: https://aka.ms/testingplatf
13921392
<target state="translated">ミドルウェア '{0}' は、'next' で開始したダウンストリームの実行が実際には失敗した後、正常に戻りました。ミドルウェアによって失敗が検出または伝播されなかったため、成功したように見える状態を許可することはできません。</target>
13931393
<note>{0} is the middleware's Uid. {Locked="next"}</note>
13941394
</trans-unit>
1395+
<trans-unit id="TestHostExecutionOrchestratorRepetitionAndRecoveryUnsupportedOnDotnetTestPipeErrorMessage">
1396+
<source>Test host orchestrators '{0}' cannot compose the 'Repetition' and 'Recovery' stages under the 'dotnettestcli' named-pipe protocol because a retry in one repeated iteration can make the next iteration report a lower attempt number to the SDK.</source>
1397+
<target state="new">Test host orchestrators '{0}' cannot compose the 'Repetition' and 'Recovery' stages under the 'dotnettestcli' named-pipe protocol because a retry in one repeated iteration can make the next iteration report a lower attempt number to the SDK.</target>
1398+
<note>{0} is the list of orchestrator Uids. {Locked="dotnettestcli"}</note>
1399+
</trans-unit>
13951400
<trans-unit id="TestHostExecutionOrchestratorStageIsInvalidErrorMessage">
13961401
<source>Test host orchestrator '{0}' declares an unsupported stage value '{1}'.</source>
13971402
<target state="new">Test host orchestrator '{0}' declares an unsupported stage value '{1}'.</target>

0 commit comments

Comments
 (0)