diff --git a/interop-testing/build.gradle b/interop-testing/build.gradle index eb6f39929a..316a57e083 100644 --- a/interop-testing/build.gradle +++ b/interop-testing/build.gradle @@ -46,9 +46,18 @@ task test_server(type: CreateStartScripts) { classpath = jar.outputs.files + project.configurations.runtime } +task reconnect_test_client(type: CreateStartScripts) { + mainClassName = "io.grpc.testing.integration.ReconnectTestClient" + applicationName = "reconnect-test-client" + defaultJvmOpts = ["-Xbootclasspath/p:" + configurations.alpnboot.asPath] + outputDir = new File(project.buildDir, 'tmp') + classpath = jar.outputs.files + project.configurations.runtime +} + applicationDistribution.into("bin") { from(test_client) from(test_server) + from(reconnect_test_client) fileMode = 0755 } diff --git a/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/ReconnectServiceGrpc.java b/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/ReconnectServiceGrpc.java new file mode 100644 index 0000000000..a9e37e1cb1 --- /dev/null +++ b/interop-testing/src/generated/main/grpc/io/grpc/testing/integration/ReconnectServiceGrpc.java @@ -0,0 +1,197 @@ +package io.grpc.testing.integration; + +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; + +@javax.annotation.Generated("by gRPC proto compiler") +public class ReconnectServiceGrpc { + + // Static method descriptors that strictly reflect the proto. + public static final io.grpc.MethodDescriptor METHOD_START = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + "grpc.testing.ReconnectService", "Start", + io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.EmptyProtos.Empty.parser()), + io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.EmptyProtos.Empty.parser())); + public static final io.grpc.MethodDescriptor METHOD_STOP = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + "grpc.testing.ReconnectService", "Stop", + io.grpc.protobuf.ProtoUtils.marshaller(com.google.protobuf.EmptyProtos.Empty.parser()), + io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.testing.integration.Messages.ReconnectInfo.parser())); + + public static ReconnectServiceStub newStub(io.grpc.Channel channel) { + return new ReconnectServiceStub(channel); + } + + public static ReconnectServiceBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new ReconnectServiceBlockingStub(channel); + } + + public static ReconnectServiceFutureStub newFutureStub( + io.grpc.Channel channel) { + return new ReconnectServiceFutureStub(channel); + } + + public static interface ReconnectService { + + public void start(com.google.protobuf.EmptyProtos.Empty request, + io.grpc.stub.StreamObserver responseObserver); + + public void stop(com.google.protobuf.EmptyProtos.Empty request, + io.grpc.stub.StreamObserver responseObserver); + } + + public static interface ReconnectServiceBlockingClient { + + public com.google.protobuf.EmptyProtos.Empty start(com.google.protobuf.EmptyProtos.Empty request); + + public io.grpc.testing.integration.Messages.ReconnectInfo stop(com.google.protobuf.EmptyProtos.Empty request); + } + + public static interface ReconnectServiceFutureClient { + + public com.google.common.util.concurrent.ListenableFuture start( + com.google.protobuf.EmptyProtos.Empty request); + + public com.google.common.util.concurrent.ListenableFuture stop( + com.google.protobuf.EmptyProtos.Empty request); + } + + public static class ReconnectServiceStub extends io.grpc.stub.AbstractStub + implements ReconnectService { + private ReconnectServiceStub(io.grpc.Channel channel) { + super(channel); + } + + private ReconnectServiceStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected ReconnectServiceStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new ReconnectServiceStub(channel, callOptions); + } + + @java.lang.Override + public void start(com.google.protobuf.EmptyProtos.Empty request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + channel.newCall(METHOD_START, callOptions), request, responseObserver); + } + + @java.lang.Override + public void stop(com.google.protobuf.EmptyProtos.Empty request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + channel.newCall(METHOD_STOP, callOptions), request, responseObserver); + } + } + + public static class ReconnectServiceBlockingStub extends io.grpc.stub.AbstractStub + implements ReconnectServiceBlockingClient { + private ReconnectServiceBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private ReconnectServiceBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected ReconnectServiceBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new ReconnectServiceBlockingStub(channel, callOptions); + } + + @java.lang.Override + public com.google.protobuf.EmptyProtos.Empty start(com.google.protobuf.EmptyProtos.Empty request) { + return blockingUnaryCall( + channel.newCall(METHOD_START, callOptions), request); + } + + @java.lang.Override + public io.grpc.testing.integration.Messages.ReconnectInfo stop(com.google.protobuf.EmptyProtos.Empty request) { + return blockingUnaryCall( + channel.newCall(METHOD_STOP, callOptions), request); + } + } + + public static class ReconnectServiceFutureStub extends io.grpc.stub.AbstractStub + implements ReconnectServiceFutureClient { + private ReconnectServiceFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private ReconnectServiceFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected ReconnectServiceFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new ReconnectServiceFutureStub(channel, callOptions); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture start( + com.google.protobuf.EmptyProtos.Empty request) { + return futureUnaryCall( + channel.newCall(METHOD_START, callOptions), request); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture stop( + com.google.protobuf.EmptyProtos.Empty request) { + return futureUnaryCall( + channel.newCall(METHOD_STOP, callOptions), request); + } + } + + public static io.grpc.ServerServiceDefinition bindService( + final ReconnectService serviceImpl) { + return io.grpc.ServerServiceDefinition.builder("grpc.testing.ReconnectService") + .addMethod(io.grpc.ServerMethodDefinition.create( + METHOD_START, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.protobuf.EmptyProtos.Empty, + com.google.protobuf.EmptyProtos.Empty>() { + @java.lang.Override + public void invoke( + com.google.protobuf.EmptyProtos.Empty request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.start(request, responseObserver); + } + }))) + .addMethod(io.grpc.ServerMethodDefinition.create( + METHOD_STOP, + asyncUnaryCall( + new io.grpc.stub.ServerCalls.UnaryMethod< + com.google.protobuf.EmptyProtos.Empty, + io.grpc.testing.integration.Messages.ReconnectInfo>() { + @java.lang.Override + public void invoke( + com.google.protobuf.EmptyProtos.Empty request, + io.grpc.stub.StreamObserver responseObserver) { + serviceImpl.stop(request, responseObserver); + } + }))).build(); + } +} diff --git a/interop-testing/src/generated/main/java/io/grpc/testing/integration/Messages.java b/interop-testing/src/generated/main/java/io/grpc/testing/integration/Messages.java index a40306982a..8325868be5 100644 --- a/interop-testing/src/generated/main/java/io/grpc/testing/integration/Messages.java +++ b/interop-testing/src/generated/main/java/io/grpc/testing/integration/Messages.java @@ -6230,6 +6230,565 @@ public final class Messages { } + public interface ReconnectInfoOrBuilder extends + // @@protoc_insertion_point(interface_extends:grpc.testing.ReconnectInfo) + com.google.protobuf.MessageOrBuilder { + + /** + * optional bool passed = 1; + */ + boolean getPassed(); + + /** + * repeated int32 backoff_ms = 2; + */ + java.util.List getBackoffMsList(); + /** + * repeated int32 backoff_ms = 2; + */ + int getBackoffMsCount(); + /** + * repeated int32 backoff_ms = 2; + */ + int getBackoffMs(int index); + } + /** + * Protobuf type {@code grpc.testing.ReconnectInfo} + * + *
+   * For reconnect interop test only.
+   * Server tells client whether its reconnects are following the spec and the
+   * reconnect backoffs it saw.
+   * 
+ */ + public static final class ReconnectInfo extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:grpc.testing.ReconnectInfo) + ReconnectInfoOrBuilder { + // Use ReconnectInfo.newBuilder() to construct. + private ReconnectInfo(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private ReconnectInfo() { + passed_ = false; + backoffMs_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ReconnectInfo( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { + + passed_ = input.readBool(); + break; + } + case 16: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + backoffMs_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + backoffMs_.add(input.readInt32()); + break; + } + case 18: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002) && input.getBytesUntilLimit() > 0) { + backoffMs_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + while (input.getBytesUntilLimit() > 0) { + backoffMs_.add(input.readInt32()); + } + input.popLimit(limit); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + backoffMs_ = java.util.Collections.unmodifiableList(backoffMs_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.testing.integration.Messages.internal_static_grpc_testing_ReconnectInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.testing.integration.Messages.internal_static_grpc_testing_ReconnectInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.grpc.testing.integration.Messages.ReconnectInfo.class, io.grpc.testing.integration.Messages.ReconnectInfo.Builder.class); + } + + private int bitField0_; + public static final int PASSED_FIELD_NUMBER = 1; + private boolean passed_; + /** + * optional bool passed = 1; + */ + public boolean getPassed() { + return passed_; + } + + public static final int BACKOFF_MS_FIELD_NUMBER = 2; + private java.util.List backoffMs_; + /** + * repeated int32 backoff_ms = 2; + */ + public java.util.List + getBackoffMsList() { + return backoffMs_; + } + /** + * repeated int32 backoff_ms = 2; + */ + public int getBackoffMsCount() { + return backoffMs_.size(); + } + /** + * repeated int32 backoff_ms = 2; + */ + public int getBackoffMs(int index) { + return backoffMs_.get(index); + } + private int backoffMsMemoizedSerializedSize = -1; + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (passed_ != false) { + output.writeBool(1, passed_); + } + if (getBackoffMsList().size() > 0) { + output.writeRawVarint32(18); + output.writeRawVarint32(backoffMsMemoizedSerializedSize); + } + for (int i = 0; i < backoffMs_.size(); i++) { + output.writeInt32NoTag(backoffMs_.get(i)); + } + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (passed_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(1, passed_); + } + { + int dataSize = 0; + for (int i = 0; i < backoffMs_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(backoffMs_.get(i)); + } + size += dataSize; + if (!getBackoffMsList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(dataSize); + } + backoffMsMemoizedSerializedSize = dataSize; + } + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static io.grpc.testing.integration.Messages.ReconnectInfo parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.testing.integration.Messages.ReconnectInfo parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.testing.integration.Messages.ReconnectInfo parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.testing.integration.Messages.ReconnectInfo parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.testing.integration.Messages.ReconnectInfo parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static io.grpc.testing.integration.Messages.ReconnectInfo parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static io.grpc.testing.integration.Messages.ReconnectInfo parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static io.grpc.testing.integration.Messages.ReconnectInfo parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static io.grpc.testing.integration.Messages.ReconnectInfo parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static io.grpc.testing.integration.Messages.ReconnectInfo parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(io.grpc.testing.integration.Messages.ReconnectInfo prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code grpc.testing.ReconnectInfo} + * + *
+     * For reconnect interop test only.
+     * Server tells client whether its reconnects are following the spec and the
+     * reconnect backoffs it saw.
+     * 
+ */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:grpc.testing.ReconnectInfo) + io.grpc.testing.integration.Messages.ReconnectInfoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.testing.integration.Messages.internal_static_grpc_testing_ReconnectInfo_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.testing.integration.Messages.internal_static_grpc_testing_ReconnectInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.grpc.testing.integration.Messages.ReconnectInfo.class, io.grpc.testing.integration.Messages.ReconnectInfo.Builder.class); + } + + // Construct using io.grpc.testing.integration.Messages.ReconnectInfo.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + passed_ = false; + + backoffMs_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.grpc.testing.integration.Messages.internal_static_grpc_testing_ReconnectInfo_descriptor; + } + + public io.grpc.testing.integration.Messages.ReconnectInfo getDefaultInstanceForType() { + return io.grpc.testing.integration.Messages.ReconnectInfo.getDefaultInstance(); + } + + public io.grpc.testing.integration.Messages.ReconnectInfo build() { + io.grpc.testing.integration.Messages.ReconnectInfo result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public io.grpc.testing.integration.Messages.ReconnectInfo buildPartial() { + io.grpc.testing.integration.Messages.ReconnectInfo result = new io.grpc.testing.integration.Messages.ReconnectInfo(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.passed_ = passed_; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + backoffMs_ = java.util.Collections.unmodifiableList(backoffMs_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.backoffMs_ = backoffMs_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof io.grpc.testing.integration.Messages.ReconnectInfo) { + return mergeFrom((io.grpc.testing.integration.Messages.ReconnectInfo)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.grpc.testing.integration.Messages.ReconnectInfo other) { + if (other == io.grpc.testing.integration.Messages.ReconnectInfo.getDefaultInstance()) return this; + if (other.getPassed() != false) { + setPassed(other.getPassed()); + } + if (!other.backoffMs_.isEmpty()) { + if (backoffMs_.isEmpty()) { + backoffMs_ = other.backoffMs_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureBackoffMsIsMutable(); + backoffMs_.addAll(other.backoffMs_); + } + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + io.grpc.testing.integration.Messages.ReconnectInfo parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.grpc.testing.integration.Messages.ReconnectInfo) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private boolean passed_ ; + /** + * optional bool passed = 1; + */ + public boolean getPassed() { + return passed_; + } + /** + * optional bool passed = 1; + */ + public Builder setPassed(boolean value) { + + passed_ = value; + onChanged(); + return this; + } + /** + * optional bool passed = 1; + */ + public Builder clearPassed() { + + passed_ = false; + onChanged(); + return this; + } + + private java.util.List backoffMs_ = java.util.Collections.emptyList(); + private void ensureBackoffMsIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + backoffMs_ = new java.util.ArrayList(backoffMs_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated int32 backoff_ms = 2; + */ + public java.util.List + getBackoffMsList() { + return java.util.Collections.unmodifiableList(backoffMs_); + } + /** + * repeated int32 backoff_ms = 2; + */ + public int getBackoffMsCount() { + return backoffMs_.size(); + } + /** + * repeated int32 backoff_ms = 2; + */ + public int getBackoffMs(int index) { + return backoffMs_.get(index); + } + /** + * repeated int32 backoff_ms = 2; + */ + public Builder setBackoffMs( + int index, int value) { + ensureBackoffMsIsMutable(); + backoffMs_.set(index, value); + onChanged(); + return this; + } + /** + * repeated int32 backoff_ms = 2; + */ + public Builder addBackoffMs(int value) { + ensureBackoffMsIsMutable(); + backoffMs_.add(value); + onChanged(); + return this; + } + /** + * repeated int32 backoff_ms = 2; + */ + public Builder addAllBackoffMs( + java.lang.Iterable values) { + ensureBackoffMsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, backoffMs_); + onChanged(); + return this; + } + /** + * repeated int32 backoff_ms = 2; + */ + public Builder clearBackoffMs() { + backoffMs_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:grpc.testing.ReconnectInfo) + } + + // @@protoc_insertion_point(class_scope:grpc.testing.ReconnectInfo) + private static final io.grpc.testing.integration.Messages.ReconnectInfo DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new io.grpc.testing.integration.Messages.ReconnectInfo(); + } + + public static io.grpc.testing.integration.Messages.ReconnectInfo getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + public static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public ReconnectInfo parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new ReconnectInfo(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public io.grpc.testing.integration.Messages.ReconnectInfo getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + private static com.google.protobuf.Descriptors.Descriptor internal_static_grpc_testing_Payload_descriptor; private static @@ -6275,6 +6834,11 @@ public final class Messages { private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_grpc_testing_StreamingOutputCallResponse_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_grpc_testing_ReconnectInfo_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_grpc_testing_ReconnectInfo_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { @@ -6305,10 +6869,11 @@ public final class Messages { "meters\030\002 \003(\0132 .grpc.testing.ResponsePara" + "meters\022&\n\007payload\030\003 \001(\0132\025.grpc.testing.P", "ayload\"E\n\033StreamingOutputCallResponse\022&\n" + - "\007payload\030\001 \001(\0132\025.grpc.testing.Payload*?\n" + - "\013PayloadType\022\020\n\014COMPRESSABLE\020\000\022\022\n\016UNCOMP" + - "RESSABLE\020\001\022\n\n\006RANDOM\020\002B\035\n\033io.grpc.testin" + - "g.integrationb\006proto3" + "\007payload\030\001 \001(\0132\025.grpc.testing.Payload\"3\n" + + "\rReconnectInfo\022\016\n\006passed\030\001 \001(\010\022\022\n\nbackof" + + "f_ms\030\002 \003(\005*?\n\013PayloadType\022\020\n\014COMPRESSABL" + + "E\020\000\022\022\n\016UNCOMPRESSABLE\020\001\022\n\n\006RANDOM\020\002B\035\n\033i" + + "o.grpc.testing.integrationb\006proto3" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { @@ -6376,6 +6941,12 @@ public final class Messages { com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_grpc_testing_StreamingOutputCallResponse_descriptor, new java.lang.String[] { "Payload", }); + internal_static_grpc_testing_ReconnectInfo_descriptor = + getDescriptor().getMessageTypes().get(9); + internal_static_grpc_testing_ReconnectInfo_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_grpc_testing_ReconnectInfo_descriptor, + new java.lang.String[] { "Passed", "BackoffMs", }); } // @@protoc_insertion_point(outer_class_scope) diff --git a/interop-testing/src/generated/main/java/io/grpc/testing/integration/Test.java b/interop-testing/src/generated/main/java/io/grpc/testing/integration/Test.java index 6d96241c59..3b43922e0e 100644 --- a/interop-testing/src/generated/main/java/io/grpc/testing/integration/Test.java +++ b/interop-testing/src/generated/main/java/io/grpc/testing/integration/Test.java @@ -34,8 +34,12 @@ public final class Test { ").grpc.testing.StreamingOutputCallRespon" + "se(\0010\001\022i\n\016HalfDuplexCall\022(.grpc.testing." + "StreamingOutputCallRequest\032).grpc.testin" + - "g.StreamingOutputCallResponse(\0010\001B\035\n\033io." + - "grpc.testing.integrationb\006proto3" + "g.StreamingOutputCallResponse(\0010\0012\177\n\020Rec" + + "onnectService\0221\n\005Start\022\023.grpc.testing.Em" + + "pty\032\023.grpc.testing.Empty\0228\n\004Stop\022\023.grpc.", + "testing.Empty\032\033.grpc.testing.ReconnectIn" + + "foB\035\n\033io.grpc.testing.integrationb\006proto" + + "3" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/ReconnectTestClient.java b/interop-testing/src/main/java/io/grpc/testing/integration/ReconnectTestClient.java new file mode 100644 index 0000000000..92486d17f5 --- /dev/null +++ b/interop-testing/src/main/java/io/grpc/testing/integration/ReconnectTestClient.java @@ -0,0 +1,132 @@ +/* + * Copyright 2015, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package io.grpc.testing.integration; + +import static org.junit.Assert.assertTrue; + +import com.google.protobuf.EmptyProtos.Empty; + +import io.grpc.ChannelImpl; +import io.grpc.StatusRuntimeException; +import io.grpc.netty.NegotiationType; +import io.grpc.netty.NettyChannelBuilder; +import io.grpc.okhttp.OkHttpChannelBuilder; +import io.grpc.testing.integration.Messages.ReconnectInfo; + +/** + * Verifies the client is reconnecting the server with correct backoffs + * + *

See the Test Spec. + */ +public class ReconnectTestClient { + private static final int TEST_TIME_MS = 540 * 1000; + + private int serverControlPort = 8080; + private int serverRetryPort = 8081; + private boolean useOkhttp = false; + private ChannelImpl controlChannel; + private ChannelImpl retryChannel; + private ReconnectServiceGrpc.ReconnectServiceBlockingStub controlStub; + private ReconnectServiceGrpc.ReconnectServiceBlockingStub retryStub; + + private void parseArgs(String[] args) { + for (String arg : args) { + if (!arg.startsWith("--")) { + System.err.println("All arguments must start with '--': " + arg); + System.exit(1); + } + String[] parts = arg.substring(2).split("=", 2); + String key = parts[0]; + String value = parts[1]; + if ("server_control_port".equals(key)) { + serverControlPort = Integer.parseInt(value); + } else if ("server_retry_port".equals(key)) { + serverRetryPort = Integer.parseInt(value); + } else if ("use_okhttp".equals(key)) { + useOkhttp = Boolean.parseBoolean(value); + } else { + System.err.println("Unknown argument: " + key); + System.exit(1); + } + } + } + + private void runTest() throws Exception { + try { + controlChannel = NettyChannelBuilder.forAddress("127.0.0.1", serverControlPort) + .negotiationType(NegotiationType.PLAINTEXT).build(); + controlStub = ReconnectServiceGrpc.newBlockingStub(controlChannel); + if (useOkhttp) { + retryChannel = OkHttpChannelBuilder.forAddress("127.0.0.1", serverRetryPort) + .negotiationType(io.grpc.okhttp.NegotiationType.TLS).build(); + } else { + retryChannel = NettyChannelBuilder.forAddress("127.0.0.1", serverRetryPort) + .negotiationType(NegotiationType.TLS).build(); + } + retryStub = ReconnectServiceGrpc.newBlockingStub(retryChannel); + controlStub.start(Empty.getDefaultInstance()); + + long startTimeStamp = System.currentTimeMillis(); + while ((System.currentTimeMillis() - startTimeStamp) < TEST_TIME_MS) { + try { + retryStub.start(Empty.getDefaultInstance()); + } catch (StatusRuntimeException expected) { + // Make CheckStyle happy. + } + Thread.sleep(50); + } + ReconnectInfo info = controlStub.stop(Empty.getDefaultInstance()); + assertTrue(info.getPassed()); + } finally { + controlChannel.shutdownNow(); + retryChannel.shutdownNow(); + } + } + + /** + * The main application allowing this client to be launched from the command line. + */ + public static void main(String[] args) { + ReconnectTestClient client = new ReconnectTestClient(); + client.parseArgs(args); + System.out.println("Starting test:"); + try { + client.runTest(); + System.out.println("Finished successfully"); + System.exit(0); + } catch (Throwable e) { + e.printStackTrace(); + System.err.println("Test failed!"); + System.exit(1); + } + } +} diff --git a/interop-testing/src/main/proto/io/grpc/testing/integration/messages.proto b/interop-testing/src/main/proto/io/grpc/testing/integration/messages.proto index 809224c123..0f29ead2ba 100644 --- a/interop-testing/src/main/proto/io/grpc/testing/integration/messages.proto +++ b/interop-testing/src/main/proto/io/grpc/testing/integration/messages.proto @@ -136,3 +136,11 @@ message StreamingOutputCallResponse { // Payload to increase response size. Payload payload = 1; } + +// For reconnect interop test only. +// Server tells client whether its reconnects are following the spec and the +// reconnect backoffs it saw. +message ReconnectInfo { + bool passed = 1; + repeated int32 backoff_ms = 2; +} diff --git a/interop-testing/src/main/proto/io/grpc/testing/integration/test.proto b/interop-testing/src/main/proto/io/grpc/testing/integration/test.proto index 3c37cc6154..6ea169a2ff 100644 --- a/interop-testing/src/main/proto/io/grpc/testing/integration/test.proto +++ b/interop-testing/src/main/proto/io/grpc/testing/integration/test.proto @@ -71,3 +71,9 @@ service TestService { rpc HalfDuplexCall(stream StreamingOutputCallRequest) returns (stream StreamingOutputCallResponse); } + +// A service used to control reconnect server. +service ReconnectService { + rpc Start(grpc.testing.Empty) returns (grpc.testing.Empty); + rpc Stop(grpc.testing.Empty) returns (grpc.testing.ReconnectInfo); +}