|
|
|
@ -213,11 +213,13 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
|
|
|
|
|
var bodySizes = new List<int> { 27182, 8, 1828, 45904 }.ConvertAll((size) => StreamingInputCallRequest.CreateBuilder().SetPayload(CreateZerosPayload(size)).Build()); |
|
|
|
|
|
|
|
|
|
var call = client.StreamingInputCall(); |
|
|
|
|
await call.RequestStream.WriteAll(bodySizes); |
|
|
|
|
using (var call = client.StreamingInputCall()) |
|
|
|
|
{ |
|
|
|
|
await call.RequestStream.WriteAll(bodySizes); |
|
|
|
|
|
|
|
|
|
var response = await call.Result; |
|
|
|
|
Assert.AreEqual(74922, response.AggregatedPayloadSize); |
|
|
|
|
var response = await call.Result; |
|
|
|
|
Assert.AreEqual(74922, response.AggregatedPayloadSize); |
|
|
|
|
} |
|
|
|
|
Console.WriteLine("Passed!"); |
|
|
|
|
}).Wait(); |
|
|
|
|
} |
|
|
|
@ -236,14 +238,15 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
(size) => ResponseParameters.CreateBuilder().SetSize(size).Build())) |
|
|
|
|
.Build(); |
|
|
|
|
|
|
|
|
|
var call = client.StreamingOutputCall(request); |
|
|
|
|
|
|
|
|
|
var responseList = await call.ResponseStream.ToList(); |
|
|
|
|
foreach (var res in responseList) |
|
|
|
|
using (var call = client.StreamingOutputCall(request)) |
|
|
|
|
{ |
|
|
|
|
Assert.AreEqual(PayloadType.COMPRESSABLE, res.Payload.Type); |
|
|
|
|
var responseList = await call.ResponseStream.ToList(); |
|
|
|
|
foreach (var res in responseList) |
|
|
|
|
{ |
|
|
|
|
Assert.AreEqual(PayloadType.COMPRESSABLE, res.Payload.Type); |
|
|
|
|
} |
|
|
|
|
CollectionAssert.AreEqual(bodySizes, responseList.ConvertAll((item) => item.Payload.Body.Length)); |
|
|
|
|
} |
|
|
|
|
CollectionAssert.AreEqual(bodySizes, responseList.ConvertAll((item) => item.Payload.Body.Length)); |
|
|
|
|
Console.WriteLine("Passed!"); |
|
|
|
|
}).Wait(); |
|
|
|
|
} |
|
|
|
@ -254,48 +257,48 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
{ |
|
|
|
|
Console.WriteLine("running ping_pong"); |
|
|
|
|
|
|
|
|
|
var call = client.FullDuplexCall(); |
|
|
|
|
|
|
|
|
|
await call.RequestStream.WriteAsync(StreamingOutputCallRequest.CreateBuilder() |
|
|
|
|
.SetResponseType(PayloadType.COMPRESSABLE) |
|
|
|
|
.AddResponseParameters(ResponseParameters.CreateBuilder().SetSize(31415)) |
|
|
|
|
.SetPayload(CreateZerosPayload(27182)).Build()); |
|
|
|
|
|
|
|
|
|
Assert.IsTrue(await call.ResponseStream.MoveNext()); |
|
|
|
|
Assert.AreEqual(PayloadType.COMPRESSABLE, call.ResponseStream.Current.Payload.Type); |
|
|
|
|
Assert.AreEqual(31415, call.ResponseStream.Current.Payload.Body.Length); |
|
|
|
|
using (var call = client.FullDuplexCall()) |
|
|
|
|
{ |
|
|
|
|
await call.RequestStream.WriteAsync(StreamingOutputCallRequest.CreateBuilder() |
|
|
|
|
.SetResponseType(PayloadType.COMPRESSABLE) |
|
|
|
|
.AddResponseParameters(ResponseParameters.CreateBuilder().SetSize(31415)) |
|
|
|
|
.SetPayload(CreateZerosPayload(27182)).Build()); |
|
|
|
|
|
|
|
|
|
await call.RequestStream.WriteAsync(StreamingOutputCallRequest.CreateBuilder() |
|
|
|
|
.SetResponseType(PayloadType.COMPRESSABLE) |
|
|
|
|
.AddResponseParameters(ResponseParameters.CreateBuilder().SetSize(9)) |
|
|
|
|
.SetPayload(CreateZerosPayload(8)).Build()); |
|
|
|
|
Assert.IsTrue(await call.ResponseStream.MoveNext()); |
|
|
|
|
Assert.AreEqual(PayloadType.COMPRESSABLE, call.ResponseStream.Current.Payload.Type); |
|
|
|
|
Assert.AreEqual(31415, call.ResponseStream.Current.Payload.Body.Length); |
|
|
|
|
|
|
|
|
|
Assert.IsTrue(await call.ResponseStream.MoveNext()); |
|
|
|
|
Assert.AreEqual(PayloadType.COMPRESSABLE, call.ResponseStream.Current.Payload.Type); |
|
|
|
|
Assert.AreEqual(9, call.ResponseStream.Current.Payload.Body.Length); |
|
|
|
|
await call.RequestStream.WriteAsync(StreamingOutputCallRequest.CreateBuilder() |
|
|
|
|
.SetResponseType(PayloadType.COMPRESSABLE) |
|
|
|
|
.AddResponseParameters(ResponseParameters.CreateBuilder().SetSize(9)) |
|
|
|
|
.SetPayload(CreateZerosPayload(8)).Build()); |
|
|
|
|
|
|
|
|
|
await call.RequestStream.WriteAsync(StreamingOutputCallRequest.CreateBuilder() |
|
|
|
|
.SetResponseType(PayloadType.COMPRESSABLE) |
|
|
|
|
.AddResponseParameters(ResponseParameters.CreateBuilder().SetSize(2653)) |
|
|
|
|
.SetPayload(CreateZerosPayload(1828)).Build()); |
|
|
|
|
Assert.IsTrue(await call.ResponseStream.MoveNext()); |
|
|
|
|
Assert.AreEqual(PayloadType.COMPRESSABLE, call.ResponseStream.Current.Payload.Type); |
|
|
|
|
Assert.AreEqual(9, call.ResponseStream.Current.Payload.Body.Length); |
|
|
|
|
|
|
|
|
|
Assert.IsTrue(await call.ResponseStream.MoveNext()); |
|
|
|
|
Assert.AreEqual(PayloadType.COMPRESSABLE, call.ResponseStream.Current.Payload.Type); |
|
|
|
|
Assert.AreEqual(2653, call.ResponseStream.Current.Payload.Body.Length); |
|
|
|
|
await call.RequestStream.WriteAsync(StreamingOutputCallRequest.CreateBuilder() |
|
|
|
|
.SetResponseType(PayloadType.COMPRESSABLE) |
|
|
|
|
.AddResponseParameters(ResponseParameters.CreateBuilder().SetSize(2653)) |
|
|
|
|
.SetPayload(CreateZerosPayload(1828)).Build()); |
|
|
|
|
|
|
|
|
|
await call.RequestStream.WriteAsync(StreamingOutputCallRequest.CreateBuilder() |
|
|
|
|
.SetResponseType(PayloadType.COMPRESSABLE) |
|
|
|
|
.AddResponseParameters(ResponseParameters.CreateBuilder().SetSize(58979)) |
|
|
|
|
.SetPayload(CreateZerosPayload(45904)).Build()); |
|
|
|
|
Assert.IsTrue(await call.ResponseStream.MoveNext()); |
|
|
|
|
Assert.AreEqual(PayloadType.COMPRESSABLE, call.ResponseStream.Current.Payload.Type); |
|
|
|
|
Assert.AreEqual(2653, call.ResponseStream.Current.Payload.Body.Length); |
|
|
|
|
|
|
|
|
|
Assert.IsTrue(await call.ResponseStream.MoveNext()); |
|
|
|
|
Assert.AreEqual(PayloadType.COMPRESSABLE, call.ResponseStream.Current.Payload.Type); |
|
|
|
|
Assert.AreEqual(58979, call.ResponseStream.Current.Payload.Body.Length); |
|
|
|
|
await call.RequestStream.WriteAsync(StreamingOutputCallRequest.CreateBuilder() |
|
|
|
|
.SetResponseType(PayloadType.COMPRESSABLE) |
|
|
|
|
.AddResponseParameters(ResponseParameters.CreateBuilder().SetSize(58979)) |
|
|
|
|
.SetPayload(CreateZerosPayload(45904)).Build()); |
|
|
|
|
|
|
|
|
|
await call.RequestStream.CompleteAsync(); |
|
|
|
|
Assert.IsTrue(await call.ResponseStream.MoveNext()); |
|
|
|
|
Assert.AreEqual(PayloadType.COMPRESSABLE, call.ResponseStream.Current.Payload.Type); |
|
|
|
|
Assert.AreEqual(58979, call.ResponseStream.Current.Payload.Body.Length); |
|
|
|
|
|
|
|
|
|
Assert.IsFalse(await call.ResponseStream.MoveNext()); |
|
|
|
|
await call.RequestStream.CompleteAsync(); |
|
|
|
|
|
|
|
|
|
Assert.IsFalse(await call.ResponseStream.MoveNext()); |
|
|
|
|
} |
|
|
|
|
Console.WriteLine("Passed!"); |
|
|
|
|
}).Wait(); |
|
|
|
|
} |
|
|
|
@ -305,12 +308,13 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
Task.Run(async () => |
|
|
|
|
{ |
|
|
|
|
Console.WriteLine("running empty_stream"); |
|
|
|
|
var call = client.FullDuplexCall(); |
|
|
|
|
await call.RequestStream.CompleteAsync(); |
|
|
|
|
|
|
|
|
|
var responseList = await call.ResponseStream.ToList(); |
|
|
|
|
Assert.AreEqual(0, responseList.Count); |
|
|
|
|
using (var call = client.FullDuplexCall()) |
|
|
|
|
{ |
|
|
|
|
await call.RequestStream.CompleteAsync(); |
|
|
|
|
|
|
|
|
|
var responseList = await call.ResponseStream.ToList(); |
|
|
|
|
Assert.AreEqual(0, responseList.Count); |
|
|
|
|
} |
|
|
|
|
Console.WriteLine("Passed!"); |
|
|
|
|
}).Wait(); |
|
|
|
|
} |
|
|
|
@ -362,19 +366,21 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
Console.WriteLine("running cancel_after_begin"); |
|
|
|
|
|
|
|
|
|
var cts = new CancellationTokenSource(); |
|
|
|
|
var call = client.StreamingInputCall(cts.Token); |
|
|
|
|
// TODO(jtattermusch): we need this to ensure call has been initiated once we cancel it. |
|
|
|
|
await Task.Delay(1000); |
|
|
|
|
cts.Cancel(); |
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
using (var call = client.StreamingInputCall(cts.Token)) |
|
|
|
|
{ |
|
|
|
|
var response = await call.Result; |
|
|
|
|
Assert.Fail(); |
|
|
|
|
} |
|
|
|
|
catch (RpcException e) |
|
|
|
|
{ |
|
|
|
|
Assert.AreEqual(StatusCode.Cancelled, e.Status.StatusCode); |
|
|
|
|
// TODO(jtattermusch): we need this to ensure call has been initiated once we cancel it. |
|
|
|
|
await Task.Delay(1000); |
|
|
|
|
cts.Cancel(); |
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
var response = await call.Result; |
|
|
|
|
Assert.Fail(); |
|
|
|
|
} |
|
|
|
|
catch (RpcException e) |
|
|
|
|
{ |
|
|
|
|
Assert.AreEqual(StatusCode.Cancelled, e.Status.StatusCode); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Console.WriteLine("Passed!"); |
|
|
|
|
}).Wait(); |
|
|
|
@ -387,27 +393,28 @@ namespace Grpc.IntegrationTesting |
|
|
|
|
Console.WriteLine("running cancel_after_first_response"); |
|
|
|
|
|
|
|
|
|
var cts = new CancellationTokenSource(); |
|
|
|
|
var call = client.FullDuplexCall(cts.Token); |
|
|
|
|
|
|
|
|
|
await call.RequestStream.WriteAsync(StreamingOutputCallRequest.CreateBuilder() |
|
|
|
|
.SetResponseType(PayloadType.COMPRESSABLE) |
|
|
|
|
.AddResponseParameters(ResponseParameters.CreateBuilder().SetSize(31415)) |
|
|
|
|
.SetPayload(CreateZerosPayload(27182)).Build()); |
|
|
|
|
using (var call = client.FullDuplexCall(cts.Token)) |
|
|
|
|
{ |
|
|
|
|
await call.RequestStream.WriteAsync(StreamingOutputCallRequest.CreateBuilder() |
|
|
|
|
.SetResponseType(PayloadType.COMPRESSABLE) |
|
|
|
|
.AddResponseParameters(ResponseParameters.CreateBuilder().SetSize(31415)) |
|
|
|
|
.SetPayload(CreateZerosPayload(27182)).Build()); |
|
|
|
|
|
|
|
|
|
Assert.IsTrue(await call.ResponseStream.MoveNext()); |
|
|
|
|
Assert.AreEqual(PayloadType.COMPRESSABLE, call.ResponseStream.Current.Payload.Type); |
|
|
|
|
Assert.AreEqual(31415, call.ResponseStream.Current.Payload.Body.Length); |
|
|
|
|
Assert.IsTrue(await call.ResponseStream.MoveNext()); |
|
|
|
|
Assert.AreEqual(PayloadType.COMPRESSABLE, call.ResponseStream.Current.Payload.Type); |
|
|
|
|
Assert.AreEqual(31415, call.ResponseStream.Current.Payload.Body.Length); |
|
|
|
|
|
|
|
|
|
cts.Cancel(); |
|
|
|
|
cts.Cancel(); |
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
await call.ResponseStream.MoveNext(); |
|
|
|
|
Assert.Fail(); |
|
|
|
|
} |
|
|
|
|
catch (RpcException e) |
|
|
|
|
{ |
|
|
|
|
Assert.AreEqual(StatusCode.Cancelled, e.Status.StatusCode); |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
await call.ResponseStream.MoveNext(); |
|
|
|
|
Assert.Fail(); |
|
|
|
|
} |
|
|
|
|
catch (RpcException e) |
|
|
|
|
{ |
|
|
|
|
Assert.AreEqual(StatusCode.Cancelled, e.Status.StatusCode); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Console.WriteLine("Passed!"); |
|
|
|
|
}).Wait(); |
|
|
|
|