aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2015-07-31 14:05:33 -0700
committerGravatar yang-g <yangg@google.com>2015-07-31 14:05:33 -0700
commit8ab383686b25af41dbc022e854c88f4465d12f27 (patch)
tree1314671ac19673a2da63ae06bedc4a605089a1f2
parent5f8d05bb9c72d950ca35e27a8da8a303765c85cb (diff)
add a test where a read and a writesdone happen at the same time
-rw-r--r--test/cpp/end2end/end2end_test.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index 5b351c169e..f6e55f3cba 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -818,6 +818,27 @@ TEST_F(End2endTest, HugeResponse) {
EXPECT_TRUE(s.ok());
}
+namespace {
+void ReaderThreadFunc(ClientReaderWriter<EchoRequest, EchoResponse>* stream) {
+ EchoResponse resp;
+ while (stream->Read(&resp)) {
+ gpr_log(GPR_INFO, "Read message");
+ }
+}
+} // namespace
+
+// Run a Read and a WritesDone simultaneously.
+TEST_F(End2endTest, SimuReadWritesDone) {
+ ResetStub();
+ ClientContext context;
+ auto stream = stub_->BidiStream(&context);
+ std::thread reader_thread(ReaderThreadFunc, stream.get());
+ stream->WritesDone();
+ Status s = stream->Finish();
+ EXPECT_TRUE(s.ok());
+ reader_thread.join();
+}
+
} // namespace testing
} // namespace grpc