make some interop tests run as async methods

pull/2664/head
Jan Tattermusch 9 years ago
parent 9b048e529e
commit b98e1dd7c4
  1. 46
      src/csharp/Grpc.IntegrationTesting/InteropClient.cs
  2. 24
      src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs

@ -130,12 +130,12 @@ namespace Grpc.IntegrationTesting
client.HeaderInterceptor = OAuth2InterceptorFactory.Create(credential);
}
RunTestCase(options.testCase, client);
RunTestCaseAsync(options.testCase, client).Wait();
}
GrpcEnvironment.Shutdown();
}
private void RunTestCase(string testCase, TestService.TestServiceClient client)
private async Task RunTestCaseAsync(string testCase, TestService.TestServiceClient client)
{
switch (testCase)
{
@ -146,16 +146,16 @@ namespace Grpc.IntegrationTesting
RunLargeUnary(client);
break;
case "client_streaming":
RunClientStreaming(client);
await RunClientStreamingAsync(client);
break;
case "server_streaming":
RunServerStreaming(client);
await RunServerStreamingAsync(client);
break;
case "ping_pong":
RunPingPong(client);
await RunPingPongAsync(client);
break;
case "empty_stream":
RunEmptyStream(client);
await RunEmptyStreamAsync(client);
break;
case "service_account_creds":
RunServiceAccountCreds(client);
@ -170,10 +170,10 @@ namespace Grpc.IntegrationTesting
RunPerRpcCreds(client);
break;
case "cancel_after_begin":
RunCancelAfterBegin(client);
await RunCancelAfterBeginAsync(client);
break;
case "cancel_after_first_response":
RunCancelAfterFirstResponse(client);
await RunCancelAfterFirstResponseAsync(client);
break;
case "benchmark_empty_unary":
RunBenchmarkEmptyUnary(client);
@ -207,9 +207,7 @@ namespace Grpc.IntegrationTesting
Console.WriteLine("Passed!");
}
public static void RunClientStreaming(TestService.ITestServiceClient client)
{
Task.Run(async () =>
public static async Task RunClientStreamingAsync(TestService.ITestServiceClient client)
{
Console.WriteLine("running client_streaming");
@ -223,12 +221,9 @@ namespace Grpc.IntegrationTesting
Assert.AreEqual(74922, response.AggregatedPayloadSize);
}
Console.WriteLine("Passed!");
}).Wait();
}
public static void RunServerStreaming(TestService.ITestServiceClient client)
{
Task.Run(async () =>
public static async Task RunServerStreamingAsync(TestService.ITestServiceClient client)
{
Console.WriteLine("running server_streaming");
@ -250,12 +245,9 @@ namespace Grpc.IntegrationTesting
CollectionAssert.AreEqual(bodySizes, responseList.ConvertAll((item) => item.Payload.Body.Length));
}
Console.WriteLine("Passed!");
}).Wait();
}
public static void RunPingPong(TestService.ITestServiceClient client)
{
Task.Run(async () =>
public static async Task RunPingPongAsync(TestService.ITestServiceClient client)
{
Console.WriteLine("running ping_pong");
@ -302,12 +294,9 @@ namespace Grpc.IntegrationTesting
Assert.IsFalse(await call.ResponseStream.MoveNext());
}
Console.WriteLine("Passed!");
}).Wait();
}
public static void RunEmptyStream(TestService.ITestServiceClient client)
{
Task.Run(async () =>
public static async Task RunEmptyStreamAsync(TestService.ITestServiceClient client)
{
Console.WriteLine("running empty_stream");
using (var call = client.FullDuplexCall())
@ -318,7 +307,6 @@ namespace Grpc.IntegrationTesting
Assert.AreEqual(0, responseList.Count);
}
Console.WriteLine("Passed!");
}).Wait();
}
public static void RunServiceAccountCreds(TestService.ITestServiceClient client)
@ -406,9 +394,7 @@ namespace Grpc.IntegrationTesting
Console.WriteLine("Passed!");
}
public static void RunCancelAfterBegin(TestService.ITestServiceClient client)
{
Task.Run(async () =>
public static async Task RunCancelAfterBeginAsync(TestService.ITestServiceClient client)
{
Console.WriteLine("running cancel_after_begin");
@ -430,12 +416,9 @@ namespace Grpc.IntegrationTesting
}
}
Console.WriteLine("Passed!");
}).Wait();
}
public static void RunCancelAfterFirstResponse(TestService.ITestServiceClient client)
{
Task.Run(async () =>
public static async Task RunCancelAfterFirstResponseAsync(TestService.ITestServiceClient client)
{
Console.WriteLine("running cancel_after_first_response");
@ -464,7 +447,6 @@ namespace Grpc.IntegrationTesting
}
}
Console.WriteLine("Passed!");
}).Wait();
}
// This is not an official interop test, but it's useful.

@ -89,39 +89,39 @@ namespace Grpc.IntegrationTesting
}
[Test]
public void ClientStreaming()
public async Task ClientStreaming()
{
InteropClient.RunClientStreaming(client);
await InteropClient.RunClientStreamingAsync(client);
}
[Test]
public void ServerStreaming()
public async Task ServerStreaming()
{
InteropClient.RunServerStreaming(client);
await InteropClient.RunServerStreamingAsync(client);
}
[Test]
public void PingPong()
public async Task PingPong()
{
InteropClient.RunPingPong(client);
await InteropClient.RunPingPongAsync(client);
}
[Test]
public void EmptyStream()
public async Task EmptyStream()
{
InteropClient.RunEmptyStream(client);
await InteropClient.RunEmptyStreamAsync(client);
}
[Test]
public void CancelAfterBegin()
public async Task CancelAfterBegin()
{
InteropClient.RunCancelAfterBegin(client);
await InteropClient.RunCancelAfterBeginAsync(client);
}
[Test]
public void CancelAfterFirstResponse()
public async Task CancelAfterFirstResponse()
{
InteropClient.RunCancelAfterFirstResponse(client);
await InteropClient.RunCancelAfterFirstResponseAsync(client);
}
}
}

Loading…
Cancel
Save