@@ -299,7 +299,7 @@ class ClientCallbackEnd2endTest
299299 }
300300 }
301301
302- void SendGenericEchoAsBidi (int num_rpcs, int reuses) {
302+ void SendGenericEchoAsBidi (int num_rpcs, int reuses, bool do_writes_done ) {
303303 const grpc::string kMethodName (" /grpc.testing.EchoTestService/Echo" );
304304 grpc::string test_string (" " );
305305 for (int i = 0 ; i < num_rpcs; i++) {
@@ -308,8 +308,8 @@ class ClientCallbackEnd2endTest
308308 ByteBuffer> {
309309 public:
310310 Client (ClientCallbackEnd2endTest* test, const grpc::string& method_name,
311- const grpc::string& test_str, int reuses)
312- : reuses_remaining_(reuses) {
311+ const grpc::string& test_str, int reuses, bool do_writes_done )
312+ : reuses_remaining_(reuses), do_writes_done_(do_writes_done) {
313313 activate_ = [this , test, method_name, test_str] {
314314 if (reuses_remaining_ > 0 ) {
315315 cli_ctx_.reset (new ClientContext);
@@ -329,7 +329,11 @@ class ClientCallbackEnd2endTest
329329 };
330330 activate_ ();
331331 }
332- void OnWriteDone (bool /* ok*/ ) override { StartWritesDone (); }
332+ void OnWriteDone (bool /* ok*/ ) override {
333+ if (do_writes_done_) {
334+ StartWritesDone ();
335+ }
336+ }
333337 void OnReadDone (bool /* ok*/ ) override {
334338 EchoResponse response;
335339 EXPECT_TRUE (ParseFromByteBuffer (&recv_buf_, &response));
@@ -355,7 +359,10 @@ class ClientCallbackEnd2endTest
355359 std::mutex mu_;
356360 std::condition_variable cv_;
357361 bool done_ = false ;
358- } rpc{this , kMethodName , test_string, reuses};
362+ const bool do_writes_done_;
363+ };
364+
365+ Client rpc (this , kMethodName , test_string, reuses, do_writes_done);
359366
360367 rpc.Await ();
361368 }
@@ -517,13 +524,19 @@ TEST_P(ClientCallbackEnd2endTest, SequentialGenericRpcs) {
517524TEST_P (ClientCallbackEnd2endTest, SequentialGenericRpcsAsBidi) {
518525 MAYBE_SKIP_TEST;
519526 ResetStub ();
520- SendGenericEchoAsBidi (10 , 1 );
527+ SendGenericEchoAsBidi (10 , 1 , /* do_writes_done= */ true );
521528}
522529
523530TEST_P (ClientCallbackEnd2endTest, SequentialGenericRpcsAsBidiWithReactorReuse) {
524531 MAYBE_SKIP_TEST;
525532 ResetStub ();
526- SendGenericEchoAsBidi (10 , 10 );
533+ SendGenericEchoAsBidi (10 , 10 , /* do_writes_done=*/ true );
534+ }
535+
536+ TEST_P (ClientCallbackEnd2endTest, GenericRpcNoWritesDone) {
537+ MAYBE_SKIP_TEST;
538+ ResetStub ();
539+ SendGenericEchoAsBidi (1 , 1 , /* do_writes_done=*/ false );
527540}
528541
529542#if GRPC_ALLOW_EXCEPTIONS
0 commit comments