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 <stoub@microsoft.com>
This commit is contained in:
Copilot 2026-02-17 13:05:31 -08:00 • committed by GitHub
commit 6fa8b50aff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
);
}
/// <summary>
/// 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).
/// </summary>
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, @"(?<failed>\d+) failed, (?<warnings>\d+) warnings");
return match.Success
&& match.Groups["failed"].Value == "0"
&& int.TryParse(match.Groups["warnings"].Value, out var warnings)
&& warnings > 0;
}
}