Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Unified Diff: net/quic/core/quic_session_test.cc

Issue 2229023002: Track when QUIC connections are application limited. Protected by quic_enable_app_limited_check. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@129327247
Patch Set: git pull upper stream Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/core/quic_sent_packet_manager_interface.h ('k') | net/quic/test_tools/quic_test_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/core/quic_session_test.cc
diff --git a/net/quic/core/quic_session_test.cc b/net/quic/core/quic_session_test.cc
index cd1e3b152d13a27a5bf587ab5698841202c8aa1e..d9f3fd8fd0d28d040a93295f621c53fae0d18170 100644
--- a/net/quic/core/quic_session_test.cc
+++ b/net/quic/core/quic_session_test.cc
@@ -492,6 +492,8 @@ TEST_P(QuicSessionTestServer, TestBatchedWrites) {
}
TEST_P(QuicSessionTestServer, OnCanWriteBundlesStreams) {
+ FLAGS_quic_enable_app_limited_check = true;
+
// Encryption needs to be established before data can be sent.
CryptoHandshakeMessage msg;
session_.GetCryptoStream()->OnHandshakeMessage(msg);
@@ -533,11 +535,14 @@ TEST_P(QuicSessionTestServer, OnCanWriteBundlesStreams) {
EXPECT_CALL(*writer, WritePacket(_, _, _, _, _))
.WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0)));
EXPECT_CALL(*send_algorithm, OnPacketSent(_, _, _, _, _));
+ EXPECT_CALL(*send_algorithm, OnApplicationLimited(_));
session_.OnCanWrite();
EXPECT_FALSE(session_.WillingAndAbleToWrite());
}
TEST_P(QuicSessionTestServer, OnCanWriteCongestionControlBlocks) {
+ FLAGS_quic_enable_app_limited_check = true;
+
InSequence s;
// Drive congestion control manually.
@@ -578,10 +583,41 @@ TEST_P(QuicSessionTestServer, OnCanWriteCongestionControlBlocks) {
EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _))
.WillOnce(Return(QuicTime::Delta::Zero()));
EXPECT_CALL(*stream4, OnCanWrite());
+ EXPECT_CALL(*send_algorithm, OnApplicationLimited(_));
session_.OnCanWrite();
EXPECT_FALSE(session_.WillingAndAbleToWrite());
}
+TEST_P(QuicSessionTestServer, OnCanWriteWriterBlocks) {
+ FLAGS_quic_enable_app_limited_check = true;
+
+ // Drive congestion control manually in order to ensure that
+ // application-limited signaling is handled correctly.
+ MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>;
+ QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId,
+ send_algorithm);
+ EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _))
+ .WillRepeatedly(Return(QuicTime::Delta::Zero()));
+
+ // Drive packet writer manually.
+ MockPacketWriter* writer = static_cast<MockPacketWriter*>(
+ QuicConnectionPeer::GetWriter(session_.connection()));
+ EXPECT_CALL(*writer, IsWriteBlocked()).WillRepeatedly(Return(true));
+ EXPECT_CALL(*writer, IsWriteBlockedDataBuffered())
+ .WillRepeatedly(Return(true));
+ EXPECT_CALL(*writer, WritePacket(_, _, _, _, _)).Times(0);
+
+ TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
+
+ session_.MarkConnectionLevelWriteBlocked(stream2->id());
+
+ EXPECT_CALL(*stream2, OnCanWrite()).Times(0);
+ EXPECT_CALL(*send_algorithm, OnApplicationLimited(_)).Times(0);
+
+ session_.OnCanWrite();
+ EXPECT_TRUE(session_.WillingAndAbleToWrite());
+}
+
TEST_P(QuicSessionTestServer, BufferedHandshake) {
EXPECT_FALSE(session_.HasPendingHandshake()); // Default value.
@@ -644,6 +680,16 @@ TEST_P(QuicSessionTestServer, OnCanWriteWithClosedStream) {
}
TEST_P(QuicSessionTestServer, OnCanWriteLimitsNumWritesIfFlowControlBlocked) {
+ FLAGS_quic_enable_app_limited_check = true;
+
+ // Drive congestion control manually in order to ensure that
+ // application-limited signaling is handled correctly.
+ MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>;
+ QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId,
+ send_algorithm);
+ EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _))
+ .WillRepeatedly(Return(QuicTime::Delta::Zero()));
+
// Ensure connection level flow control blockage.
QuicFlowControllerPeer::SetSendWindowOffset(session_.flow_controller(), 0);
EXPECT_TRUE(session_.flow_controller()->IsBlocked());
@@ -669,6 +715,10 @@ TEST_P(QuicSessionTestServer, OnCanWriteLimitsNumWritesIfFlowControlBlocked) {
QuicSpdySessionPeer::SetHeadersStream(&session_, headers_stream);
EXPECT_CALL(*headers_stream, OnCanWrite());
+ // After the crypto and header streams perform a write, the connection will be
+ // blocked by the flow control, hence it should become application-limited.
+ EXPECT_CALL(*send_algorithm, OnApplicationLimited(_));
+
session_.OnCanWrite();
EXPECT_FALSE(session_.WillingAndAbleToWrite());
}
« no previous file with comments | « net/quic/core/quic_sent_packet_manager_interface.h ('k') | net/quic/test_tools/quic_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698