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 <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/test_tools/quic_connection_peer.h" | 26 #include "net/quic/test_tools/quic_connection_peer.h" |
| 27 #include "net/quic/test_tools/quic_flow_controller_peer.h" |
27 #include "net/quic/test_tools/quic_session_peer.h" | 28 #include "net/quic/test_tools/quic_session_peer.h" |
28 #include "net/quic/test_tools/quic_test_utils.h" | 29 #include "net/quic/test_tools/quic_test_utils.h" |
29 #include "net/quic/test_tools/reliable_quic_stream_peer.h" | 30 #include "net/quic/test_tools/reliable_quic_stream_peer.h" |
30 #include "net/test/gtest_util.h" | 31 #include "net/test/gtest_util.h" |
31 #include "net/tools/epoll_server/epoll_server.h" | 32 #include "net/tools/epoll_server/epoll_server.h" |
32 #include "net/tools/quic/quic_epoll_connection_helper.h" | 33 #include "net/tools/quic/quic_epoll_connection_helper.h" |
33 #include "net/tools/quic/quic_in_memory_cache.h" | 34 #include "net/tools/quic/quic_in_memory_cache.h" |
34 #include "net/tools/quic/quic_packet_writer_wrapper.h" | 35 #include "net/tools/quic/quic_packet_writer_wrapper.h" |
35 #include "net/tools/quic/quic_server.h" | 36 #include "net/tools/quic/quic_server.h" |
36 #include "net/tools/quic/quic_socket_utils.h" | 37 #include "net/tools/quic/quic_socket_utils.h" |
37 #include "net/tools/quic/quic_spdy_client_stream.h" | 38 #include "net/tools/quic/quic_spdy_client_stream.h" |
38 #include "net/tools/quic/test_tools/http_message.h" | 39 #include "net/tools/quic/test_tools/http_message.h" |
39 #include "net/tools/quic/test_tools/packet_dropping_test_writer.h" | 40 #include "net/tools/quic/test_tools/packet_dropping_test_writer.h" |
40 #include "net/tools/quic/test_tools/quic_client_peer.h" | 41 #include "net/tools/quic/test_tools/quic_client_peer.h" |
41 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h" | 42 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h" |
42 #include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h" | 43 #include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h" |
43 #include "net/tools/quic/test_tools/quic_server_peer.h" | 44 #include "net/tools/quic/test_tools/quic_server_peer.h" |
44 #include "net/tools/quic/test_tools/quic_test_client.h" | 45 #include "net/tools/quic/test_tools/quic_test_client.h" |
45 #include "net/tools/quic/test_tools/server_thread.h" | 46 #include "net/tools/quic/test_tools/server_thread.h" |
46 #include "testing/gtest/include/gtest/gtest.h" | 47 #include "testing/gtest/include/gtest/gtest.h" |
47 | 48 |
48 using base::StringPiece; | 49 using base::StringPiece; |
49 using base::WaitableEvent; | 50 using base::WaitableEvent; |
50 using net::EpollServer; | 51 using net::EpollServer; |
51 using net::test::GenerateBody; | 52 using net::test::GenerateBody; |
52 using net::test::QuicConnectionPeer; | 53 using net::test::QuicConnectionPeer; |
| 54 using net::test::QuicFlowControllerPeer; |
53 using net::test::QuicSessionPeer; | 55 using net::test::QuicSessionPeer; |
54 using net::test::ReliableQuicStreamPeer; | 56 using net::test::ReliableQuicStreamPeer; |
| 57 using net::test::ValueRestore; |
55 using net::test::kClientDataStreamId1; | 58 using net::test::kClientDataStreamId1; |
56 using net::tools::test::PacketDroppingTestWriter; | 59 using net::tools::test::PacketDroppingTestWriter; |
57 using net::tools::test::QuicDispatcherPeer; | 60 using net::tools::test::QuicDispatcherPeer; |
58 using net::tools::test::QuicServerPeer; | 61 using net::tools::test::QuicServerPeer; |
59 using std::ostream; | 62 using std::ostream; |
60 using std::string; | 63 using std::string; |
61 using std::vector; | 64 using std::vector; |
62 | 65 |
63 namespace net { | 66 namespace net { |
64 namespace tools { | 67 namespace tools { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } | 174 } |
172 if (negotiated_version_ >= QUIC_VERSION_19) { | 175 if (negotiated_version_ >= QUIC_VERSION_19) { |
173 FLAGS_enable_quic_connection_flow_control = true; | 176 FLAGS_enable_quic_connection_flow_control = true; |
174 } | 177 } |
175 VLOG(1) << "Using Configuration: " << GetParam(); | 178 VLOG(1) << "Using Configuration: " << GetParam(); |
176 | 179 |
177 client_config_.SetDefaults(); | 180 client_config_.SetDefaults(); |
178 server_config_.SetDefaults(); | 181 server_config_.SetDefaults(); |
179 | 182 |
180 // Use different flow control windows for client/server. | 183 // Use different flow control windows for client/server. |
181 client_initial_flow_control_receive_window_ = | 184 client_config_.SetInitialFlowControlWindowToSend( |
182 2 * kInitialFlowControlWindowForTest; | 185 2 * kInitialFlowControlWindowForTest); |
183 server_initial_flow_control_receive_window_ = | 186 server_config_.SetInitialFlowControlWindowToSend( |
184 3 * kInitialFlowControlWindowForTest; | 187 3 * kInitialFlowControlWindowForTest); |
185 | 188 |
186 QuicInMemoryCachePeer::ResetForTests(); | 189 QuicInMemoryCachePeer::ResetForTests(); |
187 AddToCache("GET", "https://www.google.com/foo", | 190 AddToCache("GET", "https://www.google.com/foo", |
188 "HTTP/1.1", "200", "OK", kFooResponseBody); | 191 "HTTP/1.1", "200", "OK", kFooResponseBody); |
189 AddToCache("GET", "https://www.google.com/bar", | 192 AddToCache("GET", "https://www.google.com/bar", |
190 "HTTP/1.1", "200", "OK", kBarResponseBody); | 193 "HTTP/1.1", "200", "OK", kBarResponseBody); |
191 } | 194 } |
192 | 195 |
193 virtual ~EndToEndTest() { | 196 virtual ~EndToEndTest() { |
194 // TODO(rtenneti): port RecycleUnusedPort if needed. | 197 // TODO(rtenneti): port RecycleUnusedPort if needed. |
195 // RecycleUnusedPort(server_address_.port()); | 198 // RecycleUnusedPort(server_address_.port()); |
196 QuicInMemoryCachePeer::ResetForTests(); | 199 QuicInMemoryCachePeer::ResetForTests(); |
197 } | 200 } |
198 | 201 |
199 QuicTestClient* CreateQuicClient(QuicPacketWriterWrapper* writer) { | 202 QuicTestClient* CreateQuicClient(QuicPacketWriterWrapper* writer) { |
200 QuicTestClient* client = new QuicTestClient( | 203 QuicTestClient* client = new QuicTestClient( |
201 server_address_, | 204 server_address_, |
202 server_hostname_, | 205 server_hostname_, |
203 false, // not secure | 206 false, // not secure |
204 client_config_, | 207 client_config_, |
205 client_supported_versions_, | 208 client_supported_versions_); |
206 client_initial_flow_control_receive_window_); | |
207 client->UseWriter(writer); | 209 client->UseWriter(writer); |
208 client->Connect(); | 210 client->Connect(); |
209 return client; | 211 return client; |
210 } | 212 } |
211 | 213 |
212 void set_client_initial_flow_control_receive_window(uint32 window) { | 214 void set_client_initial_flow_control_receive_window(uint32 window) { |
213 CHECK(client_.get() == NULL); | 215 CHECK(client_.get() == NULL); |
214 DVLOG(1) << "Setting client initial flow control window: " << window; | 216 DVLOG(1) << "Setting client initial flow control window: " << window; |
215 client_initial_flow_control_receive_window_ = window; | 217 client_config_.SetInitialFlowControlWindowToSend(window); |
216 } | 218 } |
217 | 219 |
218 void set_server_initial_flow_control_receive_window(uint32 window) { | 220 void set_server_initial_flow_control_receive_window(uint32 window) { |
219 CHECK(server_thread_.get() == NULL); | 221 CHECK(server_thread_.get() == NULL); |
220 DVLOG(1) << "Setting server initial flow control window: " << window; | 222 DVLOG(1) << "Setting server initial flow control window: " << window; |
221 server_initial_flow_control_receive_window_ = window; | 223 server_config_.SetInitialFlowControlWindowToSend(window); |
222 } | 224 } |
223 | 225 |
224 bool Initialize() { | 226 bool Initialize() { |
225 // Start the server first, because CreateQuicClient() attempts | 227 // Start the server first, because CreateQuicClient() attempts |
226 // to connect to the server. | 228 // to connect to the server. |
227 StartServer(); | 229 StartServer(); |
228 client_.reset(CreateQuicClient(client_writer_)); | 230 client_.reset(CreateQuicClient(client_writer_)); |
229 static EpollEvent event(EPOLLOUT, false); | 231 static EpollEvent event(EPOLLOUT, false); |
230 client_writer_->Initialize( | 232 client_writer_->Initialize( |
231 reinterpret_cast<QuicEpollConnectionHelper*>( | 233 reinterpret_cast<QuicEpollConnectionHelper*>( |
232 QuicConnectionPeer::GetHelper( | 234 QuicConnectionPeer::GetHelper( |
233 client_->client()->session()->connection())), | 235 client_->client()->session()->connection())), |
234 new ClientDelegate(client_->client())); | 236 new ClientDelegate(client_->client())); |
235 return client_->client()->connected(); | 237 return client_->client()->connected(); |
236 } | 238 } |
237 | 239 |
238 virtual void SetUp() OVERRIDE { | 240 virtual void SetUp() OVERRIDE { |
239 // The ownership of these gets transferred to the QuicPacketWriterWrapper | 241 // The ownership of these gets transferred to the QuicPacketWriterWrapper |
240 // and QuicDispatcher when Initialize() is executed. | 242 // and QuicDispatcher when Initialize() is executed. |
241 client_writer_ = new PacketDroppingTestWriter(); | 243 client_writer_ = new PacketDroppingTestWriter(); |
242 server_writer_ = new PacketDroppingTestWriter(); | 244 server_writer_ = new PacketDroppingTestWriter(); |
243 } | 245 } |
244 | 246 |
245 virtual void TearDown() OVERRIDE { | 247 virtual void TearDown() OVERRIDE { |
246 StopServer(); | 248 StopServer(); |
247 } | 249 } |
248 | 250 |
249 void StartServer() { | 251 void StartServer() { |
250 server_thread_.reset( | 252 server_thread_.reset( |
251 new ServerThread(server_address_, | 253 new ServerThread( |
252 server_config_, | 254 new QuicServer(server_config_, server_supported_versions_), |
253 server_supported_versions_, | 255 server_address_, |
254 strike_register_no_startup_period_, | 256 strike_register_no_startup_period_)); |
255 server_initial_flow_control_receive_window_)); | |
256 server_thread_->Initialize(); | 257 server_thread_->Initialize(); |
257 server_address_ = IPEndPoint(server_address_.address(), | 258 server_address_ = IPEndPoint(server_address_.address(), |
258 server_thread_->GetPort()); | 259 server_thread_->GetPort()); |
259 QuicDispatcher* dispatcher = | 260 QuicDispatcher* dispatcher = |
260 QuicServerPeer::GetDispatcher(server_thread_->server()); | 261 QuicServerPeer::GetDispatcher(server_thread_->server()); |
261 QuicDispatcherPeer::UseWriter(dispatcher, server_writer_); | 262 QuicDispatcherPeer::UseWriter(dispatcher, server_writer_); |
262 server_writer_->Initialize( | 263 server_writer_->Initialize( |
263 QuicDispatcherPeer::GetHelper(dispatcher), | 264 QuicDispatcherPeer::GetHelper(dispatcher), |
264 new ServerDelegate(dispatcher)); | 265 new ServerDelegate(dispatcher)); |
265 server_thread_->Start(); | 266 server_thread_->Start(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 scoped_ptr<QuicTestClient> client_; | 345 scoped_ptr<QuicTestClient> client_; |
345 PacketDroppingTestWriter* client_writer_; | 346 PacketDroppingTestWriter* client_writer_; |
346 PacketDroppingTestWriter* server_writer_; | 347 PacketDroppingTestWriter* server_writer_; |
347 bool server_started_; | 348 bool server_started_; |
348 QuicConfig client_config_; | 349 QuicConfig client_config_; |
349 QuicConfig server_config_; | 350 QuicConfig server_config_; |
350 QuicVersionVector client_supported_versions_; | 351 QuicVersionVector client_supported_versions_; |
351 QuicVersionVector server_supported_versions_; | 352 QuicVersionVector server_supported_versions_; |
352 QuicVersion negotiated_version_; | 353 QuicVersion negotiated_version_; |
353 bool strike_register_no_startup_period_; | 354 bool strike_register_no_startup_period_; |
354 uint32 client_initial_flow_control_receive_window_; | |
355 uint32 server_initial_flow_control_receive_window_; | |
356 }; | 355 }; |
357 | 356 |
358 // Run all end to end tests with all supported versions. | 357 // Run all end to end tests with all supported versions. |
359 INSTANTIATE_TEST_CASE_P(EndToEndTests, | 358 INSTANTIATE_TEST_CASE_P(EndToEndTests, |
360 EndToEndTest, | 359 EndToEndTest, |
361 ::testing::ValuesIn(GetTestParams())); | 360 ::testing::ValuesIn(GetTestParams())); |
362 | 361 |
363 TEST_P(EndToEndTest, SimpleRequestResponse) { | 362 TEST_P(EndToEndTest, SimpleRequestResponse) { |
364 ASSERT_TRUE(Initialize()); | 363 ASSERT_TRUE(Initialize()); |
365 | 364 |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 // DFATAL when they are serialized after the downgrade. | 629 // DFATAL when they are serialized after the downgrade. |
631 client_->client()->WaitForCryptoHandshakeConfirmed(); | 630 client_->client()->WaitForCryptoHandshakeConfirmed(); |
632 } | 631 } |
633 ASSERT_TRUE(client_->client()->connected()); | 632 ASSERT_TRUE(client_->client()->connected()); |
634 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 633 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
635 EXPECT_EQ(2, client_->client()->session()->GetNumSentClientHellos()); | 634 EXPECT_EQ(2, client_->client()->session()->GetNumSentClientHellos()); |
636 VerifyCleanConnection(false); | 635 VerifyCleanConnection(false); |
637 } | 636 } |
638 | 637 |
639 TEST_P(EndToEndTest, LargePostFEC) { | 638 TEST_P(EndToEndTest, LargePostFEC) { |
640 // TODO(jri): Set FecPolicy to always protect on client_->stream_. | |
641 // This test currently does not do any FEC protection. | |
642 | |
643 // Connect without packet loss to avoid issues with losing handshake packets, | 639 // Connect without packet loss to avoid issues with losing handshake packets, |
644 // and then up the packet loss rate (b/10126687). | 640 // and then up the packet loss rate (b/10126687). |
645 ASSERT_TRUE(Initialize()); | 641 ASSERT_TRUE(Initialize()); |
646 | 642 |
647 // Wait for the server SHLO before upping the packet loss. | 643 // Wait for the server SHLO before upping the packet loss. |
648 client_->client()->WaitForCryptoHandshakeConfirmed(); | 644 client_->client()->WaitForCryptoHandshakeConfirmed(); |
649 SetPacketLossPercentage(30); | 645 SetPacketLossPercentage(30); |
650 | 646 |
651 // Enable FEC protection. | 647 // Enable FEC protection. |
652 QuicPacketCreator* creator = QuicConnectionPeer::GetPacketCreator( | 648 QuicPacketCreator* creator = QuicConnectionPeer::GetPacketCreator( |
653 client_->client()->session()->connection()); | 649 client_->client()->session()->connection()); |
654 creator->set_max_packets_per_fec_group(6); | 650 creator->set_max_packets_per_fec_group(3); |
| 651 // Set FecPolicy to always protect data on all streams. |
| 652 client_->SetFecPolicy(FEC_PROTECT_ALWAYS); |
655 | 653 |
656 string body; | 654 string body; |
657 GenerateBody(&body, 10240); | 655 GenerateBody(&body, 10240); |
658 | 656 |
659 HTTPMessage request(HttpConstants::HTTP_1_1, | 657 HTTPMessage request(HttpConstants::HTTP_1_1, |
660 HttpConstants::POST, "/foo"); | 658 HttpConstants::POST, "/foo"); |
661 request.AddBody(body, true); | 659 request.AddBody(body, true); |
662 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 660 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
663 VerifyCleanConnection(true); | 661 VerifyCleanConnection(true); |
664 } | 662 } |
(...skipping 17 matching lines...) Expand all Loading... |
682 HTTPMessage request(HttpConstants::HTTP_1_1, | 680 HTTPMessage request(HttpConstants::HTTP_1_1, |
683 HttpConstants::POST, "/foo"); | 681 HttpConstants::POST, "/foo"); |
684 request.AddBody(body, true); | 682 request.AddBody(body, true); |
685 | 683 |
686 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 684 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
687 // This connection will not drop packets, because the buffer size is larger | 685 // This connection will not drop packets, because the buffer size is larger |
688 // than the default receive window. | 686 // than the default receive window. |
689 VerifyCleanConnection(false); | 687 VerifyCleanConnection(false); |
690 } | 688 } |
691 | 689 |
| 690 TEST_P(EndToEndTest, DoNotSetResumeWriteAlarmIfConnectionFlowControlBlocked) { |
| 691 // Regression test for b/14677858. |
| 692 // Test that the resume write alarm is not set in QuicConnection::OnCanWrite |
| 693 // if currently connection level flow control blocked. If set, this results in |
| 694 // an infinite loop in the EpollServer, as the alarm fires and is immediately |
| 695 // rescheduled. |
| 696 ASSERT_TRUE(Initialize()); |
| 697 if (negotiated_version_ < QUIC_VERSION_19) { |
| 698 return; |
| 699 } |
| 700 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 701 |
| 702 // Ensure both stream and connection level are flow control blocked by setting |
| 703 // the send window offset to 0. |
| 704 const uint64 kFlowControlWindow = |
| 705 server_config_.GetInitialFlowControlWindowToSend(); |
| 706 QuicSpdyClientStream* stream = client_->GetOrCreateStream(); |
| 707 QuicSession* session = client_->client()->session(); |
| 708 QuicFlowControllerPeer::SetSendWindowOffset(stream->flow_controller(), 0); |
| 709 QuicFlowControllerPeer::SetSendWindowOffset(session->flow_controller(), 0); |
| 710 EXPECT_TRUE(stream->flow_controller()->IsBlocked()); |
| 711 EXPECT_TRUE(session->flow_controller()->IsBlocked()); |
| 712 |
| 713 // Make sure that the stream has data pending so that it will be marked as |
| 714 // write blocked when it receives a stream level WINDOW_UPDATE. |
| 715 stream->SendBody("hello", false); |
| 716 |
| 717 // The stream now attempts to write, fails because it is still connection |
| 718 // level flow control blocked, and is added to the write blocked list. |
| 719 QuicWindowUpdateFrame window_update(stream->id(), 2 * kFlowControlWindow); |
| 720 stream->OnWindowUpdateFrame(window_update); |
| 721 |
| 722 // Prior to fixing b/14677858 this call would result in an infinite loop in |
| 723 // Chromium. As a proxy for detecting this, we now check whether the |
| 724 // resume_writes_alarm is set after OnCanWrite. It should not be, as the |
| 725 // connection is still flow control blocked. |
| 726 session->connection()->OnCanWrite(); |
| 727 |
| 728 QuicAlarm* resume_writes_alarm = |
| 729 QuicConnectionPeer::GetResumeWritesAlarm(session->connection()); |
| 730 EXPECT_FALSE(resume_writes_alarm->IsSet()); |
| 731 } |
| 732 |
692 TEST_P(EndToEndTest, InvalidStream) { | 733 TEST_P(EndToEndTest, InvalidStream) { |
693 ASSERT_TRUE(Initialize()); | 734 ASSERT_TRUE(Initialize()); |
694 client_->client()->WaitForCryptoHandshakeConfirmed(); | 735 client_->client()->WaitForCryptoHandshakeConfirmed(); |
695 | 736 |
696 string body; | 737 string body; |
697 GenerateBody(&body, kMaxPacketSize); | 738 GenerateBody(&body, kMaxPacketSize); |
698 | 739 |
699 HTTPMessage request(HttpConstants::HTTP_1_1, | 740 HTTPMessage request(HttpConstants::HTTP_1_1, |
700 HttpConstants::POST, "/foo"); | 741 HttpConstants::POST, "/foo"); |
701 request.AddBody(body, true); | 742 request.AddBody(body, true); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 QuicTime::Delta::FromMicroseconds(500), | 781 QuicTime::Delta::FromMicroseconds(500), |
741 QuicTime::Delta::FromMicroseconds(500)); | 782 QuicTime::Delta::FromMicroseconds(500)); |
742 // Note: we do NOT ASSERT_TRUE: we may time out during initial handshake: | 783 // Note: we do NOT ASSERT_TRUE: we may time out during initial handshake: |
743 // that's enough to validate timeout in this case. | 784 // that's enough to validate timeout in this case. |
744 Initialize(); | 785 Initialize(); |
745 while (client_->client()->connected()) { | 786 while (client_->client()->connected()) { |
746 client_->client()->WaitForEvents(); | 787 client_->client()->WaitForEvents(); |
747 } | 788 } |
748 } | 789 } |
749 | 790 |
| 791 TEST_P(EndToEndTest, NegotiateMaxOpenStreams) { |
| 792 // Negotiate 1 max open stream. |
| 793 client_config_.set_max_streams_per_connection(1, 1); |
| 794 ASSERT_TRUE(Initialize()); |
| 795 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 796 |
| 797 // Make the client misbehave after negotiation. |
| 798 QuicSessionPeer::SetMaxOpenStreams(client_->client()->session(), 10); |
| 799 |
| 800 HTTPMessage request(HttpConstants::HTTP_1_1, |
| 801 HttpConstants::POST, "/foo"); |
| 802 request.AddHeader("content-length", "3"); |
| 803 request.set_has_complete_message(false); |
| 804 |
| 805 // Open two simultaneous streams. |
| 806 client_->SendMessage(request); |
| 807 client_->SendMessage(request); |
| 808 client_->WaitForResponse(); |
| 809 |
| 810 EXPECT_FALSE(client_->connected()); |
| 811 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); |
| 812 EXPECT_EQ(QUIC_TOO_MANY_OPEN_STREAMS, client_->connection_error()); |
| 813 } |
| 814 |
750 TEST_P(EndToEndTest, LimitMaxOpenStreams) { | 815 TEST_P(EndToEndTest, LimitMaxOpenStreams) { |
751 // Server limits the number of max streams to 2. | 816 // Server limits the number of max streams to 2. |
752 server_config_.set_max_streams_per_connection(2, 2); | 817 server_config_.set_max_streams_per_connection(2, 2); |
753 // Client tries to negotiate for 10. | 818 // Client tries to negotiate for 10. |
754 client_config_.set_max_streams_per_connection(10, 5); | 819 client_config_.set_max_streams_per_connection(10, 5); |
755 | 820 |
756 ASSERT_TRUE(Initialize()); | 821 ASSERT_TRUE(Initialize()); |
757 client_->client()->WaitForCryptoHandshakeConfirmed(); | 822 client_->client()->WaitForCryptoHandshakeConfirmed(); |
758 QuicConfig* client_negotiated_config = client_->client()->session()->config(); | 823 QuicConfig* client_negotiated_config = client_->client()->session()->config(); |
759 EXPECT_EQ(2u, client_negotiated_config->max_streams_per_connection()); | 824 EXPECT_EQ(2u, client_negotiated_config->max_streams_per_connection()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 TEST_P(EndToEndTest, MaxInitialRTT) { | 881 TEST_P(EndToEndTest, MaxInitialRTT) { |
817 // Client tries to suggest twice the server's max initial rtt and the server | 882 // Client tries to suggest twice the server's max initial rtt and the server |
818 // uses the max. | 883 // uses the max. |
819 client_config_.SetInitialRoundTripTimeUsToSend( | 884 client_config_.SetInitialRoundTripTimeUsToSend( |
820 2 * kMaxInitialRoundTripTimeUs); | 885 2 * kMaxInitialRoundTripTimeUs); |
821 | 886 |
822 ASSERT_TRUE(Initialize()); | 887 ASSERT_TRUE(Initialize()); |
823 client_->client()->WaitForCryptoHandshakeConfirmed(); | 888 client_->client()->WaitForCryptoHandshakeConfirmed(); |
824 server_thread_->WaitForCryptoHandshakeConfirmed(); | 889 server_thread_->WaitForCryptoHandshakeConfirmed(); |
825 | 890 |
| 891 // Pause the server so we can access the server's internals without races. |
826 server_thread_->Pause(); | 892 server_thread_->Pause(); |
827 QuicDispatcher* dispatcher = | 893 QuicDispatcher* dispatcher = |
828 QuicServerPeer::GetDispatcher(server_thread_->server()); | 894 QuicServerPeer::GetDispatcher(server_thread_->server()); |
829 ASSERT_EQ(1u, dispatcher->session_map().size()); | 895 ASSERT_EQ(1u, dispatcher->session_map().size()); |
830 QuicSession* session = dispatcher->session_map().begin()->second; | 896 QuicSession* session = dispatcher->session_map().begin()->second; |
831 const QuicSentPacketManager& client_sent_packet_manager = | 897 const QuicSentPacketManager& client_sent_packet_manager = |
832 client_->client()->session()->connection()->sent_packet_manager(); | 898 client_->client()->session()->connection()->sent_packet_manager(); |
833 const QuicSentPacketManager& server_sent_packet_manager = | 899 const QuicSentPacketManager& server_sent_packet_manager = |
834 session->connection()->sent_packet_manager(); | 900 session->connection()->sent_packet_manager(); |
835 | 901 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 QuicSession* session = dispatcher->session_map().begin()->second; | 1133 QuicSession* session = dispatcher->session_map().begin()->second; |
1068 EXPECT_EQ(kClientIFCW, | 1134 EXPECT_EQ(kClientIFCW, |
1069 session->config()->ReceivedInitialFlowControlWindowBytes()); | 1135 session->config()->ReceivedInitialFlowControlWindowBytes()); |
1070 server_thread_->Resume(); | 1136 server_thread_->Resume(); |
1071 } | 1137 } |
1072 | 1138 |
1073 } // namespace | 1139 } // namespace |
1074 } // namespace test | 1140 } // namespace test |
1075 } // namespace tools | 1141 } // namespace tools |
1076 } // namespace net | 1142 } // namespace net |
OLD | NEW |