aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/interop/interop_client.cc
diff options
context:
space:
mode:
authorGravatar Yang Gao <yangg@google.com>2015-04-24 14:42:42 -0700
committerGravatar Yang Gao <yangg@google.com>2015-04-24 14:42:42 -0700
commit68d615737b5bf968d3fa4bee37125bd81fc4fa1a (patch)
tree8eb51b82d8315b82fc821cae3c2f263056a207de /test/cpp/interop/interop_client.cc
parent884f4dad58891a119c53af664680c134c73723b3 (diff)
Add two scenarios in interop test
Diffstat (limited to 'test/cpp/interop/interop_client.cc')
-rw-r--r--test/cpp/interop/interop_client.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc
index 7f5757d2ba..874510e54f 100644
--- a/test/cpp/interop/interop_client.cc
+++ b/test/cpp/interop/interop_client.cc
@@ -307,5 +307,49 @@ void InteropClient::DoPingPong() {
gpr_log(GPR_INFO, "Ping pong streaming done.");
}
+void InteropClient::DoCancelAfterBegin() {
+ gpr_log(GPR_INFO, "Sending request steaming rpc ...");
+ std::unique_ptr<TestService::Stub> stub(TestService::NewStub(channel_));
+
+ ClientContext context;
+ StreamingInputCallRequest request;
+ StreamingInputCallResponse response;
+
+ std::unique_ptr<ClientWriter<StreamingInputCallRequest>> stream(
+ stub->StreamingInputCall(&context, &response));
+
+ gpr_log(GPR_INFO, "Trying to cancel...");
+ context.TryCancel();
+ Status s = stream->Finish();
+ GPR_ASSERT(s.code() == StatusCode::CANCELLED);
+ gpr_log(GPR_INFO, "Canceling streaming done.");
+}
+
+void InteropClient::DoCancelAfterFirstResponse() {
+ gpr_log(GPR_INFO, "Sending Ping Pong streaming rpc ...");
+ std::unique_ptr<TestService::Stub> stub(TestService::NewStub(channel_));
+
+ ClientContext context;
+ std::unique_ptr<ClientReaderWriter<StreamingOutputCallRequest,
+ StreamingOutputCallResponse>>
+ stream(stub->FullDuplexCall(&context));
+
+ StreamingOutputCallRequest request;
+ request.set_response_type(PayloadType::COMPRESSABLE);
+ ResponseParameters* response_parameter = request.add_response_parameters();
+ response_parameter->set_size(31415);
+ request.mutable_payload()->set_body(grpc::string(27182, '\0'));
+ StreamingOutputCallResponse response;
+ GPR_ASSERT(stream->Write(request));
+ GPR_ASSERT(stream->Read(&response));
+ GPR_ASSERT(response.payload().has_body());
+ GPR_ASSERT(response.payload().body() == grpc::string(31415, '\0'));
+ gpr_log(GPR_INFO, "Trying to cancel...");
+ context.TryCancel();
+
+ Status s = stream->Finish();
+ gpr_log(GPR_INFO, "Canceling pingpong streaming done.");
+}
+
} // namespace testing
} // namespace grpc