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

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

Issue 1916783003: QUIC - enable "delay_tcp_race" parameter by default. This feature showed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Deleted unneeded hanging get calls from unittests Created 4 years, 8 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_stream_factory.cc ('k') | net/quic/test_tools/quic_stream_factory_peer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_stream_factory.h" 5 #include "net/quic/quic_stream_factory.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "net/base/test_data_directory.h" 10 #include "net/base/test_data_directory.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 enable_connection_racing_(GetParam().enable_connection_racing), 219 enable_connection_racing_(GetParam().enable_connection_racing),
220 enable_non_blocking_io_(true), 220 enable_non_blocking_io_(true),
221 disable_disk_cache_(false), 221 disable_disk_cache_(false),
222 prefer_aes_(false), 222 prefer_aes_(false),
223 max_number_of_lossy_connections_(0), 223 max_number_of_lossy_connections_(0),
224 packet_loss_threshold_(1.0f), 224 packet_loss_threshold_(1.0f),
225 max_disabled_reasons_(3), 225 max_disabled_reasons_(3),
226 threshold_timeouts_with_open_streams_(2), 226 threshold_timeouts_with_open_streams_(2),
227 threshold_public_resets_post_handshake_(2), 227 threshold_public_resets_post_handshake_(2),
228 receive_buffer_size_(0), 228 receive_buffer_size_(0),
229 delay_tcp_race_(false),
230 close_sessions_on_ip_change_(false), 229 close_sessions_on_ip_change_(false),
231 disable_quic_on_timeout_with_open_streams_(false), 230 disable_quic_on_timeout_with_open_streams_(false),
232 idle_connection_timeout_seconds_(kIdleConnectionTimeoutSeconds), 231 idle_connection_timeout_seconds_(kIdleConnectionTimeoutSeconds),
233 migrate_sessions_on_network_change_(false), 232 migrate_sessions_on_network_change_(false),
234 migrate_sessions_early_(false) { 233 migrate_sessions_early_(false) {
235 clock_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); 234 clock_->AdvanceTime(QuicTime::Delta::FromSeconds(1));
236 } 235 }
237 236
238 void Initialize() { 237 void Initialize() {
239 factory_.reset(new QuicStreamFactory( 238 factory_.reset(new QuicStreamFactory(
240 &host_resolver_, &socket_factory_, http_server_properties_.GetWeakPtr(), 239 &host_resolver_, &socket_factory_, http_server_properties_.GetWeakPtr(),
241 cert_verifier_.get(), nullptr, channel_id_service_.get(), 240 cert_verifier_.get(), nullptr, channel_id_service_.get(),
242 &transport_security_state_, cert_transparency_verifier_.get(), 241 &transport_security_state_, cert_transparency_verifier_.get(),
243 /*SocketPerformanceWatcherFactory*/ nullptr, 242 /*SocketPerformanceWatcherFactory*/ nullptr,
244 &crypto_client_stream_factory_, &random_generator_, clock_, 243 &crypto_client_stream_factory_, &random_generator_, clock_,
245 kDefaultMaxPacketSize, std::string(), 244 kDefaultMaxPacketSize, std::string(),
246 SupportedVersions(GetParam().version), enable_port_selection_, 245 SupportedVersions(GetParam().version), enable_port_selection_,
247 always_require_handshake_confirmation_, disable_connection_pooling_, 246 always_require_handshake_confirmation_, disable_connection_pooling_,
248 load_server_info_timeout_srtt_multiplier_, enable_connection_racing_, 247 load_server_info_timeout_srtt_multiplier_, enable_connection_racing_,
249 enable_non_blocking_io_, disable_disk_cache_, prefer_aes_, 248 enable_non_blocking_io_, disable_disk_cache_, prefer_aes_,
250 max_number_of_lossy_connections_, packet_loss_threshold_, 249 max_number_of_lossy_connections_, packet_loss_threshold_,
251 max_disabled_reasons_, threshold_timeouts_with_open_streams_, 250 max_disabled_reasons_, threshold_timeouts_with_open_streams_,
252 threshold_public_resets_post_handshake_, receive_buffer_size_, 251 threshold_public_resets_post_handshake_, receive_buffer_size_,
253 delay_tcp_race_, /*max_server_configs_stored_in_properties*/ 0, 252 /*max_server_configs_stored_in_properties*/ 0,
254 close_sessions_on_ip_change_, 253 close_sessions_on_ip_change_,
255 disable_quic_on_timeout_with_open_streams_, 254 disable_quic_on_timeout_with_open_streams_,
256 idle_connection_timeout_seconds_, migrate_sessions_on_network_change_, 255 idle_connection_timeout_seconds_, migrate_sessions_on_network_change_,
257 migrate_sessions_early_, QuicTagVector(), 256 migrate_sessions_early_, QuicTagVector(),
258 /*enable_token_binding*/ false)); 257 /*enable_token_binding*/ false));
259 factory_->set_require_confirmation(false); 258 factory_->set_require_confirmation(false);
260 EXPECT_FALSE(factory_->has_quic_server_info_factory()); 259 EXPECT_FALSE(factory_->has_quic_server_info_factory());
261 factory_->set_quic_server_info_factory(new MockQuicServerInfoFactory()); 260 factory_->set_quic_server_info_factory(new MockQuicServerInfoFactory());
262 EXPECT_TRUE(factory_->has_quic_server_info_factory()); 261 EXPECT_TRUE(factory_->has_quic_server_info_factory());
263 } 262 }
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 bool enable_connection_racing_; 429 bool enable_connection_racing_;
431 bool enable_non_blocking_io_; 430 bool enable_non_blocking_io_;
432 bool disable_disk_cache_; 431 bool disable_disk_cache_;
433 bool prefer_aes_; 432 bool prefer_aes_;
434 int max_number_of_lossy_connections_; 433 int max_number_of_lossy_connections_;
435 double packet_loss_threshold_; 434 double packet_loss_threshold_;
436 int max_disabled_reasons_; 435 int max_disabled_reasons_;
437 int threshold_timeouts_with_open_streams_; 436 int threshold_timeouts_with_open_streams_;
438 int threshold_public_resets_post_handshake_; 437 int threshold_public_resets_post_handshake_;
439 int receive_buffer_size_; 438 int receive_buffer_size_;
440 bool delay_tcp_race_;
441 bool close_sessions_on_ip_change_; 439 bool close_sessions_on_ip_change_;
442 bool disable_quic_on_timeout_with_open_streams_; 440 bool disable_quic_on_timeout_with_open_streams_;
443 int idle_connection_timeout_seconds_; 441 int idle_connection_timeout_seconds_;
444 bool migrate_sessions_on_network_change_; 442 bool migrate_sessions_on_network_change_;
445 bool migrate_sessions_early_; 443 bool migrate_sessions_early_;
446 }; 444 };
447 445
448 INSTANTIATE_TEST_CASE_P(Version, 446 INSTANTIATE_TEST_CASE_P(Version,
449 QuicStreamFactoryTest, 447 QuicStreamFactoryTest,
450 ::testing::ValuesIn(GetTestParams())); 448 ::testing::ValuesIn(GetTestParams()));
(...skipping 3215 matching lines...) Expand 10 before | Expand all | Expand 10 after
3666 EXPECT_TRUE(socket_data3.AllReadDataConsumed()); 3664 EXPECT_TRUE(socket_data3.AllReadDataConsumed());
3667 EXPECT_TRUE(socket_data3.AllWriteDataConsumed()); 3665 EXPECT_TRUE(socket_data3.AllWriteDataConsumed());
3668 EXPECT_TRUE(socket_data4.AllReadDataConsumed()); 3666 EXPECT_TRUE(socket_data4.AllReadDataConsumed());
3669 EXPECT_TRUE(socket_data4.AllWriteDataConsumed()); 3667 EXPECT_TRUE(socket_data4.AllWriteDataConsumed());
3670 } 3668 }
3671 3669
3672 TEST_P(QuicStreamFactoryTest, EnableDelayTcpRace) { 3670 TEST_P(QuicStreamFactoryTest, EnableDelayTcpRace) {
3673 Initialize(); 3671 Initialize();
3674 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); 3672 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails();
3675 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); 3673 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details);
3676 bool delay_tcp_race = QuicStreamFactoryPeer::GetDelayTcpRace(factory_.get());
3677 QuicStreamFactoryPeer::SetDelayTcpRace(factory_.get(), false);
3678 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; 3674 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)};
3679 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0); 3675 SequencedSocketData socket_data(reads, arraysize(reads), nullptr, 0);
3680 socket_factory_.AddSocketDataProvider(&socket_data); 3676 socket_factory_.AddSocketDataProvider(&socket_data);
3681 3677
3682 ServerNetworkStats stats1; 3678 ServerNetworkStats stats1;
3683 stats1.srtt = base::TimeDelta::FromMicroseconds(10); 3679 stats1.srtt = base::TimeDelta::FromMicroseconds(10);
3684 url::SchemeHostPort server("https", kDefaultServerHostName, 3680 url::SchemeHostPort server("https", kDefaultServerHostName,
3685 kDefaultServerPort); 3681 kDefaultServerPort);
3686 http_server_properties_.SetServerNetworkStats(server, stats1); 3682 http_server_properties_.SetServerNetworkStats(server, stats1);
3687 3683
3688 crypto_client_stream_factory_.set_handshake_mode( 3684 crypto_client_stream_factory_.set_handshake_mode(
3689 MockCryptoClientStream::ZERO_RTT); 3685 MockCryptoClientStream::ZERO_RTT);
3690 host_resolver_.set_synchronous_mode(true); 3686 host_resolver_.set_synchronous_mode(true);
3691 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), 3687 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(),
3692 "192.168.0.1", ""); 3688 "192.168.0.1", "");
3693 3689
3694 QuicStreamRequest request(factory_.get()); 3690 QuicStreamRequest request(factory_.get());
3695 EXPECT_EQ(ERR_IO_PENDING, 3691 EXPECT_EQ(ERR_IO_PENDING,
3696 request.Request(host_port_pair_, privacy_mode_, 3692 request.Request(host_port_pair_, privacy_mode_,
3697 /*cert_verify_flags=*/0, url_, "POST", net_log_, 3693 /*cert_verify_flags=*/0, url_, "POST", net_log_,
3698 callback_.callback())); 3694 callback_.callback()));
3699 3695
3700 // If we don't delay TCP connection, then time delay should be 0.
3701 EXPECT_FALSE(factory_->delay_tcp_race());
3702 EXPECT_EQ(base::TimeDelta(), request.GetTimeDelayForWaitingJob());
3703
3704 // Enable |delay_tcp_race_| param and verify delay is one RTT and that
3705 // server supports QUIC.
3706 QuicStreamFactoryPeer::SetDelayTcpRace(factory_.get(), true);
3707 EXPECT_TRUE(factory_->delay_tcp_race());
3708 EXPECT_EQ(base::TimeDelta::FromMicroseconds(15), 3696 EXPECT_EQ(base::TimeDelta::FromMicroseconds(15),
3709 request.GetTimeDelayForWaitingJob()); 3697 request.GetTimeDelayForWaitingJob());
3710 3698
3711 // Confirm the handshake and verify that the stream is created. 3699 // Confirm the handshake and verify that the stream is created.
3712 crypto_client_stream_factory_.last_stream()->SendOnCryptoHandshakeEvent( 3700 crypto_client_stream_factory_.last_stream()->SendOnCryptoHandshakeEvent(
3713 QuicSession::HANDSHAKE_CONFIRMED); 3701 QuicSession::HANDSHAKE_CONFIRMED);
3714 3702
3715 EXPECT_EQ(OK, callback_.WaitForResult()); 3703 EXPECT_EQ(OK, callback_.WaitForResult());
3716 3704
3717 std::unique_ptr<QuicHttpStream> stream = request.CreateStream(); 3705 std::unique_ptr<QuicHttpStream> stream = request.CreateStream();
3718 EXPECT_TRUE(stream.get()); 3706 EXPECT_TRUE(stream.get());
3719 EXPECT_TRUE(socket_data.AllReadDataConsumed()); 3707 EXPECT_TRUE(socket_data.AllReadDataConsumed());
3720 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); 3708 EXPECT_TRUE(socket_data.AllWriteDataConsumed());
3721 QuicStreamFactoryPeer::SetDelayTcpRace(factory_.get(), delay_tcp_race);
3722 } 3709 }
3723 3710
3724 TEST_P(QuicStreamFactoryTest, MaybeInitialize) { 3711 TEST_P(QuicStreamFactoryTest, MaybeInitialize) {
3725 idle_connection_timeout_seconds_ = 500; 3712 idle_connection_timeout_seconds_ = 500;
3726 Initialize(); 3713 Initialize();
3727 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails(); 3714 ProofVerifyDetailsChromium verify_details = DefaultProofVerifyDetails();
3728 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); 3715 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details);
3729 const QuicConfig* config = QuicStreamFactoryPeer::GetConfig(factory_.get()); 3716 const QuicConfig* config = QuicStreamFactoryPeer::GetConfig(factory_.get());
3730 EXPECT_EQ(500, config->IdleConnectionStateLifetime().ToSeconds()); 3717 EXPECT_EQ(500, config->IdleConnectionStateLifetime().ToSeconds());
3731 3718
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
4095 EXPECT_TRUE(stream2.get()); 4082 EXPECT_TRUE(stream2.get());
4096 4083
4097 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); 4084 EXPECT_TRUE(socket_data1.AllReadDataConsumed());
4098 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); 4085 EXPECT_TRUE(socket_data1.AllWriteDataConsumed());
4099 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); 4086 EXPECT_TRUE(socket_data2.AllReadDataConsumed());
4100 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); 4087 EXPECT_TRUE(socket_data2.AllWriteDataConsumed());
4101 } 4088 }
4102 4089
4103 } // namespace test 4090 } // namespace test
4104 } // namespace net 4091 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_stream_factory.cc ('k') | net/quic/test_tools/quic_stream_factory_peer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698