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

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

Issue 2591143003: Add QuicStrCat. (Closed)
Patch Set: correct quic_client_bin.cc Created 4 years 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
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 <cstdint> 8 #include <cstdint>
9 #include <list> 9 #include <list>
10 #include <memory> 10 #include <memory>
(...skipping 2613 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 string large_resource; 2624 string large_resource;
2625 if (use_large_response) { 2625 if (use_large_response) {
2626 // Generate a response common body larger than flow control window for 2626 // Generate a response common body larger than flow control window for
2627 // push response. 2627 // push response.
2628 large_resource = string(resource_size, 'a'); 2628 large_resource = string(resource_size, 'a');
2629 } 2629 }
2630 std::list<QuicHttpResponseCache::ServerPushInfo> push_resources; 2630 std::list<QuicHttpResponseCache::ServerPushInfo> push_resources;
2631 for (size_t i = 0; i < num_resources; ++i) { 2631 for (size_t i = 0; i < num_resources; ++i) {
2632 string url = push_urls[i]; 2632 string url = push_urls[i];
2633 GURL resource_url(url); 2633 GURL resource_url(url);
2634 string body = use_large_response 2634 string body =
2635 ? large_resource 2635 use_large_response
2636 : "This is server push response body for " + url; 2636 ? large_resource
2637 : QuicStrCat("This is server push response body for ", url);
2637 SpdyHeaderBlock response_headers; 2638 SpdyHeaderBlock response_headers;
2638 response_headers[":version"] = "HTTP/1.1"; 2639 response_headers[":version"] = "HTTP/1.1";
2639 response_headers[":status"] = "200"; 2640 response_headers[":status"] = "200";
2640 response_headers["content-length"] = IntToString(body.size()); 2641 response_headers["content-length"] = IntToString(body.size());
2641 push_resources.push_back(QuicHttpResponseCache::ServerPushInfo( 2642 push_resources.push_back(QuicHttpResponseCache::ServerPushInfo(
2642 resource_url, std::move(response_headers), kV3LowestPriority, body)); 2643 resource_url, std::move(response_headers), kV3LowestPriority, body));
2643 } 2644 }
2644 2645
2645 response_cache_.AddSimpleResponseWithServerPushResources( 2646 response_cache_.AddSimpleResponseWithServerPushResources(
2646 host, path, 200, response_body, push_resources); 2647 host, path, 200, response_body, push_resources);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2679 "https://example.com/push_example")); 2680 "https://example.com/push_example"));
2680 QuicHeadersStream* headers_stream = 2681 QuicHeadersStream* headers_stream =
2681 QuicSpdySessionPeer::GetHeadersStream(client_->client()->session()); 2682 QuicSpdySessionPeer::GetHeadersStream(client_->client()->session());
2682 QuicStreamSequencer* sequencer = QuicStreamPeer::sequencer(headers_stream); 2683 QuicStreamSequencer* sequencer = QuicStreamPeer::sequencer(headers_stream);
2683 // Headers stream's sequencer buffer shouldn't be released because server push 2684 // Headers stream's sequencer buffer shouldn't be released because server push
2684 // hasn't finished yet. 2685 // hasn't finished yet.
2685 EXPECT_TRUE(QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer)); 2686 EXPECT_TRUE(QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer));
2686 2687
2687 for (const string& url : push_urls) { 2688 for (const string& url : push_urls) {
2688 DVLOG(1) << "send request for pushed stream on url " << url; 2689 DVLOG(1) << "send request for pushed stream on url " << url;
2689 string expected_body = "This is server push response body for " + url; 2690 string expected_body =
2691 QuicStrCat("This is server push response body for ", url);
2690 string response_body = client_->SendSynchronousRequest(url); 2692 string response_body = client_->SendSynchronousRequest(url);
2691 DVLOG(1) << "response body " << response_body; 2693 DVLOG(1) << "response body " << response_body;
2692 EXPECT_EQ(expected_body, response_body); 2694 EXPECT_EQ(expected_body, response_body);
2693 } 2695 }
2694 EXPECT_NE(FLAGS_quic_headers_stream_release_sequencer_buffer && 2696 EXPECT_NE(FLAGS_quic_headers_stream_release_sequencer_buffer &&
2695 FLAGS_quic_reduce_sequencer_buffer_memory_life_time, // NOLINT 2697 FLAGS_quic_reduce_sequencer_buffer_memory_life_time, // NOLINT
2696 QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer)); 2698 QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer));
2697 } 2699 }
2698 2700
2699 TEST_P(EndToEndTestServerPush, ServerPushUnderLimit) { 2701 TEST_P(EndToEndTestServerPush, ServerPushUnderLimit) {
(...skipping 25 matching lines...) Expand all
2725 // Send the first request: this will trigger the server to send all the push 2727 // Send the first request: this will trigger the server to send all the push
2726 // resources associated with this request, and these will be cached by the 2728 // resources associated with this request, and these will be cached by the
2727 // client. 2729 // client.
2728 EXPECT_EQ(kBody, client_->SendSynchronousRequest( 2730 EXPECT_EQ(kBody, client_->SendSynchronousRequest(
2729 "https://example.com/push_example")); 2731 "https://example.com/push_example"));
2730 2732
2731 for (const string& url : push_urls) { 2733 for (const string& url : push_urls) {
2732 // Sending subsequent requesets will not actually send anything on the wire, 2734 // Sending subsequent requesets will not actually send anything on the wire,
2733 // as the responses are already in the client's cache. 2735 // as the responses are already in the client's cache.
2734 DVLOG(1) << "send request for pushed stream on url " << url; 2736 DVLOG(1) << "send request for pushed stream on url " << url;
2735 string expected_body = "This is server push response body for " + url; 2737 string expected_body =
2738 QuicStrCat("This is server push response body for ", url);
2736 string response_body = client_->SendSynchronousRequest(url); 2739 string response_body = client_->SendSynchronousRequest(url);
2737 DVLOG(1) << "response body " << response_body; 2740 DVLOG(1) << "response body " << response_body;
2738 EXPECT_EQ(expected_body, response_body); 2741 EXPECT_EQ(expected_body, response_body);
2739 } 2742 }
2740 // Expect only original request has been sent and push responses have been 2743 // Expect only original request has been sent and push responses have been
2741 // received as normal response. 2744 // received as normal response.
2742 EXPECT_EQ(1u, client_->num_requests()); 2745 EXPECT_EQ(1u, client_->num_requests());
2743 EXPECT_EQ(1u + kNumResources, client_->num_responses()); 2746 EXPECT_EQ(1u + kNumResources, client_->num_responses());
2744 } 2747 }
2745 2748
2746 TEST_P(EndToEndTestServerPush, ServerPushOverLimitNonBlocking) { 2749 TEST_P(EndToEndTestServerPush, ServerPushOverLimitNonBlocking) {
2747 // Tests that when streams are not blocked by flow control or congestion 2750 // Tests that when streams are not blocked by flow control or congestion
2748 // control, pushing even more resources than max number of open outgoing 2751 // control, pushing even more resources than max number of open outgoing
2749 // streams should still work because all response streams get closed 2752 // streams should still work because all response streams get closed
2750 // immediately after pushing resources. 2753 // immediately after pushing resources.
2751 ASSERT_TRUE(Initialize()); 2754 ASSERT_TRUE(Initialize());
2752 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed()); 2755 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
2753 2756
2754 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok. 2757 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok.
2755 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); 2758 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2));
2756 SetReorderPercentage(30); 2759 SetReorderPercentage(30);
2757 2760
2758 // Add a response with headers, body, and push resources. 2761 // Add a response with headers, body, and push resources.
2759 const string kBody = "body content"; 2762 const string kBody = "body content";
2760 2763
2761 // One more resource than max number of outgoing stream of this session. 2764 // One more resource than max number of outgoing stream of this session.
2762 const size_t kNumResources = 1 + kNumMaxStreams; // 11. 2765 const size_t kNumResources = 1 + kNumMaxStreams; // 11.
2763 string push_urls[11]; 2766 string push_urls[11];
2764 for (size_t i = 0; i < kNumResources; ++i) { 2767 for (size_t i = 0; i < kNumResources; ++i) {
2765 push_urls[i] = "https://example.com/push_resources" + base::UintToString(i); 2768 push_urls[i] = QuicStrCat("https://example.com/push_resources", i);
2766 } 2769 }
2767 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody, 2770 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody,
2768 push_urls, kNumResources, 0); 2771 push_urls, kNumResources, 0);
2769 client_->client()->set_response_listener( 2772 client_->client()->set_response_listener(
2770 std::unique_ptr<QuicClientBase::ResponseListener>( 2773 std::unique_ptr<QuicClientBase::ResponseListener>(
2771 new TestResponseListener)); 2774 new TestResponseListener));
2772 2775
2773 // Send the first request: this will trigger the server to send all the push 2776 // Send the first request: this will trigger the server to send all the push
2774 // resources associated with this request, and these will be cached by the 2777 // resources associated with this request, and these will be cached by the
2775 // client. 2778 // client.
2776 EXPECT_EQ(kBody, client_->SendSynchronousRequest( 2779 EXPECT_EQ(kBody, client_->SendSynchronousRequest(
2777 "https://example.com/push_example")); 2780 "https://example.com/push_example"));
2778 2781
2779 for (const string& url : push_urls) { 2782 for (const string& url : push_urls) {
2780 // Sending subsequent requesets will not actually send anything on the wire, 2783 // Sending subsequent requesets will not actually send anything on the wire,
2781 // as the responses are already in the client's cache. 2784 // as the responses are already in the client's cache.
2782 EXPECT_EQ("This is server push response body for " + url, 2785 EXPECT_EQ(QuicStrCat("This is server push response body for ", url),
2783 client_->SendSynchronousRequest(url)); 2786 client_->SendSynchronousRequest(url));
2784 } 2787 }
2785 2788
2786 // Only 1 request should have been sent. 2789 // Only 1 request should have been sent.
2787 EXPECT_EQ(1u, client_->num_requests()); 2790 EXPECT_EQ(1u, client_->num_requests());
2788 // The responses to the original request and all the promised resources 2791 // The responses to the original request and all the promised resources
2789 // should have been received. 2792 // should have been received.
2790 EXPECT_EQ(12u, client_->num_responses()); 2793 EXPECT_EQ(12u, client_->num_responses());
2791 } 2794 }
2792 2795
(...skipping 19 matching lines...) Expand all
2812 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok. 2815 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok.
2813 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); 2816 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2));
2814 SetReorderPercentage(30); 2817 SetReorderPercentage(30);
2815 2818
2816 // Add a response with headers, body, and push resources. 2819 // Add a response with headers, body, and push resources.
2817 const string kBody = "body content"; 2820 const string kBody = "body content";
2818 2821
2819 const size_t kNumResources = kNumMaxStreams + 1; 2822 const size_t kNumResources = kNumMaxStreams + 1;
2820 string push_urls[11]; 2823 string push_urls[11];
2821 for (size_t i = 0; i < kNumResources; ++i) { 2824 for (size_t i = 0; i < kNumResources; ++i) {
2822 push_urls[i] = "http://example.com/push_resources" + base::UintToString(i); 2825 push_urls[i] = QuicStrCat("http://example.com/push_resources", i);
2823 } 2826 }
2824 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody, 2827 AddRequestAndResponseWithServerPush("example.com", "/push_example", kBody,
2825 push_urls, kNumResources, kBodySize); 2828 push_urls, kNumResources, kBodySize);
2826 2829
2827 client_->client()->set_response_listener( 2830 client_->client()->set_response_listener(
2828 std::unique_ptr<QuicClientBase::ResponseListener>( 2831 std::unique_ptr<QuicClientBase::ResponseListener>(
2829 new TestResponseListener)); 2832 new TestResponseListener));
2830 2833
2831 client_->SendRequest("https://example.com/push_example"); 2834 client_->SendRequest("https://example.com/push_example");
2832 2835
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2892 push_urls, kNumResources, 0); 2895 push_urls, kNumResources, 0);
2893 client_->client()->set_response_listener( 2896 client_->client()->set_response_listener(
2894 std::unique_ptr<QuicClientBase::ResponseListener>( 2897 std::unique_ptr<QuicClientBase::ResponseListener>(
2895 new TestResponseListener)); 2898 new TestResponseListener));
2896 EXPECT_EQ(kBody, client_->SendSynchronousRequest( 2899 EXPECT_EQ(kBody, client_->SendSynchronousRequest(
2897 "https://example.com/push_example")); 2900 "https://example.com/push_example"));
2898 2901
2899 for (const string& url : push_urls) { 2902 for (const string& url : push_urls) {
2900 // Sending subsequent requests will trigger sending real requests because 2903 // Sending subsequent requests will trigger sending real requests because
2901 // client doesn't support server push. 2904 // client doesn't support server push.
2902 const string expected_body = "This is server push response body for " + url; 2905 const string expected_body =
2906 QuicStrCat("This is server push response body for ", url);
2903 const string response_body = client_->SendSynchronousRequest(url); 2907 const string response_body = client_->SendSynchronousRequest(url);
2904 EXPECT_EQ(expected_body, response_body); 2908 EXPECT_EQ(expected_body, response_body);
2905 } 2909 }
2906 // Same number of requests are sent as that of responses received. 2910 // Same number of requests are sent as that of responses received.
2907 EXPECT_EQ(1 + kNumResources, client_->num_requests()); 2911 EXPECT_EQ(1 + kNumResources, client_->num_requests());
2908 EXPECT_EQ(1 + kNumResources, client_->num_responses()); 2912 EXPECT_EQ(1 + kNumResources, client_->num_responses());
2909 } 2913 }
2910 2914
2911 // TODO(fayang): this test seems to cause net_unittests timeouts :| 2915 // TODO(fayang): this test seems to cause net_unittests timeouts :|
2912 TEST_P(EndToEndTest, DISABLED_TestHugePostWithPacketLoss) { 2916 TEST_P(EndToEndTest, DISABLED_TestHugePostWithPacketLoss) {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
3047 client_->WaitForResponse(); 3051 client_->WaitForResponse();
3048 EXPECT_EQ(kBarResponseBody, client_->response_body()); 3052 EXPECT_EQ(kBarResponseBody, client_->response_body());
3049 QuicConnectionStats client_stats = 3053 QuicConnectionStats client_stats =
3050 client_->client()->session()->connection()->GetStats(); 3054 client_->client()->session()->connection()->GetStats();
3051 EXPECT_EQ(0u, client_stats.packets_lost); 3055 EXPECT_EQ(0u, client_stats.packets_lost);
3052 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); 3056 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos());
3053 } 3057 }
3054 } // namespace 3058 } // namespace
3055 } // namespace test 3059 } // namespace test
3056 } // namespace net 3060 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698