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

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

Issue 1421853006: Landing Recent QUIC changes until: Fri Oct 30 22:23:58 2015 +0000 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comments Created 5 years, 1 month 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_session.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"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 } 204 }
205 } 205 }
206 } 206 }
207 } 207 }
208 } 208 }
209 return params; 209 return params;
210 } 210 }
211 211
212 class ServerDelegate : public PacketDroppingTestWriter::Delegate { 212 class ServerDelegate : public PacketDroppingTestWriter::Delegate {
213 public: 213 public:
214 ServerDelegate(TestWriterFactory* writer_factory, 214 explicit ServerDelegate(QuicDispatcher* dispatcher)
215 QuicDispatcher* dispatcher) 215 : dispatcher_(dispatcher) {}
216 : writer_factory_(writer_factory),
217 dispatcher_(dispatcher) {}
218 ~ServerDelegate() override {} 216 ~ServerDelegate() override {}
219 void OnPacketSent(WriteResult result) override {
220 writer_factory_->OnPacketSent(result);
221 }
222 void OnCanWrite() override { dispatcher_->OnCanWrite(); } 217 void OnCanWrite() override { dispatcher_->OnCanWrite(); }
223 218
224 private: 219 private:
225 TestWriterFactory* writer_factory_;
226 QuicDispatcher* dispatcher_; 220 QuicDispatcher* dispatcher_;
227 }; 221 };
228 222
229 class ClientDelegate : public PacketDroppingTestWriter::Delegate { 223 class ClientDelegate : public PacketDroppingTestWriter::Delegate {
230 public: 224 public:
231 explicit ClientDelegate(QuicClient* client) : client_(client) {} 225 explicit ClientDelegate(QuicClient* client) : client_(client) {}
232 ~ClientDelegate() override {} 226 ~ClientDelegate() override {}
233 void OnPacketSent(WriteResult /*result*/) override {}
234 void OnCanWrite() override { 227 void OnCanWrite() override {
235 EpollEvent event(EPOLLOUT, false); 228 EpollEvent event(EPOLLOUT, false);
236 client_->OnEvent(client_->fd(), &event); 229 client_->OnEvent(client_->fd(), &event);
237 } 230 }
238 231
239 private: 232 private:
240 QuicClient* client_; 233 QuicClient* client_;
241 }; 234 };
242 235
243 class EndToEndTest : public ::testing::TestWithParam<TestParams> { 236 class EndToEndTest : public ::testing::TestWithParam<TestParams> {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 server_thread_->Initialize(); 386 server_thread_->Initialize();
394 server_address_ = IPEndPoint(server_address_.address(), 387 server_address_ = IPEndPoint(server_address_.address(),
395 server_thread_->GetPort()); 388 server_thread_->GetPort());
396 QuicDispatcher* dispatcher = 389 QuicDispatcher* dispatcher =
397 QuicServerPeer::GetDispatcher(server_thread_->server()); 390 QuicServerPeer::GetDispatcher(server_thread_->server());
398 TestWriterFactory* packet_writer_factory = new TestWriterFactory(); 391 TestWriterFactory* packet_writer_factory = new TestWriterFactory();
399 QuicDispatcherPeer::SetPacketWriterFactory(dispatcher, 392 QuicDispatcherPeer::SetPacketWriterFactory(dispatcher,
400 packet_writer_factory); 393 packet_writer_factory);
401 QuicDispatcherPeer::UseWriter(dispatcher, server_writer_); 394 QuicDispatcherPeer::UseWriter(dispatcher, server_writer_);
402 395
403 if (GetParam().server_uses_stateless_rejects_if_peer_supported) { 396 FLAGS_enable_quic_stateless_reject_support =
404 // Enable stateless rejects and force the server to always send 397 GetParam().server_uses_stateless_rejects_if_peer_supported;
405 // them.
406 FLAGS_enable_quic_stateless_reject_support = true;
407 FLAGS_quic_session_map_threshold_for_stateless_rejects = 0;
408 } else {
409 FLAGS_enable_quic_stateless_reject_support = false;
410 FLAGS_quic_session_map_threshold_for_stateless_rejects = -1;
411 }
412 398
413 server_writer_->Initialize( 399 server_writer_->Initialize(QuicDispatcherPeer::GetHelper(dispatcher),
414 QuicDispatcherPeer::GetHelper(dispatcher), 400 new ServerDelegate(dispatcher));
415 new ServerDelegate(packet_writer_factory, dispatcher));
416 if (stream_factory_ != nullptr) { 401 if (stream_factory_ != nullptr) {
417 static_cast<QuicTestServer*>(server_thread_->server()) 402 static_cast<QuicTestServer*>(server_thread_->server())
418 ->SetSpdyStreamFactory(stream_factory_); 403 ->SetSpdyStreamFactory(stream_factory_);
419 } 404 }
420 405
421 server_thread_->Start(); 406 server_thread_->Start();
422 server_started_ = true; 407 server_started_ = true;
423 } 408 }
424 409
425 void StopServer() { 410 void StopServer() {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 // Calls server_thread_ Pause() and Resume(), which may only be called once 452 // Calls server_thread_ Pause() and Resume(), which may only be called once
468 // per test. 453 // per test.
469 void VerifyCleanConnection(bool /*had_packet_loss*/) { 454 void VerifyCleanConnection(bool /*had_packet_loss*/) {
470 QuicConnectionStats client_stats = 455 QuicConnectionStats client_stats =
471 client_->client()->session()->connection()->GetStats(); 456 client_->client()->session()->connection()->GetStats();
472 // TODO(ianswett): Re-enable this check once b/19572432 is fixed. 457 // TODO(ianswett): Re-enable this check once b/19572432 is fixed.
473 // if (!had_packet_loss) { 458 // if (!had_packet_loss) {
474 // EXPECT_EQ(0u, client_stats.packets_lost); 459 // EXPECT_EQ(0u, client_stats.packets_lost);
475 // } 460 // }
476 EXPECT_EQ(0u, client_stats.packets_discarded); 461 EXPECT_EQ(0u, client_stats.packets_discarded);
477 EXPECT_EQ(0u, client_stats.packets_dropped); 462 // When doing 0-RTT with stateless rejects, the encrypted requests cause
463 // a retranmission of the SREJ packets which are dropped by the client.
464 if (!BothSidesSupportStatelessRejects()) {
465 EXPECT_EQ(0u, client_stats.packets_dropped);
466 }
478 EXPECT_EQ(client_stats.packets_received, client_stats.packets_processed); 467 EXPECT_EQ(client_stats.packets_received, client_stats.packets_processed);
479 468
480 const int num_expected_stateless_rejects = 469 const int num_expected_stateless_rejects =
481 (BothSidesSupportStatelessRejects() && 470 (BothSidesSupportStatelessRejects() &&
482 client_->client()->session()->GetNumSentClientHellos() > 0) 471 client_->client()->session()->GetNumSentClientHellos() > 0)
483 ? 1 472 ? 1
484 : 0; 473 : 0;
485 EXPECT_EQ(num_expected_stateless_rejects, 474 EXPECT_EQ(num_expected_stateless_rejects,
486 client_->client()->num_stateless_rejects_received()); 475 client_->client()->num_stateless_rejects_received());
487 476
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 EXPECT_EQ(expected_num_hellos_latest_session, 908 EXPECT_EQ(expected_num_hellos_latest_session,
920 client_->client()->session()->GetNumSentClientHellos()); 909 client_->client()->session()->GetNumSentClientHellos());
921 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); 910 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos());
922 911
923 VerifyCleanConnection(false); 912 VerifyCleanConnection(false);
924 } 913 }
925 914
926 TEST_P(EndToEndTest, StatelessRejectWithPacketLoss) { 915 TEST_P(EndToEndTest, StatelessRejectWithPacketLoss) {
927 // In this test, we intentionally drop the first packet from the 916 // In this test, we intentionally drop the first packet from the
928 // server, which corresponds with the initial REJ/SREJ response from 917 // server, which corresponds with the initial REJ/SREJ response from
929 // the server. The REJ case will succeed, due to redundancy in the 918 // the server.
930 // stateful handshake. The SREJ will fail, because there is
931 // (currently) no way to recover from a loss of the first SREJ, and
932 // all remaining state for the first handshake is black-holed on the
933 // time-wait list.
934 // TODO(jokulik): Once redundant SREJ support is added, this test
935 // should succeed.
936 server_writer_->set_fake_drop_first_n_packets(1); 919 server_writer_->set_fake_drop_first_n_packets(1);
937 // If this test will involve version negotiation then the version 920 ASSERT_TRUE(Initialize());
938 // negotiation packet will be dropped, not the SREJ, and since the
939 // version negotiation packet will be retransmitted the test will
940 // succeed.
941 const bool will_succeed =
942 !BothSidesSupportStatelessRejects() ||
943 negotiated_version_ != client_supported_versions_.front();
944 ASSERT_EQ(will_succeed, Initialize());
945 } 921 }
946 922
947 TEST_P(EndToEndTest, SetInitialReceivedConnectionOptions) { 923 TEST_P(EndToEndTest, SetInitialReceivedConnectionOptions) {
948 QuicTagVector initial_received_options; 924 QuicTagVector initial_received_options;
949 initial_received_options.push_back(kTBBR); 925 initial_received_options.push_back(kTBBR);
950 initial_received_options.push_back(kIW10); 926 initial_received_options.push_back(kIW10);
951 initial_received_options.push_back(kPRST); 927 initial_received_options.push_back(kPRST);
952 EXPECT_TRUE(server_config_.SetInitialReceivedConnectionOptions( 928 EXPECT_TRUE(server_config_.SetInitialReceivedConnectionOptions(
953 initial_received_options)); 929 initial_received_options));
954 930
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 GenerateBody(&body, kMaxPacketSize); 1042 GenerateBody(&body, kMaxPacketSize);
1067 1043
1068 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo"); 1044 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo");
1069 request.AddBody(body, true); 1045 request.AddBody(body, true);
1070 // Force the client to write with a stream ID belonging to a nonexistent 1046 // Force the client to write with a stream ID belonging to a nonexistent
1071 // server-side stream. 1047 // server-side stream.
1072 QuicSessionPeer::SetNextOutgoingStreamId(client_->client()->session(), 2); 1048 QuicSessionPeer::SetNextOutgoingStreamId(client_->client()->session(), 2);
1073 1049
1074 client_->SendCustomSynchronousRequest(request); 1050 client_->SendCustomSynchronousRequest(request);
1075 // EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); 1051 // EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error());
1076 EXPECT_EQ(QUIC_PACKET_FOR_NONEXISTENT_STREAM, client_->connection_error()); 1052 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error());
1053 EXPECT_EQ(QUIC_INVALID_STREAM_ID, client_->connection_error());
1077 } 1054 }
1078 1055
1079 // TODO(rch): this test seems to cause net_unittests timeouts :| 1056 // TODO(rch): this test seems to cause net_unittests timeouts :|
1080 TEST_P(EndToEndTest, DISABLED_MultipleTermination) { 1057 TEST_P(EndToEndTest, DISABLED_MultipleTermination) {
1081 ASSERT_TRUE(Initialize()); 1058 ASSERT_TRUE(Initialize());
1082 1059
1083 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo"); 1060 HTTPMessage request(HttpConstants::HTTP_1_1, HttpConstants::POST, "/foo");
1084 request.AddHeader("content-length", "3"); 1061 request.AddHeader("content-length", "3");
1085 request.set_has_complete_message(false); 1062 request.set_has_complete_message(false);
1086 1063
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 string request_string = 1691 string request_string =
1715 "a request body bigger than one packet" + string(kMaxPacketSize, '.'); 1692 "a request body bigger than one packet" + string(kMaxPacketSize, '.');
1716 1693
1717 // Send the request, and register the delegate for ACKs. 1694 // Send the request, and register the delegate for ACKs.
1718 client_->SendData(request_string, true, delegate.get()); 1695 client_->SendData(request_string, true, delegate.get());
1719 client_->WaitForResponse(); 1696 client_->WaitForResponse();
1720 EXPECT_EQ(kFooResponseBody, client_->response_body()); 1697 EXPECT_EQ(kFooResponseBody, client_->response_body());
1721 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); 1698 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code());
1722 1699
1723 // Send another request to flush out any pending ACKs on the server. 1700 // Send another request to flush out any pending ACKs on the server.
1724 client_->SendSynchronousRequest(request_string); 1701 client_->SendSynchronousRequest("/bar");
1725 1702
1726 // Pause the server to avoid races. 1703 // Pause the server to avoid races.
1727 server_thread_->Pause(); 1704 server_thread_->Pause();
1728 // Make sure the delegate does get the notification it expects. 1705 // Make sure the delegate does get the notification it expects.
1729 while (!delegate->has_been_notified()) { 1706 while (!delegate->has_been_notified()) {
1730 // Waits for up to 50 ms. 1707 // Waits for up to 50 ms.
1731 client_->client()->WaitForEvents(); 1708 client_->client()->WaitForEvents();
1732 } 1709 }
1733 server_thread_->Resume(); 1710 server_thread_->Resume();
1734 } 1711 }
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
2109 // There will be buffered data to write in the client's stream. 2086 // There will be buffered data to write in the client's stream.
2110 ReliableQuicStream* stream = client_->client()->session()->GetStream(5); 2087 ReliableQuicStream* stream = client_->client()->session()->GetStream(5);
2111 EXPECT_TRUE(stream != nullptr && stream->HasBufferedData()); 2088 EXPECT_TRUE(stream != nullptr && stream->HasBufferedData());
2112 } 2089 }
2113 } 2090 }
2114 2091
2115 } // namespace 2092 } // namespace
2116 } // namespace test 2093 } // namespace test
2117 } // namespace tools 2094 } // namespace tools
2118 } // namespace net 2095 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_test_utils.cc ('k') | net/tools/quic/quic_client_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698