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

Side by Side Diff: net/tools/quic/quic_time_wait_list_manager_test.cc

Issue 2846003002: Deprecate FLAGS_quic_reloadable_flag_quic_remove_packet_number_from_public_reset. (Closed)
Patch Set: remove the deprecated flag Created 3 years, 7 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/tools/quic/quic_time_wait_list_manager.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/tools/quic/quic_time_wait_list_manager.h" 5 #include "net/tools/quic/quic_time_wait_list_manager.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <memory> 8 #include <memory>
9 #include <ostream> 9 #include <ostream>
10 10
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 QuicTimeWaitListManager time_wait_list_manager_; 137 QuicTimeWaitListManager time_wait_list_manager_;
138 QuicConnectionId connection_id_; 138 QuicConnectionId connection_id_;
139 QuicSocketAddress server_address_; 139 QuicSocketAddress server_address_;
140 QuicSocketAddress client_address_; 140 QuicSocketAddress client_address_;
141 bool writer_is_blocked_; 141 bool writer_is_blocked_;
142 }; 142 };
143 143
144 class ValidatePublicResetPacketPredicate 144 class ValidatePublicResetPacketPredicate
145 : public MatcherInterface<const std::tr1::tuple<const char*, int>> { 145 : public MatcherInterface<const std::tr1::tuple<const char*, int>> {
146 public: 146 public:
147 explicit ValidatePublicResetPacketPredicate(QuicConnectionId connection_id, 147 explicit ValidatePublicResetPacketPredicate(QuicConnectionId connection_id)
148 QuicPacketNumber number) 148 : connection_id_(connection_id) {}
149 : connection_id_(connection_id), packet_number_(number) {}
150 149
151 bool MatchAndExplain( 150 bool MatchAndExplain(
152 const std::tr1::tuple<const char*, int> packet_buffer, 151 const std::tr1::tuple<const char*, int> packet_buffer,
153 testing::MatchResultListener* /* listener */) const override { 152 testing::MatchResultListener* /* listener */) const override {
154 FramerVisitorCapturingPublicReset visitor; 153 FramerVisitorCapturingPublicReset visitor;
155 QuicFramer framer(AllSupportedVersions(), QuicTime::Zero(), 154 QuicFramer framer(AllSupportedVersions(), QuicTime::Zero(),
156 Perspective::IS_CLIENT); 155 Perspective::IS_CLIENT);
157 framer.set_visitor(&visitor); 156 framer.set_visitor(&visitor);
158 QuicEncryptedPacket encrypted(std::tr1::get<0>(packet_buffer), 157 QuicEncryptedPacket encrypted(std::tr1::get<0>(packet_buffer),
159 std::tr1::get<1>(packet_buffer)); 158 std::tr1::get<1>(packet_buffer));
160 framer.ProcessPacket(encrypted); 159 framer.ProcessPacket(encrypted);
161 QuicPublicResetPacket packet = visitor.public_reset_packet(); 160 QuicPublicResetPacket packet = visitor.public_reset_packet();
162 return connection_id_ == GetPeerInMemoryConnectionId( 161 return connection_id_ == GetPeerInMemoryConnectionId(
163 packet.public_header.connection_id) && 162 packet.public_header.connection_id) &&
164 packet.public_header.reset_flag && 163 packet.public_header.reset_flag &&
165 !packet.public_header.version_flag && 164 !packet.public_header.version_flag &&
166 packet_number_ == packet.rejected_packet_number &&
167 net::test::TestPeerIPAddress() == packet.client_address.host() && 165 net::test::TestPeerIPAddress() == packet.client_address.host() &&
168 kTestPort == packet.client_address.port(); 166 kTestPort == packet.client_address.port();
169 } 167 }
170 168
171 void DescribeTo(::std::ostream* os) const override {} 169 void DescribeTo(::std::ostream* os) const override {}
172 170
173 void DescribeNegationTo(::std::ostream* os) const override {} 171 void DescribeNegationTo(::std::ostream* os) const override {}
174 172
175 private: 173 private:
176 QuicConnectionId connection_id_; 174 QuicConnectionId connection_id_;
177 QuicPacketNumber packet_number_;
178 }; 175 };
179 176
180 Matcher<const std::tr1::tuple<const char*, int>> PublicResetPacketEq( 177 Matcher<const std::tr1::tuple<const char*, int>> PublicResetPacketEq(
181 QuicConnectionId connection_id, 178 QuicConnectionId connection_id) {
182 QuicPacketNumber packet_number) { 179 return MakeMatcher(new ValidatePublicResetPacketPredicate(connection_id));
183 return MakeMatcher(
184 new ValidatePublicResetPacketPredicate(connection_id, packet_number));
185 } 180 }
186 181
187 TEST_F(QuicTimeWaitListManagerTest, CheckConnectionIdInTimeWait) { 182 TEST_F(QuicTimeWaitListManagerTest, CheckConnectionIdInTimeWait) {
188 EXPECT_FALSE(IsConnectionIdInTimeWait(connection_id_)); 183 EXPECT_FALSE(IsConnectionIdInTimeWait(connection_id_));
189 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_)); 184 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_));
190 AddConnectionId(connection_id_); 185 AddConnectionId(connection_id_);
191 EXPECT_EQ(1u, time_wait_list_manager_.num_connections()); 186 EXPECT_EQ(1u, time_wait_list_manager_.num_connections());
192 EXPECT_TRUE(IsConnectionIdInTimeWait(connection_id_)); 187 EXPECT_TRUE(IsConnectionIdInTimeWait(connection_id_));
193 } 188 }
194 189
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 247
253 ProcessPacket(connection_id_, kRandomSequenceNumber); 248 ProcessPacket(connection_id_, kRandomSequenceNumber);
254 } 249 }
255 250
256 TEST_F(QuicTimeWaitListManagerTest, SendPublicReset) { 251 TEST_F(QuicTimeWaitListManagerTest, SendPublicReset) {
257 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_)); 252 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_));
258 AddConnectionId(connection_id_); 253 AddConnectionId(connection_id_);
259 const int kRandomSequenceNumber = 1; 254 const int kRandomSequenceNumber = 1;
260 EXPECT_CALL(writer_, 255 EXPECT_CALL(writer_,
261 WritePacket(_, _, server_address_.host(), client_address_, _)) 256 WritePacket(_, _, server_address_.host(), client_address_, _))
262 .With(Args<0, 1>(PublicResetPacketEq(connection_id_, 0))) 257 .With(Args<0, 1>(PublicResetPacketEq(connection_id_)))
263 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0))); 258 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0)));
264 259
265 ProcessPacket(connection_id_, kRandomSequenceNumber); 260 ProcessPacket(connection_id_, kRandomSequenceNumber);
266 } 261 }
267 262
268 TEST_F(QuicTimeWaitListManagerTest, SendPublicResetWithExponentialBackOff) { 263 TEST_F(QuicTimeWaitListManagerTest, SendPublicResetWithExponentialBackOff) {
269 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_)); 264 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id_));
270 AddConnectionId(connection_id_); 265 AddConnectionId(connection_id_);
271 EXPECT_EQ(1u, time_wait_list_manager_.num_connections()); 266 EXPECT_EQ(1u, time_wait_list_manager_.num_connections());
272 for (int packet_number = 1; packet_number < 101; ++packet_number) { 267 for (int packet_number = 1; packet_number < 101; ++packet_number) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 TEST_F(QuicTimeWaitListManagerTest, SendQueuedPackets) { 342 TEST_F(QuicTimeWaitListManagerTest, SendQueuedPackets) {
348 QuicConnectionId connection_id = 1; 343 QuicConnectionId connection_id = 1;
349 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id)); 344 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(connection_id));
350 AddConnectionId(connection_id); 345 AddConnectionId(connection_id);
351 QuicPacketNumber packet_number = 234; 346 QuicPacketNumber packet_number = 234;
352 std::unique_ptr<QuicEncryptedPacket> packet( 347 std::unique_ptr<QuicEncryptedPacket> packet(
353 ConstructEncryptedPacket(connection_id, packet_number)); 348 ConstructEncryptedPacket(connection_id, packet_number));
354 // Let first write through. 349 // Let first write through.
355 EXPECT_CALL(writer_, 350 EXPECT_CALL(writer_,
356 WritePacket(_, _, server_address_.host(), client_address_, _)) 351 WritePacket(_, _, server_address_.host(), client_address_, _))
357 .With(Args<0, 1>(PublicResetPacketEq(connection_id, 0))) 352 .With(Args<0, 1>(PublicResetPacketEq(connection_id)))
358 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, packet->length()))); 353 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, packet->length())));
359 ProcessPacket(connection_id, packet_number); 354 ProcessPacket(connection_id, packet_number);
360 355
361 // write block for the next packet. 356 // write block for the next packet.
362 EXPECT_CALL(writer_, 357 EXPECT_CALL(writer_,
363 WritePacket(_, _, server_address_.host(), client_address_, _)) 358 WritePacket(_, _, server_address_.host(), client_address_, _))
364 .With(Args<0, 1>(PublicResetPacketEq(connection_id, 0))) 359 .With(Args<0, 1>(PublicResetPacketEq(connection_id)))
365 .WillOnce(DoAll(Assign(&writer_is_blocked_, true), 360 .WillOnce(DoAll(Assign(&writer_is_blocked_, true),
366 Return(WriteResult(WRITE_STATUS_BLOCKED, EAGAIN)))); 361 Return(WriteResult(WRITE_STATUS_BLOCKED, EAGAIN))));
367 EXPECT_CALL(visitor_, OnWriteBlocked(&time_wait_list_manager_)); 362 EXPECT_CALL(visitor_, OnWriteBlocked(&time_wait_list_manager_));
368 ProcessPacket(connection_id, packet_number); 363 ProcessPacket(connection_id, packet_number);
369 // 3rd packet. No public reset should be sent; 364 // 3rd packet. No public reset should be sent;
370 ProcessPacket(connection_id, packet_number); 365 ProcessPacket(connection_id, packet_number);
371 366
372 // write packet should not be called since we are write blocked but the 367 // write packet should not be called since we are write blocked but the
373 // should be queued. 368 // should be queued.
374 QuicConnectionId other_connection_id = 2; 369 QuicConnectionId other_connection_id = 2;
375 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(other_connection_id)); 370 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(other_connection_id));
376 AddConnectionId(other_connection_id); 371 AddConnectionId(other_connection_id);
377 QuicPacketNumber other_packet_number = 23423; 372 QuicPacketNumber other_packet_number = 23423;
378 std::unique_ptr<QuicEncryptedPacket> other_packet( 373 std::unique_ptr<QuicEncryptedPacket> other_packet(
379 ConstructEncryptedPacket(other_connection_id, other_packet_number)); 374 ConstructEncryptedPacket(other_connection_id, other_packet_number));
380 EXPECT_CALL(writer_, WritePacket(_, _, _, _, _)).Times(0); 375 EXPECT_CALL(writer_, WritePacket(_, _, _, _, _)).Times(0);
381 EXPECT_CALL(visitor_, OnWriteBlocked(&time_wait_list_manager_)); 376 EXPECT_CALL(visitor_, OnWriteBlocked(&time_wait_list_manager_));
382 ProcessPacket(other_connection_id, other_packet_number); 377 ProcessPacket(other_connection_id, other_packet_number);
383 EXPECT_EQ(2u, time_wait_list_manager_.num_connections()); 378 EXPECT_EQ(2u, time_wait_list_manager_.num_connections());
384 379
385 // Now expect all the write blocked public reset packets to be sent again. 380 // Now expect all the write blocked public reset packets to be sent again.
386 writer_is_blocked_ = false; 381 writer_is_blocked_ = false;
387 EXPECT_CALL(writer_, 382 EXPECT_CALL(writer_,
388 WritePacket(_, _, server_address_.host(), client_address_, _)) 383 WritePacket(_, _, server_address_.host(), client_address_, _))
389 .With(Args<0, 1>(PublicResetPacketEq(connection_id, 0))) 384 .With(Args<0, 1>(PublicResetPacketEq(connection_id)))
390 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, packet->length()))); 385 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, packet->length())));
391 EXPECT_CALL(writer_, 386 EXPECT_CALL(writer_,
392 WritePacket(_, _, server_address_.host(), client_address_, _)) 387 WritePacket(_, _, server_address_.host(), client_address_, _))
393 .With(Args<0, 1>(PublicResetPacketEq(other_connection_id, 0))) 388 .With(Args<0, 1>(PublicResetPacketEq(other_connection_id)))
394 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, other_packet->length()))); 389 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, other_packet->length())));
395 time_wait_list_manager_.OnCanWrite(); 390 time_wait_list_manager_.OnCanWrite();
396 } 391 }
397 392
398 TEST_F(QuicTimeWaitListManagerTest, GetQuicVersionFromMap) { 393 TEST_F(QuicTimeWaitListManagerTest, GetQuicVersionFromMap) {
399 const int kConnectionId1 = 123; 394 const int kConnectionId1 = 123;
400 const int kConnectionId2 = 456; 395 const int kConnectionId2 = 456;
401 const int kConnectionId3 = 789; 396 const int kConnectionId3 = 789;
402 397
403 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(kConnectionId1)); 398 EXPECT_CALL(visitor_, OnConnectionAddedToTimeWaitList(kConnectionId1));
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 EXPECT_EQ(static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections), 518 EXPECT_EQ(static_cast<size_t>(FLAGS_quic_time_wait_list_max_connections),
524 time_wait_list_manager_.num_connections()); 519 time_wait_list_manager_.num_connections());
525 EXPECT_FALSE(IsConnectionIdInTimeWait(id_to_evict)); 520 EXPECT_FALSE(IsConnectionIdInTimeWait(id_to_evict));
526 EXPECT_TRUE(IsConnectionIdInTimeWait(current_connection_id)); 521 EXPECT_TRUE(IsConnectionIdInTimeWait(current_connection_id));
527 } 522 }
528 } 523 }
529 524
530 } // namespace 525 } // namespace
531 } // namespace test 526 } // namespace test
532 } // namespace net 527 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_time_wait_list_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698