OLD | NEW |
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 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | |
11 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
13 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
14 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
15 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
16 #include "base/time/time.h" | 15 #include "base/time/time.h" |
17 #include "net/base/ip_endpoint.h" | 16 #include "net/base/ip_endpoint.h" |
18 #include "net/quic/congestion_control/tcp_cubic_sender.h" | 17 #include "net/quic/congestion_control/tcp_cubic_sender.h" |
19 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" | 18 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" |
20 #include "net/quic/crypto/null_encrypter.h" | 19 #include "net/quic/crypto/null_encrypter.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 QuicTestClient* CreateQuicClient(QuicPacketWriterWrapper* writer) { | 296 QuicTestClient* CreateQuicClient(QuicPacketWriterWrapper* writer) { |
298 QuicTestClient* client = | 297 QuicTestClient* client = |
299 new QuicTestClient(server_address_, server_hostname_, client_config_, | 298 new QuicTestClient(server_address_, server_hostname_, client_config_, |
300 client_supported_versions_); | 299 client_supported_versions_); |
301 client->UseWriter(writer); | 300 client->UseWriter(writer); |
302 client->Connect(); | 301 client->Connect(); |
303 return client; | 302 return client; |
304 } | 303 } |
305 | 304 |
306 void set_smaller_flow_control_receive_window() { | 305 void set_smaller_flow_control_receive_window() { |
307 const uint32 kClientIFCW = 64 * 1024; | 306 const uint32_t kClientIFCW = 64 * 1024; |
308 const uint32 kServerIFCW = 1024 * 1024; | 307 const uint32_t kServerIFCW = 1024 * 1024; |
309 set_client_initial_stream_flow_control_receive_window(kClientIFCW); | 308 set_client_initial_stream_flow_control_receive_window(kClientIFCW); |
310 set_client_initial_session_flow_control_receive_window( | 309 set_client_initial_session_flow_control_receive_window( |
311 kSessionToStreamRatio * kClientIFCW); | 310 kSessionToStreamRatio * kClientIFCW); |
312 set_server_initial_stream_flow_control_receive_window(kServerIFCW); | 311 set_server_initial_stream_flow_control_receive_window(kServerIFCW); |
313 set_server_initial_session_flow_control_receive_window( | 312 set_server_initial_session_flow_control_receive_window( |
314 kSessionToStreamRatio * kServerIFCW); | 313 kSessionToStreamRatio * kServerIFCW); |
315 } | 314 } |
316 | 315 |
317 void set_client_initial_stream_flow_control_receive_window(uint32 window) { | 316 void set_client_initial_stream_flow_control_receive_window(uint32_t window) { |
318 CHECK(client_.get() == nullptr); | 317 CHECK(client_.get() == nullptr); |
319 DVLOG(1) << "Setting client initial stream flow control window: " << window; | 318 DVLOG(1) << "Setting client initial stream flow control window: " << window; |
320 client_config_.SetInitialStreamFlowControlWindowToSend(window); | 319 client_config_.SetInitialStreamFlowControlWindowToSend(window); |
321 } | 320 } |
322 | 321 |
323 void set_client_initial_session_flow_control_receive_window(uint32 window) { | 322 void set_client_initial_session_flow_control_receive_window(uint32_t window) { |
324 CHECK(client_.get() == nullptr); | 323 CHECK(client_.get() == nullptr); |
325 DVLOG(1) << "Setting client initial session flow control window: " | 324 DVLOG(1) << "Setting client initial session flow control window: " |
326 << window; | 325 << window; |
327 client_config_.SetInitialSessionFlowControlWindowToSend(window); | 326 client_config_.SetInitialSessionFlowControlWindowToSend(window); |
328 } | 327 } |
329 | 328 |
330 void set_server_initial_stream_flow_control_receive_window(uint32 window) { | 329 void set_server_initial_stream_flow_control_receive_window(uint32_t window) { |
331 CHECK(server_thread_.get() == nullptr); | 330 CHECK(server_thread_.get() == nullptr); |
332 DVLOG(1) << "Setting server initial stream flow control window: " << window; | 331 DVLOG(1) << "Setting server initial stream flow control window: " << window; |
333 server_config_.SetInitialStreamFlowControlWindowToSend(window); | 332 server_config_.SetInitialStreamFlowControlWindowToSend(window); |
334 } | 333 } |
335 | 334 |
336 void set_server_initial_session_flow_control_receive_window(uint32 window) { | 335 void set_server_initial_session_flow_control_receive_window(uint32_t window) { |
337 CHECK(server_thread_.get() == nullptr); | 336 CHECK(server_thread_.get() == nullptr); |
338 DVLOG(1) << "Setting server initial session flow control window: " | 337 DVLOG(1) << "Setting server initial session flow control window: " |
339 << window; | 338 << window; |
340 server_config_.SetInitialSessionFlowControlWindowToSend(window); | 339 server_config_.SetInitialSessionFlowControlWindowToSend(window); |
341 } | 340 } |
342 | 341 |
343 const QuicSentPacketManager* GetSentPacketManagerFromFirstServerSession() | 342 const QuicSentPacketManager* GetSentPacketManagerFromFirstServerSession() |
344 const { | 343 const { |
345 QuicDispatcher* dispatcher = | 344 QuicDispatcher* dispatcher = |
346 QuicServerPeer::GetDispatcher(server_thread_->server()); | 345 QuicServerPeer::GetDispatcher(server_thread_->server()); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 server_thread_->Quit(); | 439 server_thread_->Quit(); |
441 server_thread_->Join(); | 440 server_thread_->Join(); |
442 } | 441 } |
443 } | 442 } |
444 | 443 |
445 void AddToCache(StringPiece path, int response_code, StringPiece body) { | 444 void AddToCache(StringPiece path, int response_code, StringPiece body) { |
446 QuicInMemoryCache::GetInstance()->AddSimpleResponse("www.google.com", path, | 445 QuicInMemoryCache::GetInstance()->AddSimpleResponse("www.google.com", path, |
447 response_code, body); | 446 response_code, body); |
448 } | 447 } |
449 | 448 |
450 void SetPacketLossPercentage(int32 loss) { | 449 void SetPacketLossPercentage(int32_t loss) { |
451 // TODO(rtenneti): enable when we can do random packet loss tests in | 450 // TODO(rtenneti): enable when we can do random packet loss tests in |
452 // chrome's tree. | 451 // chrome's tree. |
453 if (loss != 0 && loss != 100) | 452 if (loss != 0 && loss != 100) |
454 return; | 453 return; |
455 client_writer_->set_fake_packet_loss_percentage(loss); | 454 client_writer_->set_fake_packet_loss_percentage(loss); |
456 server_writer_->set_fake_packet_loss_percentage(loss); | 455 server_writer_->set_fake_packet_loss_percentage(loss); |
457 } | 456 } |
458 | 457 |
459 void SetPacketSendDelay(QuicTime::Delta delay) { | 458 void SetPacketSendDelay(QuicTime::Delta delay) { |
460 // TODO(rtenneti): enable when we can do random packet send delay tests in | 459 // TODO(rtenneti): enable when we can do random packet send delay tests in |
461 // chrome's tree. | 460 // chrome's tree. |
462 // client_writer_->set_fake_packet_delay(delay); | 461 // client_writer_->set_fake_packet_delay(delay); |
463 // server_writer_->set_fake_packet_delay(delay); | 462 // server_writer_->set_fake_packet_delay(delay); |
464 } | 463 } |
465 | 464 |
466 void SetReorderPercentage(int32 reorder) { | 465 void SetReorderPercentage(int32_t reorder) { |
467 // TODO(rtenneti): enable when we can do random packet reorder tests in | 466 // TODO(rtenneti): enable when we can do random packet reorder tests in |
468 // chrome's tree. | 467 // chrome's tree. |
469 // client_writer_->set_fake_reorder_percentage(reorder); | 468 // client_writer_->set_fake_reorder_percentage(reorder); |
470 // server_writer_->set_fake_reorder_percentage(reorder); | 469 // server_writer_->set_fake_reorder_percentage(reorder); |
471 } | 470 } |
472 | 471 |
473 // Verifies that the client and server connections were both free of packets | 472 // Verifies that the client and server connections were both free of packets |
474 // being discarded, based on connection stats. | 473 // being discarded, based on connection stats. |
475 // Calls server_thread_ Pause() and Resume(), which may only be called once | 474 // Calls server_thread_ Pause() and Resume(), which may only be called once |
476 // per test. | 475 // per test. |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 // Regression test for b/14677858. | 1032 // Regression test for b/14677858. |
1034 // Test that the resume write alarm is not set in QuicConnection::OnCanWrite | 1033 // Test that the resume write alarm is not set in QuicConnection::OnCanWrite |
1035 // if currently connection level flow control blocked. If set, this results in | 1034 // if currently connection level flow control blocked. If set, this results in |
1036 // an infinite loop in the EpollServer, as the alarm fires and is immediately | 1035 // an infinite loop in the EpollServer, as the alarm fires and is immediately |
1037 // rescheduled. | 1036 // rescheduled. |
1038 ASSERT_TRUE(Initialize()); | 1037 ASSERT_TRUE(Initialize()); |
1039 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1038 client_->client()->WaitForCryptoHandshakeConfirmed(); |
1040 | 1039 |
1041 // Ensure both stream and connection level are flow control blocked by setting | 1040 // Ensure both stream and connection level are flow control blocked by setting |
1042 // the send window offset to 0. | 1041 // the send window offset to 0. |
1043 const uint64 flow_control_window = | 1042 const uint64_t flow_control_window = |
1044 server_config_.GetInitialStreamFlowControlWindowToSend(); | 1043 server_config_.GetInitialStreamFlowControlWindowToSend(); |
1045 QuicSpdyClientStream* stream = client_->GetOrCreateStream(); | 1044 QuicSpdyClientStream* stream = client_->GetOrCreateStream(); |
1046 QuicSession* session = client_->client()->session(); | 1045 QuicSession* session = client_->client()->session(); |
1047 QuicFlowControllerPeer::SetSendWindowOffset(stream->flow_controller(), 0); | 1046 QuicFlowControllerPeer::SetSendWindowOffset(stream->flow_controller(), 0); |
1048 QuicFlowControllerPeer::SetSendWindowOffset(session->flow_controller(), 0); | 1047 QuicFlowControllerPeer::SetSendWindowOffset(session->flow_controller(), 0); |
1049 EXPECT_TRUE(stream->flow_controller()->IsBlocked()); | 1048 EXPECT_TRUE(stream->flow_controller()->IsBlocked()); |
1050 EXPECT_TRUE(session->flow_controller()->IsBlocked()); | 1049 EXPECT_TRUE(session->flow_controller()->IsBlocked()); |
1051 | 1050 |
1052 // Make sure that the stream has data pending so that it will be marked as | 1051 // Make sure that the stream has data pending so that it will be marked as |
1053 // write blocked when it receives a stream level WINDOW_UPDATE. | 1052 // write blocked when it receives a stream level WINDOW_UPDATE. |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 client_config_.SetMaxStreamsPerConnection(10, 5); | 1213 client_config_.SetMaxStreamsPerConnection(10, 5); |
1215 | 1214 |
1216 ASSERT_TRUE(Initialize()); | 1215 ASSERT_TRUE(Initialize()); |
1217 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1216 client_->client()->WaitForCryptoHandshakeConfirmed(); |
1218 QuicConfig* client_negotiated_config = client_->client()->session()->config(); | 1217 QuicConfig* client_negotiated_config = client_->client()->session()->config(); |
1219 EXPECT_EQ(2u, client_negotiated_config->MaxStreamsPerConnection()); | 1218 EXPECT_EQ(2u, client_negotiated_config->MaxStreamsPerConnection()); |
1220 } | 1219 } |
1221 | 1220 |
1222 TEST_P(EndToEndTest, ClientSuggestsRTT) { | 1221 TEST_P(EndToEndTest, ClientSuggestsRTT) { |
1223 // Client suggests initial RTT, verify it is used. | 1222 // Client suggests initial RTT, verify it is used. |
1224 const uint32 kInitialRTT = 20000; | 1223 const uint32_t kInitialRTT = 20000; |
1225 client_config_.SetInitialRoundTripTimeUsToSend(kInitialRTT); | 1224 client_config_.SetInitialRoundTripTimeUsToSend(kInitialRTT); |
1226 | 1225 |
1227 ASSERT_TRUE(Initialize()); | 1226 ASSERT_TRUE(Initialize()); |
1228 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1227 client_->client()->WaitForCryptoHandshakeConfirmed(); |
1229 server_thread_->WaitForCryptoHandshakeConfirmed(); | 1228 server_thread_->WaitForCryptoHandshakeConfirmed(); |
1230 | 1229 |
1231 // Pause the server so we can access the server's internals without races. | 1230 // Pause the server so we can access the server's internals without races. |
1232 server_thread_->Pause(); | 1231 server_thread_->Pause(); |
1233 QuicDispatcher* dispatcher = | 1232 QuicDispatcher* dispatcher = |
1234 QuicServerPeer::GetDispatcher(server_thread_->server()); | 1233 QuicServerPeer::GetDispatcher(server_thread_->server()); |
(...skipping 28 matching lines...) Expand all Loading... |
1263 QuicSession* session = dispatcher->session_map().begin()->second; | 1262 QuicSession* session = dispatcher->session_map().begin()->second; |
1264 const QuicSentPacketManager& client_sent_packet_manager = | 1263 const QuicSentPacketManager& client_sent_packet_manager = |
1265 client_->client()->session()->connection()->sent_packet_manager(); | 1264 client_->client()->session()->connection()->sent_packet_manager(); |
1266 | 1265 |
1267 // Now that acks have been exchanged, the RTT estimate has decreased on the | 1266 // Now that acks have been exchanged, the RTT estimate has decreased on the |
1268 // server and is not infinite on the client. | 1267 // server and is not infinite on the client. |
1269 EXPECT_FALSE( | 1268 EXPECT_FALSE( |
1270 client_sent_packet_manager.GetRttStats()->smoothed_rtt().IsInfinite()); | 1269 client_sent_packet_manager.GetRttStats()->smoothed_rtt().IsInfinite()); |
1271 const RttStats& server_rtt_stats = | 1270 const RttStats& server_rtt_stats = |
1272 *session->connection()->sent_packet_manager().GetRttStats(); | 1271 *session->connection()->sent_packet_manager().GetRttStats(); |
1273 EXPECT_EQ(static_cast<int64>(kMaxInitialRoundTripTimeUs), | 1272 EXPECT_EQ(static_cast<int64_t>(kMaxInitialRoundTripTimeUs), |
1274 server_rtt_stats.initial_rtt_us()); | 1273 server_rtt_stats.initial_rtt_us()); |
1275 EXPECT_GE(static_cast<int64>(kMaxInitialRoundTripTimeUs), | 1274 EXPECT_GE(static_cast<int64_t>(kMaxInitialRoundTripTimeUs), |
1276 server_rtt_stats.smoothed_rtt().ToMicroseconds()); | 1275 server_rtt_stats.smoothed_rtt().ToMicroseconds()); |
1277 server_thread_->Resume(); | 1276 server_thread_->Resume(); |
1278 } | 1277 } |
1279 | 1278 |
1280 TEST_P(EndToEndTest, MinInitialRTT) { | 1279 TEST_P(EndToEndTest, MinInitialRTT) { |
1281 // Client tries to suggest 0 and the server uses the default. | 1280 // Client tries to suggest 0 and the server uses the default. |
1282 client_config_.SetInitialRoundTripTimeUsToSend(0); | 1281 client_config_.SetInitialRoundTripTimeUsToSend(0); |
1283 | 1282 |
1284 ASSERT_TRUE(Initialize()); | 1283 ASSERT_TRUE(Initialize()); |
1285 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1284 client_->client()->WaitForCryptoHandshakeConfirmed(); |
1286 server_thread_->WaitForCryptoHandshakeConfirmed(); | 1285 server_thread_->WaitForCryptoHandshakeConfirmed(); |
1287 | 1286 |
1288 // Pause the server so we can access the server's internals without races. | 1287 // Pause the server so we can access the server's internals without races. |
1289 server_thread_->Pause(); | 1288 server_thread_->Pause(); |
1290 QuicDispatcher* dispatcher = | 1289 QuicDispatcher* dispatcher = |
1291 QuicServerPeer::GetDispatcher(server_thread_->server()); | 1290 QuicServerPeer::GetDispatcher(server_thread_->server()); |
1292 ASSERT_EQ(1u, dispatcher->session_map().size()); | 1291 ASSERT_EQ(1u, dispatcher->session_map().size()); |
1293 QuicSession* session = dispatcher->session_map().begin()->second; | 1292 QuicSession* session = dispatcher->session_map().begin()->second; |
1294 const QuicSentPacketManager& client_sent_packet_manager = | 1293 const QuicSentPacketManager& client_sent_packet_manager = |
1295 client_->client()->session()->connection()->sent_packet_manager(); | 1294 client_->client()->session()->connection()->sent_packet_manager(); |
1296 const QuicSentPacketManager& server_sent_packet_manager = | 1295 const QuicSentPacketManager& server_sent_packet_manager = |
1297 session->connection()->sent_packet_manager(); | 1296 session->connection()->sent_packet_manager(); |
1298 | 1297 |
1299 // Now that acks have been exchanged, the RTT estimate has decreased on the | 1298 // Now that acks have been exchanged, the RTT estimate has decreased on the |
1300 // server and is not infinite on the client. | 1299 // server and is not infinite on the client. |
1301 EXPECT_FALSE( | 1300 EXPECT_FALSE( |
1302 client_sent_packet_manager.GetRttStats()->smoothed_rtt().IsInfinite()); | 1301 client_sent_packet_manager.GetRttStats()->smoothed_rtt().IsInfinite()); |
1303 // Expect the default rtt of 100ms. | 1302 // Expect the default rtt of 100ms. |
1304 EXPECT_EQ(static_cast<int64>(100 * kNumMicrosPerMilli), | 1303 EXPECT_EQ(static_cast<int64_t>(100 * kNumMicrosPerMilli), |
1305 server_sent_packet_manager.GetRttStats()->initial_rtt_us()); | 1304 server_sent_packet_manager.GetRttStats()->initial_rtt_us()); |
1306 // Ensure the bandwidth is valid. | 1305 // Ensure the bandwidth is valid. |
1307 client_sent_packet_manager.BandwidthEstimate(); | 1306 client_sent_packet_manager.BandwidthEstimate(); |
1308 server_sent_packet_manager.BandwidthEstimate(); | 1307 server_sent_packet_manager.BandwidthEstimate(); |
1309 server_thread_->Resume(); | 1308 server_thread_->Resume(); |
1310 } | 1309 } |
1311 | 1310 |
1312 TEST_P(EndToEndTest, 0ByteConnectionId) { | 1311 TEST_P(EndToEndTest, 0ByteConnectionId) { |
1313 client_config_.SetBytesForConnectionIdToSend(0); | 1312 client_config_.SetBytesForConnectionIdToSend(0); |
1314 ASSERT_TRUE(Initialize()); | 1313 ASSERT_TRUE(Initialize()); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 // Verify that the client's ephemeral port is different. | 1527 // Verify that the client's ephemeral port is different. |
1529 IPEndPoint new_address = client_->client()->client_address(); | 1528 IPEndPoint new_address = client_->client()->client_address(); |
1530 EXPECT_EQ(old_address.address(), new_address.address()); | 1529 EXPECT_EQ(old_address.address(), new_address.address()); |
1531 EXPECT_NE(old_address.port(), new_address.port()); | 1530 EXPECT_NE(old_address.port(), new_address.port()); |
1532 } | 1531 } |
1533 | 1532 |
1534 TEST_P(EndToEndTest, DifferentFlowControlWindows) { | 1533 TEST_P(EndToEndTest, DifferentFlowControlWindows) { |
1535 // Client and server can set different initial flow control receive windows. | 1534 // Client and server can set different initial flow control receive windows. |
1536 // These are sent in CHLO/SHLO. Tests that these values are exchanged properly | 1535 // These are sent in CHLO/SHLO. Tests that these values are exchanged properly |
1537 // in the crypto handshake. | 1536 // in the crypto handshake. |
1538 const uint32 kClientStreamIFCW = 123456; | 1537 const uint32_t kClientStreamIFCW = 123456; |
1539 const uint32 kClientSessionIFCW = 234567; | 1538 const uint32_t kClientSessionIFCW = 234567; |
1540 set_client_initial_stream_flow_control_receive_window(kClientStreamIFCW); | 1539 set_client_initial_stream_flow_control_receive_window(kClientStreamIFCW); |
1541 set_client_initial_session_flow_control_receive_window(kClientSessionIFCW); | 1540 set_client_initial_session_flow_control_receive_window(kClientSessionIFCW); |
1542 | 1541 |
1543 uint32 kServerStreamIFCW = | 1542 uint32_t kServerStreamIFCW = |
1544 GetParam().auto_tune_flow_control_window ? 32 * 1024 : 654321; | 1543 GetParam().auto_tune_flow_control_window ? 32 * 1024 : 654321; |
1545 uint32 kServerSessionIFCW = | 1544 uint32_t kServerSessionIFCW = |
1546 GetParam().auto_tune_flow_control_window ? 48 * 1024 : 765432; | 1545 GetParam().auto_tune_flow_control_window ? 48 * 1024 : 765432; |
1547 set_server_initial_stream_flow_control_receive_window(kServerStreamIFCW); | 1546 set_server_initial_stream_flow_control_receive_window(kServerStreamIFCW); |
1548 set_server_initial_session_flow_control_receive_window(kServerSessionIFCW); | 1547 set_server_initial_session_flow_control_receive_window(kServerSessionIFCW); |
1549 | 1548 |
1550 ASSERT_TRUE(Initialize()); | 1549 ASSERT_TRUE(Initialize()); |
1551 | 1550 |
1552 // Values are exchanged during crypto handshake, so wait for that to finish. | 1551 // Values are exchanged during crypto handshake, so wait for that to finish. |
1553 client_->client()->WaitForCryptoHandshakeConfirmed(); | 1552 client_->client()->WaitForCryptoHandshakeConfirmed(); |
1554 server_thread_->WaitForCryptoHandshakeConfirmed(); | 1553 server_thread_->WaitForCryptoHandshakeConfirmed(); |
1555 | 1554 |
(...skipping 28 matching lines...) Expand all Loading... |
1584 EXPECT_EQ(kClientSessionIFCW, | 1583 EXPECT_EQ(kClientSessionIFCW, |
1585 session->config()->ReceivedInitialSessionFlowControlWindowBytes()); | 1584 session->config()->ReceivedInitialSessionFlowControlWindowBytes()); |
1586 EXPECT_EQ(kClientSessionIFCW, QuicFlowControllerPeer::SendWindowOffset( | 1585 EXPECT_EQ(kClientSessionIFCW, QuicFlowControllerPeer::SendWindowOffset( |
1587 session->flow_controller())); | 1586 session->flow_controller())); |
1588 server_thread_->Resume(); | 1587 server_thread_->Resume(); |
1589 } | 1588 } |
1590 | 1589 |
1591 TEST_P(EndToEndTest, HeadersAndCryptoStreamsNoConnectionFlowControl) { | 1590 TEST_P(EndToEndTest, HeadersAndCryptoStreamsNoConnectionFlowControl) { |
1592 // The special headers and crypto streams should be subject to per-stream flow | 1591 // The special headers and crypto streams should be subject to per-stream flow |
1593 // control limits, but should not be subject to connection level flow control. | 1592 // control limits, but should not be subject to connection level flow control. |
1594 const uint32 kStreamIFCW = | 1593 const uint32_t kStreamIFCW = |
1595 GetParam().auto_tune_flow_control_window ? 32 * 1024 : 123456; | 1594 GetParam().auto_tune_flow_control_window ? 32 * 1024 : 123456; |
1596 const uint32 kSessionIFCW = | 1595 const uint32_t kSessionIFCW = |
1597 GetParam().auto_tune_flow_control_window ? 48 * 1024 : 234567; | 1596 GetParam().auto_tune_flow_control_window ? 48 * 1024 : 234567; |
1598 set_client_initial_stream_flow_control_receive_window(kStreamIFCW); | 1597 set_client_initial_stream_flow_control_receive_window(kStreamIFCW); |
1599 set_client_initial_session_flow_control_receive_window(kSessionIFCW); | 1598 set_client_initial_session_flow_control_receive_window(kSessionIFCW); |
1600 set_server_initial_stream_flow_control_receive_window(kStreamIFCW); | 1599 set_server_initial_stream_flow_control_receive_window(kStreamIFCW); |
1601 set_server_initial_session_flow_control_receive_window(kSessionIFCW); | 1600 set_server_initial_session_flow_control_receive_window(kSessionIFCW); |
1602 | 1601 |
1603 ASSERT_TRUE(Initialize()); | 1602 ASSERT_TRUE(Initialize()); |
1604 | 1603 |
1605 // Wait for crypto handshake to finish. This should have contributed to the | 1604 // Wait for crypto handshake to finish. This should have contributed to the |
1606 // crypto stream flow control window, but not affected the session flow | 1605 // crypto stream flow control window, but not affected the session flow |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2013 // locally_close_streams_highest_offset_ (which will never be deleted). | 2012 // locally_close_streams_highest_offset_ (which will never be deleted). |
2014 // To set up the test condition, the server must do the following in order: | 2013 // To set up the test condition, the server must do the following in order: |
2015 // start sending the response and call CloseReadSide | 2014 // start sending the response and call CloseReadSide |
2016 // receive the FIN of the request | 2015 // receive the FIN of the request |
2017 // send the FIN of the response | 2016 // send the FIN of the response |
2018 | 2017 |
2019 string response_body; | 2018 string response_body; |
2020 // The response body must be larger than the flow control window so the server | 2019 // The response body must be larger than the flow control window so the server |
2021 // must receive a window update from the client before it can finish sending | 2020 // must receive a window update from the client before it can finish sending |
2022 // it. | 2021 // it. |
2023 uint32 response_body_size = | 2022 uint32_t response_body_size = |
2024 2 * client_config_.GetInitialStreamFlowControlWindowToSend(); | 2023 2 * client_config_.GetInitialStreamFlowControlWindowToSend(); |
2025 GenerateBody(&response_body, response_body_size); | 2024 GenerateBody(&response_body, response_body_size); |
2026 | 2025 |
2027 StreamWithErrorFactory stream_factory(response_body); | 2026 StreamWithErrorFactory stream_factory(response_body); |
2028 SetSpdyStreamFactory(&stream_factory); | 2027 SetSpdyStreamFactory(&stream_factory); |
2029 | 2028 |
2030 ASSERT_TRUE(Initialize()); | 2029 ASSERT_TRUE(Initialize()); |
2031 | 2030 |
2032 client_->client()->WaitForCryptoHandshakeConfirmed(); | 2031 client_->client()->WaitForCryptoHandshakeConfirmed(); |
2033 | 2032 |
2034 // A POST that gets an early error response, after the headers are received | 2033 // A POST that gets an early error response, after the headers are received |
2035 // and before the body is received, due to invalid content-length. | 2034 // and before the body is received, due to invalid content-length. |
2036 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/garbage"); | 2035 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/garbage"); |
2037 // The body must be large enough that the FIN will be in a different packet | 2036 // The body must be large enough that the FIN will be in a different packet |
2038 // than the end of the headers, but short enough to not require a flow control | 2037 // than the end of the headers, but short enough to not require a flow control |
2039 // update. This allows headers processing to trigger the error response | 2038 // update. This allows headers processing to trigger the error response |
2040 // before the request FIN is processed but receive the request FIN before the | 2039 // before the request FIN is processed but receive the request FIN before the |
2041 // response is sent completely. | 2040 // response is sent completely. |
2042 const uint32 kRequestBodySize = kMaxPacketSize + 10; | 2041 const uint32_t kRequestBodySize = kMaxPacketSize + 10; |
2043 string request_body; | 2042 string request_body; |
2044 GenerateBody(&request_body, kRequestBodySize); | 2043 GenerateBody(&request_body, kRequestBodySize); |
2045 request.AddBody(request_body, false); | 2044 request.AddBody(request_body, false); |
2046 // Set an invalid content-length, so the request will receive an early 500 | 2045 // Set an invalid content-length, so the request will receive an early 500 |
2047 // response. Must be done after AddBody, which also sets content-length. | 2046 // response. Must be done after AddBody, which also sets content-length. |
2048 request.AddHeader("content-length", "-1"); | 2047 request.AddHeader("content-length", "-1"); |
2049 request.set_skip_message_validation(true); | 2048 request.set_skip_message_validation(true); |
2050 | 2049 |
2051 // Send the request. | 2050 // Send the request. |
2052 client_->SendMessage(request); | 2051 client_->SendMessage(request); |
(...skipping 13 matching lines...) Expand all Loading... |
2066 | 2065 |
2067 // The stream is not waiting for the arrival of the peer's final offset. | 2066 // The stream is not waiting for the arrival of the peer's final offset. |
2068 EXPECT_EQ( | 2067 EXPECT_EQ( |
2069 0u, QuicSessionPeer::GetLocallyClosedStreamsHighestOffset(server_session) | 2068 0u, QuicSessionPeer::GetLocallyClosedStreamsHighestOffset(server_session) |
2070 .size()); | 2069 .size()); |
2071 | 2070 |
2072 server_thread_->Resume(); | 2071 server_thread_->Resume(); |
2073 } | 2072 } |
2074 | 2073 |
2075 TEST_P(EndToEndTest, LargePostEarlyResponse) { | 2074 TEST_P(EndToEndTest, LargePostEarlyResponse) { |
2076 const uint32 kWindowSize = 65536; | 2075 const uint32_t kWindowSize = 65536; |
2077 set_client_initial_stream_flow_control_receive_window(kWindowSize); | 2076 set_client_initial_stream_flow_control_receive_window(kWindowSize); |
2078 set_client_initial_session_flow_control_receive_window(kWindowSize); | 2077 set_client_initial_session_flow_control_receive_window(kWindowSize); |
2079 set_server_initial_stream_flow_control_receive_window(kWindowSize); | 2078 set_server_initial_stream_flow_control_receive_window(kWindowSize); |
2080 set_server_initial_session_flow_control_receive_window(kWindowSize); | 2079 set_server_initial_session_flow_control_receive_window(kWindowSize); |
2081 | 2080 |
2082 ASSERT_TRUE(Initialize()); | 2081 ASSERT_TRUE(Initialize()); |
2083 | 2082 |
2084 client_->client()->WaitForCryptoHandshakeConfirmed(); | 2083 client_->client()->WaitForCryptoHandshakeConfirmed(); |
2085 | 2084 |
2086 // POST to a URL that gets an early error response, after the headers are | 2085 // POST to a URL that gets an early error response, after the headers are |
2087 // received and before the body is received. | 2086 // received and before the body is received. |
2088 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/garbage"); | 2087 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/garbage"); |
2089 const uint32 kBodySize = 2 * kWindowSize; | 2088 const uint32_t kBodySize = 2 * kWindowSize; |
2090 // Invalid content-length so the request will receive an early 500 response. | 2089 // Invalid content-length so the request will receive an early 500 response. |
2091 request.AddHeader("content-length", "-1"); | 2090 request.AddHeader("content-length", "-1"); |
2092 request.set_skip_message_validation(true); | 2091 request.set_skip_message_validation(true); |
2093 request.set_has_complete_message(false); | 2092 request.set_has_complete_message(false); |
2094 | 2093 |
2095 // Tell the client to not close the stream if it receives an early response. | 2094 // Tell the client to not close the stream if it receives an early response. |
2096 client_->set_allow_bidirectional_data(true); | 2095 client_->set_allow_bidirectional_data(true); |
2097 // Send the headers. | 2096 // Send the headers. |
2098 client_->SendMessage(request); | 2097 client_->SendMessage(request); |
2099 // Receive the response and let the server close writing. | 2098 // Receive the response and let the server close writing. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2150 | 2149 |
2151 EXPECT_EQ(kBody, client_->SendSynchronousRequest("/trailer_url")); | 2150 EXPECT_EQ(kBody, client_->SendSynchronousRequest("/trailer_url")); |
2152 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 2151 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
2153 EXPECT_EQ(trailers, client_->response_trailers()); | 2152 EXPECT_EQ(trailers, client_->response_trailers()); |
2154 } | 2153 } |
2155 | 2154 |
2156 } // namespace | 2155 } // namespace |
2157 } // namespace test | 2156 } // namespace test |
2158 } // namespace tools | 2157 } // namespace tools |
2159 } // namespace net | 2158 } // namespace net |
OLD | NEW |