Bring up to 0.1.13 conformance (#1254)

This commit is contained in:
Stephen Toub 2026-02-10 11:33:52 -05:00 • committed by GitHub
commit 27b5eb8031
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -470,11 +470,23 @@ public class StreamableHttpServerConformanceTests(ITestOutputHelper outputHelper
await CallInitializeAndValidateAsync();
await CallEchoAndValidateAsync();
// Add 5 seconds to idle timeout to account for the interval of the PeriodicTimer.
fakeTimeProvider.Advance(TimeSpan.FromHours(2) + TimeSpan.FromSeconds(5));
// The background IdleTrackingBackgroundService prunes sessions asynchronously after
// the PeriodicTimer (5s interval) tick fires. We advance past the 2-hour idle timeout
// then poll until the session returns NotFound. Each HTTP POST also refreshes the
// session's LastActivityTicks via AcquireReferenceAsync, so we must re-advance time
// each iteration to ensure the session appears idle again for the next prune pass.
var deadline = DateTime.UtcNow + TestConstants.DefaultTimeout;
HttpStatusCode statusCode;
do
{
fakeTimeProvider.Advance(TimeSpan.FromHours(2) + TimeSpan.FromSeconds(5));
await Task.Delay(100, TestContext.Current.CancellationToken);
using var response = await HttpClient.PostAsync("", JsonContent(EchoRequest), TestContext.Current.CancellationToken);
statusCode = response.StatusCode;
}
while (statusCode != HttpStatusCode.NotFound && DateTime.UtcNow < deadline);
using var response = await HttpClient.PostAsync("", JsonContent(EchoRequest), TestContext.Current.CancellationToken);
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
Assert.Equal(HttpStatusCode.NotFound, statusCode);
}
[Fact]