diff --git a/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceImpl.cs b/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceImpl.cs index 47a15224f16..7e7bc713a03 100644 --- a/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceImpl.cs +++ b/src/csharp/Grpc.IntegrationTesting/BenchmarkServiceImpl.cs @@ -46,16 +46,13 @@ namespace Grpc.Testing /// public class BenchmarkServiceImpl : BenchmarkService.IBenchmarkService { - private readonly int responseSize; - - public BenchmarkServiceImpl(int responseSize) + public BenchmarkServiceImpl() { - this.responseSize = responseSize; } public Task UnaryCall(SimpleRequest request, ServerCallContext context) { - var response = new SimpleResponse { Payload = CreateZerosPayload(responseSize) }; + var response = new SimpleResponse { Payload = CreateZerosPayload(request.ResponseSize) }; return Task.FromResult(response); } @@ -63,7 +60,7 @@ namespace Grpc.Testing { await requestStream.ForEachAsync(async request => { - var response = new SimpleResponse { Payload = CreateZerosPayload(responseSize) }; + var response = new SimpleResponse { Payload = CreateZerosPayload(request.ResponseSize) }; await responseStream.WriteAsync(response); }); } diff --git a/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs b/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs index 3223d0d0800..0b6a8ee6267 100644 --- a/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs +++ b/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs @@ -64,6 +64,8 @@ namespace Grpc.IntegrationTesting string target = config.ServerTargets.Single(); GrpcPreconditions.CheckArgument(config.LoadParams.LoadCase == LoadParams.LoadOneofCase.ClosedLoop, "Only closed loop scenario supported for C#"); + GrpcPreconditions.CheckArgument(config.ClientType == ClientType.SYNC_CLIENT, + "Only sync client support for C#"); GrpcPreconditions.CheckArgument(config.ClientChannels == 1, "ClientConfig.ClientChannels needs to be 1"); if (config.OutstandingRpcsPerChannel != 0) @@ -98,7 +100,7 @@ namespace Grpc.IntegrationTesting { case RpcType.UNARY: return new SyncUnaryClientRunner(channel, - config.PayloadConfig.SimpleParams.ReqSize, + config.PayloadConfig.SimpleParams, config.HistogramParams); case RpcType.STREAMING: @@ -116,7 +118,7 @@ namespace Grpc.IntegrationTesting const double SecondsToNanos = 1e9; readonly Channel channel; - readonly int payloadSize; + readonly SimpleProtoParams payloadParams; readonly Histogram histogram; readonly BenchmarkService.IBenchmarkServiceClient client; @@ -124,10 +126,9 @@ namespace Grpc.IntegrationTesting readonly CancellationTokenSource stoppedCts; readonly WallClockStopwatch wallClockStopwatch = new WallClockStopwatch(); - public SyncUnaryClientRunner(Channel channel, int payloadSize, HistogramParams histogramParams) + public SyncUnaryClientRunner(Channel channel, SimpleProtoParams payloadParams, HistogramParams histogramParams) { this.channel = GrpcPreconditions.CheckNotNull(channel); - this.payloadSize = payloadSize; this.histogram = new Histogram(histogramParams.Resolution, histogramParams.MaxPossible); this.stoppedCts = new CancellationTokenSource(); @@ -161,7 +162,8 @@ namespace Grpc.IntegrationTesting { var request = new SimpleRequest { - Payload = CreateZerosPayload(payloadSize) + Payload = CreateZerosPayload(payloadParams.ReqSize), + ResponseSize = payloadParams.RespSize }; var stopwatch = new Stopwatch(); diff --git a/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs b/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs index 9f210081e78..516436ac5ac 100644 --- a/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs +++ b/src/csharp/Grpc.IntegrationTesting/ServerRunners.cs @@ -77,11 +77,11 @@ namespace Grpc.IntegrationTesting Logger.Warning("ServerConfig.CoreList is not supported for C#. Ignoring the value"); } - // TODO: qps_driver needs to setup payload properly... - int responseSize = config.PayloadConfig != null ? config.PayloadConfig.SimpleParams.RespSize : 0; + GrpcPreconditions.CheckArgument(config.PayloadConfig == null, + "ServerConfig.PayloadConfig shouldn't be set for BenchmarkService based server."); var server = new Server { - Services = { BenchmarkService.BindService(new BenchmarkServiceImpl(responseSize)) }, + Services = { BenchmarkService.BindService(new BenchmarkServiceImpl()) }, Ports = { new ServerPort("[::]", config.Port, credentials) } };