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

Side by Side Diff: net/quic/quic_unacked_packet_map_test.cc

Issue 551223002: Discard old packets from the QuicSentPacketManager which are only (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_flaky_test_74798317
Patch Set: Created 6 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 unified diff | Download patch
« no previous file with comments | « net/quic/quic_unacked_packet_map.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_unacked_packet_map.h" 5 #include "net/quic/quic_unacked_packet_map.h"
6 6
7 #include "net/quic/test_tools/quic_test_utils.h" 7 #include "net/quic/test_tools/quic_test_utils.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 using std::min;
11
10 namespace net { 12 namespace net {
11 namespace test { 13 namespace test {
12 namespace { 14 namespace {
13 15
14 // Default packet length. 16 // Default packet length.
15 const uint32 kDefaultAckLength = 50; 17 const uint32 kDefaultAckLength = 50;
16 const uint32 kDefaultLength = 1000; 18 const uint32 kDefaultLength = 1000;
17 19
18 class QuicUnackedPacketMapTest : public ::testing::Test { 20 class QuicUnackedPacketMapTest : public ::testing::Test {
19 protected: 21 protected:
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 VerifyUnackedPackets(unacked, arraysize(unacked)); 108 VerifyUnackedPackets(unacked, arraysize(unacked));
107 VerifyInFlightPackets(NULL, 0); 109 VerifyInFlightPackets(NULL, 0);
108 VerifyRetransmittablePackets(NULL, 0); 110 VerifyRetransmittablePackets(NULL, 0);
109 111
110 unacked_packets_.IncreaseLargestObserved(1); 112 unacked_packets_.IncreaseLargestObserved(1);
111 VerifyUnackedPackets(NULL, 0); 113 VerifyUnackedPackets(NULL, 0);
112 VerifyInFlightPackets(NULL, 0); 114 VerifyInFlightPackets(NULL, 0);
113 VerifyRetransmittablePackets(NULL, 0); 115 VerifyRetransmittablePackets(NULL, 0);
114 } 116 }
115 117
118 TEST_F(QuicUnackedPacketMapTest, DiscardOldRttOnly) {
119 // Acks are only tracked for RTT measurement purposes, and are discarded
120 // when more than 200 accumulate.
121 for (int i = 1; i < 400; ++i) {
122 unacked_packets_.AddPacket(CreateNonRetransmittablePacket(i));
123 unacked_packets_.SetSent(i, now_, kDefaultAckLength, false);
124 unacked_packets_.RemoveObsoletePackets();
125 EXPECT_EQ(static_cast<size_t>(min(i, 200)),
126 unacked_packets_.GetNumUnackedPacketsDebugOnly());
127 }
128 }
129
116 TEST_F(QuicUnackedPacketMapTest, RetransmittableInflightAndRtt) { 130 TEST_F(QuicUnackedPacketMapTest, RetransmittableInflightAndRtt) {
117 // Simulate a retransmittable packet being sent and acked. 131 // Simulate a retransmittable packet being sent and acked.
118 unacked_packets_.AddPacket(CreateRetransmittablePacket(1)); 132 unacked_packets_.AddPacket(CreateRetransmittablePacket(1));
119 unacked_packets_.SetSent(1, now_, kDefaultLength, true); 133 unacked_packets_.SetSent(1, now_, kDefaultLength, true);
120 134
121 QuicPacketSequenceNumber unacked[] = { 1 }; 135 QuicPacketSequenceNumber unacked[] = { 1 };
122 VerifyUnackedPackets(unacked, arraysize(unacked)); 136 VerifyUnackedPackets(unacked, arraysize(unacked));
123 VerifyInFlightPackets(unacked, arraysize(unacked)); 137 VerifyInFlightPackets(unacked, arraysize(unacked));
124 VerifyRetransmittablePackets(unacked, arraysize(unacked)); 138 VerifyRetransmittablePackets(unacked, arraysize(unacked));
125 139
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 unacked_packets_.ClearPreviousRetransmissions(5); 259 unacked_packets_.ClearPreviousRetransmissions(5);
246 QuicPacketSequenceNumber unacked5[] = { 7 }; 260 QuicPacketSequenceNumber unacked5[] = { 7 };
247 VerifyUnackedPackets(unacked5, arraysize(unacked5)); 261 VerifyUnackedPackets(unacked5, arraysize(unacked5));
248 QuicPacketSequenceNumber retransmittable5[] = { 7 }; 262 QuicPacketSequenceNumber retransmittable5[] = { 7 };
249 VerifyRetransmittablePackets(retransmittable5, arraysize(retransmittable5)); 263 VerifyRetransmittablePackets(retransmittable5, arraysize(retransmittable5));
250 } 264 }
251 265
252 } // namespace 266 } // namespace
253 } // namespace test 267 } // namespace test
254 } // namespace net 268 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_unacked_packet_map.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698