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

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

Issue 23464033: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix valgrind error Created 7 years, 3 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 | Annotate | Revision Log
« 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 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 body->reserve(length); 54 body->reserve(length);
55 for (int i = 0; i < length; ++i) { 55 for (int i = 0; i < length; ++i) {
56 body->append(1, static_cast<char>(32 + i % (126 - 32))); 56 body->append(1, static_cast<char>(32 + i % (126 - 32)));
57 } 57 }
58 } 58 }
59 59
60 60
61 // Simple wrapper class to run server in a thread. 61 // Simple wrapper class to run server in a thread.
62 class ServerThread : public base::SimpleThread { 62 class ServerThread : public base::SimpleThread {
63 public: 63 public:
64 explicit ServerThread(IPEndPoint address, const QuicConfig& config) 64 ServerThread(IPEndPoint address,
65 const QuicConfig& config,
66 bool strike_register_no_startup_period)
65 : SimpleThread("server_thread"), 67 : SimpleThread("server_thread"),
66 listening_(true, false), 68 listening_(true, false),
67 quit_(true, false), 69 quit_(true, false),
68 server_(config), 70 server_(config),
69 address_(address), 71 address_(address),
70 port_(0) { 72 port_(0) {
73 if (strike_register_no_startup_period) {
74 server_.SetStrikeRegisterNoStartupPeriod();
75 }
71 } 76 }
72 virtual ~ServerThread() { 77 virtual ~ServerThread() {
73 } 78 }
74 79
75 virtual void Run() OVERRIDE { 80 virtual void Run() OVERRIDE {
76 server_.Listen(address_); 81 server_.Listen(address_);
77 82
78 port_lock_.Acquire(); 83 port_lock_.Acquire();
79 port_ = server_.port(); 84 port_ = server_.port();
80 port_lock_.Release(); 85 port_lock_.Release();
(...skipping 28 matching lines...) Expand all
109 114
110 class EndToEndTest : public ::testing::TestWithParam<QuicVersion> { 115 class EndToEndTest : public ::testing::TestWithParam<QuicVersion> {
111 public: 116 public:
112 static void SetUpTestCase() { 117 static void SetUpTestCase() {
113 QuicInMemoryCache::GetInstance()->ResetForTests(); 118 QuicInMemoryCache::GetInstance()->ResetForTests();
114 } 119 }
115 120
116 protected: 121 protected:
117 EndToEndTest() 122 EndToEndTest()
118 : server_hostname_("example.com"), 123 : server_hostname_("example.com"),
119 server_started_(false) { 124 server_started_(false),
125 strike_register_no_startup_period_(false) {
120 net::IPAddressNumber ip; 126 net::IPAddressNumber ip;
121 CHECK(net::ParseIPLiteralToNumber("127.0.0.1", &ip)); 127 CHECK(net::ParseIPLiteralToNumber("127.0.0.1", &ip));
122 server_address_ = IPEndPoint(ip, 0); 128 server_address_ = IPEndPoint(ip, 0);
123 client_config_.SetDefaults(); 129 client_config_.SetDefaults();
124 server_config_.SetDefaults(); 130 server_config_.SetDefaults();
125 131
126 AddToCache("GET", kLargeRequest, "HTTP/1.1", "200", "OK", kFooResponseBody); 132 AddToCache("GET", kLargeRequest, "HTTP/1.1", "200", "OK", kFooResponseBody);
127 AddToCache("GET", "https://www.google.com/foo", 133 AddToCache("GET", "https://www.google.com/foo",
128 "HTTP/1.1", "200", "OK", kFooResponseBody); 134 "HTTP/1.1", "200", "OK", kFooResponseBody);
129 AddToCache("GET", "https://www.google.com/bar", 135 AddToCache("GET", "https://www.google.com/bar",
(...skipping 17 matching lines...) Expand all
147 StartServer(); 153 StartServer();
148 client_.reset(CreateQuicClient()); 154 client_.reset(CreateQuicClient());
149 return client_->client()->connected(); 155 return client_->client()->connected();
150 } 156 }
151 157
152 virtual void TearDown() { 158 virtual void TearDown() {
153 StopServer(); 159 StopServer();
154 } 160 }
155 161
156 void StartServer() { 162 void StartServer() {
157 server_thread_.reset(new ServerThread(server_address_, server_config_)); 163 server_thread_.reset(new ServerThread(server_address_, server_config_,
164 strike_register_no_startup_period_));
158 server_thread_->Start(); 165 server_thread_->Start();
159 server_thread_->listening()->Wait(); 166 server_thread_->listening()->Wait();
160 server_address_ = IPEndPoint(server_address_.address(), 167 server_address_ = IPEndPoint(server_address_.address(),
161 server_thread_->GetPort()); 168 server_thread_->GetPort());
162 server_started_ = true; 169 server_started_ = true;
163 } 170 }
164 171
165 void StopServer() { 172 void StopServer() {
166 if (!server_started_) 173 if (!server_started_)
167 return; 174 return;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 210 }
204 211
205 IPEndPoint server_address_; 212 IPEndPoint server_address_;
206 string server_hostname_; 213 string server_hostname_;
207 scoped_ptr<ServerThread> server_thread_; 214 scoped_ptr<ServerThread> server_thread_;
208 scoped_ptr<QuicTestClient> client_; 215 scoped_ptr<QuicTestClient> client_;
209 bool server_started_; 216 bool server_started_;
210 QuicConfig client_config_; 217 QuicConfig client_config_;
211 QuicConfig server_config_; 218 QuicConfig server_config_;
212 QuicVersion version_; 219 QuicVersion version_;
220 bool strike_register_no_startup_period_;
213 }; 221 };
214 222
215 // Run all end to end tests with all supported versions. 223 // Run all end to end tests with all supported versions.
216 INSTANTIATE_TEST_CASE_P(EndToEndTests, 224 INSTANTIATE_TEST_CASE_P(EndToEndTests,
217 EndToEndTest, 225 EndToEndTest,
218 ::testing::ValuesIn(kSupportedQuicVersions)); 226 ::testing::ValuesIn(kSupportedQuicVersions));
219 227
220 TEST_P(EndToEndTest, SimpleRequestResponse) { 228 TEST_P(EndToEndTest, SimpleRequestResponse) {
221 // TODO(rtenneti): Delete this when NSS is supported. 229 // TODO(rtenneti): Delete this when NSS is supported.
222 if (!Aes128Gcm12Encrypter::IsSupported()) { 230 if (!Aes128Gcm12Encrypter::IsSupported()) {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 GenerateBody(&body, 10240); 443 GenerateBody(&body, 10240);
436 444
437 HTTPMessage request(HttpConstants::HTTP_1_1, 445 HTTPMessage request(HttpConstants::HTTP_1_1,
438 HttpConstants::POST, "/foo"); 446 HttpConstants::POST, "/foo");
439 request.AddBody(body, true); 447 request.AddBody(body, true);
440 448
441 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); 449 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request));
442 } 450 }
443 451
444 TEST_P(EndToEndTest, LargePostZeroRTTFailure) { 452 TEST_P(EndToEndTest, LargePostZeroRTTFailure) {
453 // Have the server accept 0-RTT without waiting a startup period.
454 strike_register_no_startup_period_ = true;
455
445 // Send a request and then disconnect. This prepares the client to attempt 456 // Send a request and then disconnect. This prepares the client to attempt
446 // a 0-RTT handshake for the next request. 457 // a 0-RTT handshake for the next request.
447 ASSERT_TRUE(Initialize()); 458 ASSERT_TRUE(Initialize());
448 459
449 string body; 460 string body;
450 GenerateBody(&body, 20480); 461 GenerateBody(&body, 20480);
451 462
452 HTTPMessage request(HttpConstants::HTTP_1_1, 463 HTTPMessage request(HttpConstants::HTTP_1_1,
453 HttpConstants::POST, "/foo"); 464 HttpConstants::POST, "/foo");
454 request.AddBody(body, true); 465 request.AddBody(body, true);
455 466
456 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); 467 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request));
468 EXPECT_EQ(2, client_->client()->session()->GetNumSentClientHellos());
457 469
458 client_->Disconnect(); 470 client_->Disconnect();
459 471
460 // The 0-RTT handshake should succeed. 472 // The 0-RTT handshake should succeed.
461 // TODO(wtc): figure out why this 0-RTT handshake takes 1 RTT.
462 client_->Connect(); 473 client_->Connect();
463 ASSERT_TRUE(client_->client()->connected()); 474 ASSERT_TRUE(client_->client()->connected());
464 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); 475 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request));
476 EXPECT_EQ(1, client_->client()->session()->GetNumSentClientHellos());
465 477
466 client_->Disconnect(); 478 client_->Disconnect();
467 479
468 // Restart the server so that the 0-RTT handshake will take 1 RTT. 480 // Restart the server so that the 0-RTT handshake will take 1 RTT.
469 StopServer(); 481 StopServer();
470 StartServer(); 482 StartServer();
471 483
472 client_->Connect(); 484 client_->Connect();
473 ASSERT_TRUE(client_->client()->connected()); 485 ASSERT_TRUE(client_->client()->connected());
474 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); 486 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request));
487 EXPECT_EQ(2, client_->client()->session()->GetNumSentClientHellos());
475 } 488 }
476 489
477 // TODO(ianswett): Enable once b/9295090 is fixed. 490 // TODO(ianswett): Enable once b/9295090 is fixed.
478 TEST_P(EndToEndTest, DISABLED_LargePostFEC) { 491 TEST_P(EndToEndTest, DISABLED_LargePostFEC) {
479 // FLAGS_fake_packet_loss_percentage = 30; 492 // FLAGS_fake_packet_loss_percentage = 30;
480 ASSERT_TRUE(Initialize()); 493 ASSERT_TRUE(Initialize());
481 client_->options()->max_packets_per_fec_group = 6; 494 client_->options()->max_packets_per_fec_group = 6;
482 495
483 // TODO(rtenneti): Delete this when NSS is supported. 496 // TODO(rtenneti): Delete this when NSS is supported.
484 if (!Aes128Gcm12Encrypter::IsSupported()) { 497 if (!Aes128Gcm12Encrypter::IsSupported()) {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 QuicEpollConnectionHelperPeer::SetWriter(helper, NULL); 710 QuicEpollConnectionHelperPeer::SetWriter(helper, NULL);
698 711
699 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); 712 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error());
700 EXPECT_EQ(QUIC_ERROR_MIGRATING_ADDRESS, client_->connection_error()); 713 EXPECT_EQ(QUIC_ERROR_MIGRATING_ADDRESS, client_->connection_error());
701 } 714 }
702 715
703 } // namespace 716 } // namespace
704 } // namespace test 717 } // namespace test
705 } // namespace tools 718 } // namespace tools
706 } // namespace net 719 } // 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