Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Flaky: MtpServerProcessTests.StartAsyncTimeoutKillsProcessAndReleasesListener races between timeout and early-exit failure

Abierto Apto para principiantes
#11,631 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
csharp
Área
testing-qa

Línea de trabajo

Comienza con test/UnitTests/Microsoft.Testing.Platform.ServerMode.Client.Sources.UnitTests/MtpServerProcessTests.cs y la prueba StartAsyncTimeoutKillsProcessAndReleasesListener; inspecciona el asset NeverConnects.cmd y MtpServerProcess.Startup.cs. Ejecuta la prueba net8.0 exclusiva de Windows para reproducir la condición de carrera. Se considera terminado cuando la prueba pasa de forma fiable y se conservan las aserciones de process-killed, survived.txt y port-release.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

area/mtp area/testing-platform area/timeout type/flaky-test

Summary

MtpServerProcessTests.StartAsyncTimeoutKillsProcessAndReleasesListener (Windows-only, net8.0) fails intermittently on CI with an assertion mismatch between the two possible startup-failure messages.

Observed in build 1615940 (Build Windows Debug, running the merge commit of PR #11607, whose changes are unrelated to server-mode client sources):

test/UnitTests/Microsoft.Testing.Platform.ServerMode.Client.Sources.UnitTests/MtpServerProcessTests.cs(79,1): error : StartAsyncTimeoutKillsProcessAndReleasesListener [net8.0]
Assertion failed. Expected string to contain the specified substring.

expected substring: "did not connect back within"
actual:             "The Microsoft.Testing.Platform application '...\NeverConnects.cmd' exited with code 0 before connecting back. "

The test took 2s 185ms, i.e. roughly the runtime of the ping 127.0.0.1 -n 3 in the NeverConnects.cmd asset, instead of completing near the configured 300 ms ConnectionTimeout.

Root cause

The test configures ConnectionTimeout = TimeSpan.FromMilliseconds(300) and asserts the timeout-specific message. But in MtpServerProcess.Startup.cs, CreateTimeoutOrStoppedFailureAsync first calls TryGetProcessStoppedFailureAsync(...) and only falls back to the "did not connect back within {timeout}s" message when the process has not been observed as exited:

Exception? stopped = await TryGetProcessStoppedFailureAsync(...);
return stopped ?? new MtpServerConnectionClosedException($"... did not connect back within ...");

On a loaded agent the launched .cmd can be observed as exited by the time the failure message is constructed, so the early-exit message wins and the assertion fails. The 300 ms timeout leaves essentially no margin against Windows process-start and exit-observation latency, which makes the race easy to lose.

Suggested fix directions

  • Make the asset's lifetime much longer than the configured timeout (or make the timeout meaningfully larger) so the timeout path deterministically wins the race, while keeping the existing "the process was killed and the port was released" assertions.
  • Alternatively, assert the behaviour the test actually guards (process killed, survived.txt absent, port rebindable) without pinning the exact failure-message variant, or accept either message when the process is observed as stopped.

Please avoid "fixing" this by relaxing the kill/port-release assertions — those are the meaningful part of the test.

Notes

  • Introduced with the added coverage in #11613.
  • Not caused by #11607; the failure reproduces on its merge commit only because that commit includes main.
Lenguaje dominante
C#
Estrellas
1k
Forks
312
Merge medio
8 h 11 min
PR fusionados (30 d)
488

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/testfx

Todos los issues de microsoft/testfx

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.