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

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

Issue 1908103002: Landing Recent QUIC changes until 4/15/2016 17:20 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 8 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/quic/test_tools/simple_quic_framer.cc ('k') | net/tools/quic/quic_client.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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 247
248 class EndToEndTest : public ::testing::TestWithParam<TestParams> { 248 class EndToEndTest : public ::testing::TestWithParam<TestParams> {
249 protected: 249 protected:
250 EndToEndTest() 250 EndToEndTest()
251 : initialized_(false), 251 : initialized_(false),
252 server_address_(IPEndPoint(Loopback4(), 0)), 252 server_address_(IPEndPoint(Loopback4(), 0)),
253 server_hostname_("example.com"), 253 server_hostname_("example.com"),
254 server_started_(false), 254 server_started_(false),
255 strike_register_no_startup_period_(false), 255 strike_register_no_startup_period_(false),
256 chlo_multiplier_(0), 256 chlo_multiplier_(0),
257 stream_factory_(nullptr) { 257 stream_factory_(nullptr),
258 support_server_push_(false) {
258 client_supported_versions_ = GetParam().client_supported_versions; 259 client_supported_versions_ = GetParam().client_supported_versions;
259 server_supported_versions_ = GetParam().server_supported_versions; 260 server_supported_versions_ = GetParam().server_supported_versions;
260 negotiated_version_ = GetParam().negotiated_version; 261 negotiated_version_ = GetParam().negotiated_version;
261 262
262 VLOG(1) << "Using Configuration: " << GetParam(); 263 VLOG(1) << "Using Configuration: " << GetParam();
263 264
264 // Use different flow control windows for client/server. 265 // Use different flow control windows for client/server.
265 client_config_.SetInitialStreamFlowControlWindowToSend( 266 client_config_.SetInitialStreamFlowControlWindowToSend(
266 2 * kInitialStreamFlowControlWindowForTest); 267 2 * kInitialStreamFlowControlWindowForTest);
267 client_config_.SetInitialSessionFlowControlWindowToSend( 268 client_config_.SetInitialSessionFlowControlWindowToSend(
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 return &session->connection()->sent_packet_manager(); 337 return &session->connection()->sent_packet_manager();
337 } 338 }
338 339
339 bool Initialize() { 340 bool Initialize() {
340 QuicTagVector copt; 341 QuicTagVector copt;
341 server_config_.SetConnectionOptionsToSend(copt); 342 server_config_.SetConnectionOptionsToSend(copt);
342 343
343 // TODO(nimia): Consider setting the congestion control algorithm for the 344 // TODO(nimia): Consider setting the congestion control algorithm for the
344 // client as well according to the test parameter. 345 // client as well according to the test parameter.
345 copt.push_back(GetParam().congestion_control_tag); 346 copt.push_back(GetParam().congestion_control_tag);
346 copt.push_back(kSPSH); 347 if (support_server_push_) {
347 348 copt.push_back(kSPSH);
349 }
348 if (GetParam().client_supports_stateless_rejects) { 350 if (GetParam().client_supports_stateless_rejects) {
349 copt.push_back(kSREJ); 351 copt.push_back(kSREJ);
350 } 352 }
351 client_config_.SetConnectionOptionsToSend(copt); 353 client_config_.SetConnectionOptionsToSend(copt);
352 354
353 // Start the server first, because CreateQuicClient() attempts 355 // Start the server first, because CreateQuicClient() attempts
354 // to connect to the server. 356 // to connect to the server.
355 StartServer(); 357 StartServer();
356 358
357 client_.reset(CreateQuicClient(client_writer_)); 359 client_.reset(CreateQuicClient(client_writer_));
358 static EpollEvent event(EPOLLOUT, false); 360 static EpollEvent event(EPOLLOUT, false);
359 client_writer_->Initialize( 361 client_writer_->Initialize(
360 reinterpret_cast<QuicEpollConnectionHelper*>( 362 reinterpret_cast<QuicEpollConnectionHelper*>(
361 QuicConnectionPeer::GetHelper( 363 QuicConnectionPeer::GetHelper(
362 client_->client()->session()->connection())), 364 client_->client()->session()->connection())),
365 QuicConnectionPeer::GetAlarmFactory(
366 client_->client()->session()->connection()),
363 new ClientDelegate(client_->client())); 367 new ClientDelegate(client_->client()));
368
364 initialized_ = true; 369 initialized_ = true;
365 return client_->client()->connected(); 370 return client_->client()->connected();
366 } 371 }
367 372
368 void SetUp() override { 373 void SetUp() override {
369 // The ownership of these gets transferred to the QuicPacketWriterWrapper 374 // The ownership of these gets transferred to the QuicPacketWriterWrapper
370 // when Initialize() is executed. 375 // when Initialize() is executed.
371 client_writer_ = new PacketDroppingTestWriter(); 376 client_writer_ = new PacketDroppingTestWriter();
372 server_writer_ = new PacketDroppingTestWriter(); 377 server_writer_ = new PacketDroppingTestWriter();
373 } 378 }
(...skipping 16 matching lines...) Expand all
390 server_address_ = 395 server_address_ =
391 IPEndPoint(server_address_.address(), server_thread_->GetPort()); 396 IPEndPoint(server_address_.address(), server_thread_->GetPort());
392 QuicDispatcher* dispatcher = 397 QuicDispatcher* dispatcher =
393 QuicServerPeer::GetDispatcher(server_thread_->server()); 398 QuicServerPeer::GetDispatcher(server_thread_->server());
394 QuicDispatcherPeer::UseWriter(dispatcher, server_writer_); 399 QuicDispatcherPeer::UseWriter(dispatcher, server_writer_);
395 400
396 FLAGS_enable_quic_stateless_reject_support = 401 FLAGS_enable_quic_stateless_reject_support =
397 GetParam().server_uses_stateless_rejects_if_peer_supported; 402 GetParam().server_uses_stateless_rejects_if_peer_supported;
398 403
399 server_writer_->Initialize(QuicDispatcherPeer::GetHelper(dispatcher), 404 server_writer_->Initialize(QuicDispatcherPeer::GetHelper(dispatcher),
405 QuicDispatcherPeer::GetAlarmFactory(dispatcher),
400 new ServerDelegate(dispatcher)); 406 new ServerDelegate(dispatcher));
401 if (stream_factory_ != nullptr) { 407 if (stream_factory_ != nullptr) {
402 static_cast<QuicTestServer*>(server_thread_->server()) 408 static_cast<QuicTestServer*>(server_thread_->server())
403 ->SetSpdyStreamFactory(stream_factory_); 409 ->SetSpdyStreamFactory(stream_factory_);
404 } 410 }
405 411
406 server_thread_->Start(); 412 server_thread_->Start();
407 server_started_ = true; 413 server_started_ = true;
408 } 414 }
409 415
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 PacketDroppingTestWriter* server_writer_; 519 PacketDroppingTestWriter* server_writer_;
514 bool server_started_; 520 bool server_started_;
515 QuicConfig client_config_; 521 QuicConfig client_config_;
516 QuicConfig server_config_; 522 QuicConfig server_config_;
517 QuicVersionVector client_supported_versions_; 523 QuicVersionVector client_supported_versions_;
518 QuicVersionVector server_supported_versions_; 524 QuicVersionVector server_supported_versions_;
519 QuicVersion negotiated_version_; 525 QuicVersion negotiated_version_;
520 bool strike_register_no_startup_period_; 526 bool strike_register_no_startup_period_;
521 size_t chlo_multiplier_; 527 size_t chlo_multiplier_;
522 QuicTestServer::StreamFactory* stream_factory_; 528 QuicTestServer::StreamFactory* stream_factory_;
529 bool support_server_push_;
523 }; 530 };
524 531
525 // Run all end to end tests with all supported versions. 532 // Run all end to end tests with all supported versions.
526 INSTANTIATE_TEST_CASE_P(EndToEndTests, 533 INSTANTIATE_TEST_CASE_P(EndToEndTests,
527 EndToEndTest, 534 EndToEndTest,
528 ::testing::ValuesIn(GetTestParams())); 535 ::testing::ValuesIn(GetTestParams()));
529 536
530 TEST_P(EndToEndTest, SimpleRequestResponse) { 537 TEST_P(EndToEndTest, SimpleRequestResponse) {
531 ASSERT_TRUE(Initialize()); 538 ASSERT_TRUE(Initialize());
532 539
(...skipping 1757 matching lines...) Expand 10 before | Expand all | Expand 10 after
2290 EXPECT_EQ(trailers, client_->response_trailers()); 2297 EXPECT_EQ(trailers, client_->response_trailers());
2291 } 2298 }
2292 2299
2293 class EndToEndTestServerPush : public EndToEndTest { 2300 class EndToEndTestServerPush : public EndToEndTest {
2294 protected: 2301 protected:
2295 const size_t kNumMaxStreams = 10; 2302 const size_t kNumMaxStreams = 10;
2296 2303
2297 EndToEndTestServerPush() : EndToEndTest() { 2304 EndToEndTestServerPush() : EndToEndTest() {
2298 FLAGS_quic_supports_push_promise = true; 2305 FLAGS_quic_supports_push_promise = true;
2299 client_config_.SetMaxStreamsPerConnection(kNumMaxStreams, kNumMaxStreams); 2306 client_config_.SetMaxStreamsPerConnection(kNumMaxStreams, kNumMaxStreams);
2307 support_server_push_ = true;
2300 } 2308 }
2301 2309
2302 // Add a request with its response and |num_resources| push resources into 2310 // Add a request with its response and |num_resources| push resources into
2303 // cache. 2311 // cache.
2304 // If |resource_size| == 0, response body of push resources use default string 2312 // If |resource_size| == 0, response body of push resources use default string
2305 // concatenating with resource url. Otherwise, generate a string of 2313 // concatenating with resource url. Otherwise, generate a string of
2306 // |resource_size| as body. 2314 // |resource_size| as body.
2307 void AddRequestAndResponseWithServerPush(string host, 2315 void AddRequestAndResponseWithServerPush(string host,
2308 string path, 2316 string path,
2309 string response_body, 2317 string response_body,
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2537 } 2545 }
2538 2546
2539 // Because of server push, client gets all pushed resources without actually 2547 // Because of server push, client gets all pushed resources without actually
2540 // sending requests for them. 2548 // sending requests for them.
2541 EXPECT_EQ(1u, client_->num_requests()); 2549 EXPECT_EQ(1u, client_->num_requests());
2542 // Including response to original request, 12 responses in total were 2550 // Including response to original request, 12 responses in total were
2543 // recieved. 2551 // recieved.
2544 EXPECT_EQ(12u, client_->num_responses()); 2552 EXPECT_EQ(12u, client_->num_responses());
2545 } 2553 }
2546 2554
2555 TEST_P(EndToEndTestServerPush, DisabledWithoutConnectionOption) {
2556 // Tests that server push won't be triggered when kSPSH is not set by client.
2557 support_server_push_ = false;
2558 ASSERT_TRUE(Initialize());
2559
2560 // Add a response with headers, body, and push resources.
2561 const string kBody = "body content";
2562 size_t const kNumResources = 4;
2563 string push_urls[] = {
2564 "https://example.com/font.woff", "https://example.com/script.js",
2565 "https://fonts.example.com/font.woff",
2566 "https://example.com/logo-hires.jpg",
2567 };
2568 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody,
2569 push_urls, kNumResources, 0);
2570 client_->client()->set_response_listener(new TestResponseListener);
2571 EXPECT_EQ(kBody, client_->SendSynchronousRequest(
2572 "https://example.com/push_example"));
2573
2574 for (const string& url : push_urls) {
2575 // Sending subsequent requests will trigger sending real requests because
2576 // client doesn't support server push.
2577 const string expected_body = "This is server push response body for " + url;
2578 const string response_body = client_->SendSynchronousRequest(url);
2579 EXPECT_EQ(expected_body, response_body);
2580 }
2581 // Same number of requests are sent as that of responses received.
2582 EXPECT_EQ(1 + kNumResources, client_->num_requests());
2583 EXPECT_EQ(1 + kNumResources, client_->num_responses());
2584 }
2585
2547 // TODO(fayang): this test seems to cause net_unittests timeouts :| 2586 // TODO(fayang): this test seems to cause net_unittests timeouts :|
2548 TEST_P(EndToEndTest, DISABLED_TestHugePostWithPacketLoss) { 2587 TEST_P(EndToEndTest, DISABLED_TestHugePostWithPacketLoss) {
2549 // This test tests a huge post with introduced packet loss from client to 2588 // This test tests a huge post with introduced packet loss from client to
2550 // server and body size greater than 4GB, making sure QUIC code does not break 2589 // server and body size greater than 4GB, making sure QUIC code does not break
2551 // for 32-bit builds. 2590 // for 32-bit builds.
2552 ServerStreamThatDropsBodyFactory stream_factory; 2591 ServerStreamThatDropsBodyFactory stream_factory;
2553 SetSpdyStreamFactory(&stream_factory); 2592 SetSpdyStreamFactory(&stream_factory);
2554 ASSERT_TRUE(Initialize()); 2593 ASSERT_TRUE(Initialize());
2555 // Set client's epoll server's time out to 0 to make this test be finished 2594 // Set client's epoll server's time out to 0 to make this test be finished
2556 // within a short time. 2595 // within a short time.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2596 // Use a quic client that drops received body. 2635 // Use a quic client that drops received body.
2597 QuicTestClient* client = new QuicTestClientThatDropsBody( 2636 QuicTestClient* client = new QuicTestClientThatDropsBody(
2598 server_address_, server_hostname_, client_config_, 2637 server_address_, server_hostname_, client_config_,
2599 client_supported_versions_); 2638 client_supported_versions_);
2600 client->UseWriter(client_writer_); 2639 client->UseWriter(client_writer_);
2601 client->Connect(); 2640 client->Connect();
2602 client_.reset(client); 2641 client_.reset(client);
2603 static EpollEvent event(EPOLLOUT, false); 2642 static EpollEvent event(EPOLLOUT, false);
2604 client_writer_->Initialize( 2643 client_writer_->Initialize(
2605 QuicConnectionPeer::GetHelper(client_->client()->session()->connection()), 2644 QuicConnectionPeer::GetHelper(client_->client()->session()->connection()),
2645 QuicConnectionPeer::GetAlarmFactory(
2646 client_->client()->session()->connection()),
2606 new ClientDelegate(client_->client())); 2647 new ClientDelegate(client_->client()));
2607 initialized_ = true; 2648 initialized_ = true;
2608 ASSERT_TRUE(client_->client()->connected()); 2649 ASSERT_TRUE(client_->client()->connected());
2609 2650
2610 client_->client()->WaitForCryptoHandshakeConfirmed(); 2651 client_->client()->WaitForCryptoHandshakeConfirmed();
2611 SetPacketLossPercentage(1); 2652 SetPacketLossPercentage(1);
2612 client_->SendRequest("/huge_response"); 2653 client_->SendRequest("/huge_response");
2613 client_->WaitForResponse(); 2654 client_->WaitForResponse();
2614 VerifyCleanConnection(false); 2655 VerifyCleanConnection(false);
2615 } 2656 }
2616 2657
2617 } // namespace 2658 } // namespace
2618 } // namespace test 2659 } // namespace test
2619 } // namespace net 2660 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/simple_quic_framer.cc ('k') | net/tools/quic/quic_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698