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

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

Issue 1911653003: Add a server push disabled test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@119583512
Patch Set: Rebase 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 | « no previous file | no next file » | 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_));
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 PacketDroppingTestWriter* server_writer_; 515 PacketDroppingTestWriter* server_writer_;
514 bool server_started_; 516 bool server_started_;
515 QuicConfig client_config_; 517 QuicConfig client_config_;
516 QuicConfig server_config_; 518 QuicConfig server_config_;
517 QuicVersionVector client_supported_versions_; 519 QuicVersionVector client_supported_versions_;
518 QuicVersionVector server_supported_versions_; 520 QuicVersionVector server_supported_versions_;
519 QuicVersion negotiated_version_; 521 QuicVersion negotiated_version_;
520 bool strike_register_no_startup_period_; 522 bool strike_register_no_startup_period_;
521 size_t chlo_multiplier_; 523 size_t chlo_multiplier_;
522 QuicTestServer::StreamFactory* stream_factory_; 524 QuicTestServer::StreamFactory* stream_factory_;
525 bool support_server_push_;
523 }; 526 };
524 527
525 // Run all end to end tests with all supported versions. 528 // Run all end to end tests with all supported versions.
526 INSTANTIATE_TEST_CASE_P(EndToEndTests, 529 INSTANTIATE_TEST_CASE_P(EndToEndTests,
527 EndToEndTest, 530 EndToEndTest,
528 ::testing::ValuesIn(GetTestParams())); 531 ::testing::ValuesIn(GetTestParams()));
529 532
530 TEST_P(EndToEndTest, SimpleRequestResponse) { 533 TEST_P(EndToEndTest, SimpleRequestResponse) {
531 ASSERT_TRUE(Initialize()); 534 ASSERT_TRUE(Initialize());
532 535
(...skipping 1757 matching lines...) Expand 10 before | Expand all | Expand 10 after
2290 EXPECT_EQ(trailers, client_->response_trailers()); 2293 EXPECT_EQ(trailers, client_->response_trailers());
2291 } 2294 }
2292 2295
2293 class EndToEndTestServerPush : public EndToEndTest { 2296 class EndToEndTestServerPush : public EndToEndTest {
2294 protected: 2297 protected:
2295 const size_t kNumMaxStreams = 10; 2298 const size_t kNumMaxStreams = 10;
2296 2299
2297 EndToEndTestServerPush() : EndToEndTest() { 2300 EndToEndTestServerPush() : EndToEndTest() {
2298 FLAGS_quic_supports_push_promise = true; 2301 FLAGS_quic_supports_push_promise = true;
2299 client_config_.SetMaxStreamsPerConnection(kNumMaxStreams, kNumMaxStreams); 2302 client_config_.SetMaxStreamsPerConnection(kNumMaxStreams, kNumMaxStreams);
2303 support_server_push_ = true;
2300 } 2304 }
2301 2305
2302 // Add a request with its response and |num_resources| push resources into 2306 // Add a request with its response and |num_resources| push resources into
2303 // cache. 2307 // cache.
2304 // If |resource_size| == 0, response body of push resources use default string 2308 // If |resource_size| == 0, response body of push resources use default string
2305 // concatenating with resource url. Otherwise, generate a string of 2309 // concatenating with resource url. Otherwise, generate a string of
2306 // |resource_size| as body. 2310 // |resource_size| as body.
2307 void AddRequestAndResponseWithServerPush(string host, 2311 void AddRequestAndResponseWithServerPush(string host,
2308 string path, 2312 string path,
2309 string response_body, 2313 string response_body,
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2537 } 2541 }
2538 2542
2539 // Because of server push, client gets all pushed resources without actually 2543 // Because of server push, client gets all pushed resources without actually
2540 // sending requests for them. 2544 // sending requests for them.
2541 EXPECT_EQ(1u, client_->num_requests()); 2545 EXPECT_EQ(1u, client_->num_requests());
2542 // Including response to original request, 12 responses in total were 2546 // Including response to original request, 12 responses in total were
2543 // recieved. 2547 // recieved.
2544 EXPECT_EQ(12u, client_->num_responses()); 2548 EXPECT_EQ(12u, client_->num_responses());
2545 } 2549 }
2546 2550
2551 TEST_P(EndToEndTestServerPush, DisabledWithoutConnectionOption) {
2552 // Tests that server push won't be triggered when kSPSH is not set by client.
2553 support_server_push_ = false;
2554 ASSERT_TRUE(Initialize());
2555
2556 // Add a response with headers, body, and push resources.
2557 const string kBody = "body content";
2558 size_t const kNumResources = 4;
2559 string push_urls[] = {
2560 "https://example.com/font.woff", "https://example.com/script.js",
2561 "https://fonts.example.com/font.woff",
2562 "https://example.com/logo-hires.jpg",
2563 };
2564 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody,
2565 push_urls, kNumResources, 0);
2566 client_->client()->set_response_listener(new TestResponseListener);
2567 EXPECT_EQ(kBody, client_->SendSynchronousRequest(
2568 "https://example.com/push_example"));
2569
2570 for (const string& url : push_urls) {
2571 // Sending subsequent requests will trigger sending real requests because
2572 // client doesn't support server push.
2573 const string expected_body =
2574 "This is server push response body for " + url;
2575 const string response_body = client_->SendSynchronousRequest(url);
2576 EXPECT_EQ(expected_body, response_body);
2577 }
2578 // Same number of requests are sent as that of responses received.
2579 EXPECT_EQ(1 + kNumResources, client_->num_requests());
2580 EXPECT_EQ(1 + kNumResources, client_->num_responses());
2581 }
2582
2547 // TODO(fayang): this test seems to cause net_unittests timeouts :| 2583 // TODO(fayang): this test seems to cause net_unittests timeouts :|
2548 TEST_P(EndToEndTest, DISABLED_TestHugePostWithPacketLoss) { 2584 TEST_P(EndToEndTest, DISABLED_TestHugePostWithPacketLoss) {
2549 // This test tests a huge post with introduced packet loss from client to 2585 // 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 2586 // server and body size greater than 4GB, making sure QUIC code does not break
2551 // for 32-bit builds. 2587 // for 32-bit builds.
2552 ServerStreamThatDropsBodyFactory stream_factory; 2588 ServerStreamThatDropsBodyFactory stream_factory;
2553 SetSpdyStreamFactory(&stream_factory); 2589 SetSpdyStreamFactory(&stream_factory);
2554 ASSERT_TRUE(Initialize()); 2590 ASSERT_TRUE(Initialize());
2555 // Set client's epoll server's time out to 0 to make this test be finished 2591 // Set client's epoll server's time out to 0 to make this test be finished
2556 // within a short time. 2592 // within a short time.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2610 client_->client()->WaitForCryptoHandshakeConfirmed(); 2646 client_->client()->WaitForCryptoHandshakeConfirmed();
2611 SetPacketLossPercentage(1); 2647 SetPacketLossPercentage(1);
2612 client_->SendRequest("/huge_response"); 2648 client_->SendRequest("/huge_response");
2613 client_->WaitForResponse(); 2649 client_->WaitForResponse();
2614 VerifyCleanConnection(false); 2650 VerifyCleanConnection(false);
2615 } 2651 }
2616 2652
2617 } // namespace 2653 } // namespace
2618 } // namespace test 2654 } // namespace test
2619 } // namespace net 2655 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698