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

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

Issue 2307933003: Quic: add unittests for reduced PING Timeout (Closed)
Patch Set: Created 4 years, 3 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
« net/quic/core/quic_connection.h ('K') | « net/quic/core/quic_connection.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/core/quic_connection_test.cc
diff --git a/net/quic/core/quic_connection_test.cc b/net/quic/core/quic_connection_test.cc
index a24a222430932e8519dc4db79107d02761c04585..1f80381a2f1c713fb21f4848253ff2a76acb1400 100644
--- a/net/quic/core/quic_connection_test.cc
+++ b/net/quic/core/quic_connection_test.cc
@@ -2913,7 +2913,7 @@ TEST_P(QuicConnectionTest, PingAfterSend) {
ProcessAckPacket(&frame);
EXPECT_TRUE(connection_.GetPingAlarm()->IsSet());
// The ping timer is set slightly less than 15 seconds in the future, because
- // of the 1s ping timer alarm granularity.
+ // of the 1st ping timer alarm granularity.
Ryan Hamilton 2016/09/02 21:26:52 this really mean 1 second, not first.
Zhongyi Shi 2016/09/02 21:44:45 Sorry for misread the code.
EXPECT_EQ(clock_.ApproximateNow() + QuicTime::Delta::FromSeconds(15) -
QuicTime::Delta::FromMilliseconds(5),
connection_.GetPingAlarm()->deadline());
@@ -2932,6 +2932,51 @@ TEST_P(QuicConnectionTest, PingAfterSend) {
EXPECT_FALSE(connection_.GetPingAlarm()->IsSet());
}
+TEST_P(QuicConnectionTest, ReducedPingTimeout) {
+ EXPECT_TRUE(connection_.connected());
+ EXPECT_CALL(visitor_, HasOpenDynamicStreams()).WillRepeatedly(Return(true));
+ EXPECT_FALSE(connection_.GetPingAlarm()->IsSet());
+
+ // Use a reduced ping timeout for this connection.
+ connection_.set_ping_timeout(QuicTime::Delta::FromSeconds(10));
Ryan Hamilton 2016/09/02 21:26:52 To confirm, this test fails if you comment out thi
Zhongyi Shi 2016/09/02 21:44:45 Yes! I just ran the test with this setter commente
+
+ // Advance to 5ms, and send a packet to the peer, which will set
+ // the ping alarm.
+ clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
+ EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet());
+ SendStreamDataToPeer(kHeadersStreamId, "GET /", 0, kFin, nullptr);
+ EXPECT_TRUE(connection_.GetPingAlarm()->IsSet());
+ EXPECT_EQ(clock_.ApproximateNow() + QuicTime::Delta::FromSeconds(10),
+ connection_.GetPingAlarm()->deadline());
+
+ // Now recevie and ACK of the previous packet, which will move the
+ // ping alarm forward.
+ clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
+ QuicAckFrame frame = InitAckFrame(1);
+ EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
+ EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
+ ProcessAckPacket(&frame);
+ EXPECT_TRUE(connection_.GetPingAlarm()->IsSet());
+ // The ping timer is set slightly less than 10 seconds in the future, because
+ // of the 1st ping timer alarm granularity.
+ EXPECT_EQ(clock_.ApproximateNow() + QuicTime::Delta::FromSeconds(10) -
+ QuicTime::Delta::FromMilliseconds(5),
+ connection_.GetPingAlarm()->deadline());
+
+ writer_->Reset();
+ clock_.AdvanceTime(QuicTime::Delta::FromSeconds(10));
+ connection_.GetPingAlarm()->Fire();
+ EXPECT_EQ(1u, writer_->frame_count());
+ ASSERT_EQ(1u, writer_->ping_frames().size());
+ writer_->Reset();
+
+ EXPECT_CALL(visitor_, HasOpenDynamicStreams()).WillRepeatedly(Return(false));
+ clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
+ SendAckPacketToPeer();
+
+ EXPECT_FALSE(connection_.GetPingAlarm()->IsSet());
+}
+
// Tests whether sending an MTU discovery packet to peer successfully causes the
// maximum packet size to increase.
TEST_P(QuicConnectionTest, SendMtuDiscoveryPacket) {
« net/quic/core/quic_connection.h ('K') | « net/quic/core/quic_connection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698