Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix server.KillAsync() and improve abandoned call test #4436

Merged
merged 8 commits into from
Dec 15, 2015
Prev Previous commit
Fix AbandonedCall test
  • Loading branch information
jtattermusch committed Dec 15, 2015
commit d63b1d62b13914462cfee7ed6137395179e66eb0
11 changes: 7 additions & 4 deletions src/csharp/Grpc.Core.Tests/ShutdownTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,20 @@ public void Init()
}

[Test]
public async Task AbandonedCall()
public async Task AbandonedCall_ServerKillAsync()
{
var readyToShutdown = new TaskCompletionSource<object>();
helper.DuplexStreamingHandler = new DuplexStreamingServerMethod<string, string>(async (requestStream, responseStream, context) =>
{
readyToShutdown.SetResult(null);
await requestStream.ToListAsync();
});

var call = Calls.AsyncDuplexStreamingCall(helper.CreateDuplexStreamingCall(new CallOptions(deadline: DateTime.UtcNow.AddMilliseconds(1))));
var call = Calls.AsyncDuplexStreamingCall(helper.CreateDuplexStreamingCall());
await readyToShutdown.Task; // make sure handler is running

channel.ShutdownAsync().Wait();
server.ShutdownAsync().Wait();
await channel.ShutdownAsync(); // channel.ShutdownAsync() works even if there's a pending call.
await server.KillAsync(); // server.ShutdownAsync() would hang waiting for the call to finish.
}
}
}