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

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

Issue 411823002: Land Recent QUIC Changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase TOT Created 6 years, 4 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/test_tools/quic_test_utils.cc ('k') | net/tools/quic/quic_client.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 <stddef.h> 5 #include <stddef.h>
6 #include <string> 6 #include <string>
7 #include <sys/epoll.h> 7 #include <sys/epoll.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/synchronization/waitable_event.h" 14 #include "base/synchronization/waitable_event.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "net/base/ip_endpoint.h" 16 #include "net/base/ip_endpoint.h"
17 #include "net/quic/congestion_control/tcp_cubic_sender.h" 17 #include "net/quic/congestion_control/tcp_cubic_sender.h"
18 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" 18 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h"
19 #include "net/quic/crypto/null_encrypter.h" 19 #include "net/quic/crypto/null_encrypter.h"
20 #include "net/quic/quic_flags.h" 20 #include "net/quic/quic_flags.h"
21 #include "net/quic/quic_framer.h" 21 #include "net/quic/quic_framer.h"
22 #include "net/quic/quic_packet_creator.h" 22 #include "net/quic/quic_packet_creator.h"
23 #include "net/quic/quic_protocol.h" 23 #include "net/quic/quic_protocol.h"
24 #include "net/quic/quic_sent_packet_manager.h" 24 #include "net/quic/quic_sent_packet_manager.h"
25 #include "net/quic/quic_server_id.h" 25 #include "net/quic/quic_server_id.h"
26 #include "net/quic/quic_utils.h"
26 #include "net/quic/test_tools/quic_connection_peer.h" 27 #include "net/quic/test_tools/quic_connection_peer.h"
27 #include "net/quic/test_tools/quic_flow_controller_peer.h" 28 #include "net/quic/test_tools/quic_flow_controller_peer.h"
29 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h"
28 #include "net/quic/test_tools/quic_session_peer.h" 30 #include "net/quic/test_tools/quic_session_peer.h"
29 #include "net/quic/test_tools/quic_test_utils.h" 31 #include "net/quic/test_tools/quic_test_utils.h"
30 #include "net/quic/test_tools/reliable_quic_stream_peer.h" 32 #include "net/quic/test_tools/reliable_quic_stream_peer.h"
31 #include "net/test/gtest_util.h" 33 #include "net/test/gtest_util.h"
32 #include "net/tools/epoll_server/epoll_server.h" 34 #include "net/tools/epoll_server/epoll_server.h"
33 #include "net/tools/quic/quic_epoll_connection_helper.h" 35 #include "net/tools/quic/quic_epoll_connection_helper.h"
34 #include "net/tools/quic/quic_in_memory_cache.h" 36 #include "net/tools/quic/quic_in_memory_cache.h"
35 #include "net/tools/quic/quic_packet_writer_wrapper.h" 37 #include "net/tools/quic/quic_packet_writer_wrapper.h"
36 #include "net/tools/quic/quic_server.h" 38 #include "net/tools/quic/quic_server.h"
37 #include "net/tools/quic/quic_socket_utils.h" 39 #include "net/tools/quic/quic_socket_utils.h"
38 #include "net/tools/quic/quic_spdy_client_stream.h" 40 #include "net/tools/quic/quic_spdy_client_stream.h"
39 #include "net/tools/quic/test_tools/http_message.h" 41 #include "net/tools/quic/test_tools/http_message.h"
40 #include "net/tools/quic/test_tools/packet_dropping_test_writer.h" 42 #include "net/tools/quic/test_tools/packet_dropping_test_writer.h"
41 #include "net/tools/quic/test_tools/quic_client_peer.h" 43 #include "net/tools/quic/test_tools/quic_client_peer.h"
42 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h" 44 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h"
43 #include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h" 45 #include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h"
44 #include "net/tools/quic/test_tools/quic_server_peer.h" 46 #include "net/tools/quic/test_tools/quic_server_peer.h"
45 #include "net/tools/quic/test_tools/quic_test_client.h" 47 #include "net/tools/quic/test_tools/quic_test_client.h"
46 #include "net/tools/quic/test_tools/server_thread.h" 48 #include "net/tools/quic/test_tools/server_thread.h"
47 #include "testing/gtest/include/gtest/gtest.h" 49 #include "testing/gtest/include/gtest/gtest.h"
48 50
49 using base::StringPiece; 51 using base::StringPiece;
50 using base::WaitableEvent; 52 using base::WaitableEvent;
51 using net::EpollServer; 53 using net::EpollServer;
52 using net::test::GenerateBody; 54 using net::test::GenerateBody;
53 using net::test::QuicConnectionPeer; 55 using net::test::QuicConnectionPeer;
54 using net::test::QuicFlowControllerPeer; 56 using net::test::QuicFlowControllerPeer;
57 using net::test::QuicSentPacketManagerPeer;
55 using net::test::QuicSessionPeer; 58 using net::test::QuicSessionPeer;
56 using net::test::ReliableQuicStreamPeer; 59 using net::test::ReliableQuicStreamPeer;
57 using net::test::ValueRestore; 60 using net::test::ValueRestore;
58 using net::test::kClientDataStreamId1; 61 using net::test::kClientDataStreamId1;
59 using net::tools::test::PacketDroppingTestWriter; 62 using net::tools::test::PacketDroppingTestWriter;
60 using net::tools::test::QuicDispatcherPeer; 63 using net::tools::test::QuicDispatcherPeer;
61 using net::tools::test::QuicServerPeer; 64 using net::tools::test::QuicServerPeer;
62 using std::ostream; 65 using std::ostream;
63 using std::string; 66 using std::string;
64 using std::vector; 67 using std::vector;
65 68
66 namespace net { 69 namespace net {
67 namespace tools { 70 namespace tools {
68 namespace test { 71 namespace test {
69 namespace { 72 namespace {
70 73
71 const char* kFooResponseBody = "Artichoke hearts make me happy."; 74 const char* kFooResponseBody = "Artichoke hearts make me happy.";
72 const char* kBarResponseBody = "Palm hearts are pretty delicious, also."; 75 const char* kBarResponseBody = "Palm hearts are pretty delicious, also.";
73 76
74 // Run all tests with the cross products of all versions. 77 // Run all tests with the cross products of all versions.
75 struct TestParams { 78 struct TestParams {
76 TestParams(const QuicVersionVector& client_supported_versions, 79 TestParams(const QuicVersionVector& client_supported_versions,
77 const QuicVersionVector& server_supported_versions, 80 const QuicVersionVector& server_supported_versions,
78 QuicVersion negotiated_version, 81 QuicVersion negotiated_version,
79 bool use_pacing) 82 bool use_pacing,
83 bool use_fec,
84 QuicTag congestion_control_tag)
80 : client_supported_versions(client_supported_versions), 85 : client_supported_versions(client_supported_versions),
81 server_supported_versions(server_supported_versions), 86 server_supported_versions(server_supported_versions),
82 negotiated_version(negotiated_version), 87 negotiated_version(negotiated_version),
83 use_pacing(use_pacing) { 88 use_pacing(use_pacing),
89 use_fec(use_fec),
90 congestion_control_tag(congestion_control_tag) {
84 } 91 }
85 92
86 friend ostream& operator<<(ostream& os, const TestParams& p) { 93 friend ostream& operator<<(ostream& os, const TestParams& p) {
87 os << "{ server_supported_versions: " 94 os << "{ server_supported_versions: "
88 << QuicVersionVectorToString(p.server_supported_versions); 95 << QuicVersionVectorToString(p.server_supported_versions);
89 os << " client_supported_versions: " 96 os << " client_supported_versions: "
90 << QuicVersionVectorToString(p.client_supported_versions); 97 << QuicVersionVectorToString(p.client_supported_versions);
91 os << " negotiated_version: " << QuicVersionToString(p.negotiated_version); 98 os << " negotiated_version: " << QuicVersionToString(p.negotiated_version);
92 os << " use_pacing: " << p.use_pacing << " }"; 99 os << " use_pacing: " << p.use_pacing;
100 os << " use_fec: " << p.use_fec;
101 os << " congestion_control_tag: "
102 << QuicUtils::TagToString(p.congestion_control_tag) << " }";
93 return os; 103 return os;
94 } 104 }
95 105
96 QuicVersionVector client_supported_versions; 106 QuicVersionVector client_supported_versions;
97 QuicVersionVector server_supported_versions; 107 QuicVersionVector server_supported_versions;
98 QuicVersion negotiated_version; 108 QuicVersion negotiated_version;
99 bool use_pacing; 109 bool use_pacing;
110 bool use_fec;
111 QuicTag congestion_control_tag;
100 }; 112 };
101 113
102 // Constructs various test permutations. 114 // Constructs various test permutations.
103 vector<TestParams> GetTestParams() { 115 vector<TestParams> GetTestParams() {
104 vector<TestParams> params; 116 vector<TestParams> params;
105 QuicVersionVector all_supported_versions = QuicSupportedVersions(); 117 QuicVersionVector all_supported_versions = QuicSupportedVersions();
106 for (int use_pacing = 0; use_pacing < 2; ++use_pacing) { 118 // TODO(rtenneti): Add kTBBR after BBR code is checked in.
107 // Add an entry for server and client supporting all versions. 119 // QuicTag congestion_control_tags[] = {kRENO, kTBBR, kQBIC};
108 params.push_back(TestParams(all_supported_versions, 120 QuicTag congestion_control_tags[] = {kRENO, kQBIC};
109 all_supported_versions, 121 for (size_t congestion_control_index = 0;
110 all_supported_versions[0], 122 congestion_control_index < arraysize(congestion_control_tags);
111 use_pacing != 0)); 123 congestion_control_index++) {
124 QuicTag congestion_control_tag =
125 congestion_control_tags[congestion_control_index];
126 for (int use_fec = 0; use_fec < 2; ++use_fec) {
127 for (int use_pacing = 0; use_pacing < 2; ++use_pacing) {
128 // Add an entry for server and client supporting all versions.
129 params.push_back(TestParams(all_supported_versions,
130 all_supported_versions,
131 all_supported_versions[0],
132 use_pacing != 0,
133 use_fec != 0,
134 congestion_control_tag));
112 135
113 // Test client supporting all versions and server supporting 1 version. 136 // Test client supporting all versions and server supporting 1 version.
114 // Simulate an old server and exercise version downgrade in the client. 137 // Simulate an old server and exercise version downgrade in the client.
115 // Protocol negotiation should occur. Skip the i = 0 case because it is 138 // Protocol negotiation should occur. Skip the i = 0 case because it is
116 // essentially the same as the default case. 139 // essentially the same as the default case.
117 for (size_t i = 1; i < all_supported_versions.size(); ++i) { 140 for (size_t i = 1; i < all_supported_versions.size(); ++i) {
118 QuicVersionVector server_supported_versions; 141 QuicVersionVector server_supported_versions;
119 server_supported_versions.push_back(all_supported_versions[i]); 142 server_supported_versions.push_back(all_supported_versions[i]);
120 if (all_supported_versions[i] >= QUIC_VERSION_18) { 143 if (all_supported_versions[i] >= QUIC_VERSION_18) {
121 // Until flow control is globally rolled out and we remove 144 // Until flow control is globally rolled out and we remove
122 // QUIC_VERSION_16, the server MUST support at least one QUIC version 145 // QUIC_VERSION_16, the server MUST support at least one QUIC
123 // that does not use flow control. 146 // version that does not use flow control.
124 server_supported_versions.push_back(QUIC_VERSION_16); 147 server_supported_versions.push_back(QUIC_VERSION_16);
148 }
149 params.push_back(TestParams(all_supported_versions,
150 server_supported_versions,
151 server_supported_versions[0],
152 use_pacing != 0,
153 use_fec != 0,
154 congestion_control_tag));
155 }
125 } 156 }
126 params.push_back(TestParams(all_supported_versions,
127 server_supported_versions,
128 server_supported_versions[0],
129 use_pacing != 0));
130 } 157 }
131 } 158 }
132 return params; 159 return params;
133 } 160 }
134 161
135 class ServerDelegate : public PacketDroppingTestWriter::Delegate { 162 class ServerDelegate : public PacketDroppingTestWriter::Delegate {
136 public: 163 public:
137 explicit ServerDelegate(QuicDispatcher* dispatcher) 164 explicit ServerDelegate(QuicDispatcher* dispatcher)
138 : dispatcher_(dispatcher) {} 165 : dispatcher_(dispatcher) {}
139 virtual ~ServerDelegate() {} 166 virtual ~ServerDelegate() {}
(...skipping 21 matching lines...) Expand all
161 server_started_(false), 188 server_started_(false),
162 strike_register_no_startup_period_(false) { 189 strike_register_no_startup_period_(false) {
163 net::IPAddressNumber ip; 190 net::IPAddressNumber ip;
164 CHECK(net::ParseIPLiteralToNumber("127.0.0.1", &ip)); 191 CHECK(net::ParseIPLiteralToNumber("127.0.0.1", &ip));
165 server_address_ = IPEndPoint(ip, 0); 192 server_address_ = IPEndPoint(ip, 0);
166 193
167 client_supported_versions_ = GetParam().client_supported_versions; 194 client_supported_versions_ = GetParam().client_supported_versions;
168 server_supported_versions_ = GetParam().server_supported_versions; 195 server_supported_versions_ = GetParam().server_supported_versions;
169 negotiated_version_ = GetParam().negotiated_version; 196 negotiated_version_ = GetParam().negotiated_version;
170 FLAGS_enable_quic_pacing = GetParam().use_pacing; 197 FLAGS_enable_quic_pacing = GetParam().use_pacing;
198 FLAGS_enable_quic_fec = GetParam().use_fec;
171 199
172 if (negotiated_version_ >= QUIC_VERSION_19) { 200 if (negotiated_version_ >= QUIC_VERSION_19) {
173 FLAGS_enable_quic_connection_flow_control_2 = true; 201 FLAGS_enable_quic_connection_flow_control_2 = true;
174 } 202 }
175 VLOG(1) << "Using Configuration: " << GetParam(); 203 VLOG(1) << "Using Configuration: " << GetParam();
176 204
177 client_config_.SetDefaults(); 205 client_config_.SetDefaults();
178 server_config_.SetDefaults(); 206 server_config_.SetDefaults();
179 207
180 // Use different flow control windows for client/server. 208 // Use different flow control windows for client/server.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 server_config_.SetInitialStreamFlowControlWindowToSend(window); 277 server_config_.SetInitialStreamFlowControlWindowToSend(window);
250 } 278 }
251 279
252 void set_server_initial_session_flow_control_receive_window(uint32 window) { 280 void set_server_initial_session_flow_control_receive_window(uint32 window) {
253 CHECK(server_thread_.get() == NULL); 281 CHECK(server_thread_.get() == NULL);
254 DLOG(INFO) << "Setting server initial session flow control window: " 282 DLOG(INFO) << "Setting server initial session flow control window: "
255 << window; 283 << window;
256 server_config_.SetInitialSessionFlowControlWindowToSend(window); 284 server_config_.SetInitialSessionFlowControlWindowToSend(window);
257 } 285 }
258 286
287 const QuicSentPacketManager *
288 GetSentPacketManagerFromFirstServerSession() const {
289 QuicDispatcher* dispatcher =
290 QuicServerPeer::GetDispatcher(server_thread_->server());
291 QuicSession* session = dispatcher->session_map().begin()->second;
292 return &session->connection()->sent_packet_manager();
293 }
294
259 bool Initialize() { 295 bool Initialize() {
296 QuicTagVector copt;
297
298 // TODO(nimia): Consider setting the congestion control algorithm for the
299 // client as well according to the test parameter.
300 copt.push_back(GetParam().congestion_control_tag);
301
302 if (GetParam().use_fec) {
303 // Set FEC config in client's connection options and in client session.
304 copt.push_back(kFHDR);
305 }
306
307 client_config_.SetConnectionOptionsToSend(copt);
308
260 // Start the server first, because CreateQuicClient() attempts 309 // Start the server first, because CreateQuicClient() attempts
261 // to connect to the server. 310 // to connect to the server.
262 StartServer(); 311 StartServer();
263 client_.reset(CreateQuicClient(client_writer_)); 312 client_.reset(CreateQuicClient(client_writer_));
313 if (GetParam().use_fec) {
314 // Set FecPolicy to always protect data on all streams.
315 client_->SetFecPolicy(FEC_PROTECT_ALWAYS);
316 }
264 static EpollEvent event(EPOLLOUT, false); 317 static EpollEvent event(EPOLLOUT, false);
265 client_writer_->Initialize( 318 client_writer_->Initialize(
266 reinterpret_cast<QuicEpollConnectionHelper*>( 319 reinterpret_cast<QuicEpollConnectionHelper*>(
267 QuicConnectionPeer::GetHelper( 320 QuicConnectionPeer::GetHelper(
268 client_->client()->session()->connection())), 321 client_->client()->session()->connection())),
269 new ClientDelegate(client_->client())); 322 new ClientDelegate(client_->client()));
270 return client_->client()->connected(); 323 return client_->client()->connected();
271 } 324 }
272 325
273 virtual void SetUp() OVERRIDE { 326 virtual void SetUp() OVERRIDE {
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 // Otherwise it may have queued frames which will trigger a 714 // Otherwise it may have queued frames which will trigger a
662 // DFATAL when they are serialized after the downgrade. 715 // DFATAL when they are serialized after the downgrade.
663 client_->client()->WaitForCryptoHandshakeConfirmed(); 716 client_->client()->WaitForCryptoHandshakeConfirmed();
664 } 717 }
665 ASSERT_TRUE(client_->client()->connected()); 718 ASSERT_TRUE(client_->client()->connected());
666 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); 719 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request));
667 EXPECT_EQ(2, client_->client()->session()->GetNumSentClientHellos()); 720 EXPECT_EQ(2, client_->client()->session()->GetNumSentClientHellos());
668 VerifyCleanConnection(false); 721 VerifyCleanConnection(false);
669 } 722 }
670 723
671 TEST_P(EndToEndTest, LargePostFec) { 724 TEST_P(EndToEndTest, CorrectlyConfiguredFec) {
672 ValueRestore<bool> old_flag(&FLAGS_enable_quic_fec, true);
673
674 // Connect without packet loss to avoid issues with losing handshake packets,
675 // and then up the packet loss rate (b/10126687).
676 ASSERT_TRUE(Initialize());
677
678 // Wait for the server SHLO before upping the packet loss.
679 client_->client()->WaitForCryptoHandshakeConfirmed();
680 SetPacketLossPercentage(30);
681
682 // Verify that FEC is enabled.
683 QuicPacketCreator* creator = QuicConnectionPeer::GetPacketCreator(
684 client_->client()->session()->connection());
685 EXPECT_TRUE(creator->IsFecEnabled());
686
687 // Set FecPolicy to always protect data on all streams.
688 client_->SetFecPolicy(FEC_PROTECT_ALWAYS);
689
690 string body;
691 GenerateBody(&body, 10240);
692
693 HTTPMessage request(HttpConstants::HTTP_1_1,
694 HttpConstants::POST, "/foo");
695 request.AddBody(body, true);
696 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request));
697 VerifyCleanConnection(true);
698 }
699
700 TEST_P(EndToEndTest, ClientSpecifiedFecProtectionForHeaders) {
701 ValueRestore<bool> old_flag(&FLAGS_enable_quic_fec, true);
702
703 // Set FEC config in client's connection options and in client session.
704 QuicTagVector copt;
705 copt.push_back(kFHDR);
706 client_config_.SetConnectionOptionsToSend(copt);
707
708 // Connect without packet loss to avoid issues with losing handshake packets,
709 // and then up the packet loss rate (b/10126687).
710 ASSERT_TRUE(Initialize()); 725 ASSERT_TRUE(Initialize());
711 client_->client()->WaitForCryptoHandshakeConfirmed(); 726 client_->client()->WaitForCryptoHandshakeConfirmed();
712 server_thread_->WaitForCryptoHandshakeConfirmed(); 727 server_thread_->WaitForCryptoHandshakeConfirmed();
713 728
714 // Verify that FEC is enabled. 729 FecPolicy expected_policy =
715 QuicPacketCreator* creator = QuicConnectionPeer::GetPacketCreator( 730 GetParam().use_fec ? FEC_PROTECT_ALWAYS : FEC_PROTECT_OPTIONAL;
716 client_->client()->session()->connection());
717 EXPECT_TRUE(creator->IsFecEnabled());
718 731
719 // Verify that server headers stream is FEC protected. 732 // Verify that server's FEC configuration is correct.
720 server_thread_->Pause(); 733 server_thread_->Pause();
721 QuicDispatcher* dispatcher = 734 QuicDispatcher* dispatcher =
722 QuicServerPeer::GetDispatcher(server_thread_->server()); 735 QuicServerPeer::GetDispatcher(server_thread_->server());
723 ASSERT_EQ(1u, dispatcher->session_map().size()); 736 ASSERT_EQ(1u, dispatcher->session_map().size());
724 QuicSession* session = dispatcher->session_map().begin()->second; 737 QuicSession* session = dispatcher->session_map().begin()->second;
725 EXPECT_EQ(FEC_PROTECT_ALWAYS, 738 EXPECT_EQ(expected_policy,
726 QuicSessionPeer::GetHeadersStream(session)->fec_policy()); 739 QuicSessionPeer::GetHeadersStream(session)->fec_policy());
727 server_thread_->Resume(); 740 server_thread_->Resume();
728 741
729 // Verify that at the client, headers stream is protected and other data 742 // Verify that client's FEC configuration is correct.
730 // streams are optionally protected. 743 EXPECT_EQ(expected_policy,
731 EXPECT_EQ(FEC_PROTECT_ALWAYS, QuicSessionPeer::GetHeadersStream( 744 QuicSessionPeer::GetHeadersStream(
732 client_->client()->session())->fec_policy()); 745 client_->client()->session())->fec_policy());
733 EXPECT_EQ(FEC_PROTECT_OPTIONAL, client_->GetOrCreateStream()->fec_policy()); 746 EXPECT_EQ(expected_policy,
747 client_->GetOrCreateStream()->fec_policy());
734 } 748 }
735 749
736 // TODO(shess): This is flaky on ChromiumOS bots. 750 // TODO(shess): This is flaky on ChromiumOS bots.
737 // http://crbug.com/374871 751 // http://crbug.com/374871
738 TEST_P(EndToEndTest, DISABLED_LargePostSmallBandwidthLargeBuffer) { 752 TEST_P(EndToEndTest, DISABLED_LargePostSmallBandwidthLargeBuffer) {
739 ASSERT_TRUE(Initialize()); 753 ASSERT_TRUE(Initialize());
740 SetPacketSendDelay(QuicTime::Delta::FromMicroseconds(1)); 754 SetPacketSendDelay(QuicTime::Delta::FromMicroseconds(1));
741 // 256KB per second with a 256KB buffer from server to client. Wireless 755 // 256KB per second with a 256KB buffer from server to client. Wireless
742 // clients commonly have larger buffers, but our max CWND is 200. 756 // clients commonly have larger buffers, but our max CWND is 200.
743 server_writer_->set_max_bandwidth_and_buffer_size( 757 server_writer_->set_max_bandwidth_and_buffer_size(
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 // Open two simultaneous streams. 891 // Open two simultaneous streams.
878 client_->SendMessage(request); 892 client_->SendMessage(request);
879 client_->SendMessage(request); 893 client_->SendMessage(request);
880 client_->WaitForResponse(); 894 client_->WaitForResponse();
881 895
882 EXPECT_FALSE(client_->connected()); 896 EXPECT_FALSE(client_->connected());
883 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); 897 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error());
884 EXPECT_EQ(QUIC_TOO_MANY_OPEN_STREAMS, client_->connection_error()); 898 EXPECT_EQ(QUIC_TOO_MANY_OPEN_STREAMS, client_->connection_error());
885 } 899 }
886 900
901 TEST_P(EndToEndTest, NegotiateCongestionControl) {
902 ASSERT_TRUE(Initialize());
903 client_->client()->WaitForCryptoHandshakeConfirmed();
904
905 CongestionControlType expected_congestion_control_type;
906 switch (GetParam().congestion_control_tag) {
907 case kRENO:
908 expected_congestion_control_type = kReno;
909 break;
910 case kTBBR:
911 expected_congestion_control_type = kBBR;
912 break;
913 case kQBIC:
914 expected_congestion_control_type = kCubic;
915 break;
916 default:
917 DLOG(FATAL) << "Unexpected congestion control tag";
918 }
919
920 EXPECT_EQ(expected_congestion_control_type,
921 QuicSentPacketManagerPeer::GetCongestionControlAlgorithm(
922 *GetSentPacketManagerFromFirstServerSession())
923 ->GetCongestionControlType());
924 }
925
887 TEST_P(EndToEndTest, LimitMaxOpenStreams) { 926 TEST_P(EndToEndTest, LimitMaxOpenStreams) {
888 // Server limits the number of max streams to 2. 927 // Server limits the number of max streams to 2.
889 server_config_.set_max_streams_per_connection(2, 2); 928 server_config_.set_max_streams_per_connection(2, 2);
890 // Client tries to negotiate for 10. 929 // Client tries to negotiate for 10.
891 client_config_.set_max_streams_per_connection(10, 5); 930 client_config_.set_max_streams_per_connection(10, 5);
892 931
893 ASSERT_TRUE(Initialize()); 932 ASSERT_TRUE(Initialize());
894 client_->client()->WaitForCryptoHandshakeConfirmed(); 933 client_->client()->WaitForCryptoHandshakeConfirmed();
895 QuicConfig* client_negotiated_config = client_->client()->session()->config(); 934 QuicConfig* client_negotiated_config = client_->client()->session()->config();
896 EXPECT_EQ(2u, client_negotiated_config->max_streams_per_connection()); 935 EXPECT_EQ(2u, client_negotiated_config->max_streams_per_connection());
897 } 936 }
898 937
899 // TODO(rtenneti): DISABLED_LimitCongestionWindowAndRTT seems to be flaky. 938 // TODO(rtenneti): DISABLED_LimitCongestionWindowAndRTT seems to be flaky.
900 // http://crbug.com/321870. 939 // http://crbug.com/321870.
901 TEST_P(EndToEndTest, DISABLED_LimitCongestionWindowAndRTT) { 940 TEST_P(EndToEndTest, DISABLED_LimitCongestionWindowAndRTT) {
902 // Client tries to request twice the server's max initial window, and the 941 // Client tries to request twice the server's max initial window, and the
903 // server limits it to the max. 942 // server limits it to the max.
904 client_config_.SetInitialCongestionWindowToSend(2 * kMaxInitialWindow); 943 client_config_.SetInitialCongestionWindowToSend(2 * kMaxInitialWindow);
905 client_config_.SetInitialRoundTripTimeUsToSend(1); 944 client_config_.SetInitialRoundTripTimeUsToSend(1);
906 945
907 ASSERT_TRUE(Initialize()); 946 ASSERT_TRUE(Initialize());
908 client_->client()->WaitForCryptoHandshakeConfirmed(); 947 client_->client()->WaitForCryptoHandshakeConfirmed();
909 server_thread_->WaitForCryptoHandshakeConfirmed(); 948 server_thread_->WaitForCryptoHandshakeConfirmed();
910 949
911 // Pause the server so we can access the server's internals without races. 950 // Pause the server so we can access the server's internals without races.
912 server_thread_->Pause(); 951 server_thread_->Pause();
913 QuicDispatcher* dispatcher = 952 QuicDispatcher* dispatcher =
914 QuicServerPeer::GetDispatcher(server_thread_->server()); 953 QuicServerPeer::GetDispatcher(server_thread_->server());
915 ASSERT_EQ(1u, dispatcher->session_map().size()); 954 ASSERT_EQ(1u, dispatcher->session_map().size());
916 QuicSession* session = dispatcher->session_map().begin()->second;
917 const QuicSentPacketManager& client_sent_packet_manager = 955 const QuicSentPacketManager& client_sent_packet_manager =
918 client_->client()->session()->connection()->sent_packet_manager(); 956 client_->client()->session()->connection()->sent_packet_manager();
919 const QuicSentPacketManager& server_sent_packet_manager = 957 const QuicSentPacketManager& server_sent_packet_manager =
920 session->connection()->sent_packet_manager(); 958 *GetSentPacketManagerFromFirstServerSession();
921 959
922 // The client shouldn't set it's initial window based on the negotiated value. 960 // The client shouldn't set it's initial window based on the negotiated value.
923 EXPECT_EQ(kDefaultInitialWindow * kDefaultTCPMSS, 961 EXPECT_EQ(kDefaultInitialWindow * kDefaultTCPMSS,
924 client_sent_packet_manager.GetCongestionWindow()); 962 client_sent_packet_manager.GetCongestionWindow());
925 EXPECT_EQ(kMaxInitialWindow * kDefaultTCPMSS, 963 EXPECT_EQ(kMaxInitialWindow * kDefaultTCPMSS,
926 server_sent_packet_manager.GetCongestionWindow()); 964 server_sent_packet_manager.GetCongestionWindow());
927 965
928 EXPECT_EQ(FLAGS_enable_quic_pacing, 966 EXPECT_EQ(FLAGS_enable_quic_pacing,
929 server_sent_packet_manager.using_pacing()); 967 server_sent_packet_manager.using_pacing());
930 EXPECT_EQ(FLAGS_enable_quic_pacing, 968 EXPECT_EQ(FLAGS_enable_quic_pacing,
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 1141
1104 TEST_P(EndToEndTest, ConnectionMigrationClientIPChanged) { 1142 TEST_P(EndToEndTest, ConnectionMigrationClientIPChanged) {
1105 // Tests that the client's IP can not change during an established QUIC 1143 // Tests that the client's IP can not change during an established QUIC
1106 // connection. If it changes, the connection is closed by the server as we do 1144 // connection. If it changes, the connection is closed by the server as we do
1107 // not yet support IP migration. 1145 // not yet support IP migration.
1108 ASSERT_TRUE(Initialize()); 1146 ASSERT_TRUE(Initialize());
1109 1147
1110 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); 1148 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
1111 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 1149 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
1112 1150
1113 scoped_ptr<WrongAddressWriter> writer(new WrongAddressWriter()); 1151 WrongAddressWriter* writer = new WrongAddressWriter();
1114 1152
1115 writer->set_writer(new QuicDefaultPacketWriter(client_->client()->fd())); 1153 writer->set_writer(new QuicDefaultPacketWriter(client_->client()->fd()));
1116 QuicConnectionPeer::SetWriter(client_->client()->session()->connection(), 1154 QuicConnectionPeer::SetWriter(client_->client()->session()->connection(),
1117 writer.get()); 1155 writer,
1156 true /* owns_writer */);
1118 1157
1119 client_->SendSynchronousRequest("/bar"); 1158 client_->SendSynchronousRequest("/bar");
1120 1159
1121 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); 1160 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error());
1122 EXPECT_EQ(QUIC_ERROR_MIGRATING_ADDRESS, client_->connection_error()); 1161 EXPECT_EQ(QUIC_ERROR_MIGRATING_ADDRESS, client_->connection_error());
1123 } 1162 }
1124 1163
1125 TEST_P(EndToEndTest, ConnectionMigrationClientPortChanged) { 1164 TEST_P(EndToEndTest, ConnectionMigrationClientPortChanged) {
1126 // Tests that the client's port can change during an established QUIC 1165 // Tests that the client's port can change during an established QUIC
1127 // connection, and that doing so does not result in the connection being 1166 // connection, and that doing so does not result in the connection being
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 session->flow_controller(); 1363 session->flow_controller();
1325 EXPECT_EQ(kSessionIFCW, QuicFlowControllerPeer::ReceiveWindowSize( 1364 EXPECT_EQ(kSessionIFCW, QuicFlowControllerPeer::ReceiveWindowSize(
1326 server_connection_flow_controller)); 1365 server_connection_flow_controller));
1327 server_thread_->Resume(); 1366 server_thread_->Resume();
1328 } 1367 }
1329 1368
1330 } // namespace 1369 } // namespace
1331 } // namespace test 1370 } // namespace test
1332 } // namespace tools 1371 } // namespace tools
1333 } // namespace net 1372 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_test_utils.cc ('k') | net/tools/quic/quic_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698