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

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

Issue 2222393002: Make QuicDispatcher to queue packets for new connections while waiting for CHLOs. Flag protected by… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@129318081
Patch Set: add new files Created 4 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/tools/quic/chlo_extractor.cc ('k') | net/tools/quic/quic_dispatcher.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 <sys/epoll.h> 6 #include <sys/epoll.h>
7 7
8 #include <list> 8 #include <list>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 30 matching lines...) Expand all
41 #include "net/tools/epoll_server/epoll_server.h" 41 #include "net/tools/epoll_server/epoll_server.h"
42 #include "net/tools/quic/quic_epoll_connection_helper.h" 42 #include "net/tools/quic/quic_epoll_connection_helper.h"
43 #include "net/tools/quic/quic_in_memory_cache.h" 43 #include "net/tools/quic/quic_in_memory_cache.h"
44 #include "net/tools/quic/quic_packet_writer_wrapper.h" 44 #include "net/tools/quic/quic_packet_writer_wrapper.h"
45 #include "net/tools/quic/quic_server.h" 45 #include "net/tools/quic/quic_server.h"
46 #include "net/tools/quic/quic_simple_server_stream.h" 46 #include "net/tools/quic/quic_simple_server_stream.h"
47 #include "net/tools/quic/quic_socket_utils.h" 47 #include "net/tools/quic/quic_socket_utils.h"
48 #include "net/tools/quic/quic_spdy_client_stream.h" 48 #include "net/tools/quic/quic_spdy_client_stream.h"
49 #include "net/tools/quic/test_tools/http_message.h" 49 #include "net/tools/quic/test_tools/http_message.h"
50 #include "net/tools/quic/test_tools/packet_dropping_test_writer.h" 50 #include "net/tools/quic/test_tools/packet_dropping_test_writer.h"
51 #include "net/tools/quic/test_tools/packet_reordering_writer.h"
51 #include "net/tools/quic/test_tools/quic_client_peer.h" 52 #include "net/tools/quic/test_tools/quic_client_peer.h"
52 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h" 53 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h"
53 #include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h" 54 #include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h"
54 #include "net/tools/quic/test_tools/quic_server_peer.h" 55 #include "net/tools/quic/test_tools/quic_server_peer.h"
55 #include "net/tools/quic/test_tools/quic_test_client.h" 56 #include "net/tools/quic/test_tools/quic_test_client.h"
56 #include "net/tools/quic/test_tools/quic_test_server.h" 57 #include "net/tools/quic/test_tools/quic_test_server.h"
57 #include "net/tools/quic/test_tools/server_thread.h" 58 #include "net/tools/quic/test_tools/server_thread.h"
58 #include "testing/gtest/include/gtest/gtest.h" 59 #include "testing/gtest/include/gtest/gtest.h"
59 60
60 using base::IntToString; 61 using base::IntToString;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 94
94 // Run all tests with the cross products of all versions. 95 // Run all tests with the cross products of all versions.
95 struct TestParams { 96 struct TestParams {
96 TestParams(const QuicVersionVector& client_supported_versions, 97 TestParams(const QuicVersionVector& client_supported_versions,
97 const QuicVersionVector& server_supported_versions, 98 const QuicVersionVector& server_supported_versions,
98 QuicVersion negotiated_version, 99 QuicVersion negotiated_version,
99 bool client_supports_stateless_rejects, 100 bool client_supports_stateless_rejects,
100 bool server_uses_stateless_rejects_if_peer_supported, 101 bool server_uses_stateless_rejects_if_peer_supported,
101 QuicTag congestion_control_tag, 102 QuicTag congestion_control_tag,
102 bool disable_hpack_dynamic_table, 103 bool disable_hpack_dynamic_table,
103 bool force_hol_blocking) 104 bool force_hol_blocking,
105 bool use_cheap_stateless_reject)
104 : client_supported_versions(client_supported_versions), 106 : client_supported_versions(client_supported_versions),
105 server_supported_versions(server_supported_versions), 107 server_supported_versions(server_supported_versions),
106 negotiated_version(negotiated_version), 108 negotiated_version(negotiated_version),
107 client_supports_stateless_rejects(client_supports_stateless_rejects), 109 client_supports_stateless_rejects(client_supports_stateless_rejects),
108 server_uses_stateless_rejects_if_peer_supported( 110 server_uses_stateless_rejects_if_peer_supported(
109 server_uses_stateless_rejects_if_peer_supported), 111 server_uses_stateless_rejects_if_peer_supported),
110 congestion_control_tag(congestion_control_tag), 112 congestion_control_tag(congestion_control_tag),
111 disable_hpack_dynamic_table(disable_hpack_dynamic_table), 113 disable_hpack_dynamic_table(disable_hpack_dynamic_table),
112 force_hol_blocking(force_hol_blocking) {} 114 force_hol_blocking(force_hol_blocking),
115 use_cheap_stateless_reject(use_cheap_stateless_reject) {}
113 116
114 friend ostream& operator<<(ostream& os, const TestParams& p) { 117 friend ostream& operator<<(ostream& os, const TestParams& p) {
115 os << "{ server_supported_versions: " 118 os << "{ server_supported_versions: "
116 << QuicVersionVectorToString(p.server_supported_versions); 119 << QuicVersionVectorToString(p.server_supported_versions);
117 os << " client_supported_versions: " 120 os << " client_supported_versions: "
118 << QuicVersionVectorToString(p.client_supported_versions); 121 << QuicVersionVectorToString(p.client_supported_versions);
119 os << " negotiated_version: " << QuicVersionToString(p.negotiated_version); 122 os << " negotiated_version: " << QuicVersionToString(p.negotiated_version);
120 os << " client_supports_stateless_rejects: " 123 os << " client_supports_stateless_rejects: "
121 << p.client_supports_stateless_rejects; 124 << p.client_supports_stateless_rejects;
122 os << " server_uses_stateless_rejects_if_peer_supported: " 125 os << " server_uses_stateless_rejects_if_peer_supported: "
123 << p.server_uses_stateless_rejects_if_peer_supported; 126 << p.server_uses_stateless_rejects_if_peer_supported;
124 os << " congestion_control_tag: " 127 os << " congestion_control_tag: "
125 << QuicUtils::TagToString(p.congestion_control_tag); 128 << QuicUtils::TagToString(p.congestion_control_tag);
126 os << " disable_hpack_dynamic_table: " << p.disable_hpack_dynamic_table; 129 os << " disable_hpack_dynamic_table: " << p.disable_hpack_dynamic_table;
127 os << " force_hol_blocking: " << p.force_hol_blocking << " }"; 130 os << " force_hol_blocking: " << p.force_hol_blocking;
131 os << " use_cheap_stateless_reject: " << p.use_cheap_stateless_reject
132 << " }";
128 return os; 133 return os;
129 } 134 }
130 135
131 QuicVersionVector client_supported_versions; 136 QuicVersionVector client_supported_versions;
132 QuicVersionVector server_supported_versions; 137 QuicVersionVector server_supported_versions;
133 QuicVersion negotiated_version; 138 QuicVersion negotiated_version;
134 bool client_supports_stateless_rejects; 139 bool client_supports_stateless_rejects;
135 bool server_uses_stateless_rejects_if_peer_supported; 140 bool server_uses_stateless_rejects_if_peer_supported;
136 QuicTag congestion_control_tag; 141 QuicTag congestion_control_tag;
137 bool disable_hpack_dynamic_table; 142 bool disable_hpack_dynamic_table;
138 bool force_hol_blocking; 143 bool force_hol_blocking;
144 bool use_cheap_stateless_reject;
139 }; 145 };
140 146
141 // Constructs various test permutations. 147 // Constructs various test permutations.
142 vector<TestParams> GetTestParams() { 148 vector<TestParams> GetTestParams() {
143 // Divide the versions into buckets in which the intra-frame format 149 // Divide the versions into buckets in which the intra-frame format
144 // is compatible. When clients encounter QUIC version negotiation 150 // is compatible. When clients encounter QUIC version negotiation
145 // they simply retransmit all packets using the new version's 151 // they simply retransmit all packets using the new version's
146 // QUIC framing. However, they are unable to change the intra-frame 152 // QUIC framing. However, they are unable to change the intra-frame
147 // layout (for example to change SPDY/4 headers to SPDY/3). So 153 // layout (for example to change SPDY/4 headers to SPDY/3). So
148 // these tests need to ensure that clients are never attempting 154 // these tests need to ensure that clients are never attempting
(...skipping 18 matching lines...) Expand all
167 } else { 173 } else {
168 // Versions: 34+ 174 // Versions: 34+
169 // QUIC_VERSION_34 deprecates entropy and uses new ack and stop waiting 175 // QUIC_VERSION_34 deprecates entropy and uses new ack and stop waiting
170 // wire formats. 176 // wire formats.
171 version_buckets[3].push_back(version); 177 version_buckets[3].push_back(version);
172 } 178 }
173 } 179 }
174 180
175 // This must be kept in sync with the number of nested for-loops below as it 181 // This must be kept in sync with the number of nested for-loops below as it
176 // is used to prune the number of tests that are run. 182 // is used to prune the number of tests that are run.
177 const int kMaxEnabledOptions = 4; 183 const int kMaxEnabledOptions = 5;
178 int max_enabled_options = 0; 184 int max_enabled_options = 0;
179 vector<TestParams> params; 185 vector<TestParams> params;
180 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { 186 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) {
181 for (bool client_supports_stateless_rejects : {true, false}) { 187 for (bool client_supports_stateless_rejects : {true, false}) {
182 for (const QuicTag congestion_control_tag : {kRENO, kQBIC}) { 188 for (const QuicTag congestion_control_tag : {kRENO, kQBIC}) {
183 for (bool disable_hpack_dynamic_table : {false}) { 189 for (bool disable_hpack_dynamic_table : {false}) {
184 for (bool force_hol_blocking : {true, false}) { 190 for (bool force_hol_blocking : {true, false}) {
185 int enabled_options = 0; 191 for (bool use_cheap_stateless_reject : {true, false}) {
186 if (force_hol_blocking) { 192 int enabled_options = 0;
187 ++enabled_options; 193 if (force_hol_blocking) {
188 } 194 ++enabled_options;
189 if (congestion_control_tag != kQBIC) { 195 }
190 ++enabled_options; 196 if (congestion_control_tag != kQBIC) {
191 } 197 ++enabled_options;
192 if (disable_hpack_dynamic_table) { 198 }
193 ++enabled_options; 199 if (disable_hpack_dynamic_table) {
194 } 200 ++enabled_options;
195 if (client_supports_stateless_rejects) { 201 }
196 ++enabled_options; 202 if (client_supports_stateless_rejects) {
197 } 203 ++enabled_options;
198 if (server_uses_stateless_rejects_if_peer_supported) { 204 }
199 ++enabled_options; 205 if (server_uses_stateless_rejects_if_peer_supported) {
200 } 206 ++enabled_options;
201 CHECK_GE(kMaxEnabledOptions, enabled_options); 207 }
202 if (enabled_options > max_enabled_options) { 208 if (use_cheap_stateless_reject) {
203 max_enabled_options = enabled_options; 209 ++enabled_options;
204 } 210 }
211 CHECK_GE(kMaxEnabledOptions, enabled_options);
212 if (enabled_options > max_enabled_options) {
213 max_enabled_options = enabled_options;
214 }
205 215
206 // Run tests with no options, a single option, or all the options 216 // Run tests with no options, a single option, or all the
207 // enabled to avoid a combinatorial explosion. 217 // options enabled to avoid a combinatorial explosion.
208 if (enabled_options > 1 && enabled_options < kMaxEnabledOptions) { 218 if (enabled_options > 1 && enabled_options < kMaxEnabledOptions) {
209 continue;
210 }
211
212 for (const QuicVersionVector& client_versions : version_buckets) {
213 CHECK(!client_versions.empty());
214 // Add an entry for server and client supporting all versions.
215 params.push_back(TestParams(
216 client_versions, all_supported_versions,
217 client_versions.front(), client_supports_stateless_rejects,
218 server_uses_stateless_rejects_if_peer_supported,
219 congestion_control_tag, disable_hpack_dynamic_table,
220 force_hol_blocking));
221
222 // Run version negotiation tests tests with no options, or all
223 // the options enabled to avoid a combinatorial explosion.
224 if (enabled_options > 0 && enabled_options < kMaxEnabledOptions) {
225 continue; 219 continue;
226 } 220 }
227 221
228 // Test client supporting all versions and server 222 for (const QuicVersionVector& client_versions : version_buckets) {
229 // supporting 1 version. Simulate an old server and 223 CHECK(!client_versions.empty());
230 // exercise version downgrade in the client. Protocol 224 // Add an entry for server and client supporting all versions.
231 // negotiation should occur. Skip the i = 0 case
232 // because it is essentially the same as the default
233 // case.
234 for (size_t i = 1; i < client_versions.size(); ++i) {
235 QuicVersionVector server_supported_versions;
236 server_supported_versions.push_back(client_versions[i]);
237 params.push_back(TestParams( 225 params.push_back(TestParams(
238 client_versions, server_supported_versions, 226 client_versions, all_supported_versions,
239 server_supported_versions.front(), 227 client_versions.front(), client_supports_stateless_rejects,
240 client_supports_stateless_rejects,
241 server_uses_stateless_rejects_if_peer_supported, 228 server_uses_stateless_rejects_if_peer_supported,
242 congestion_control_tag, disable_hpack_dynamic_table, 229 congestion_control_tag, disable_hpack_dynamic_table,
243 force_hol_blocking)); 230 force_hol_blocking, use_cheap_stateless_reject));
244 } 231
245 } 232 // Run version negotiation tests tests with no options, or all
246 } 233 // the options enabled to avoid a combinatorial explosion.
247 } 234 if (enabled_options > 0 &&
248 } 235 enabled_options < kMaxEnabledOptions) {
249 } 236 continue;
237 }
238
239 // Test client supporting all versions and server supporting 1
240 // version. Simulate an old server and exercise version
241 // downgrade in the client. Protocol negotiation should occur.
242 // Skip the i = 0 case because it is essentially the same as
243 // the default case.
244 for (size_t i = 1; i < client_versions.size(); ++i) {
245 QuicVersionVector server_supported_versions;
246 server_supported_versions.push_back(client_versions[i]);
247 params.push_back(TestParams(
248 client_versions, server_supported_versions,
249 server_supported_versions.front(),
250 client_supports_stateless_rejects,
251 server_uses_stateless_rejects_if_peer_supported,
252 congestion_control_tag, disable_hpack_dynamic_table,
253 force_hol_blocking, use_cheap_stateless_reject));
254 } // End of version for loop.
255 } // End of 2nd version for loop.
256 } // End of use_cheap_stateless_reject for loop.
257 } // End of force_hol_blocking loop.
258 } // End of disable_hpack_dynamic_table for loop.
259 } // End of congestion_control_tag for loop.
260 } // End of client_supports_stateless_rejects for loop.
250 CHECK_EQ(kMaxEnabledOptions, max_enabled_options); 261 CHECK_EQ(kMaxEnabledOptions, max_enabled_options);
251 } 262 } // End of server_uses_stateless_rejects_if_peer_supported for loop.
252 return params; 263 return params;
253 } 264 }
254 265
255 class ServerDelegate : public PacketDroppingTestWriter::Delegate { 266 class ServerDelegate : public PacketDroppingTestWriter::Delegate {
256 public: 267 public:
257 explicit ServerDelegate(QuicDispatcher* dispatcher) 268 explicit ServerDelegate(QuicDispatcher* dispatcher)
258 : dispatcher_(dispatcher) {} 269 : dispatcher_(dispatcher) {}
259 ~ServerDelegate() override {} 270 ~ServerDelegate() override {}
260 void OnCanWrite() override { dispatcher_->OnCanWrite(); } 271 void OnCanWrite() override { dispatcher_->OnCanWrite(); }
261 272
(...skipping 13 matching lines...) Expand all
275 private: 286 private:
276 QuicClient* client_; 287 QuicClient* client_;
277 }; 288 };
278 289
279 class EndToEndTest : public ::testing::TestWithParam<TestParams> { 290 class EndToEndTest : public ::testing::TestWithParam<TestParams> {
280 protected: 291 protected:
281 EndToEndTest() 292 EndToEndTest()
282 : initialized_(false), 293 : initialized_(false),
283 server_address_(IPEndPoint(Loopback4(), 0)), 294 server_address_(IPEndPoint(Loopback4(), 0)),
284 server_hostname_("test.example.com"), 295 server_hostname_("test.example.com"),
296 client_writer_(nullptr),
297 server_writer_(nullptr),
285 server_started_(false), 298 server_started_(false),
286 strike_register_no_startup_period_(false), 299 strike_register_no_startup_period_(false),
287 chlo_multiplier_(0), 300 chlo_multiplier_(0),
288 stream_factory_(nullptr), 301 stream_factory_(nullptr),
289 support_server_push_(false) { 302 support_server_push_(false) {
290 client_supported_versions_ = GetParam().client_supported_versions; 303 client_supported_versions_ = GetParam().client_supported_versions;
291 server_supported_versions_ = GetParam().server_supported_versions; 304 server_supported_versions_ = GetParam().server_supported_versions;
292 negotiated_version_ = GetParam().negotiated_version; 305 negotiated_version_ = GetParam().negotiated_version;
293 306
294 VLOG(1) << "Using Configuration: " << GetParam(); 307 VLOG(1) << "Using Configuration: " << GetParam();
(...skipping 20 matching lines...) Expand all
315 AddToCache("/foo", 200, kFooResponseBody); 328 AddToCache("/foo", 200, kFooResponseBody);
316 AddToCache("/bar", 200, kBarResponseBody); 329 AddToCache("/bar", 200, kBarResponseBody);
317 } 330 }
318 331
319 ~EndToEndTest() override { 332 ~EndToEndTest() override {
320 // TODO(rtenneti): port RecycleUnusedPort if needed. 333 // TODO(rtenneti): port RecycleUnusedPort if needed.
321 // RecycleUnusedPort(server_address_.port()); 334 // RecycleUnusedPort(server_address_.port());
322 QuicInMemoryCachePeer::ResetForTests(); 335 QuicInMemoryCachePeer::ResetForTests();
323 } 336 }
324 337
338 virtual void CreateClientWithWriter() {
339 client_.reset(CreateQuicClient(client_writer_));
340 }
341
325 QuicTestClient* CreateQuicClient(QuicPacketWriterWrapper* writer) { 342 QuicTestClient* CreateQuicClient(QuicPacketWriterWrapper* writer) {
326 QuicTestClient* client = new QuicTestClient( 343 QuicTestClient* client = new QuicTestClient(
327 server_address_, server_hostname_, client_config_, 344 server_address_, server_hostname_, client_config_,
328 client_supported_versions_, CryptoTestUtils::ProofVerifierForTesting()); 345 client_supported_versions_, CryptoTestUtils::ProofVerifierForTesting());
329 client->UseWriter(writer); 346 client->UseWriter(writer);
330 client->Connect(); 347 client->Connect();
331 return client; 348 return client;
332 } 349 }
333 350
334 void set_smaller_flow_control_receive_window() { 351 void set_smaller_flow_control_receive_window() {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 if (GetParam().force_hol_blocking) { 412 if (GetParam().force_hol_blocking) {
396 client_config_.SetForceHolBlocking(); 413 client_config_.SetForceHolBlocking();
397 QuicConfigPeer::SetReceivedForceHolBlocking(&server_config_); 414 QuicConfigPeer::SetReceivedForceHolBlocking(&server_config_);
398 } 415 }
399 client_config_.SetConnectionOptionsToSend(copt); 416 client_config_.SetConnectionOptionsToSend(copt);
400 417
401 // Start the server first, because CreateQuicClient() attempts 418 // Start the server first, because CreateQuicClient() attempts
402 // to connect to the server. 419 // to connect to the server.
403 StartServer(); 420 StartServer();
404 421
405 client_.reset(CreateQuicClient(client_writer_)); 422 CreateClientWithWriter();
406 static EpollEvent event(EPOLLOUT, false); 423 static EpollEvent event(EPOLLOUT, false);
407 client_writer_->Initialize( 424 if (client_writer_ != nullptr) {
408 reinterpret_cast<QuicEpollConnectionHelper*>( 425 client_writer_->Initialize(
409 QuicConnectionPeer::GetHelper( 426 reinterpret_cast<QuicEpollConnectionHelper*>(
410 client_->client()->session()->connection())), 427 QuicConnectionPeer::GetHelper(
411 QuicConnectionPeer::GetAlarmFactory( 428 client_->client()->session()->connection())),
412 client_->client()->session()->connection()), 429 QuicConnectionPeer::GetAlarmFactory(
413 new ClientDelegate(client_->client())); 430 client_->client()->session()->connection()),
414 431 new ClientDelegate(client_->client()));
432 }
415 initialized_ = true; 433 initialized_ = true;
416 return client_->client()->connected(); 434 return client_->client()->connected();
417 } 435 }
418 436
419 void SetUp() override { 437 void SetUp() override {
420 // The ownership of these gets transferred to the QuicPacketWriterWrapper 438 // The ownership of these gets transferred to the QuicPacketWriterWrapper
421 // when Initialize() is executed. 439 // when Initialize() is executed.
422 client_writer_ = new PacketDroppingTestWriter(); 440 client_writer_ = new PacketDroppingTestWriter();
423 server_writer_ = new PacketDroppingTestWriter(); 441 server_writer_ = new PacketDroppingTestWriter();
424 } 442 }
425 443
426 void TearDown() override { 444 void TearDown() override {
427 ASSERT_TRUE(initialized_) << "You must call Initialize() in every test " 445 ASSERT_TRUE(initialized_) << "You must call Initialize() in every test "
428 << "case. Otherwise, your test will leak memory."; 446 << "case. Otherwise, your test will leak memory.";
429 StopServer(); 447 StopServer();
430 } 448 }
431 449
432 void StartServer() { 450 void StartServer() {
451 FLAGS_quic_use_cheap_stateless_rejects =
452 GetParam().use_cheap_stateless_reject;
433 server_thread_.reset(new ServerThread( 453 server_thread_.reset(new ServerThread(
434 new QuicTestServer(CryptoTestUtils::ProofSourceForTesting(), 454 new QuicTestServer(CryptoTestUtils::ProofSourceForTesting(),
435 server_config_, server_supported_versions_), 455 server_config_, server_supported_versions_),
436 server_address_, strike_register_no_startup_period_)); 456 server_address_, strike_register_no_startup_period_));
437 if (chlo_multiplier_ != 0) { 457 if (chlo_multiplier_ != 0) {
438 server_thread_->server()->SetChloMultiplier(chlo_multiplier_); 458 server_thread_->server()->SetChloMultiplier(chlo_multiplier_);
439 } 459 }
440 server_thread_->Initialize(); 460 server_thread_->Initialize();
441 server_address_ = 461 server_address_ =
442 IPEndPoint(server_address_.address(), server_thread_->GetPort()); 462 IPEndPoint(server_address_.address(), server_thread_->GetPort());
(...skipping 2337 matching lines...) Expand 10 before | Expand all | Expand 10 after
2780 client_->client()->WaitForCryptoHandshakeConfirmed(); 2800 client_->client()->WaitForCryptoHandshakeConfirmed();
2781 SetPacketLossPercentage(1); 2801 SetPacketLossPercentage(1);
2782 client_->SendRequest("/huge_response"); 2802 client_->SendRequest("/huge_response");
2783 client_->WaitForResponse(); 2803 client_->WaitForResponse();
2784 // TODO(fayang): Fix this test to work with stateless rejects. 2804 // TODO(fayang): Fix this test to work with stateless rejects.
2785 if (!BothSidesSupportStatelessRejects()) { 2805 if (!BothSidesSupportStatelessRejects()) {
2786 VerifyCleanConnection(true); 2806 VerifyCleanConnection(true);
2787 } 2807 }
2788 } 2808 }
2789 2809
2810 class EndToEndBufferedPacketsTest : public EndToEndTest {
2811 public:
2812 EndToEndBufferedPacketsTest() : EndToEndTest() {
2813 FLAGS_quic_buffer_packet_till_chlo = true;
2814 }
2815
2816 void CreateClientWithWriter() override {
2817 LOG(ERROR) << "create client with reorder_writer_ ";
2818 reorder_writer_ = new PacketReorderingWriter();
2819 client_.reset(EndToEndTest::CreateQuicClient(reorder_writer_));
2820 }
2821
2822 void SetUp() override {
2823 // Don't initialize client writer in base class.
2824 server_writer_ = new PacketDroppingTestWriter();
2825 }
2826
2827 protected:
2828 PacketReorderingWriter* reorder_writer_;
2829 };
2830
2831 INSTANTIATE_TEST_CASE_P(EndToEndBufferedPacketsTests,
2832 EndToEndBufferedPacketsTest,
2833 testing::ValuesIn(GetTestParams()));
2834
2835 TEST_P(EndToEndBufferedPacketsTest, Buffer0RttRequest) {
2836 ASSERT_TRUE(Initialize());
2837 if (negotiated_version_ <= QUIC_VERSION_32) {
2838 // Since no 0-rtt for v32 and under, and this test relies on 0-rtt, skip
2839 // this test if QUIC doesn't do 0-rtt.
2840 return;
2841 }
2842 // Finish one request to make sure handshake established.
2843 client_->SendSynchronousRequest("/foo");
2844 // Disconnect for next 0-rtt request.
2845 client_->Disconnect();
2846
2847 // Client get valid STK now. Do a 0-rtt request.
2848 // Buffer a CHLO till another packets sent out.
2849 reorder_writer_->SetDelay(1);
2850 // Only send out a CHLO.
2851 client_->client()->Initialize();
2852 client_->client()->StartConnect();
2853 ASSERT_TRUE(client_->client()->connected());
2854 // Send a request before handshake finishes.
2855 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::GET, "/bar");
2856 client_->SendMessage(request);
2857 client_->WaitForResponse();
2858 EXPECT_EQ(kBarResponseBody, client_->response_body());
2859 QuicConnectionStats client_stats =
2860 client_->client()->session()->connection()->GetStats();
2861 EXPECT_EQ(0u, client_stats.packets_lost);
2862 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos());
2863 }
2864
2790 } // namespace 2865 } // namespace
2791 } // namespace test 2866 } // namespace test
2792 } // namespace net 2867 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/chlo_extractor.cc ('k') | net/tools/quic/quic_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698