Update QuicSessionTestServer.OnCanWrite. Update QuicSessionTestServer.OnCanWrite to reflect behavior for every combination of values of quic_priority_respect_incremental and quic_disable_batch_write flags. Tested locally at: http://sponge2/05735687-de62-4b69-b23c-2acd11bd9096 http://sponge2/246e07a2-db21-412c-9268-c3c69835e60e http://sponge2/72ca7f7f-e557-4c0b-b7ad-53d389809814 http://sponge2/f204baaf-04ec-4022-952d-0329e17588e7 Also, remove QuicSpdySessionTestServer.OnCanWrite, because the two tests are identical. PiperOrigin-RevId: 518533125
diff --git a/quiche/quic/core/http/quic_spdy_session_test.cc b/quiche/quic/core/http/quic_spdy_session_test.cc index 89ee9e4..966b231 100644 --- a/quiche/quic/core/http/quic_spdy_session_test.cc +++ b/quiche/quic/core/http/quic_spdy_session_test.cc
@@ -807,36 +807,6 @@ msg); } -TEST_P(QuicSpdySessionTestServer, OnCanWrite) { - CompleteHandshake(); - session_.set_writev_consumes_all_data(true); - TestStream* stream2 = session_.CreateOutgoingBidirectionalStream(); - TestStream* stream4 = session_.CreateOutgoingBidirectionalStream(); - TestStream* stream6 = session_.CreateOutgoingBidirectionalStream(); - - session_.MarkConnectionLevelWriteBlocked(stream2->id()); - session_.MarkConnectionLevelWriteBlocked(stream6->id()); - session_.MarkConnectionLevelWriteBlocked(stream4->id()); - - InSequence s; - - // Reregister, to test the loop limit. - EXPECT_CALL(*stream2, OnCanWrite()).WillOnce(Invoke([this, stream2]() { - session_.SendStreamData(stream2); - session_.MarkConnectionLevelWriteBlocked(stream2->id()); - })); - // 2 will get called a second time as it didn't finish its block - EXPECT_CALL(*stream2, OnCanWrite()).WillOnce(Invoke([this, stream2]() { - session_.SendStreamData(stream2); - })); - EXPECT_CALL(*stream6, OnCanWrite()).WillOnce(Invoke([this, stream6]() { - session_.SendStreamData(stream6); - })); - // 4 will not get called, as we exceeded the loop limit. - session_.OnCanWrite(); - EXPECT_TRUE(session_.WillingAndAbleToWrite()); -} - TEST_P(QuicSpdySessionTestServer, TooLargeStreamBlocked) { // STREAMS_BLOCKED frame is IETF QUIC only. if (!VersionUsesHttp3(transport_version())) {
diff --git a/quiche/quic/core/quic_session_test.cc b/quiche/quic/core/quic_session_test.cc index c8f5f5b..bdf74b3 100644 --- a/quiche/quic/core/quic_session_test.cc +++ b/quiche/quic/core/quic_session_test.cc
@@ -994,6 +994,11 @@ msg); } +// SpdySession::OnCanWrite() queries QuicWriteBlockedList for the number of +// streams that are marked as connection level write blocked, then queries +// QuicWriteBlockedList that many times for what stream to write data on. This +// can result in some streams writing multiple times in a single +// SpdySession::OnCanWrite() call while other streams not getting a turn. TEST_P(QuicSessionTestServer, OnCanWrite) { CompleteHandshake(); session_.set_writev_consumes_all_data(true); @@ -1012,14 +1017,29 @@ session_.SendStreamData(stream2); session_.MarkConnectionLevelWriteBlocked(stream2->id()); })); - // 2 will get called a second time as it didn't finish its block - EXPECT_CALL(*stream2, OnCanWrite()).WillOnce(Invoke([this, stream2]() { - session_.SendStreamData(stream2); - })); - EXPECT_CALL(*stream6, OnCanWrite()).WillOnce(Invoke([this, stream6]() { - session_.SendStreamData(stream6); - })); - // 4 will not get called, as we exceeded the loop limit. + + if (!GetQuicReloadableFlag(quic_disable_batch_write) || + GetQuicReloadableFlag(quic_priority_respect_incremental)) { + // If batched writes are enabled, stream 2 will write again. Also, streams + // are non-incremental by default, so if the incremental flag is respected, + // then stream 2 will write again. (If it is not respected, then every + // stream is treated as incremental.) + EXPECT_CALL(*stream2, OnCanWrite()).WillOnce(Invoke([this, stream2]() { + session_.SendStreamData(stream2); + })); + EXPECT_CALL(*stream6, OnCanWrite()).WillOnce(Invoke([this, stream6]() { + session_.SendStreamData(stream6); + })); + } else { + EXPECT_CALL(*stream6, OnCanWrite()).WillOnce(Invoke([this, stream6]() { + session_.SendStreamData(stream6); + })); + EXPECT_CALL(*stream4, OnCanWrite()).WillOnce(Invoke([this, stream4]() { + session_.SendStreamData(stream4); + })); + } + + // Stream 4 will not get called, as we exceeded the loop limit. session_.OnCanWrite(); EXPECT_TRUE(session_.WillingAndAbleToWrite()); }