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

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

Issue 2183493002: Add a merely pass-through QuicMultipathSentPacketManager. Protected behind blocked flag FLAGS_quic_… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
OLDNEW
(Empty)
1 #include "net/quic/quic_multipath_sent_packet_manager.h"
Zhongyi Shi 2016/07/25 22:30:34 ditto
2
3 #include "net/quic/test_tools/quic_multipath_sent_packet_manager_peer.h"
4 #include "net/quic/test_tools/quic_test_utils.h"
5 #include "net/test/gtest_util.h"
6 #include "testing/gmock/include/gmock/gmock.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 using testing::Return;
10 using testing::StrictMock;
11 using testing::_;
12
13 namespace net {
14 namespace test {
15
16 namespace {
17
18 const QuicPathId kTestPathId1 = 1;
19 const QuicPathId kTestPathId2 = 2;
20 const QuicPathId kTestPathId3 = 3;
21
22 class QuicMultipathSentPacketManagerTest : public testing::Test {
23 public:
24 QuicMultipathSentPacketManagerTest()
25 : manager_0_(new StrictMock<MockSentPacketManager>),
26 manager_1_(new StrictMock<MockSentPacketManager>),
27 manager_2_(new StrictMock<MockSentPacketManager>),
28 multipath_manager_(manager_0_, &delegate_) {
29 // Paths 0 and 1 are active, and path 2 is closing.
30 QuicMultipathSentPacketManagerPeer::AddPathWithActiveState(
31 &multipath_manager_, manager_1_);
32 QuicMultipathSentPacketManagerPeer::AddPathWithCloseState(
33 &multipath_manager_, manager_2_);
34 }
35
36 ~QuicMultipathSentPacketManagerTest() override {}
37
38 MockSentPacketManager* manager_0_;
39 MockSentPacketManager* manager_1_;
40 MockSentPacketManager* manager_2_;
41 QuicMultipathSentPacketManager multipath_manager_;
42 MockClock clock_;
43 StrictMock<MockConnectionCloseDelegate> delegate_;
44 };
45
46 TEST_F(QuicMultipathSentPacketManagerTest, SetFromConfig) {
47 EXPECT_CALL(*manager_0_, SetFromConfig(_)).Times(1);
48 EXPECT_CALL(*manager_1_, SetFromConfig(_)).Times(1);
49 EXPECT_CALL(*manager_2_, SetFromConfig(_)).Times(1);
50 QuicConfig config;
51 multipath_manager_.SetFromConfig(config);
52 }
53
54 TEST_F(QuicMultipathSentPacketManagerTest, ResumeConnectionState) {
55 EXPECT_CALL(*manager_0_, ResumeConnectionState(_, true));
56 multipath_manager_.ResumeConnectionState(CachedNetworkParameters(), true);
57 }
58
59 TEST_F(QuicMultipathSentPacketManagerTest, SetNumOpenStreams) {
60 size_t kNumStreams = 10;
61 EXPECT_CALL(*manager_0_, SetNumOpenStreams(kNumStreams));
62 EXPECT_CALL(*manager_1_, SetNumOpenStreams(kNumStreams));
63 EXPECT_CALL(*manager_2_, SetNumOpenStreams(kNumStreams));
64 multipath_manager_.SetNumOpenStreams(kNumStreams);
65 }
66
67 TEST_F(QuicMultipathSentPacketManagerTest, SetMaxPacingRate) {
68 QuicBandwidth kBandwidth = QuicBandwidth::FromBitsPerSecond(1000);
69 EXPECT_CALL(*manager_0_, SetMaxPacingRate(kBandwidth));
70 multipath_manager_.SetMaxPacingRate(kBandwidth);
71 }
72
73 TEST_F(QuicMultipathSentPacketManagerTest, SetHandshakeConfirmed) {
74 EXPECT_CALL(*manager_0_, SetHandshakeConfirmed());
75 multipath_manager_.SetHandshakeConfirmed();
76 }
77
78 TEST_F(QuicMultipathSentPacketManagerTest, OnIncomingAck) {
79 QuicAckFrame frame0;
80 QuicAckFrame frame1;
81 frame1.path_id = kTestPathId1;
82 QuicAckFrame frame2;
83 frame2.path_id = kTestPathId2;
84 QuicAckFrame frame3;
85 frame3.path_id = kTestPathId3;
86 EXPECT_CALL(*manager_0_, OnIncomingAck(_, QuicTime::Zero()));
87 EXPECT_CALL(*manager_1_, OnIncomingAck(_, QuicTime::Zero()));
88 EXPECT_CALL(*manager_2_, OnIncomingAck(_, QuicTime::Zero())).Times(0);
89 multipath_manager_.OnIncomingAck(frame0, QuicTime::Zero());
90 multipath_manager_.OnIncomingAck(frame1, QuicTime::Zero());
91 multipath_manager_.OnIncomingAck(frame2, QuicTime::Zero());
92 multipath_manager_.OnIncomingAck(frame3, QuicTime::Zero());
93 }
94
95 TEST_F(QuicMultipathSentPacketManagerTest, IsUnacked) {
96 EXPECT_CALL(*manager_0_, IsUnacked(kDefaultPathId, 1)).WillOnce(Return(true));
97 EXPECT_CALL(*manager_1_, IsUnacked(kTestPathId1, 2)).WillOnce(Return(false));
98 EXPECT_CALL(*manager_2_, IsUnacked(kTestPathId2, 3)).WillOnce(Return(true));
99 EXPECT_TRUE(multipath_manager_.IsUnacked(kDefaultPathId, 1));
100 EXPECT_FALSE(multipath_manager_.IsUnacked(kTestPathId1, 2));
101 EXPECT_TRUE(multipath_manager_.IsUnacked(kTestPathId2, 3));
102 /*
103 EXPECT_DFATAL(multipath_manager_.IsUnacked(kTestPathId3, 4), "");
104 */
105 }
106
107 TEST_F(QuicMultipathSentPacketManagerTest, HasRetransmittableFrames) {
108 EXPECT_CALL(*manager_0_, HasRetransmittableFrames(kDefaultPathId, 1))
109 .WillOnce(Return(true));
110 EXPECT_CALL(*manager_1_, HasRetransmittableFrames(kTestPathId1, 2))
111 .WillOnce(Return(false));
112 EXPECT_CALL(*manager_2_, HasRetransmittableFrames(kTestPathId2, 3))
113 .WillOnce(Return(true));
114 EXPECT_TRUE(multipath_manager_.HasRetransmittableFrames(kDefaultPathId, 1));
115 EXPECT_FALSE(multipath_manager_.HasRetransmittableFrames(kTestPathId1, 2));
116 EXPECT_TRUE(multipath_manager_.HasRetransmittableFrames(kTestPathId2, 3));
117 /*
118 EXPECT_DFATAL(multipath_manager_.HasRetransmittableFrames(kTestPathId3, 4),
119 "");
120 */
121 }
122
123 TEST_F(QuicMultipathSentPacketManagerTest, RetransmitUnackedPackets) {
124 EXPECT_CALL(*manager_0_, RetransmitUnackedPackets(HANDSHAKE_RETRANSMISSION));
125 multipath_manager_.RetransmitUnackedPackets(HANDSHAKE_RETRANSMISSION);
126 }
127
128 TEST_F(QuicMultipathSentPacketManagerTest, MaybeRetransmitTailLossProbe) {
129 EXPECT_CALL(*manager_0_, MaybeRetransmitTailLossProbe())
130 .WillOnce(Return(false));
131 EXPECT_CALL(*manager_1_, MaybeRetransmitTailLossProbe())
132 .WillOnce(Return(false));
133 EXPECT_FALSE(multipath_manager_.MaybeRetransmitTailLossProbe());
134 EXPECT_CALL(*manager_0_, MaybeRetransmitTailLossProbe())
135 .WillOnce(Return(false));
136 EXPECT_CALL(*manager_1_, MaybeRetransmitTailLossProbe())
137 .WillOnce(Return(true));
138 EXPECT_TRUE(multipath_manager_.MaybeRetransmitTailLossProbe());
139 }
140
141 TEST_F(QuicMultipathSentPacketManagerTest, NeuterUnencryptedPackets) {
142 EXPECT_CALL(*manager_0_, NeuterUnencryptedPackets());
143 multipath_manager_.NeuterUnencryptedPackets();
144 }
145
146 TEST_F(QuicMultipathSentPacketManagerTest, HasPendingRetransmissions) {
147 EXPECT_CALL(*manager_0_, HasPendingRetransmissions()).WillOnce(Return(true));
148 EXPECT_TRUE(multipath_manager_.HasPendingRetransmissions());
149 }
150
151 TEST_F(QuicMultipathSentPacketManagerTest, NextPendingRetransmission) {
152 SerializedPacket packet(kDefaultPathId, 1, PACKET_6BYTE_PACKET_NUMBER,
153 nullptr, 1250, 0u, false, false);
154 PendingRetransmission retransmission(
155 packet.path_id, packet.packet_number, LOSS_RETRANSMISSION,
156 packet.retransmittable_frames, packet.has_crypto_handshake,
157 packet.num_padding_bytes, packet.encryption_level,
158 packet.packet_number_length);
159 EXPECT_CALL(*manager_0_, NextPendingRetransmission())
160 .WillOnce(Return(retransmission));
161 multipath_manager_.NextPendingRetransmission();
162 }
163
164 TEST_F(QuicMultipathSentPacketManagerTest, HasUnackedPackets) {
165 EXPECT_CALL(*manager_0_, HasUnackedPackets()).WillOnce(Return(false));
166 EXPECT_CALL(*manager_1_, HasUnackedPackets()).WillOnce(Return(false));
167 EXPECT_CALL(*manager_2_, HasUnackedPackets()).Times(0);
168 EXPECT_FALSE(multipath_manager_.HasUnackedPackets());
169 EXPECT_CALL(*manager_0_, HasUnackedPackets()).WillOnce(Return(false));
170 EXPECT_CALL(*manager_1_, HasUnackedPackets()).WillOnce(Return(true));
171 EXPECT_TRUE(multipath_manager_.HasUnackedPackets());
172 }
173
174 TEST_F(QuicMultipathSentPacketManagerTest, GetLeastUnacked) {
175 EXPECT_CALL(*manager_0_, GetLeastUnacked(kDefaultPathId)).WillOnce(Return(2));
176 EXPECT_CALL(*manager_1_, GetLeastUnacked(kTestPathId1)).WillOnce(Return(3));
177 EXPECT_CALL(*manager_2_, GetLeastUnacked(kTestPathId2)).WillOnce(Return(4));
178 EXPECT_EQ(2u, multipath_manager_.GetLeastUnacked(kDefaultPathId));
179 EXPECT_EQ(3u, multipath_manager_.GetLeastUnacked(kTestPathId1));
180 EXPECT_EQ(4u, multipath_manager_.GetLeastUnacked(kTestPathId2));
181 EXPECT_EQ(0u, multipath_manager_.GetLeastUnacked(kTestPathId3));
182 }
183
184 TEST_F(QuicMultipathSentPacketManagerTest, OnPacketSent) {
185 SerializedPacket packet0(kDefaultPathId, 1, PACKET_6BYTE_PACKET_NUMBER,
186 nullptr, 1250, 0u, false, false);
187 SerializedPacket packet1(kTestPathId1, 1, PACKET_6BYTE_PACKET_NUMBER, nullptr,
188 1250, 0u, false, false);
189 SerializedPacket packet2(kTestPathId2, 1, PACKET_6BYTE_PACKET_NUMBER, nullptr,
190 1250, 0u, false, false);
191 SerializedPacket packet3(kTestPathId3, 1, PACKET_6BYTE_PACKET_NUMBER, nullptr,
192 1250, 0u, false, false);
193 EXPECT_CALL(*manager_0_,
194 OnPacketSent(&packet0, kInvalidPathId, 0, clock_.Now(),
195 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA));
196 multipath_manager_.OnPacketSent(&packet0, kInvalidPathId, 0, clock_.Now(),
197 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA);
198 EXPECT_CALL(*manager_1_,
199 OnPacketSent(&packet1, kInvalidPathId, 0, clock_.Now(),
200 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA));
201 multipath_manager_.OnPacketSent(&packet1, kInvalidPathId, 0, clock_.Now(),
202 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA);
203 EXPECT_CALL(*manager_2_, OnPacketSent(_, _, _, _, _, _)).Times(0);
204 EXPECT_CALL(delegate_,
205 OnUnrecoverableError(QUIC_MULTIPATH_PATH_NOT_ACTIVE, _, _));
206 /*
207 EXPECT_DFATAL(multipath_manager_.OnPacketSent(
208 &packet2, kInvalidPathId, 0, clock_.Now(),
209 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA),
210 "");
211 */
212 EXPECT_CALL(delegate_,
213 OnUnrecoverableError(QUIC_MULTIPATH_PATH_DOES_NOT_EXIST, _, _));
214 /*
215 EXPECT_DFATAL(multipath_manager_.OnPacketSent(
216 &packet3, kInvalidPathId, 0, clock_.Now(),
217 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA),
218 "");
219 */
220 }
221
222 TEST_F(QuicMultipathSentPacketManagerTest, OnRetransmissionTimeout) {
223 QuicTime time0 = clock_.Now() + QuicTime::Delta::FromMilliseconds(50);
224 QuicTime time1 = clock_.Now() + QuicTime::Delta::FromMilliseconds(100);
225 EXPECT_CALL(*manager_0_, GetRetransmissionTime()).WillOnce(Return(time0));
226 EXPECT_CALL(*manager_1_, GetRetransmissionTime()).WillOnce(Return(time1));
227 EXPECT_CALL(*manager_0_, OnRetransmissionTimeout());
228 multipath_manager_.OnRetransmissionTimeout();
229 }
230
231 TEST_F(QuicMultipathSentPacketManagerTest, TimeUntilSend) {
232 QuicPathId path_id = kInvalidPathId;
233 EXPECT_CALL(*manager_0_,
234 TimeUntilSend(clock_.Now(), HAS_RETRANSMITTABLE_DATA, &path_id))
235 .WillOnce(Return(QuicTime::Delta::FromMilliseconds(200)));
236 EXPECT_CALL(*manager_1_,
237 TimeUntilSend(clock_.Now(), HAS_RETRANSMITTABLE_DATA, &path_id))
238 .WillOnce(Return(QuicTime::Delta::FromMilliseconds(100)));
239 EXPECT_EQ(QuicTime::Delta::FromMilliseconds(100),
240 multipath_manager_.TimeUntilSend(
241 clock_.Now(), HAS_RETRANSMITTABLE_DATA, &path_id));
242 EXPECT_EQ(kTestPathId1, path_id);
243 }
244
245 TEST_F(QuicMultipathSentPacketManagerTest, GetRetransmissionTime) {
246 QuicTime time0 = clock_.Now() + QuicTime::Delta::FromMilliseconds(200);
247 QuicTime time1 = clock_.Now() + QuicTime::Delta::FromMilliseconds(100);
248 EXPECT_CALL(*manager_0_, GetRetransmissionTime()).WillOnce(Return(time0));
249 EXPECT_CALL(*manager_1_, GetRetransmissionTime()).WillOnce(Return(time1));
250 EXPECT_EQ(time1, multipath_manager_.GetRetransmissionTime());
251 }
252
253 TEST_F(QuicMultipathSentPacketManagerTest, GetRttStats) {
254 EXPECT_CALL(*manager_0_, GetRttStats());
255 multipath_manager_.GetRttStats();
256 }
257
258 TEST_F(QuicMultipathSentPacketManagerTest, BandwidthEstimate) {
259 QuicBandwidth bandwidth = QuicBandwidth::FromKBitsPerSecond(100);
260 EXPECT_CALL(*manager_0_, BandwidthEstimate()).WillOnce(Return(bandwidth));
261 EXPECT_EQ(bandwidth, multipath_manager_.BandwidthEstimate());
262 }
263
264 TEST_F(QuicMultipathSentPacketManagerTest, GetCongestionWindowInTcpMss) {
265 EXPECT_CALL(*manager_0_, GetCongestionWindowInTcpMss()).WillOnce(Return(100));
266 EXPECT_EQ(100u, multipath_manager_.GetCongestionWindowInTcpMss());
267 }
268
269 TEST_F(QuicMultipathSentPacketManagerTest, EstimateMaxPacketsInFlight) {
270 QuicByteCount max_packet_length = 1250;
271 EXPECT_CALL(*manager_0_, EstimateMaxPacketsInFlight(max_packet_length))
272 .WillOnce(Return(100));
273 EXPECT_CALL(*manager_1_, EstimateMaxPacketsInFlight(max_packet_length))
274 .WillOnce(Return(200));
275 EXPECT_CALL(*manager_2_, EstimateMaxPacketsInFlight(max_packet_length))
276 .WillOnce(Return(300));
277 EXPECT_EQ(300u,
278 multipath_manager_.EstimateMaxPacketsInFlight(max_packet_length));
279 }
280
281 TEST_F(QuicMultipathSentPacketManagerTest, GetSlowStartThresholdInTcpMss) {
282 EXPECT_CALL(*manager_0_, GetSlowStartThresholdInTcpMss())
283 .WillOnce(Return(100));
284 EXPECT_EQ(100u, multipath_manager_.GetSlowStartThresholdInTcpMss());
285 }
286
287 TEST_F(QuicMultipathSentPacketManagerTest, CancelRetransmissionsForStream) {
288 EXPECT_CALL(*manager_0_, CancelRetransmissionsForStream(1));
289 EXPECT_CALL(*manager_1_, CancelRetransmissionsForStream(1));
290 EXPECT_CALL(*manager_2_, CancelRetransmissionsForStream(1));
291 multipath_manager_.CancelRetransmissionsForStream(1);
292 }
293
294 TEST_F(QuicMultipathSentPacketManagerTest, OnConnectionMigration) {
295 EXPECT_CALL(*manager_0_, OnConnectionMigration(kDefaultPathId, PORT_CHANGE));
296 EXPECT_CALL(*manager_2_, OnConnectionMigration(_, _)).Times(0);
297 multipath_manager_.OnConnectionMigration(kDefaultPathId, PORT_CHANGE);
298 EXPECT_CALL(delegate_,
299 OnUnrecoverableError(QUIC_MULTIPATH_PATH_NOT_ACTIVE, _, _));
300 /*
301 EXPECT_DFATAL(
302 multipath_manager_.OnConnectionMigration(kTestPathId2, PORT_CHANGE), "");
303 */
304 EXPECT_CALL(delegate_,
305 OnUnrecoverableError(QUIC_MULTIPATH_PATH_DOES_NOT_EXIST, _, _));
306 multipath_manager_.OnConnectionMigration(kTestPathId3, PORT_CHANGE);
307 }
308
309 TEST_F(QuicMultipathSentPacketManagerTest, IsHandshakeConfirmed) {
310 EXPECT_CALL(*manager_0_, IsHandshakeConfirmed()).WillOnce(Return(true));
311 EXPECT_TRUE(multipath_manager_.IsHandshakeConfirmed());
312 }
313
314 TEST_F(QuicMultipathSentPacketManagerTest, SetDebugDelegate) {
315 EXPECT_CALL(*manager_0_, SetDebugDelegate(nullptr));
316 EXPECT_CALL(*manager_1_, SetDebugDelegate(nullptr));
317 EXPECT_CALL(*manager_2_, SetDebugDelegate(nullptr));
318 multipath_manager_.SetDebugDelegate(nullptr);
319 }
320
321 TEST_F(QuicMultipathSentPacketManagerTest, GetLargestObserved) {
322 EXPECT_CALL(*manager_0_, GetLargestObserved(kDefaultPathId))
323 .WillOnce(Return(10));
324 EXPECT_CALL(*manager_1_, GetLargestObserved(kTestPathId1))
325 .WillOnce(Return(11));
326 EXPECT_CALL(*manager_2_, GetLargestObserved(kTestPathId2))
327 .WillOnce(Return(12));
328 EXPECT_EQ(10u, multipath_manager_.GetLargestObserved(kDefaultPathId));
329 EXPECT_EQ(11u, multipath_manager_.GetLargestObserved(kTestPathId1));
330 EXPECT_EQ(12u, multipath_manager_.GetLargestObserved(kTestPathId2));
331 EXPECT_DFATAL(multipath_manager_.GetLargestObserved(kTestPathId3), "");
332 }
333
334 TEST_F(QuicMultipathSentPacketManagerTest, GetLargestSentPacket) {
335 EXPECT_CALL(*manager_0_, GetLargestSentPacket(kDefaultPathId))
336 .WillOnce(Return(10));
337 EXPECT_CALL(*manager_1_, GetLargestSentPacket(kTestPathId1))
338 .WillOnce(Return(11));
339 EXPECT_CALL(*manager_2_, GetLargestSentPacket(kTestPathId2))
340 .WillOnce(Return(12));
341 EXPECT_EQ(10u, multipath_manager_.GetLargestSentPacket(kDefaultPathId));
342 EXPECT_EQ(11u, multipath_manager_.GetLargestSentPacket(kTestPathId1));
343 EXPECT_EQ(12u, multipath_manager_.GetLargestSentPacket(kTestPathId2));
344 EXPECT_EQ(0u, multipath_manager_.GetLargestSentPacket(kTestPathId3));
345 }
346
347 TEST_F(QuicMultipathSentPacketManagerTest, GetLeastPacketAwaitedByPeer) {
348 EXPECT_CALL(*manager_0_, GetLeastPacketAwaitedByPeer(kDefaultPathId))
349 .WillOnce(Return(10));
350 EXPECT_CALL(*manager_1_, GetLeastPacketAwaitedByPeer(kTestPathId1))
351 .WillOnce(Return(11));
352 EXPECT_CALL(*manager_2_, GetLeastPacketAwaitedByPeer(kTestPathId2))
353 .WillOnce(Return(12));
354 EXPECT_EQ(10u,
355 multipath_manager_.GetLeastPacketAwaitedByPeer(kDefaultPathId));
356 EXPECT_EQ(11u, multipath_manager_.GetLeastPacketAwaitedByPeer(kTestPathId1));
357 EXPECT_EQ(12u, multipath_manager_.GetLeastPacketAwaitedByPeer(kTestPathId2));
358 EXPECT_EQ(0u, multipath_manager_.GetLeastPacketAwaitedByPeer(kTestPathId3));
359 }
360
361 TEST_F(QuicMultipathSentPacketManagerTest, SetNetworkChangeVisitor) {
362 EXPECT_CALL(*manager_0_, SetNetworkChangeVisitor(nullptr));
363 EXPECT_CALL(*manager_1_, SetNetworkChangeVisitor(nullptr));
364 multipath_manager_.SetNetworkChangeVisitor(nullptr);
365 }
366
367 TEST_F(QuicMultipathSentPacketManagerTest, InSlowStart) {
368 EXPECT_CALL(*manager_0_, InSlowStart()).WillOnce(Return(true));
369 EXPECT_TRUE(multipath_manager_.InSlowStart());
370 }
371
372 TEST_F(QuicMultipathSentPacketManagerTest, GetConsecutiveRtoCount) {
373 EXPECT_CALL(*manager_0_, GetConsecutiveRtoCount()).WillOnce(Return(4));
374 EXPECT_EQ(4u, multipath_manager_.GetConsecutiveRtoCount());
375 }
376
377 TEST_F(QuicMultipathSentPacketManagerTest, GetConsecutiveTlpCount) {
378 EXPECT_CALL(*manager_0_, GetConsecutiveTlpCount()).WillOnce(Return(3));
379 EXPECT_EQ(3u, multipath_manager_.GetConsecutiveTlpCount());
380 }
381
382 } // namespace
383 } // namespace test
384 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698