From 6fa8b50affa5b0c6e71d6856f2db8fe1cba1a0e3 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Feb 2026 13:05:31 -0800 Subject: [PATCH] Fix flaky sse-retry conformance test caused by CI timing sensitivity (#1279) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com> Co-authored-by: Stephen Toub --- .../ClientConformanceTests.cs | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/tests/ModelContextProtocol.AspNetCore.Tests/ClientConformanceTests.cs b/tests/ModelContextProtocol.AspNetCore.Tests/ClientConformanceTests.cs index 295fc9b..f9a5c1a 100644 --- a/tests/ModelContextProtocol.AspNetCore.Tests/ClientConformanceTests.cs +++ b/tests/ModelContextProtocol.AspNetCore.Tests/ClientConformanceTests.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using System.Text; +using System.Text.RegularExpressions; using ModelContextProtocol.Tests.Utils; namespace ModelContextProtocol.ConformanceTests; @@ -118,10 +119,32 @@ public class ClientConformanceTests ); } + var output = outputBuilder.ToString(); + var error = errorBuilder.ToString(); + var success = process.ExitCode == 0 || HasOnlyWarnings(output, error); + return ( - Success: process.ExitCode == 0, - Output: outputBuilder.ToString(), - Error: errorBuilder.ToString() + Success: success, + Output: output, + Error: error ); } + + /// + /// Checks if the conformance test output indicates that all checks passed with only + /// warnings (no actual failures). The conformance runner exits with code 1 for warnings, + /// but warnings represent acceptable behavior (e.g., timing tolerances in CI environments). + /// + private static bool HasOnlyWarnings(string output, string error) + { + // The conformance runner outputs a summary line like: + // "Passed: 2/2, 0 failed, 1 warnings" + // If there are 0 failures but warnings > 0, the test behavior is acceptable. + var combined = output + error; + var match = Regex.Match(combined, @"(?\d+) failed, (?\d+) warnings"); + return match.Success + && match.Groups["failed"].Value == "0" + && int.TryParse(match.Groups["warnings"].Value, out var warnings) + && warnings > 0; + } }