提交 0648b019 编写于 作者: A Andy Gocke 提交者: GitHub

Relax compiler server spinwait test (#11864)

The test fired cancellation then waited 100ms for cancellation to be acknowledged.
There's no guarantee on a heavily loaded machine that cancellation will be
acknowledged in that time frame. This test should be reliable, so this 
removes the time out to prevent flakiness. Fixes #11819
上级 24de6a55
......@@ -150,8 +150,9 @@ public async Task ConnectToPipeWithSpinWait()
{
// No server should be started with the current pipe name
var client = CreateClient();
var oneSecondInMs = (int)TimeSpan.FromSeconds(1).TotalMilliseconds;
Assert.False(client.TryConnectToNamedPipeWithSpinWait(oneSecondInMs,
var oneSec = TimeSpan.FromSeconds(1);
Assert.False(client.TryConnectToNamedPipeWithSpinWait((int)oneSec.TotalMilliseconds,
default(CancellationToken)));
// Try again with infinite timeout and cancel
......@@ -160,24 +161,17 @@ public async Task ConnectToPipeWithSpinWait()
cts.Token),
cts.Token);
Assert.False(connection.IsCompleted);
// Spin for a little bit
await Task.Delay(TimeSpan.FromMilliseconds(100));
cts.Cancel();
await Task.WhenAny(connection, Task.Delay(TimeSpan.FromMilliseconds(100)))
.ConfigureAwait(false);
Assert.True(connection.IsCompleted);
Assert.True(connection.IsCanceled);
await Assert.ThrowsAnyAsync<OperationCanceledException>(
async () => await connection.ConfigureAwait(false)).ConfigureAwait(false);
// Create server and try again
Assert.True(TryCreateServer(_pipeName));
Assert.True(client.TryConnectToNamedPipeWithSpinWait(oneSecondInMs,
Assert.True(client.TryConnectToNamedPipeWithSpinWait((int)oneSec.TotalMilliseconds,
default(CancellationToken)));
// With infinite timeout
connection = Task.Run(() =>
client.TryConnectToNamedPipeWithSpinWait(Timeout.Infinite, default(CancellationToken)));
await Task.WhenAny(connection, Task.Delay(oneSecondInMs)).ConfigureAwait(false);
Assert.True(connection.IsCompleted);
Assert.True(await connection.ConfigureAwait(false));
Assert.True(client.TryConnectToNamedPipeWithSpinWait(Timeout.Infinite,
default(CancellationToken)));
}
[Fact]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册