未验证 提交 610f34eb 编写于 作者: M Miha Zupan 提交者: GitHub

Avoid test race condition between two completing requests (#52887)

上级 7be77b8f
......@@ -585,6 +585,7 @@ public void EventSource_ConnectionPoolAtMaxConnections_LogsRequestLeftQueue()
{
var firstRequestReceived = new SemaphoreSlim(0, 1);
var secondRequestSent = new SemaphoreSlim(0, 1);
var firstRequestFinished = new SemaphoreSlim(0, 1);
await GetFactoryForVersion(version).CreateClientAndServerAsync(
async uri =>
......@@ -605,7 +606,13 @@ public void EventSource_ConnectionPoolAtMaxConnections_LogsRequestLeftQueue()
Task secondRequest = client.GetStringAsync(uri);
secondRequestSent.Release();
await new[] { firstRequest, secondRequest }.WhenAllOrAnyFailed();
// We are asserting that ActivityIds between Start/Stop pairs match below
// We wait for the first request to finish to ensure that RequestStop events
// are logged in the same order as RequestStarts
await firstRequest;
firstRequestFinished.Release();
await secondRequest;
},
async server =>
{
......@@ -634,6 +641,7 @@ public void EventSource_ConnectionPoolAtMaxConnections_LogsRequestLeftQueue()
await connection.SendResponseAsync();
// Second request
Assert.True(await firstRequestFinished.WaitAsync(TimeSpan.FromSeconds(10)));
await connection.ReadRequestDataAsync(readBody: false);
await connection.SendResponseAsync();
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册