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

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

Issue 2536033004: Remove uses of gfe2::test::GenerateBody from QUIC code and use the string fill constructor instead. (Closed)
Patch Set: 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 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 client_->response_body()); 725 client_->response_body());
726 EXPECT_EQ("500", client_->response_headers()->find(":status")->second); 726 EXPECT_EQ("500", client_->response_headers()->find(":status")->second);
727 } 727 }
728 728
729 TEST_P(EndToEndTest, LargePostNoPacketLoss) { 729 TEST_P(EndToEndTest, LargePostNoPacketLoss) {
730 ASSERT_TRUE(Initialize()); 730 ASSERT_TRUE(Initialize());
731 731
732 client_->client()->WaitForCryptoHandshakeConfirmed(); 732 client_->client()->WaitForCryptoHandshakeConfirmed();
733 733
734 // 1 MB body. 734 // 1 MB body.
735 string body; 735 string body(1024 * 1024, 'a');
736 GenerateBody(&body, 1024 * 1024);
737 SpdyHeaderBlock headers; 736 SpdyHeaderBlock headers;
738 headers[":method"] = "POST"; 737 headers[":method"] = "POST";
739 headers[":path"] = "/foo"; 738 headers[":path"] = "/foo";
740 headers[":scheme"] = "https"; 739 headers[":scheme"] = "https";
741 headers[":authority"] = server_hostname_; 740 headers[":authority"] = server_hostname_;
742 741
743 EXPECT_EQ(kFooResponseBody, 742 EXPECT_EQ(kFooResponseBody,
744 client_->SendCustomSynchronousRequest(headers, body)); 743 client_->SendCustomSynchronousRequest(headers, body));
745 // TODO(ianswett): There should not be packet loss in this test, but on some 744 // TODO(ianswett): There should not be packet loss in this test, but on some
746 // platforms the receive buffer overflows. 745 // platforms the receive buffer overflows.
747 VerifyCleanConnection(true); 746 VerifyCleanConnection(true);
748 } 747 }
749 748
750 TEST_P(EndToEndTest, LargePostNoPacketLoss1sRTT) { 749 TEST_P(EndToEndTest, LargePostNoPacketLoss1sRTT) {
751 ASSERT_TRUE(Initialize()); 750 ASSERT_TRUE(Initialize());
752 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(1000)); 751 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(1000));
753 752
754 client_->client()->WaitForCryptoHandshakeConfirmed(); 753 client_->client()->WaitForCryptoHandshakeConfirmed();
755 754
756 // 100 KB body. 755 // 100 KB body.
757 string body; 756 string body(100 * 1024, 'a');
758 GenerateBody(&body, 100 * 1024);
759 SpdyHeaderBlock headers; 757 SpdyHeaderBlock headers;
760 headers[":method"] = "POST"; 758 headers[":method"] = "POST";
761 headers[":path"] = "/foo"; 759 headers[":path"] = "/foo";
762 headers[":scheme"] = "https"; 760 headers[":scheme"] = "https";
763 headers[":authority"] = server_hostname_; 761 headers[":authority"] = server_hostname_;
764 762
765 EXPECT_EQ(kFooResponseBody, 763 EXPECT_EQ(kFooResponseBody,
766 client_->SendCustomSynchronousRequest(headers, body)); 764 client_->SendCustomSynchronousRequest(headers, body));
767 VerifyCleanConnection(false); 765 VerifyCleanConnection(false);
768 } 766 }
769 767
770 TEST_P(EndToEndTest, LargePostWithPacketLoss) { 768 TEST_P(EndToEndTest, LargePostWithPacketLoss) {
771 if (!BothSidesSupportStatelessRejects()) { 769 if (!BothSidesSupportStatelessRejects()) {
772 // Connect with lower fake packet loss than we'd like to test. 770 // Connect with lower fake packet loss than we'd like to test.
773 // Until b/10126687 is fixed, losing handshake packets is pretty 771 // Until b/10126687 is fixed, losing handshake packets is pretty
774 // brutal. 772 // brutal.
775 // TODO(jokulik): Until we support redundant SREJ packets, don't 773 // TODO(jokulik): Until we support redundant SREJ packets, don't
776 // drop handshake packets for stateless rejects. 774 // drop handshake packets for stateless rejects.
777 SetPacketLossPercentage(5); 775 SetPacketLossPercentage(5);
778 } 776 }
779 ASSERT_TRUE(Initialize()); 777 ASSERT_TRUE(Initialize());
780 778
781 // Wait for the server SHLO before upping the packet loss. 779 // Wait for the server SHLO before upping the packet loss.
782 client_->client()->WaitForCryptoHandshakeConfirmed(); 780 client_->client()->WaitForCryptoHandshakeConfirmed();
783 SetPacketLossPercentage(30); 781 SetPacketLossPercentage(30);
784 782
785 // 10 KB body. 783 // 10 KB body.
786 string body; 784 string body(1024 * 10, 'a');
787 GenerateBody(&body, 1024 * 10);
788 SpdyHeaderBlock headers; 785 SpdyHeaderBlock headers;
789 headers[":method"] = "POST"; 786 headers[":method"] = "POST";
790 headers[":path"] = "/foo"; 787 headers[":path"] = "/foo";
791 headers[":scheme"] = "https"; 788 headers[":scheme"] = "https";
792 headers[":authority"] = server_hostname_; 789 headers[":authority"] = server_hostname_;
793 790
794 EXPECT_EQ(kFooResponseBody, 791 EXPECT_EQ(kFooResponseBody,
795 client_->SendCustomSynchronousRequest(headers, body)); 792 client_->SendCustomSynchronousRequest(headers, body));
796 VerifyCleanConnection(true); 793 VerifyCleanConnection(true);
797 } 794 }
798 795
799 TEST_P(EndToEndTest, LargePostWithPacketLossAndBlockedSocket) { 796 TEST_P(EndToEndTest, LargePostWithPacketLossAndBlockedSocket) {
800 if (!BothSidesSupportStatelessRejects()) { 797 if (!BothSidesSupportStatelessRejects()) {
801 // Connect with lower fake packet loss than we'd like to test. Until 798 // Connect with lower fake packet loss than we'd like to test. Until
802 // b/10126687 is fixed, losing handshake packets is pretty brutal. 799 // b/10126687 is fixed, losing handshake packets is pretty brutal.
803 // TODO(jokulik): Until we support redundant SREJ packets, don't 800 // TODO(jokulik): Until we support redundant SREJ packets, don't
804 // drop handshake packets for stateless rejects. 801 // drop handshake packets for stateless rejects.
805 SetPacketLossPercentage(5); 802 SetPacketLossPercentage(5);
806 } 803 }
807 ASSERT_TRUE(Initialize()); 804 ASSERT_TRUE(Initialize());
808 805
809 // Wait for the server SHLO before upping the packet loss. 806 // Wait for the server SHLO before upping the packet loss.
810 client_->client()->WaitForCryptoHandshakeConfirmed(); 807 client_->client()->WaitForCryptoHandshakeConfirmed();
811 SetPacketLossPercentage(10); 808 SetPacketLossPercentage(10);
812 client_writer_->set_fake_blocked_socket_percentage(10); 809 client_writer_->set_fake_blocked_socket_percentage(10);
813 810
814 // 10 KB body. 811 // 10 KB body.
815 string body; 812 string body(1024 * 10, 'a');
816 GenerateBody(&body, 1024 * 10);
817 SpdyHeaderBlock headers; 813 SpdyHeaderBlock headers;
818 headers[":method"] = "POST"; 814 headers[":method"] = "POST";
819 headers[":path"] = "/foo"; 815 headers[":path"] = "/foo";
820 headers[":scheme"] = "https"; 816 headers[":scheme"] = "https";
821 headers[":authority"] = server_hostname_; 817 headers[":authority"] = server_hostname_;
822 818
823 EXPECT_EQ(kFooResponseBody, 819 EXPECT_EQ(kFooResponseBody,
824 client_->SendCustomSynchronousRequest(headers, body)); 820 client_->SendCustomSynchronousRequest(headers, body));
825 } 821 }
826 822
827 TEST_P(EndToEndTest, LargePostNoPacketLossWithDelayAndReordering) { 823 TEST_P(EndToEndTest, LargePostNoPacketLossWithDelayAndReordering) {
828 ASSERT_TRUE(Initialize()); 824 ASSERT_TRUE(Initialize());
829 825
830 client_->client()->WaitForCryptoHandshakeConfirmed(); 826 client_->client()->WaitForCryptoHandshakeConfirmed();
831 // Both of these must be called when the writer is not actively used. 827 // Both of these must be called when the writer is not actively used.
832 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); 828 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2));
833 SetReorderPercentage(30); 829 SetReorderPercentage(30);
834 830
835 // 1 MB body. 831 // 1 MB body.
836 string body; 832 string body(1024 * 1024, 'a');
837 GenerateBody(&body, 1024 * 1024);
838 SpdyHeaderBlock headers; 833 SpdyHeaderBlock headers;
839 headers[":method"] = "POST"; 834 headers[":method"] = "POST";
840 headers[":path"] = "/foo"; 835 headers[":path"] = "/foo";
841 headers[":scheme"] = "https"; 836 headers[":scheme"] = "https";
842 headers[":authority"] = server_hostname_; 837 headers[":authority"] = server_hostname_;
843 838
844 EXPECT_EQ(kFooResponseBody, 839 EXPECT_EQ(kFooResponseBody,
845 client_->SendCustomSynchronousRequest(headers, body)); 840 client_->SendCustomSynchronousRequest(headers, body));
846 } 841 }
847 842
848 TEST_P(EndToEndTest, LargePostZeroRTTFailure) { 843 TEST_P(EndToEndTest, LargePostZeroRTTFailure) {
849 // Send a request and then disconnect. This prepares the client to attempt 844 // Send a request and then disconnect. This prepares the client to attempt
850 // a 0-RTT handshake for the next request. 845 // a 0-RTT handshake for the next request.
851 ASSERT_TRUE(Initialize()); 846 ASSERT_TRUE(Initialize());
852 847
853 string body; 848 string body(20480, 'a');
854 GenerateBody(&body, 20480);
855 SpdyHeaderBlock headers; 849 SpdyHeaderBlock headers;
856 headers[":method"] = "POST"; 850 headers[":method"] = "POST";
857 headers[":path"] = "/foo"; 851 headers[":path"] = "/foo";
858 headers[":scheme"] = "https"; 852 headers[":scheme"] = "https";
859 headers[":authority"] = server_hostname_; 853 headers[":authority"] = server_hostname_;
860 854
861 EXPECT_EQ(kFooResponseBody, 855 EXPECT_EQ(kFooResponseBody,
862 client_->SendCustomSynchronousRequest(headers, body)); 856 client_->SendCustomSynchronousRequest(headers, body));
863 // In the non-stateless case, the same session is used for both 857 // In the non-stateless case, the same session is used for both
864 // hellos, so the number of hellos sent on that session is 2. In 858 // hellos, so the number of hellos sent on that session is 2. In
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); 948 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos());
955 949
956 VerifyCleanConnection(false); 950 VerifyCleanConnection(false);
957 } 951 }
958 952
959 TEST_P(EndToEndTest, LargePostSynchronousRequest) { 953 TEST_P(EndToEndTest, LargePostSynchronousRequest) {
960 // Send a request and then disconnect. This prepares the client to attempt 954 // Send a request and then disconnect. This prepares the client to attempt
961 // a 0-RTT handshake for the next request. 955 // a 0-RTT handshake for the next request.
962 ASSERT_TRUE(Initialize()); 956 ASSERT_TRUE(Initialize());
963 957
964 string body; 958 string body(20480, 'a');
965 GenerateBody(&body, 20480);
966 SpdyHeaderBlock headers; 959 SpdyHeaderBlock headers;
967 headers[":method"] = "POST"; 960 headers[":method"] = "POST";
968 headers[":path"] = "/foo"; 961 headers[":path"] = "/foo";
969 headers[":scheme"] = "https"; 962 headers[":scheme"] = "https";
970 headers[":authority"] = server_hostname_; 963 headers[":authority"] = server_hostname_;
971 964
972 EXPECT_EQ(kFooResponseBody, 965 EXPECT_EQ(kFooResponseBody,
973 client_->SendCustomSynchronousRequest(headers, body)); 966 client_->SendCustomSynchronousRequest(headers, body));
974 // In the non-stateless case, the same session is used for both 967 // In the non-stateless case, the same session is used for both
975 // hellos, so the number of hellos sent on that session is 2. In 968 // hellos, so the number of hellos sent on that session is 2. In
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 ASSERT_TRUE(Initialize()); 1048 ASSERT_TRUE(Initialize());
1056 SetPacketSendDelay(QuicTime::Delta::FromMicroseconds(1)); 1049 SetPacketSendDelay(QuicTime::Delta::FromMicroseconds(1));
1057 // 256KB per second with a 256KB buffer from server to client. Wireless 1050 // 256KB per second with a 256KB buffer from server to client. Wireless
1058 // clients commonly have larger buffers, but our max CWND is 200. 1051 // clients commonly have larger buffers, but our max CWND is 200.
1059 server_writer_->set_max_bandwidth_and_buffer_size( 1052 server_writer_->set_max_bandwidth_and_buffer_size(
1060 QuicBandwidth::FromBytesPerSecond(256 * 1024), 256 * 1024); 1053 QuicBandwidth::FromBytesPerSecond(256 * 1024), 256 * 1024);
1061 1054
1062 client_->client()->WaitForCryptoHandshakeConfirmed(); 1055 client_->client()->WaitForCryptoHandshakeConfirmed();
1063 1056
1064 // 1 MB body. 1057 // 1 MB body.
1065 string body; 1058 string body(1024 * 1024, 'a');
1066 GenerateBody(&body, 1024 * 1024);
1067 SpdyHeaderBlock headers; 1059 SpdyHeaderBlock headers;
1068 headers[":method"] = "POST"; 1060 headers[":method"] = "POST";
1069 headers[":path"] = "/foo"; 1061 headers[":path"] = "/foo";
1070 headers[":scheme"] = "https"; 1062 headers[":scheme"] = "https";
1071 headers[":authority"] = server_hostname_; 1063 headers[":authority"] = server_hostname_;
1072 1064
1073 EXPECT_EQ(kFooResponseBody, 1065 EXPECT_EQ(kFooResponseBody,
1074 client_->SendCustomSynchronousRequest(headers, body)); 1066 client_->SendCustomSynchronousRequest(headers, body));
1075 // This connection may drop packets, because the buffer is smaller than the 1067 // This connection may drop packets, because the buffer is smaller than the
1076 // max CWND. 1068 // max CWND.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 1106
1115 QuicAlarm* resume_writes_alarm = 1107 QuicAlarm* resume_writes_alarm =
1116 QuicConnectionPeer::GetResumeWritesAlarm(session->connection()); 1108 QuicConnectionPeer::GetResumeWritesAlarm(session->connection());
1117 EXPECT_FALSE(resume_writes_alarm->IsSet()); 1109 EXPECT_FALSE(resume_writes_alarm->IsSet());
1118 } 1110 }
1119 1111
1120 TEST_P(EndToEndTest, InvalidStream) { 1112 TEST_P(EndToEndTest, InvalidStream) {
1121 ASSERT_TRUE(Initialize()); 1113 ASSERT_TRUE(Initialize());
1122 client_->client()->WaitForCryptoHandshakeConfirmed(); 1114 client_->client()->WaitForCryptoHandshakeConfirmed();
1123 1115
1124 string body; 1116 string body(kMaxPacketSize, 'a');
1125 GenerateBody(&body, kMaxPacketSize);
1126 SpdyHeaderBlock headers; 1117 SpdyHeaderBlock headers;
1127 headers[":method"] = "POST"; 1118 headers[":method"] = "POST";
1128 headers[":path"] = "/foo"; 1119 headers[":path"] = "/foo";
1129 headers[":scheme"] = "https"; 1120 headers[":scheme"] = "https";
1130 headers[":authority"] = server_hostname_; 1121 headers[":authority"] = server_hostname_;
1131 1122
1132 // Force the client to write with a stream ID belonging to a nonexistent 1123 // Force the client to write with a stream ID belonging to a nonexistent
1133 // server-side stream. 1124 // server-side stream.
1134 QuicSessionPeer::SetNextOutgoingStreamId(client_->client()->session(), 2); 1125 QuicSessionPeer::SetNextOutgoingStreamId(client_->client()->session(), 2);
1135 1126
1136 client_->SendCustomSynchronousRequest(headers, body); 1127 client_->SendCustomSynchronousRequest(headers, body);
1137 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); 1128 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error());
1138 EXPECT_EQ(QUIC_INVALID_STREAM_ID, client_->connection_error()); 1129 EXPECT_EQ(QUIC_INVALID_STREAM_ID, client_->connection_error());
1139 } 1130 }
1140 1131
1141 // Test that if the the server will close the connection if the client attempts 1132 // Test that if the the server will close the connection if the client attempts
1142 // to send a request with overly large headers. 1133 // to send a request with overly large headers.
1143 TEST_P(EndToEndTest, LargeHeaders) { 1134 TEST_P(EndToEndTest, LargeHeaders) {
1144 ASSERT_TRUE(Initialize()); 1135 ASSERT_TRUE(Initialize());
1145 client_->client()->WaitForCryptoHandshakeConfirmed(); 1136 client_->client()->WaitForCryptoHandshakeConfirmed();
1146 1137
1147 string body; 1138 string body(kMaxPacketSize, 'a');
1148 GenerateBody(&body, kMaxPacketSize);
1149 SpdyHeaderBlock headers; 1139 SpdyHeaderBlock headers;
1150 headers[":method"] = "POST"; 1140 headers[":method"] = "POST";
1151 headers[":path"] = "/foo"; 1141 headers[":path"] = "/foo";
1152 headers[":scheme"] = "https"; 1142 headers[":scheme"] = "https";
1153 headers[":authority"] = server_hostname_; 1143 headers[":authority"] = server_hostname_;
1154 headers["key1"] = string(15 * 1024, 'a'); 1144 headers["key1"] = string(15 * 1024, 'a');
1155 headers["key2"] = string(15 * 1024, 'a'); 1145 headers["key2"] = string(15 * 1024, 'a');
1156 headers["key3"] = string(15 * 1024, 'a'); 1146 headers["key3"] = string(15 * 1024, 'a');
1157 1147
1158 client_->SendCustomSynchronousRequest(headers, body); 1148 client_->SendCustomSynchronousRequest(headers, body);
1159 if (FLAGS_quic_limit_uncompressed_headers) { 1149 if (FLAGS_quic_limit_uncompressed_headers) {
1160 EXPECT_EQ(QUIC_HEADERS_TOO_LARGE, client_->stream_error()); 1150 EXPECT_EQ(QUIC_HEADERS_TOO_LARGE, client_->stream_error());
1161 } else { 1151 } else {
1162 EXPECT_EQ(QUIC_STREAM_NO_ERROR, client_->stream_error()); 1152 EXPECT_EQ(QUIC_STREAM_NO_ERROR, client_->stream_error());
1163 EXPECT_EQ(kFooResponseBody, client_->response_body()); 1153 EXPECT_EQ(kFooResponseBody, client_->response_body());
1164 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); 1154 EXPECT_EQ("200", client_->response_headers()->find(":status")->second);
1165 } 1155 }
1166 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error()); 1156 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error());
1167 } 1157 }
1168 1158
1169 TEST_P(EndToEndTest, EarlyResponseWithQuicStreamNoError) { 1159 TEST_P(EndToEndTest, EarlyResponseWithQuicStreamNoError) {
1170 ASSERT_TRUE(Initialize()); 1160 ASSERT_TRUE(Initialize());
1171 client_->client()->WaitForCryptoHandshakeConfirmed(); 1161 client_->client()->WaitForCryptoHandshakeConfirmed();
1172 1162
1173 string large_body; 1163 string large_body(1024 * 1024, 'a');
1174 GenerateBody(&large_body, 1024 * 1024);
1175 SpdyHeaderBlock headers; 1164 SpdyHeaderBlock headers;
1176 headers[":method"] = "POST"; 1165 headers[":method"] = "POST";
1177 headers[":path"] = "/foo"; 1166 headers[":path"] = "/foo";
1178 headers[":scheme"] = "https"; 1167 headers[":scheme"] = "https";
1179 headers[":authority"] = server_hostname_; 1168 headers[":authority"] = server_hostname_;
1180 // Insert an invalid content_length field in request to trigger an early 1169 // Insert an invalid content_length field in request to trigger an early
1181 // response from server. 1170 // response from server.
1182 headers["content-length"] = "-3"; 1171 headers["content-length"] = "-3";
1183 1172
1184 client_->SendCustomSynchronousRequest(headers, large_body); 1173 client_->SendCustomSynchronousRequest(headers, large_body);
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 1500
1512 TEST_P(EndToEndTest, MaxStreamsUberTest) { 1501 TEST_P(EndToEndTest, MaxStreamsUberTest) {
1513 if (!BothSidesSupportStatelessRejects()) { 1502 if (!BothSidesSupportStatelessRejects()) {
1514 // Connect with lower fake packet loss than we'd like to test. Until 1503 // Connect with lower fake packet loss than we'd like to test. Until
1515 // b/10126687 is fixed, losing handshake packets is pretty brutal. 1504 // b/10126687 is fixed, losing handshake packets is pretty brutal.
1516 // TODO(jokulik): Until we support redundant SREJ packets, don't 1505 // TODO(jokulik): Until we support redundant SREJ packets, don't
1517 // drop handshake packets for stateless rejects. 1506 // drop handshake packets for stateless rejects.
1518 SetPacketLossPercentage(1); 1507 SetPacketLossPercentage(1);
1519 } 1508 }
1520 ASSERT_TRUE(Initialize()); 1509 ASSERT_TRUE(Initialize());
1521 string large_body; 1510 string large_body(10240, 'a');
1522 GenerateBody(&large_body, 10240);
1523 int max_streams = 100; 1511 int max_streams = 100;
1524 1512
1525 AddToCache("/large_response", 200, large_body); 1513 AddToCache("/large_response", 200, large_body);
1526 1514
1527 client_->client()->WaitForCryptoHandshakeConfirmed(); 1515 client_->client()->WaitForCryptoHandshakeConfirmed();
1528 SetPacketLossPercentage(10); 1516 SetPacketLossPercentage(10);
1529 1517
1530 for (int i = 0; i < max_streams; ++i) { 1518 for (int i = 0; i < max_streams; ++i) {
1531 EXPECT_LT(0, client_->SendRequest("/large_response")); 1519 EXPECT_LT(0, client_->SendRequest("/large_response"));
1532 } 1520 }
1533 1521
1534 // WaitForEvents waits 50ms and returns true if there are outstanding 1522 // WaitForEvents waits 50ms and returns true if there are outstanding
1535 // requests. 1523 // requests.
1536 while (client_->client()->WaitForEvents() == true) { 1524 while (client_->client()->WaitForEvents() == true) {
1537 } 1525 }
1538 } 1526 }
1539 1527
1540 TEST_P(EndToEndTest, StreamCancelErrorTest) { 1528 TEST_P(EndToEndTest, StreamCancelErrorTest) {
1541 ASSERT_TRUE(Initialize()); 1529 ASSERT_TRUE(Initialize());
1542 string small_body; 1530 string small_body(256, 'a');
1543 GenerateBody(&small_body, 256);
1544 1531
1545 AddToCache("/small_response", 200, small_body); 1532 AddToCache("/small_response", 200, small_body);
1546 1533
1547 client_->client()->WaitForCryptoHandshakeConfirmed(); 1534 client_->client()->WaitForCryptoHandshakeConfirmed();
1548 1535
1549 QuicSession* session = client_->client()->session(); 1536 QuicSession* session = client_->client()->session();
1550 // Lose the request. 1537 // Lose the request.
1551 SetPacketLossPercentage(100); 1538 SetPacketLossPercentage(100);
1552 EXPECT_LT(0, client_->SendRequest("/small_response")); 1539 EXPECT_LT(0, client_->SendRequest("/small_response"));
1553 client_->client()->WaitForEvents(); 1540 client_->client()->WaitForEvents();
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
2249 QuicInMemoryCache* in_memory_cache, 2236 QuicInMemoryCache* in_memory_cache,
2250 int64_t body_bytes) 2237 int64_t body_bytes)
2251 : QuicSimpleServerStream(id, session, in_memory_cache), 2238 : QuicSimpleServerStream(id, session, in_memory_cache),
2252 body_bytes_(body_bytes) {} 2239 body_bytes_(body_bytes) {}
2253 2240
2254 ~ServerStreamThatSendsHugeResponse() override {} 2241 ~ServerStreamThatSendsHugeResponse() override {}
2255 2242
2256 protected: 2243 protected:
2257 void SendResponse() override { 2244 void SendResponse() override {
2258 QuicInMemoryCache::Response response; 2245 QuicInMemoryCache::Response response;
2259 string body; 2246 string body(body_bytes_, 'a');
2260 GenerateBody(&body, body_bytes_);
2261 response.set_body(body); 2247 response.set_body(body);
2262 SendHeadersAndBodyAndTrailers(response.headers().Clone(), response.body(), 2248 SendHeadersAndBodyAndTrailers(response.headers().Clone(), response.body(),
2263 response.trailers().Clone()); 2249 response.trailers().Clone());
2264 } 2250 }
2265 2251
2266 private: 2252 private:
2267 // Use a explicit int64_t rather than size_t to simulate a 64-bit server 2253 // Use a explicit int64_t rather than size_t to simulate a 64-bit server
2268 // talking to a 32-bit client. 2254 // talking to a 32-bit client.
2269 int64_t body_bytes_; 2255 int64_t body_bytes_;
2270 }; 2256 };
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2378 set_smaller_flow_control_receive_window(); 2364 set_smaller_flow_control_receive_window();
2379 2365
2380 // Verify that an incoming FIN is recorded in a stream object even if the read 2366 // Verify that an incoming FIN is recorded in a stream object even if the read
2381 // side has been closed. This prevents an entry from being made in 2367 // side has been closed. This prevents an entry from being made in
2382 // locally_close_streams_highest_offset_ (which will never be deleted). 2368 // locally_close_streams_highest_offset_ (which will never be deleted).
2383 // To set up the test condition, the server must do the following in order: 2369 // To set up the test condition, the server must do the following in order:
2384 // start sending the response and call CloseReadSide 2370 // start sending the response and call CloseReadSide
2385 // receive the FIN of the request 2371 // receive the FIN of the request
2386 // send the FIN of the response 2372 // send the FIN of the response
2387 2373
2388 string response_body;
2389 // The response body must be larger than the flow control window so the server 2374 // The response body must be larger than the flow control window so the server
2390 // must receive a window update from the client before it can finish sending 2375 // must receive a window update from the client before it can finish sending
2391 // it. 2376 // it.
2392 uint32_t response_body_size = 2377 uint32_t response_body_size =
2393 2 * client_config_.GetInitialStreamFlowControlWindowToSend(); 2378 2 * client_config_.GetInitialStreamFlowControlWindowToSend();
2394 GenerateBody(&response_body, response_body_size); 2379 string response_body(response_body_size, 'a');
2395 2380
2396 StreamWithErrorFactory stream_factory(response_body); 2381 StreamWithErrorFactory stream_factory(response_body);
2397 SetSpdyStreamFactory(&stream_factory); 2382 SetSpdyStreamFactory(&stream_factory);
2398 2383
2399 ASSERT_TRUE(Initialize()); 2384 ASSERT_TRUE(Initialize());
2400 2385
2401 client_->client()->WaitForCryptoHandshakeConfirmed(); 2386 client_->client()->WaitForCryptoHandshakeConfirmed();
2402 2387
2403 // A POST that gets an early error response, after the headers are received 2388 // A POST that gets an early error response, after the headers are received
2404 // and before the body is received, due to invalid content-length. 2389 // and before the body is received, due to invalid content-length.
2405 // Set an invalid content-length, so the request will receive an early 500 2390 // Set an invalid content-length, so the request will receive an early 500
2406 // response. 2391 // response.
2407 SpdyHeaderBlock headers; 2392 SpdyHeaderBlock headers;
2408 headers[":method"] = "POST"; 2393 headers[":method"] = "POST";
2409 headers[":path"] = "/garbage"; 2394 headers[":path"] = "/garbage";
2410 headers[":scheme"] = "https"; 2395 headers[":scheme"] = "https";
2411 headers[":authority"] = server_hostname_; 2396 headers[":authority"] = server_hostname_;
2412 headers["content-length"] = "-1"; 2397 headers["content-length"] = "-1";
2413 2398
2414 // The body must be large enough that the FIN will be in a different packet 2399 // The body must be large enough that the FIN will be in a different packet
2415 // than the end of the headers, but short enough to not require a flow control 2400 // than the end of the headers, but short enough to not require a flow control
2416 // update. This allows headers processing to trigger the error response 2401 // update. This allows headers processing to trigger the error response
2417 // before the request FIN is processed but receive the request FIN before the 2402 // before the request FIN is processed but receive the request FIN before the
2418 // response is sent completely. 2403 // response is sent completely.
2419 const uint32_t kRequestBodySize = kMaxPacketSize + 10; 2404 const uint32_t kRequestBodySize = kMaxPacketSize + 10;
2420 string request_body; 2405 string request_body(kRequestBodySize, 'a');
2421 GenerateBody(&request_body, kRequestBodySize);
2422 2406
2423 // Send the request. 2407 // Send the request.
2424 client_->SendMessage(headers, request_body); 2408 client_->SendMessage(headers, request_body);
2425 client_->WaitForResponse(); 2409 client_->WaitForResponse();
2426 EXPECT_EQ("500", client_->response_headers()->find(":status")->second); 2410 EXPECT_EQ("500", client_->response_headers()->find(":status")->second);
2427 2411
2428 // Pause the server so we can access the server's internals without races. 2412 // Pause the server so we can access the server's internals without races.
2429 server_thread_->Pause(); 2413 server_thread_->Pause();
2430 2414
2431 QuicDispatcher* dispatcher = 2415 QuicDispatcher* dispatcher =
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
2529 string path, 2513 string path,
2530 string response_body, 2514 string response_body,
2531 string* push_urls, 2515 string* push_urls,
2532 const size_t num_resources, 2516 const size_t num_resources,
2533 const size_t resource_size) { 2517 const size_t resource_size) {
2534 bool use_large_response = resource_size != 0; 2518 bool use_large_response = resource_size != 0;
2535 string large_resource; 2519 string large_resource;
2536 if (use_large_response) { 2520 if (use_large_response) {
2537 // Generate a response common body larger than flow control window for 2521 // Generate a response common body larger than flow control window for
2538 // push response. 2522 // push response.
2539 GenerateBody(&large_resource, resource_size); 2523 large_resource = string(resource_size, 'a');
2540 } 2524 }
2541 std::list<QuicInMemoryCache::ServerPushInfo> push_resources; 2525 std::list<QuicInMemoryCache::ServerPushInfo> push_resources;
2542 for (size_t i = 0; i < num_resources; ++i) { 2526 for (size_t i = 0; i < num_resources; ++i) {
2543 string url = push_urls[i]; 2527 string url = push_urls[i];
2544 GURL resource_url(url); 2528 GURL resource_url(url);
2545 string body = use_large_response 2529 string body = use_large_response
2546 ? large_resource 2530 ? large_resource
2547 : "This is server push response body for " + url; 2531 : "This is server push response body for " + url;
2548 SpdyHeaderBlock response_headers; 2532 SpdyHeaderBlock response_headers;
2549 response_headers[":version"] = "HTTP/1.1"; 2533 response_headers[":version"] = "HTTP/1.1";
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2831 client_->epoll_server()->set_timeout_in_us(0); 2815 client_->epoll_server()->set_timeout_in_us(0);
2832 2816
2833 client_->client()->WaitForCryptoHandshakeConfirmed(); 2817 client_->client()->WaitForCryptoHandshakeConfirmed();
2834 SetPacketLossPercentage(1); 2818 SetPacketLossPercentage(1);
2835 // To avoid storing the whole request body in memory, use a loop to repeatedly 2819 // To avoid storing the whole request body in memory, use a loop to repeatedly
2836 // send body size of kSizeBytes until the whole request body size is reached. 2820 // send body size of kSizeBytes until the whole request body size is reached.
2837 const int kSizeBytes = 128 * 1024; 2821 const int kSizeBytes = 128 * 1024;
2838 // Request body size is 4G plus one more kSizeBytes. 2822 // Request body size is 4G plus one more kSizeBytes.
2839 int64_t request_body_size_bytes = pow(2, 32) + kSizeBytes; 2823 int64_t request_body_size_bytes = pow(2, 32) + kSizeBytes;
2840 ASSERT_LT(INT64_C(4294967296), request_body_size_bytes); 2824 ASSERT_LT(INT64_C(4294967296), request_body_size_bytes);
2841 string body; 2825 string body(kSizeBytes, 'a');
2842 GenerateBody(&body, kSizeBytes);
2843 2826
2844 SpdyHeaderBlock headers; 2827 SpdyHeaderBlock headers;
2845 headers[":method"] = "POST"; 2828 headers[":method"] = "POST";
2846 headers[":path"] = "/foo"; 2829 headers[":path"] = "/foo";
2847 headers[":scheme"] = "https"; 2830 headers[":scheme"] = "https";
2848 headers[":authority"] = server_hostname_; 2831 headers[":authority"] = server_hostname_;
2849 headers["content-length"] = IntToString(request_body_size_bytes); 2832 headers["content-length"] = IntToString(request_body_size_bytes);
2850 2833
2851 client_->SendMessage(headers, "", /*fin=*/false); 2834 client_->SendMessage(headers, "", /*fin=*/false);
2852 2835
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2957 client_->WaitForResponse(); 2940 client_->WaitForResponse();
2958 EXPECT_EQ(kBarResponseBody, client_->response_body()); 2941 EXPECT_EQ(kBarResponseBody, client_->response_body());
2959 QuicConnectionStats client_stats = 2942 QuicConnectionStats client_stats =
2960 client_->client()->session()->connection()->GetStats(); 2943 client_->client()->session()->connection()->GetStats();
2961 EXPECT_EQ(0u, client_stats.packets_lost); 2944 EXPECT_EQ(0u, client_stats.packets_lost);
2962 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); 2945 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos());
2963 } 2946 }
2964 } // namespace 2947 } // namespace
2965 } // namespace test 2948 } // namespace test
2966 } // namespace net 2949 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_spdy_stream_test.cc ('k') | net/tools/quic/quic_simple_server_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698