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

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

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