Reduce flakiness in long-running stateless HTTP tool timeout test (#1300)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: halter73 <54385+halter73@users.noreply.github.com>
This commit is contained in:
parent
b967835144
commit
231e013160
1 changed files with 39 additions and 24 deletions
|
|
@ -245,9 +245,16 @@ public abstract class MapMcpTests(ITestOutputHelper testOutputHelper) : KestrelI
|
||||||
app.MapMcp();
|
app.MapMcp();
|
||||||
await app.StartAsync(TestContext.Current.CancellationToken);
|
await app.StartAsync(TestContext.Current.CancellationToken);
|
||||||
|
|
||||||
|
// Retry a couple of times to reduce occasional flakiness on low-resource machines.
|
||||||
|
// If the server regresses to flushing only after tool completion, each attempt should still fail
|
||||||
|
// because HttpClient timeout (1 second) is below the tool duration (2 seconds).
|
||||||
|
for (var attempt = 0; attempt < 3; attempt++)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
// Create a custom HttpClient with a very short timeout (1 second)
|
// Create a custom HttpClient with a very short timeout (1 second)
|
||||||
// The tool will take 2 seconds to complete
|
// The tool will take 2 seconds to complete
|
||||||
using var shortTimeoutClient = new HttpClient(SocketsHttpHandler)
|
using var shortTimeoutClient = new HttpClient(SocketsHttpHandler, disposeHandler: false)
|
||||||
{
|
{
|
||||||
BaseAddress = new Uri("http://localhost:5000/"),
|
BaseAddress = new Uri("http://localhost:5000/"),
|
||||||
Timeout = TimeSpan.FromSeconds(1)
|
Timeout = TimeSpan.FromSeconds(1)
|
||||||
|
|
@ -273,6 +280,14 @@ public abstract class MapMcpTests(ITestOutputHelper testOutputHelper) : KestrelI
|
||||||
|
|
||||||
var content = Assert.Single(response.Content.OfType<TextContentBlock>());
|
var content = Assert.Single(response.Content.OfType<TextContentBlock>());
|
||||||
Assert.Equal("Operation completed after 2000ms", content.Text);
|
Assert.Equal("Operation completed after 2000ms", content.Text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch (OperationCanceledException) when (attempt < 2)
|
||||||
|
{
|
||||||
|
// Retry intermittent timeout-related failures on slow CI machines.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClaimsPrincipal CreateUser(string name)
|
private ClaimsPrincipal CreateUser(string name)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue