Flaky: MtpServerProcessTests.StartAsyncTimeoutKillsProcessAndReleasesListener races between timeout and early-exit failure
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
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.txtabsent, 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
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/testfx
-
type/automation type/tech-debt
Dificultad 4/5 3-5 días Aptitud para principiantes 58/100
Los mantenedores suelen responder en 1 día
-
type/automation type/tech-debt
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
area/infrastructure area/vendored-sync area/winui needs/triage
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
area/mstest area/mtp area/winui needs/triage
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
Los mantenedores suelen responder en 1 día
-
type/automation type/test-gap
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/testfx
Issues similares
-
go 🏃 testing 🧪
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
valkey-io/valkey-glide#7239 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
SubtitleEdit/subtitleedit#15462 ·
Los mantenedores suelen responder en 1 día
-
:watch: Not Triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
comp:instrumentation.aspnetcore
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
open-telemetry/opentelemetry-dotnet-contrib#5427 ·
Los mantenedores suelen responder en 1 día
-
[feature request] Condier making `TelemetrySpan`'s constructor and `Activity` property publicAbiertoenhancement needs-triage pkg:OpenTelemetry
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
open-telemetry/opentelemetry-dotnet#7851 · 4 comentarios ·
Los mantenedores suelen responder en 1 día