From f5c7f4e15440cb0461a61afd6c0504f248e95af0 Mon Sep 17 00:00:00 2001 From: Chengyuan Zhang Date: Wed, 21 Oct 2020 17:57:34 -0700 Subject: [PATCH] interop-testing: add proto definitions for xDS circuit breaking test (#7545) --- .../LoadBalancerStatsServiceGrpc.java | 86 +++++ .../XdsUpdateClientConfigureServiceGrpc.java | 315 ++++++++++++++++++ .../main/proto/grpc/testing/messages.proto | 37 ++ .../src/main/proto/grpc/testing/test.proto | 12 +- 4 files changed, 449 insertions(+), 1 deletion(-) create mode 100644 interop-testing/src/generated/main/grpc/io/grpc/testing/integration/XdsUpdateClientConfigureServiceGrpc.java diff --git a/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/LoadBalancerStatsServiceGrpc.java b/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/LoadBalancerStatsServiceGrpc.java index 8332196e82a..f2e3bcf217a 100644 --- a/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/LoadBalancerStatsServiceGrpc.java +++ b/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/LoadBalancerStatsServiceGrpc.java @@ -61,6 +61,37 @@ io.grpc.testing.integration.Messages.LoadBalancerStatsResponse> getGetClientStat return getGetClientStatsMethod; } + private static volatile io.grpc.MethodDescriptor getGetClientAccumulatedStatsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetClientAccumulatedStats", + requestType = io.grpc.testing.integration.Messages.LoadBalancerAccumulatedStatsRequest.class, + responseType = io.grpc.testing.integration.Messages.LoadBalancerAccumulatedStatsResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getGetClientAccumulatedStatsMethod() { + io.grpc.MethodDescriptor getGetClientAccumulatedStatsMethod; + if ((getGetClientAccumulatedStatsMethod = LoadBalancerStatsServiceGrpc.getGetClientAccumulatedStatsMethod) == null) { + synchronized (LoadBalancerStatsServiceGrpc.class) { + if ((getGetClientAccumulatedStatsMethod = LoadBalancerStatsServiceGrpc.getGetClientAccumulatedStatsMethod) == null) { + LoadBalancerStatsServiceGrpc.getGetClientAccumulatedStatsMethod = getGetClientAccumulatedStatsMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetClientAccumulatedStats")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.grpc.testing.integration.Messages.LoadBalancerAccumulatedStatsRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.grpc.testing.integration.Messages.LoadBalancerAccumulatedStatsResponse.getDefaultInstance())) + .setSchemaDescriptor(new LoadBalancerStatsServiceMethodDescriptorSupplier("GetClientAccumulatedStats")) + .build(); + } + } + } + return getGetClientAccumulatedStatsMethod; + } + /** * Creates a new async stub that supports all call types for the service */ @@ -122,6 +153,16 @@ public void getClientStats(io.grpc.testing.integration.Messages.LoadBalancerStat asyncUnimplementedUnaryCall(getGetClientStatsMethod(), responseObserver); } + /** + *
+     * Gets the accumulated stats for RPCs sent by a test client.
+     * 
+ */ + public void getClientAccumulatedStats(io.grpc.testing.integration.Messages.LoadBalancerAccumulatedStatsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetClientAccumulatedStatsMethod(), responseObserver); + } + @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) .addMethod( @@ -131,6 +172,13 @@ public void getClientStats(io.grpc.testing.integration.Messages.LoadBalancerStat io.grpc.testing.integration.Messages.LoadBalancerStatsRequest, io.grpc.testing.integration.Messages.LoadBalancerStatsResponse>( this, METHODID_GET_CLIENT_STATS))) + .addMethod( + getGetClientAccumulatedStatsMethod(), + asyncUnaryCall( + new MethodHandlers< + io.grpc.testing.integration.Messages.LoadBalancerAccumulatedStatsRequest, + io.grpc.testing.integration.Messages.LoadBalancerAccumulatedStatsResponse>( + this, METHODID_GET_CLIENT_ACCUMULATED_STATS))) .build(); } } @@ -162,6 +210,17 @@ public void getClientStats(io.grpc.testing.integration.Messages.LoadBalancerStat asyncUnaryCall( getChannel().newCall(getGetClientStatsMethod(), getCallOptions()), request, responseObserver); } + + /** + *
+     * Gets the accumulated stats for RPCs sent by a test client.
+     * 
+ */ + public void getClientAccumulatedStats(io.grpc.testing.integration.Messages.LoadBalancerAccumulatedStatsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetClientAccumulatedStatsMethod(), getCallOptions()), request, responseObserver); + } } /** @@ -190,6 +249,16 @@ public io.grpc.testing.integration.Messages.LoadBalancerStatsResponse getClientS return blockingUnaryCall( getChannel(), getGetClientStatsMethod(), getCallOptions(), request); } + + /** + *
+     * Gets the accumulated stats for RPCs sent by a test client.
+     * 
+ */ + public io.grpc.testing.integration.Messages.LoadBalancerAccumulatedStatsResponse getClientAccumulatedStats(io.grpc.testing.integration.Messages.LoadBalancerAccumulatedStatsRequest request) { + return blockingUnaryCall( + getChannel(), getGetClientAccumulatedStatsMethod(), getCallOptions(), request); + } } /** @@ -219,9 +288,21 @@ public com.google.common.util.concurrent.ListenableFuture + * Gets the accumulated stats for RPCs sent by a test client. + * + */ + public com.google.common.util.concurrent.ListenableFuture getClientAccumulatedStats( + io.grpc.testing.integration.Messages.LoadBalancerAccumulatedStatsRequest request) { + return futureUnaryCall( + getChannel().newCall(getGetClientAccumulatedStatsMethod(), getCallOptions()), request); + } } private static final int METHODID_GET_CLIENT_STATS = 0; + private static final int METHODID_GET_CLIENT_ACCUMULATED_STATS = 1; private static final class MethodHandlers implements io.grpc.stub.ServerCalls.UnaryMethod, @@ -244,6 +325,10 @@ public void invoke(Req request, io.grpc.stub.StreamObserver responseObserv serviceImpl.getClientStats((io.grpc.testing.integration.Messages.LoadBalancerStatsRequest) request, (io.grpc.stub.StreamObserver) responseObserver); break; + case METHODID_GET_CLIENT_ACCUMULATED_STATS: + serviceImpl.getClientAccumulatedStats((io.grpc.testing.integration.Messages.LoadBalancerAccumulatedStatsRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; default: throw new AssertionError(); } @@ -306,6 +391,7 @@ public static io.grpc.ServiceDescriptor getServiceDescriptor() { serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) .setSchemaDescriptor(new LoadBalancerStatsServiceFileDescriptorSupplier()) .addMethod(getGetClientStatsMethod()) + .addMethod(getGetClientAccumulatedStatsMethod()) .build(); } } diff --git a/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/XdsUpdateClientConfigureServiceGrpc.java b/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/XdsUpdateClientConfigureServiceGrpc.java new file mode 100644 index 00000000000..aea386f9d0e --- /dev/null +++ b/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/XdsUpdateClientConfigureServiceGrpc.java @@ -0,0 +1,315 @@ +package io.grpc.testing.integration; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + *
+ * A service to dynamically update the configuration of an xDS test client.
+ * 
+ */ +@javax.annotation.Generated( + value = "by gRPC proto compiler", + comments = "Source: grpc/testing/test.proto") +public final class XdsUpdateClientConfigureServiceGrpc { + + private XdsUpdateClientConfigureServiceGrpc() {} + + public static final String SERVICE_NAME = "grpc.testing.XdsUpdateClientConfigureService"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor getConfigureMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "Configure", + requestType = io.grpc.testing.integration.Messages.ClientConfigureRequest.class, + responseType = io.grpc.testing.integration.Messages.ClientConfigureResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getConfigureMethod() { + io.grpc.MethodDescriptor getConfigureMethod; + if ((getConfigureMethod = XdsUpdateClientConfigureServiceGrpc.getConfigureMethod) == null) { + synchronized (XdsUpdateClientConfigureServiceGrpc.class) { + if ((getConfigureMethod = XdsUpdateClientConfigureServiceGrpc.getConfigureMethod) == null) { + XdsUpdateClientConfigureServiceGrpc.getConfigureMethod = getConfigureMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "Configure")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.grpc.testing.integration.Messages.ClientConfigureRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.grpc.testing.integration.Messages.ClientConfigureResponse.getDefaultInstance())) + .setSchemaDescriptor(new XdsUpdateClientConfigureServiceMethodDescriptorSupplier("Configure")) + .build(); + } + } + } + return getConfigureMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static XdsUpdateClientConfigureServiceStub newStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public XdsUpdateClientConfigureServiceStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new XdsUpdateClientConfigureServiceStub(channel, callOptions); + } + }; + return XdsUpdateClientConfigureServiceStub.newStub(factory, channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static XdsUpdateClientConfigureServiceBlockingStub newBlockingStub( + io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public XdsUpdateClientConfigureServiceBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new XdsUpdateClientConfigureServiceBlockingStub(channel, callOptions); + } + }; + return XdsUpdateClientConfigureServiceBlockingStub.newStub(factory, channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static XdsUpdateClientConfigureServiceFutureStub newFutureStub( + io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public XdsUpdateClientConfigureServiceFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new XdsUpdateClientConfigureServiceFutureStub(channel, callOptions); + } + }; + return XdsUpdateClientConfigureServiceFutureStub.newStub(factory, channel); + } + + /** + *
+   * A service to dynamically update the configuration of an xDS test client.
+   * 
+ */ + public static abstract class XdsUpdateClientConfigureServiceImplBase implements io.grpc.BindableService { + + /** + *
+     * Update the tes client's configuration.
+     * 
+ */ + public void configure(io.grpc.testing.integration.Messages.ClientConfigureRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getConfigureMethod(), responseObserver); + } + + @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getConfigureMethod(), + asyncUnaryCall( + new MethodHandlers< + io.grpc.testing.integration.Messages.ClientConfigureRequest, + io.grpc.testing.integration.Messages.ClientConfigureResponse>( + this, METHODID_CONFIGURE))) + .build(); + } + } + + /** + *
+   * A service to dynamically update the configuration of an xDS test client.
+   * 
+ */ + public static final class XdsUpdateClientConfigureServiceStub extends io.grpc.stub.AbstractAsyncStub { + private XdsUpdateClientConfigureServiceStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected XdsUpdateClientConfigureServiceStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new XdsUpdateClientConfigureServiceStub(channel, callOptions); + } + + /** + *
+     * Update the tes client's configuration.
+     * 
+ */ + public void configure(io.grpc.testing.integration.Messages.ClientConfigureRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getConfigureMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + *
+   * A service to dynamically update the configuration of an xDS test client.
+   * 
+ */ + public static final class XdsUpdateClientConfigureServiceBlockingStub extends io.grpc.stub.AbstractBlockingStub { + private XdsUpdateClientConfigureServiceBlockingStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected XdsUpdateClientConfigureServiceBlockingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new XdsUpdateClientConfigureServiceBlockingStub(channel, callOptions); + } + + /** + *
+     * Update the tes client's configuration.
+     * 
+ */ + public io.grpc.testing.integration.Messages.ClientConfigureResponse configure(io.grpc.testing.integration.Messages.ClientConfigureRequest request) { + return blockingUnaryCall( + getChannel(), getConfigureMethod(), getCallOptions(), request); + } + } + + /** + *
+   * A service to dynamically update the configuration of an xDS test client.
+   * 
+ */ + public static final class XdsUpdateClientConfigureServiceFutureStub extends io.grpc.stub.AbstractFutureStub { + private XdsUpdateClientConfigureServiceFutureStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected XdsUpdateClientConfigureServiceFutureStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new XdsUpdateClientConfigureServiceFutureStub(channel, callOptions); + } + + /** + *
+     * Update the tes client's configuration.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture configure( + io.grpc.testing.integration.Messages.ClientConfigureRequest request) { + return futureUnaryCall( + getChannel().newCall(getConfigureMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_CONFIGURE = 0; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final XdsUpdateClientConfigureServiceImplBase serviceImpl; + private final int methodId; + + MethodHandlers(XdsUpdateClientConfigureServiceImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_CONFIGURE: + serviceImpl.configure((io.grpc.testing.integration.Messages.ClientConfigureRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class XdsUpdateClientConfigureServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + XdsUpdateClientConfigureServiceBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return io.grpc.testing.integration.Test.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("XdsUpdateClientConfigureService"); + } + } + + private static final class XdsUpdateClientConfigureServiceFileDescriptorSupplier + extends XdsUpdateClientConfigureServiceBaseDescriptorSupplier { + XdsUpdateClientConfigureServiceFileDescriptorSupplier() {} + } + + private static final class XdsUpdateClientConfigureServiceMethodDescriptorSupplier + extends XdsUpdateClientConfigureServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + XdsUpdateClientConfigureServiceMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (XdsUpdateClientConfigureServiceGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new XdsUpdateClientConfigureServiceFileDescriptorSupplier()) + .addMethod(getConfigureMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/interop-testing/src/main/proto/grpc/testing/messages.proto b/interop-testing/src/main/proto/grpc/testing/messages.proto index a84f708ee3d..5bfc9a5214d 100644 --- a/interop-testing/src/main/proto/grpc/testing/messages.proto +++ b/interop-testing/src/main/proto/grpc/testing/messages.proto @@ -202,3 +202,40 @@ message LoadBalancerStatsResponse { // The number of completed RPCs for each type (UnaryCall or EmptyCall). map rpcs_by_method = 3; } + +// Request for retrieving a test client's accumulated stats. +message LoadBalancerAccumulatedStatsRequest {} + +// Accumulated stats for RPCs sent by a test client. +message LoadBalancerAccumulatedStatsResponse { + // The total number of RPCs have ever issued. + int32 num_rpcs_started = 1; + // The total number of RPCs have ever completed successfully for each peer. + map num_rpcs_succeeded_by_peer = 2; + // The total number of RPCs have ever failed. + int32 num_rpcs_failed = 3; +} + +// Configurations for a test client. +message ClientConfigureRequest { + // Type of RPCs to send. + enum RpcType { + EMPTY_CALL = 0; + UNARY_CALL = 1; + } + + // Metadata to be attached for the given type of RPCs. + message Metadata { + RpcType type = 1; + string key = 2; + string value = 3; + } + + // The types of RPCs the client sends. + repeated RpcType types = 1; + // The collection of custom metadata to be attached to RPCs sent by the client. + repeated Metadata metadata = 2; +} + +// Response for updating a test client's configuration. +message ClientConfigureResponse {} diff --git a/interop-testing/src/main/proto/grpc/testing/test.proto b/interop-testing/src/main/proto/grpc/testing/test.proto index 0438d61392b..f8b0927cc98 100644 --- a/interop-testing/src/main/proto/grpc/testing/test.proto +++ b/interop-testing/src/main/proto/grpc/testing/test.proto @@ -81,7 +81,11 @@ service ReconnectService { service LoadBalancerStatsService { // Gets the backend distribution for RPCs sent by a test client. rpc GetClientStats(LoadBalancerStatsRequest) - returns (LoadBalancerStatsResponse) {} + returns (LoadBalancerStatsResponse) {} + + // Gets the accumulated stats for RPCs sent by a test client. + rpc GetClientAccumulatedStats(LoadBalancerAccumulatedStatsRequest) + returns (LoadBalancerAccumulatedStatsResponse) {} } // A service to remotely control health status of an xDS test server. @@ -89,3 +93,9 @@ service XdsUpdateHealthService { rpc SetServing(grpc.testing.Empty) returns (grpc.testing.Empty); rpc SetNotServing(grpc.testing.Empty) returns (grpc.testing.Empty); } + +// A service to dynamically update the configuration of an xDS test client. +service XdsUpdateClientConfigureService { + // Update the tes client's configuration. + rpc Configure(ClientConfigureRequest) returns (ClientConfigureResponse); +}