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

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

Issue 2542743003: Make QuicClientBase::WaitForCryptoHandshakeComplete return false if the handshake fails. There's cu… (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
« no previous file with comments | « no previous file | net/tools/quic/quic_client_base.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 <cstdint> 8 #include <cstdint>
9 #include <list> 9 #include <list>
10 #include <memory> 10 #include <memory>
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 bool force_hol_blocking_; 574 bool force_hol_blocking_;
575 }; 575 };
576 576
577 // Run all end to end tests with all supported versions. 577 // Run all end to end tests with all supported versions.
578 INSTANTIATE_TEST_CASE_P(EndToEndTests, 578 INSTANTIATE_TEST_CASE_P(EndToEndTests,
579 EndToEndTest, 579 EndToEndTest,
580 ::testing::ValuesIn(GetTestParams())); 580 ::testing::ValuesIn(GetTestParams()));
581 581
582 TEST_P(EndToEndTest, HandshakeSuccessful) { 582 TEST_P(EndToEndTest, HandshakeSuccessful) {
583 ASSERT_TRUE(Initialize()); 583 ASSERT_TRUE(Initialize());
584 client_->client()->WaitForCryptoHandshakeConfirmed(); 584 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
585 QuicCryptoStream* crypto_stream = 585 QuicCryptoStream* crypto_stream =
586 QuicSessionPeer::GetCryptoStream(client_->client()->session()); 586 QuicSessionPeer::GetCryptoStream(client_->client()->session());
587 QuicStreamSequencer* sequencer = QuicStreamPeer::sequencer(crypto_stream); 587 QuicStreamSequencer* sequencer = QuicStreamPeer::sequencer(crypto_stream);
588 EXPECT_NE(FLAGS_quic_release_crypto_stream_buffer, 588 EXPECT_NE(FLAGS_quic_release_crypto_stream_buffer,
589 QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer)); 589 QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer));
590 server_thread_->Pause(); 590 server_thread_->Pause();
591 QuicDispatcher* dispatcher = 591 QuicDispatcher* dispatcher =
592 QuicServerPeer::GetDispatcher(server_thread_->server()); 592 QuicServerPeer::GetDispatcher(server_thread_->server());
593 QuicSession* server_session = dispatcher->session_map().begin()->second.get(); 593 QuicSession* server_session = dispatcher->session_map().begin()->second.get();
594 crypto_stream = QuicSessionPeer::GetCryptoStream(server_session); 594 crypto_stream = QuicSessionPeer::GetCryptoStream(server_session);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 // triggering an error response. 722 // triggering an error response.
723 client_->SendCustomSynchronousRequest(headers, ""); 723 client_->SendCustomSynchronousRequest(headers, "");
724 EXPECT_EQ(QuicSimpleServerStream::kErrorResponseBody, 724 EXPECT_EQ(QuicSimpleServerStream::kErrorResponseBody,
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 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
733 733
734 // 1 MB body. 734 // 1 MB body.
735 string body(1024 * 1024, 'a'); 735 string body(1024 * 1024, 'a');
736 SpdyHeaderBlock headers; 736 SpdyHeaderBlock headers;
737 headers[":method"] = "POST"; 737 headers[":method"] = "POST";
738 headers[":path"] = "/foo"; 738 headers[":path"] = "/foo";
739 headers[":scheme"] = "https"; 739 headers[":scheme"] = "https";
740 headers[":authority"] = server_hostname_; 740 headers[":authority"] = server_hostname_;
741 741
742 EXPECT_EQ(kFooResponseBody, 742 EXPECT_EQ(kFooResponseBody,
743 client_->SendCustomSynchronousRequest(headers, body)); 743 client_->SendCustomSynchronousRequest(headers, body));
744 // 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
745 // platforms the receive buffer overflows. 745 // platforms the receive buffer overflows.
746 VerifyCleanConnection(true); 746 VerifyCleanConnection(true);
747 } 747 }
748 748
749 TEST_P(EndToEndTest, LargePostNoPacketLoss1sRTT) { 749 TEST_P(EndToEndTest, LargePostNoPacketLoss1sRTT) {
750 ASSERT_TRUE(Initialize()); 750 ASSERT_TRUE(Initialize());
751 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(1000)); 751 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(1000));
752 752
753 client_->client()->WaitForCryptoHandshakeConfirmed(); 753 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
754 754
755 // 100 KB body. 755 // 100 KB body.
756 string body(100 * 1024, 'a'); 756 string body(100 * 1024, 'a');
757 SpdyHeaderBlock headers; 757 SpdyHeaderBlock headers;
758 headers[":method"] = "POST"; 758 headers[":method"] = "POST";
759 headers[":path"] = "/foo"; 759 headers[":path"] = "/foo";
760 headers[":scheme"] = "https"; 760 headers[":scheme"] = "https";
761 headers[":authority"] = server_hostname_; 761 headers[":authority"] = server_hostname_;
762 762
763 EXPECT_EQ(kFooResponseBody, 763 EXPECT_EQ(kFooResponseBody,
764 client_->SendCustomSynchronousRequest(headers, body)); 764 client_->SendCustomSynchronousRequest(headers, body));
765 VerifyCleanConnection(false); 765 VerifyCleanConnection(false);
766 } 766 }
767 767
768 TEST_P(EndToEndTest, LargePostWithPacketLoss) { 768 TEST_P(EndToEndTest, LargePostWithPacketLoss) {
769 if (!BothSidesSupportStatelessRejects()) { 769 if (!BothSidesSupportStatelessRejects()) {
770 // 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.
771 // Until b/10126687 is fixed, losing handshake packets is pretty 771 // Until b/10126687 is fixed, losing handshake packets is pretty
772 // brutal. 772 // brutal.
773 // TODO(jokulik): Until we support redundant SREJ packets, don't 773 // TODO(jokulik): Until we support redundant SREJ packets, don't
774 // drop handshake packets for stateless rejects. 774 // drop handshake packets for stateless rejects.
775 SetPacketLossPercentage(5); 775 SetPacketLossPercentage(5);
776 } 776 }
777 ASSERT_TRUE(Initialize()); 777 ASSERT_TRUE(Initialize());
778 778
779 // Wait for the server SHLO before upping the packet loss. 779 // Wait for the server SHLO before upping the packet loss.
780 client_->client()->WaitForCryptoHandshakeConfirmed(); 780 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
781 SetPacketLossPercentage(30); 781 SetPacketLossPercentage(30);
782 782
783 // 10 KB body. 783 // 10 KB body.
784 string body(1024 * 10, 'a'); 784 string body(1024 * 10, 'a');
785 SpdyHeaderBlock headers; 785 SpdyHeaderBlock headers;
786 headers[":method"] = "POST"; 786 headers[":method"] = "POST";
787 headers[":path"] = "/foo"; 787 headers[":path"] = "/foo";
788 headers[":scheme"] = "https"; 788 headers[":scheme"] = "https";
789 headers[":authority"] = server_hostname_; 789 headers[":authority"] = server_hostname_;
790 790
791 EXPECT_EQ(kFooResponseBody, 791 EXPECT_EQ(kFooResponseBody,
792 client_->SendCustomSynchronousRequest(headers, body)); 792 client_->SendCustomSynchronousRequest(headers, body));
793 VerifyCleanConnection(true); 793 VerifyCleanConnection(true);
794 } 794 }
795 795
796 TEST_P(EndToEndTest, LargePostWithPacketLossAndBlockedSocket) { 796 TEST_P(EndToEndTest, LargePostWithPacketLossAndBlockedSocket) {
797 if (!BothSidesSupportStatelessRejects()) { 797 if (!BothSidesSupportStatelessRejects()) {
798 // 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
799 // b/10126687 is fixed, losing handshake packets is pretty brutal. 799 // b/10126687 is fixed, losing handshake packets is pretty brutal.
800 // TODO(jokulik): Until we support redundant SREJ packets, don't 800 // TODO(jokulik): Until we support redundant SREJ packets, don't
801 // drop handshake packets for stateless rejects. 801 // drop handshake packets for stateless rejects.
802 SetPacketLossPercentage(5); 802 SetPacketLossPercentage(5);
803 } 803 }
804 ASSERT_TRUE(Initialize()); 804 ASSERT_TRUE(Initialize());
805 805
806 // Wait for the server SHLO before upping the packet loss. 806 // Wait for the server SHLO before upping the packet loss.
807 client_->client()->WaitForCryptoHandshakeConfirmed(); 807 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
808 SetPacketLossPercentage(10); 808 SetPacketLossPercentage(10);
809 client_writer_->set_fake_blocked_socket_percentage(10); 809 client_writer_->set_fake_blocked_socket_percentage(10);
810 810
811 // 10 KB body. 811 // 10 KB body.
812 string body(1024 * 10, 'a'); 812 string body(1024 * 10, 'a');
813 SpdyHeaderBlock headers; 813 SpdyHeaderBlock headers;
814 headers[":method"] = "POST"; 814 headers[":method"] = "POST";
815 headers[":path"] = "/foo"; 815 headers[":path"] = "/foo";
816 headers[":scheme"] = "https"; 816 headers[":scheme"] = "https";
817 headers[":authority"] = server_hostname_; 817 headers[":authority"] = server_hostname_;
818 818
819 EXPECT_EQ(kFooResponseBody, 819 EXPECT_EQ(kFooResponseBody,
820 client_->SendCustomSynchronousRequest(headers, body)); 820 client_->SendCustomSynchronousRequest(headers, body));
821 } 821 }
822 822
823 TEST_P(EndToEndTest, LargePostNoPacketLossWithDelayAndReordering) { 823 TEST_P(EndToEndTest, LargePostNoPacketLossWithDelayAndReordering) {
824 ASSERT_TRUE(Initialize()); 824 ASSERT_TRUE(Initialize());
825 825
826 client_->client()->WaitForCryptoHandshakeConfirmed(); 826 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
827 // 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.
828 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); 828 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2));
829 SetReorderPercentage(30); 829 SetReorderPercentage(30);
830 830
831 // 1 MB body. 831 // 1 MB body.
832 string body(1024 * 1024, 'a'); 832 string body(1024 * 1024, 'a');
833 SpdyHeaderBlock headers; 833 SpdyHeaderBlock headers;
834 headers[":method"] = "POST"; 834 headers[":method"] = "POST";
835 headers[":path"] = "/foo"; 835 headers[":path"] = "/foo";
836 headers[":scheme"] = "https"; 836 headers[":scheme"] = "https";
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 1020
1021 TEST_P(EndToEndTest, SetInitialReceivedConnectionOptions) { 1021 TEST_P(EndToEndTest, SetInitialReceivedConnectionOptions) {
1022 QuicTagVector initial_received_options; 1022 QuicTagVector initial_received_options;
1023 initial_received_options.push_back(kTBBR); 1023 initial_received_options.push_back(kTBBR);
1024 initial_received_options.push_back(kIW10); 1024 initial_received_options.push_back(kIW10);
1025 initial_received_options.push_back(kPRST); 1025 initial_received_options.push_back(kPRST);
1026 EXPECT_TRUE(server_config_.SetInitialReceivedConnectionOptions( 1026 EXPECT_TRUE(server_config_.SetInitialReceivedConnectionOptions(
1027 initial_received_options)); 1027 initial_received_options));
1028 1028
1029 ASSERT_TRUE(Initialize()); 1029 ASSERT_TRUE(Initialize());
1030 client_->client()->WaitForCryptoHandshakeConfirmed(); 1030 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1031 server_thread_->WaitForCryptoHandshakeConfirmed(); 1031 server_thread_->WaitForCryptoHandshakeConfirmed();
1032 1032
1033 EXPECT_FALSE(server_config_.SetInitialReceivedConnectionOptions( 1033 EXPECT_FALSE(server_config_.SetInitialReceivedConnectionOptions(
1034 initial_received_options)); 1034 initial_received_options));
1035 1035
1036 // Verify that server's configuration is correct. 1036 // Verify that server's configuration is correct.
1037 server_thread_->Pause(); 1037 server_thread_->Pause();
1038 EXPECT_TRUE(server_config_.HasReceivedConnectionOptions()); 1038 EXPECT_TRUE(server_config_.HasReceivedConnectionOptions());
1039 EXPECT_TRUE( 1039 EXPECT_TRUE(
1040 ContainsQuicTag(server_config_.ReceivedConnectionOptions(), kTBBR)); 1040 ContainsQuicTag(server_config_.ReceivedConnectionOptions(), kTBBR));
1041 EXPECT_TRUE( 1041 EXPECT_TRUE(
1042 ContainsQuicTag(server_config_.ReceivedConnectionOptions(), kIW10)); 1042 ContainsQuicTag(server_config_.ReceivedConnectionOptions(), kIW10));
1043 EXPECT_TRUE( 1043 EXPECT_TRUE(
1044 ContainsQuicTag(server_config_.ReceivedConnectionOptions(), kPRST)); 1044 ContainsQuicTag(server_config_.ReceivedConnectionOptions(), kPRST));
1045 } 1045 }
1046 1046
1047 TEST_P(EndToEndTest, LargePostSmallBandwidthLargeBuffer) { 1047 TEST_P(EndToEndTest, LargePostSmallBandwidthLargeBuffer) {
1048 ASSERT_TRUE(Initialize()); 1048 ASSERT_TRUE(Initialize());
1049 SetPacketSendDelay(QuicTime::Delta::FromMicroseconds(1)); 1049 SetPacketSendDelay(QuicTime::Delta::FromMicroseconds(1));
1050 // 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
1051 // clients commonly have larger buffers, but our max CWND is 200. 1051 // clients commonly have larger buffers, but our max CWND is 200.
1052 server_writer_->set_max_bandwidth_and_buffer_size( 1052 server_writer_->set_max_bandwidth_and_buffer_size(
1053 QuicBandwidth::FromBytesPerSecond(256 * 1024), 256 * 1024); 1053 QuicBandwidth::FromBytesPerSecond(256 * 1024), 256 * 1024);
1054 1054
1055 client_->client()->WaitForCryptoHandshakeConfirmed(); 1055 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1056 1056
1057 // 1 MB body. 1057 // 1 MB body.
1058 string body(1024 * 1024, 'a'); 1058 string body(1024 * 1024, 'a');
1059 SpdyHeaderBlock headers; 1059 SpdyHeaderBlock headers;
1060 headers[":method"] = "POST"; 1060 headers[":method"] = "POST";
1061 headers[":path"] = "/foo"; 1061 headers[":path"] = "/foo";
1062 headers[":scheme"] = "https"; 1062 headers[":scheme"] = "https";
1063 headers[":authority"] = server_hostname_; 1063 headers[":authority"] = server_hostname_;
1064 1064
1065 EXPECT_EQ(kFooResponseBody, 1065 EXPECT_EQ(kFooResponseBody,
1066 client_->SendCustomSynchronousRequest(headers, body)); 1066 client_->SendCustomSynchronousRequest(headers, body));
1067 // 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
1068 // max CWND. 1068 // max CWND.
1069 VerifyCleanConnection(true); 1069 VerifyCleanConnection(true);
1070 } 1070 }
1071 1071
1072 TEST_P(EndToEndTest, DoNotSetResumeWriteAlarmIfConnectionFlowControlBlocked) { 1072 TEST_P(EndToEndTest, DoNotSetResumeWriteAlarmIfConnectionFlowControlBlocked) {
1073 // Regression test for b/14677858. 1073 // Regression test for b/14677858.
1074 // Test that the resume write alarm is not set in QuicConnection::OnCanWrite 1074 // Test that the resume write alarm is not set in QuicConnection::OnCanWrite
1075 // if currently connection level flow control blocked. If set, this results in 1075 // if currently connection level flow control blocked. If set, this results in
1076 // an infinite loop in the EpollServer, as the alarm fires and is immediately 1076 // an infinite loop in the EpollServer, as the alarm fires and is immediately
1077 // rescheduled. 1077 // rescheduled.
1078 ASSERT_TRUE(Initialize()); 1078 ASSERT_TRUE(Initialize());
1079 client_->client()->WaitForCryptoHandshakeConfirmed(); 1079 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1080 1080
1081 // Ensure both stream and connection level are flow control blocked by setting 1081 // Ensure both stream and connection level are flow control blocked by setting
1082 // the send window offset to 0. 1082 // the send window offset to 0.
1083 const uint64_t flow_control_window = 1083 const uint64_t flow_control_window =
1084 server_config_.GetInitialStreamFlowControlWindowToSend(); 1084 server_config_.GetInitialStreamFlowControlWindowToSend();
1085 QuicSpdyClientStream* stream = client_->GetOrCreateStream(); 1085 QuicSpdyClientStream* stream = client_->GetOrCreateStream();
1086 QuicSession* session = client_->client()->session(); 1086 QuicSession* session = client_->client()->session();
1087 QuicFlowControllerPeer::SetSendWindowOffset(stream->flow_controller(), 0); 1087 QuicFlowControllerPeer::SetSendWindowOffset(stream->flow_controller(), 0);
1088 QuicFlowControllerPeer::SetSendWindowOffset(session->flow_controller(), 0); 1088 QuicFlowControllerPeer::SetSendWindowOffset(session->flow_controller(), 0);
1089 EXPECT_TRUE(stream->flow_controller()->IsBlocked()); 1089 EXPECT_TRUE(stream->flow_controller()->IsBlocked());
(...skipping 14 matching lines...) Expand all
1104 // connection is still flow control blocked. 1104 // connection is still flow control blocked.
1105 session->connection()->OnCanWrite(); 1105 session->connection()->OnCanWrite();
1106 1106
1107 QuicAlarm* resume_writes_alarm = 1107 QuicAlarm* resume_writes_alarm =
1108 QuicConnectionPeer::GetResumeWritesAlarm(session->connection()); 1108 QuicConnectionPeer::GetResumeWritesAlarm(session->connection());
1109 EXPECT_FALSE(resume_writes_alarm->IsSet()); 1109 EXPECT_FALSE(resume_writes_alarm->IsSet());
1110 } 1110 }
1111 1111
1112 TEST_P(EndToEndTest, InvalidStream) { 1112 TEST_P(EndToEndTest, InvalidStream) {
1113 ASSERT_TRUE(Initialize()); 1113 ASSERT_TRUE(Initialize());
1114 client_->client()->WaitForCryptoHandshakeConfirmed(); 1114 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1115 1115
1116 string body(kMaxPacketSize, 'a'); 1116 string body(kMaxPacketSize, 'a');
1117 SpdyHeaderBlock headers; 1117 SpdyHeaderBlock headers;
1118 headers[":method"] = "POST"; 1118 headers[":method"] = "POST";
1119 headers[":path"] = "/foo"; 1119 headers[":path"] = "/foo";
1120 headers[":scheme"] = "https"; 1120 headers[":scheme"] = "https";
1121 headers[":authority"] = server_hostname_; 1121 headers[":authority"] = server_hostname_;
1122 1122
1123 // 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
1124 // server-side stream. 1124 // server-side stream.
1125 QuicSessionPeer::SetNextOutgoingStreamId(client_->client()->session(), 2); 1125 QuicSessionPeer::SetNextOutgoingStreamId(client_->client()->session(), 2);
1126 1126
1127 client_->SendCustomSynchronousRequest(headers, body); 1127 client_->SendCustomSynchronousRequest(headers, body);
1128 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); 1128 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error());
1129 EXPECT_EQ(QUIC_INVALID_STREAM_ID, client_->connection_error()); 1129 EXPECT_EQ(QUIC_INVALID_STREAM_ID, client_->connection_error());
1130 } 1130 }
1131 1131
1132 // 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
1133 // to send a request with overly large headers. 1133 // to send a request with overly large headers.
1134 TEST_P(EndToEndTest, LargeHeaders) { 1134 TEST_P(EndToEndTest, LargeHeaders) {
1135 ASSERT_TRUE(Initialize()); 1135 ASSERT_TRUE(Initialize());
1136 client_->client()->WaitForCryptoHandshakeConfirmed(); 1136 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1137 1137
1138 string body(kMaxPacketSize, 'a'); 1138 string body(kMaxPacketSize, 'a');
1139 SpdyHeaderBlock headers; 1139 SpdyHeaderBlock headers;
1140 headers[":method"] = "POST"; 1140 headers[":method"] = "POST";
1141 headers[":path"] = "/foo"; 1141 headers[":path"] = "/foo";
1142 headers[":scheme"] = "https"; 1142 headers[":scheme"] = "https";
1143 headers[":authority"] = server_hostname_; 1143 headers[":authority"] = server_hostname_;
1144 headers["key1"] = string(15 * 1024, 'a'); 1144 headers["key1"] = string(15 * 1024, 'a');
1145 headers["key2"] = string(15 * 1024, 'a'); 1145 headers["key2"] = string(15 * 1024, 'a');
1146 headers["key3"] = string(15 * 1024, 'a'); 1146 headers["key3"] = string(15 * 1024, 'a');
1147 1147
1148 client_->SendCustomSynchronousRequest(headers, body); 1148 client_->SendCustomSynchronousRequest(headers, body);
1149 if (FLAGS_quic_limit_uncompressed_headers) { 1149 if (FLAGS_quic_limit_uncompressed_headers) {
1150 EXPECT_EQ(QUIC_HEADERS_TOO_LARGE, client_->stream_error()); 1150 EXPECT_EQ(QUIC_HEADERS_TOO_LARGE, client_->stream_error());
1151 } else { 1151 } else {
1152 EXPECT_EQ(QUIC_STREAM_NO_ERROR, client_->stream_error()); 1152 EXPECT_EQ(QUIC_STREAM_NO_ERROR, client_->stream_error());
1153 EXPECT_EQ(kFooResponseBody, client_->response_body()); 1153 EXPECT_EQ(kFooResponseBody, client_->response_body());
1154 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); 1154 EXPECT_EQ("200", client_->response_headers()->find(":status")->second);
1155 } 1155 }
1156 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error()); 1156 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error());
1157 } 1157 }
1158 1158
1159 TEST_P(EndToEndTest, EarlyResponseWithQuicStreamNoError) { 1159 TEST_P(EndToEndTest, EarlyResponseWithQuicStreamNoError) {
1160 ASSERT_TRUE(Initialize()); 1160 ASSERT_TRUE(Initialize());
1161 client_->client()->WaitForCryptoHandshakeConfirmed(); 1161 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1162 1162
1163 string large_body(1024 * 1024, 'a'); 1163 string large_body(1024 * 1024, 'a');
1164 SpdyHeaderBlock headers; 1164 SpdyHeaderBlock headers;
1165 headers[":method"] = "POST"; 1165 headers[":method"] = "POST";
1166 headers[":path"] = "/foo"; 1166 headers[":path"] = "/foo";
1167 headers[":scheme"] = "https"; 1167 headers[":scheme"] = "https";
1168 headers[":authority"] = server_hostname_; 1168 headers[":authority"] = server_hostname_;
1169 // 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
1170 // response from server. 1170 // response from server.
1171 headers["content-length"] = "-3"; 1171 headers["content-length"] = "-3";
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 Initialize(); 1206 Initialize();
1207 while (client_->client()->connected()) { 1207 while (client_->client()->connected()) {
1208 client_->client()->WaitForEvents(); 1208 client_->client()->WaitForEvents();
1209 } 1209 }
1210 } 1210 }
1211 1211
1212 TEST_P(EndToEndTest, NegotiateMaxOpenStreams) { 1212 TEST_P(EndToEndTest, NegotiateMaxOpenStreams) {
1213 // Negotiate 1 max open stream. 1213 // Negotiate 1 max open stream.
1214 client_config_.SetMaxStreamsPerConnection(1, 1); 1214 client_config_.SetMaxStreamsPerConnection(1, 1);
1215 ASSERT_TRUE(Initialize()); 1215 ASSERT_TRUE(Initialize());
1216 client_->client()->WaitForCryptoHandshakeConfirmed(); 1216 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1217 1217
1218 if (negotiated_version_ > QUIC_VERSION_34) { 1218 if (negotiated_version_ > QUIC_VERSION_34) {
1219 // Newer versions use max incoming dynamic streams. 1219 // Newer versions use max incoming dynamic streams.
1220 return; 1220 return;
1221 } 1221 }
1222 1222
1223 // Make the client misbehave after negotiation. 1223 // Make the client misbehave after negotiation.
1224 const int kServerMaxStreams = kMaxStreamsMinimumIncrement + 1; 1224 const int kServerMaxStreams = kMaxStreamsMinimumIncrement + 1;
1225 QuicSessionPeer::SetMaxOpenOutgoingStreams(client_->client()->session(), 1225 QuicSessionPeer::SetMaxOpenOutgoingStreams(client_->client()->session(),
1226 kServerMaxStreams + 1); 1226 kServerMaxStreams + 1);
(...skipping 17 matching lines...) Expand all
1244 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error()); 1244 EXPECT_EQ(QUIC_NO_ERROR, client_->connection_error());
1245 } 1245 }
1246 1246
1247 TEST_P(EndToEndTest, MaxIncomingDynamicStreamsLimitRespected) { 1247 TEST_P(EndToEndTest, MaxIncomingDynamicStreamsLimitRespected) {
1248 // Set a limit on maximum number of incoming dynamic streams. 1248 // Set a limit on maximum number of incoming dynamic streams.
1249 // Make sure the limit is respected. 1249 // Make sure the limit is respected.
1250 const uint32_t kServerMaxIncomingDynamicStreams = 1; 1250 const uint32_t kServerMaxIncomingDynamicStreams = 1;
1251 server_config_.SetMaxIncomingDynamicStreamsToSend( 1251 server_config_.SetMaxIncomingDynamicStreamsToSend(
1252 kServerMaxIncomingDynamicStreams); 1252 kServerMaxIncomingDynamicStreams);
1253 ASSERT_TRUE(Initialize()); 1253 ASSERT_TRUE(Initialize());
1254 client_->client()->WaitForCryptoHandshakeConfirmed(); 1254 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1255 1255
1256 if (negotiated_version_ <= QUIC_VERSION_34) { 1256 if (negotiated_version_ <= QUIC_VERSION_34) {
1257 // Earlier versions negotiated max open streams. 1257 // Earlier versions negotiated max open streams.
1258 return; 1258 return;
1259 } 1259 }
1260 1260
1261 // Make the client misbehave after negotiation. 1261 // Make the client misbehave after negotiation.
1262 const int kServerMaxStreams = 1262 const int kServerMaxStreams =
1263 kMaxStreamsMinimumIncrement + kServerMaxIncomingDynamicStreams; 1263 kMaxStreamsMinimumIncrement + kServerMaxIncomingDynamicStreams;
1264 QuicSessionPeer::SetMaxOpenOutgoingStreams(client_->client()->session(), 1264 QuicSessionPeer::SetMaxOpenOutgoingStreams(client_->client()->session(),
(...skipping 20 matching lines...) Expand all
1285 1285
1286 TEST_P(EndToEndTest, SetIndependentMaxIncomingDynamicStreamsLimits) { 1286 TEST_P(EndToEndTest, SetIndependentMaxIncomingDynamicStreamsLimits) {
1287 // Each endpoint can set max incoming dynamic streams independently. 1287 // Each endpoint can set max incoming dynamic streams independently.
1288 const uint32_t kClientMaxIncomingDynamicStreams = 2; 1288 const uint32_t kClientMaxIncomingDynamicStreams = 2;
1289 const uint32_t kServerMaxIncomingDynamicStreams = 1; 1289 const uint32_t kServerMaxIncomingDynamicStreams = 1;
1290 client_config_.SetMaxIncomingDynamicStreamsToSend( 1290 client_config_.SetMaxIncomingDynamicStreamsToSend(
1291 kClientMaxIncomingDynamicStreams); 1291 kClientMaxIncomingDynamicStreams);
1292 server_config_.SetMaxIncomingDynamicStreamsToSend( 1292 server_config_.SetMaxIncomingDynamicStreamsToSend(
1293 kServerMaxIncomingDynamicStreams); 1293 kServerMaxIncomingDynamicStreams);
1294 ASSERT_TRUE(Initialize()); 1294 ASSERT_TRUE(Initialize());
1295 client_->client()->WaitForCryptoHandshakeConfirmed(); 1295 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1296 1296
1297 if (negotiated_version_ <= QUIC_VERSION_34) { 1297 if (negotiated_version_ <= QUIC_VERSION_34) {
1298 // Earlier versions negotiated max open streams. 1298 // Earlier versions negotiated max open streams.
1299 return; 1299 return;
1300 } 1300 }
1301 1301
1302 // The client has received the server's limit and vice versa. 1302 // The client has received the server's limit and vice versa.
1303 EXPECT_EQ(kServerMaxIncomingDynamicStreams, 1303 EXPECT_EQ(kServerMaxIncomingDynamicStreams,
1304 client_->client()->session()->max_open_outgoing_streams()); 1304 client_->client()->session()->max_open_outgoing_streams());
1305 server_thread_->Pause(); 1305 server_thread_->Pause();
1306 QuicDispatcher* dispatcher = 1306 QuicDispatcher* dispatcher =
1307 QuicServerPeer::GetDispatcher(server_thread_->server()); 1307 QuicServerPeer::GetDispatcher(server_thread_->server());
1308 QuicSession* server_session = dispatcher->session_map().begin()->second.get(); 1308 QuicSession* server_session = dispatcher->session_map().begin()->second.get();
1309 EXPECT_EQ(kClientMaxIncomingDynamicStreams, 1309 EXPECT_EQ(kClientMaxIncomingDynamicStreams,
1310 server_session->max_open_outgoing_streams()); 1310 server_session->max_open_outgoing_streams());
1311 server_thread_->Resume(); 1311 server_thread_->Resume();
1312 } 1312 }
1313 1313
1314 TEST_P(EndToEndTest, NegotiateCongestionControl) { 1314 TEST_P(EndToEndTest, NegotiateCongestionControl) {
1315 FLAGS_quic_allow_new_bbr = true; 1315 FLAGS_quic_allow_new_bbr = true;
1316 // Disable this flag because if connection uses multipath sent packet manager, 1316 // Disable this flag because if connection uses multipath sent packet manager,
1317 // static_cast here does not work. 1317 // static_cast here does not work.
1318 FLAGS_quic_enable_multipath = false; 1318 FLAGS_quic_enable_multipath = false;
1319 ASSERT_TRUE(Initialize()); 1319 ASSERT_TRUE(Initialize());
1320 client_->client()->WaitForCryptoHandshakeConfirmed(); 1320 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1321 1321
1322 CongestionControlType expected_congestion_control_type = kReno; 1322 CongestionControlType expected_congestion_control_type = kReno;
1323 switch (GetParam().congestion_control_tag) { 1323 switch (GetParam().congestion_control_tag) {
1324 case kRENO: 1324 case kRENO:
1325 expected_congestion_control_type = kReno; 1325 expected_congestion_control_type = kReno;
1326 break; 1326 break;
1327 case kTBBR: 1327 case kTBBR:
1328 expected_congestion_control_type = kBBR; 1328 expected_congestion_control_type = kBBR;
1329 break; 1329 break;
1330 case kQBIC: 1330 case kQBIC:
(...skipping 13 matching lines...) Expand all
1344 server_thread_->Resume(); 1344 server_thread_->Resume();
1345 } 1345 }
1346 1346
1347 TEST_P(EndToEndTest, LimitMaxOpenStreams) { 1347 TEST_P(EndToEndTest, LimitMaxOpenStreams) {
1348 // Server limits the number of max streams to 2. 1348 // Server limits the number of max streams to 2.
1349 server_config_.SetMaxStreamsPerConnection(2, 2); 1349 server_config_.SetMaxStreamsPerConnection(2, 2);
1350 // Client tries to negotiate for 10. 1350 // Client tries to negotiate for 10.
1351 client_config_.SetMaxStreamsPerConnection(10, 5); 1351 client_config_.SetMaxStreamsPerConnection(10, 5);
1352 1352
1353 ASSERT_TRUE(Initialize()); 1353 ASSERT_TRUE(Initialize());
1354 client_->client()->WaitForCryptoHandshakeConfirmed(); 1354 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1355 if (negotiated_version_ > QUIC_VERSION_34) { 1355 if (negotiated_version_ > QUIC_VERSION_34) {
1356 // No negotiated max streams beyond version 34. 1356 // No negotiated max streams beyond version 34.
1357 return; 1357 return;
1358 } 1358 }
1359 QuicConfig* client_negotiated_config = client_->client()->session()->config(); 1359 QuicConfig* client_negotiated_config = client_->client()->session()->config();
1360 EXPECT_EQ(2u, client_negotiated_config->MaxStreamsPerConnection()); 1360 EXPECT_EQ(2u, client_negotiated_config->MaxStreamsPerConnection());
1361 } 1361 }
1362 1362
1363 TEST_P(EndToEndTest, ClientSuggestsRTT) { 1363 TEST_P(EndToEndTest, ClientSuggestsRTT) {
1364 // Client suggests initial RTT, verify it is used. 1364 // Client suggests initial RTT, verify it is used.
1365 const uint32_t kInitialRTT = 20000; 1365 const uint32_t kInitialRTT = 20000;
1366 client_config_.SetInitialRoundTripTimeUsToSend(kInitialRTT); 1366 client_config_.SetInitialRoundTripTimeUsToSend(kInitialRTT);
1367 1367
1368 ASSERT_TRUE(Initialize()); 1368 ASSERT_TRUE(Initialize());
1369 client_->client()->WaitForCryptoHandshakeConfirmed(); 1369 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1370 server_thread_->WaitForCryptoHandshakeConfirmed(); 1370 server_thread_->WaitForCryptoHandshakeConfirmed();
1371 1371
1372 // Pause the server so we can access the server's internals without races. 1372 // Pause the server so we can access the server's internals without races.
1373 server_thread_->Pause(); 1373 server_thread_->Pause();
1374 QuicDispatcher* dispatcher = 1374 QuicDispatcher* dispatcher =
1375 QuicServerPeer::GetDispatcher(server_thread_->server()); 1375 QuicServerPeer::GetDispatcher(server_thread_->server());
1376 ASSERT_EQ(1u, dispatcher->session_map().size()); 1376 ASSERT_EQ(1u, dispatcher->session_map().size());
1377 const QuicSentPacketManagerInterface& client_sent_packet_manager = 1377 const QuicSentPacketManagerInterface& client_sent_packet_manager =
1378 client_->client()->session()->connection()->sent_packet_manager(); 1378 client_->client()->session()->connection()->sent_packet_manager();
1379 const QuicSentPacketManagerInterface* server_sent_packet_manager = 1379 const QuicSentPacketManagerInterface* server_sent_packet_manager =
1380 GetSentPacketManagerFromFirstServerSession(); 1380 GetSentPacketManagerFromFirstServerSession();
1381 1381
1382 EXPECT_EQ(kInitialRTT, 1382 EXPECT_EQ(kInitialRTT,
1383 client_sent_packet_manager.GetRttStats()->initial_rtt_us()); 1383 client_sent_packet_manager.GetRttStats()->initial_rtt_us());
1384 EXPECT_EQ(kInitialRTT, 1384 EXPECT_EQ(kInitialRTT,
1385 server_sent_packet_manager->GetRttStats()->initial_rtt_us()); 1385 server_sent_packet_manager->GetRttStats()->initial_rtt_us());
1386 server_thread_->Resume(); 1386 server_thread_->Resume();
1387 } 1387 }
1388 1388
1389 TEST_P(EndToEndTest, MaxInitialRTT) { 1389 TEST_P(EndToEndTest, MaxInitialRTT) {
1390 // Client tries to suggest twice the server's max initial rtt and the server 1390 // Client tries to suggest twice the server's max initial rtt and the server
1391 // uses the max. 1391 // uses the max.
1392 client_config_.SetInitialRoundTripTimeUsToSend(2 * 1392 client_config_.SetInitialRoundTripTimeUsToSend(2 *
1393 kMaxInitialRoundTripTimeUs); 1393 kMaxInitialRoundTripTimeUs);
1394 1394
1395 ASSERT_TRUE(Initialize()); 1395 ASSERT_TRUE(Initialize());
1396 client_->client()->WaitForCryptoHandshakeConfirmed(); 1396 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1397 server_thread_->WaitForCryptoHandshakeConfirmed(); 1397 server_thread_->WaitForCryptoHandshakeConfirmed();
1398 1398
1399 // Pause the server so we can access the server's internals without races. 1399 // Pause the server so we can access the server's internals without races.
1400 server_thread_->Pause(); 1400 server_thread_->Pause();
1401 QuicDispatcher* dispatcher = 1401 QuicDispatcher* dispatcher =
1402 QuicServerPeer::GetDispatcher(server_thread_->server()); 1402 QuicServerPeer::GetDispatcher(server_thread_->server());
1403 ASSERT_EQ(1u, dispatcher->session_map().size()); 1403 ASSERT_EQ(1u, dispatcher->session_map().size());
1404 QuicSession* session = dispatcher->session_map().begin()->second.get(); 1404 QuicSession* session = dispatcher->session_map().begin()->second.get();
1405 const QuicSentPacketManagerInterface& client_sent_packet_manager = 1405 const QuicSentPacketManagerInterface& client_sent_packet_manager =
1406 client_->client()->session()->connection()->sent_packet_manager(); 1406 client_->client()->session()->connection()->sent_packet_manager();
1407 1407
1408 // Now that acks have been exchanged, the RTT estimate has decreased on the 1408 // Now that acks have been exchanged, the RTT estimate has decreased on the
1409 // server and is not infinite on the client. 1409 // server and is not infinite on the client.
1410 EXPECT_FALSE( 1410 EXPECT_FALSE(
1411 client_sent_packet_manager.GetRttStats()->smoothed_rtt().IsInfinite()); 1411 client_sent_packet_manager.GetRttStats()->smoothed_rtt().IsInfinite());
1412 const RttStats& server_rtt_stats = 1412 const RttStats& server_rtt_stats =
1413 *session->connection()->sent_packet_manager().GetRttStats(); 1413 *session->connection()->sent_packet_manager().GetRttStats();
1414 EXPECT_EQ(static_cast<int64_t>(kMaxInitialRoundTripTimeUs), 1414 EXPECT_EQ(static_cast<int64_t>(kMaxInitialRoundTripTimeUs),
1415 server_rtt_stats.initial_rtt_us()); 1415 server_rtt_stats.initial_rtt_us());
1416 EXPECT_GE(static_cast<int64_t>(kMaxInitialRoundTripTimeUs), 1416 EXPECT_GE(static_cast<int64_t>(kMaxInitialRoundTripTimeUs),
1417 server_rtt_stats.smoothed_rtt().ToMicroseconds()); 1417 server_rtt_stats.smoothed_rtt().ToMicroseconds());
1418 server_thread_->Resume(); 1418 server_thread_->Resume();
1419 } 1419 }
1420 1420
1421 TEST_P(EndToEndTest, MinInitialRTT) { 1421 TEST_P(EndToEndTest, MinInitialRTT) {
1422 // Client tries to suggest 0 and the server uses the default. 1422 // Client tries to suggest 0 and the server uses the default.
1423 client_config_.SetInitialRoundTripTimeUsToSend(0); 1423 client_config_.SetInitialRoundTripTimeUsToSend(0);
1424 1424
1425 ASSERT_TRUE(Initialize()); 1425 ASSERT_TRUE(Initialize());
1426 client_->client()->WaitForCryptoHandshakeConfirmed(); 1426 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1427 server_thread_->WaitForCryptoHandshakeConfirmed(); 1427 server_thread_->WaitForCryptoHandshakeConfirmed();
1428 1428
1429 // Pause the server so we can access the server's internals without races. 1429 // Pause the server so we can access the server's internals without races.
1430 server_thread_->Pause(); 1430 server_thread_->Pause();
1431 QuicDispatcher* dispatcher = 1431 QuicDispatcher* dispatcher =
1432 QuicServerPeer::GetDispatcher(server_thread_->server()); 1432 QuicServerPeer::GetDispatcher(server_thread_->server());
1433 ASSERT_EQ(1u, dispatcher->session_map().size()); 1433 ASSERT_EQ(1u, dispatcher->session_map().size());
1434 QuicSession* session = dispatcher->session_map().begin()->second.get(); 1434 QuicSession* session = dispatcher->session_map().begin()->second.get();
1435 const QuicSentPacketManagerInterface& client_sent_packet_manager = 1435 const QuicSentPacketManagerInterface& client_sent_packet_manager =
1436 client_->client()->session()->connection()->sent_packet_manager(); 1436 client_->client()->session()->connection()->sent_packet_manager();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 // TODO(jokulik): Until we support redundant SREJ packets, don't 1505 // TODO(jokulik): Until we support redundant SREJ packets, don't
1506 // drop handshake packets for stateless rejects. 1506 // drop handshake packets for stateless rejects.
1507 SetPacketLossPercentage(1); 1507 SetPacketLossPercentage(1);
1508 } 1508 }
1509 ASSERT_TRUE(Initialize()); 1509 ASSERT_TRUE(Initialize());
1510 string large_body(10240, 'a'); 1510 string large_body(10240, 'a');
1511 int max_streams = 100; 1511 int max_streams = 100;
1512 1512
1513 AddToCache("/large_response", 200, large_body); 1513 AddToCache("/large_response", 200, large_body);
1514 1514
1515 client_->client()->WaitForCryptoHandshakeConfirmed(); 1515 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1516 SetPacketLossPercentage(10); 1516 SetPacketLossPercentage(10);
1517 1517
1518 for (int i = 0; i < max_streams; ++i) { 1518 for (int i = 0; i < max_streams; ++i) {
1519 EXPECT_LT(0, client_->SendRequest("/large_response")); 1519 EXPECT_LT(0, client_->SendRequest("/large_response"));
1520 } 1520 }
1521 1521
1522 // WaitForEvents waits 50ms and returns true if there are outstanding 1522 // WaitForEvents waits 50ms and returns true if there are outstanding
1523 // requests. 1523 // requests.
1524 while (client_->client()->WaitForEvents() == true) { 1524 while (client_->client()->WaitForEvents() == true) {
1525 } 1525 }
1526 } 1526 }
1527 1527
1528 TEST_P(EndToEndTest, StreamCancelErrorTest) { 1528 TEST_P(EndToEndTest, StreamCancelErrorTest) {
1529 ASSERT_TRUE(Initialize()); 1529 ASSERT_TRUE(Initialize());
1530 string small_body(256, 'a'); 1530 string small_body(256, 'a');
1531 1531
1532 AddToCache("/small_response", 200, small_body); 1532 AddToCache("/small_response", 200, small_body);
1533 1533
1534 client_->client()->WaitForCryptoHandshakeConfirmed(); 1534 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1535 1535
1536 QuicSession* session = client_->client()->session(); 1536 QuicSession* session = client_->client()->session();
1537 // Lose the request. 1537 // Lose the request.
1538 SetPacketLossPercentage(100); 1538 SetPacketLossPercentage(100);
1539 EXPECT_LT(0, client_->SendRequest("/small_response")); 1539 EXPECT_LT(0, client_->SendRequest("/small_response"));
1540 client_->client()->WaitForEvents(); 1540 client_->client()->WaitForEvents();
1541 // Transmit the cancel, and ensure the connection is torn down properly. 1541 // Transmit the cancel, and ensure the connection is torn down properly.
1542 SetPacketLossPercentage(0); 1542 SetPacketLossPercentage(0);
1543 QuicStreamId stream_id = kClientDataStreamId1; 1543 QuicStreamId stream_id = kClientDataStreamId1;
1544 session->SendRstStream(stream_id, QUIC_STREAM_CANCELLED, 0); 1544 session->SendRstStream(stream_id, QUIC_STREAM_CANCELLED, 0);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 set_client_initial_session_flow_control_receive_window(kClientSessionIFCW); 1652 set_client_initial_session_flow_control_receive_window(kClientSessionIFCW);
1653 1653
1654 uint32_t kServerStreamIFCW = 32 * 1024; 1654 uint32_t kServerStreamIFCW = 32 * 1024;
1655 uint32_t kServerSessionIFCW = 48 * 1024; 1655 uint32_t kServerSessionIFCW = 48 * 1024;
1656 set_server_initial_stream_flow_control_receive_window(kServerStreamIFCW); 1656 set_server_initial_stream_flow_control_receive_window(kServerStreamIFCW);
1657 set_server_initial_session_flow_control_receive_window(kServerSessionIFCW); 1657 set_server_initial_session_flow_control_receive_window(kServerSessionIFCW);
1658 1658
1659 ASSERT_TRUE(Initialize()); 1659 ASSERT_TRUE(Initialize());
1660 1660
1661 // Values are exchanged during crypto handshake, so wait for that to finish. 1661 // Values are exchanged during crypto handshake, so wait for that to finish.
1662 client_->client()->WaitForCryptoHandshakeConfirmed(); 1662 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1663 server_thread_->WaitForCryptoHandshakeConfirmed(); 1663 server_thread_->WaitForCryptoHandshakeConfirmed();
1664 1664
1665 // Open a data stream to make sure the stream level flow control is updated. 1665 // Open a data stream to make sure the stream level flow control is updated.
1666 QuicSpdyClientStream* stream = client_->GetOrCreateStream(); 1666 QuicSpdyClientStream* stream = client_->GetOrCreateStream();
1667 stream->WriteOrBufferBody("hello", false, nullptr); 1667 stream->WriteOrBufferBody("hello", false, nullptr);
1668 1668
1669 // Client should have the right values for server's receive window. 1669 // Client should have the right values for server's receive window.
1670 EXPECT_EQ(kServerStreamIFCW, 1670 EXPECT_EQ(kServerStreamIFCW,
1671 client_->client() 1671 client_->client()
1672 ->session() 1672 ->session()
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 set_client_initial_stream_flow_control_receive_window(kStreamIFCW); 1705 set_client_initial_stream_flow_control_receive_window(kStreamIFCW);
1706 set_client_initial_session_flow_control_receive_window(kSessionIFCW); 1706 set_client_initial_session_flow_control_receive_window(kSessionIFCW);
1707 set_server_initial_stream_flow_control_receive_window(kStreamIFCW); 1707 set_server_initial_stream_flow_control_receive_window(kStreamIFCW);
1708 set_server_initial_session_flow_control_receive_window(kSessionIFCW); 1708 set_server_initial_session_flow_control_receive_window(kSessionIFCW);
1709 1709
1710 ASSERT_TRUE(Initialize()); 1710 ASSERT_TRUE(Initialize());
1711 1711
1712 // Wait for crypto handshake to finish. This should have contributed to the 1712 // Wait for crypto handshake to finish. This should have contributed to the
1713 // crypto stream flow control window, but not affected the session flow 1713 // crypto stream flow control window, but not affected the session flow
1714 // control window. 1714 // control window.
1715 client_->client()->WaitForCryptoHandshakeConfirmed(); 1715 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1716 server_thread_->WaitForCryptoHandshakeConfirmed(); 1716 server_thread_->WaitForCryptoHandshakeConfirmed();
1717 1717
1718 QuicCryptoStream* crypto_stream = 1718 QuicCryptoStream* crypto_stream =
1719 QuicSessionPeer::GetCryptoStream(client_->client()->session()); 1719 QuicSessionPeer::GetCryptoStream(client_->client()->session());
1720 EXPECT_LT( 1720 EXPECT_LT(
1721 QuicFlowControllerPeer::SendWindowSize(crypto_stream->flow_controller()), 1721 QuicFlowControllerPeer::SendWindowSize(crypto_stream->flow_controller()),
1722 kStreamIFCW); 1722 kStreamIFCW);
1723 EXPECT_EQ(kSessionIFCW, QuicFlowControllerPeer::SendWindowSize( 1723 EXPECT_EQ(kSessionIFCW, QuicFlowControllerPeer::SendWindowSize(
1724 client_->client()->session()->flow_controller())); 1724 client_->client()->session()->flow_controller()));
1725 1725
(...skipping 22 matching lines...) Expand all
1748 EXPECT_EQ(kSessionIFCW, QuicFlowControllerPeer::ReceiveWindowSize( 1748 EXPECT_EQ(kSessionIFCW, QuicFlowControllerPeer::ReceiveWindowSize(
1749 server_connection_flow_controller)); 1749 server_connection_flow_controller));
1750 server_thread_->Resume(); 1750 server_thread_->Resume();
1751 } 1751 }
1752 1752
1753 TEST_P(EndToEndTest, FlowControlsSynced) { 1753 TEST_P(EndToEndTest, FlowControlsSynced) {
1754 set_smaller_flow_control_receive_window(); 1754 set_smaller_flow_control_receive_window();
1755 1755
1756 ASSERT_TRUE(Initialize()); 1756 ASSERT_TRUE(Initialize());
1757 1757
1758 client_->client()->WaitForCryptoHandshakeConfirmed(); 1758 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1759 server_thread_->WaitForCryptoHandshakeConfirmed(); 1759 server_thread_->WaitForCryptoHandshakeConfirmed();
1760 1760
1761 server_thread_->Pause(); 1761 server_thread_->Pause();
1762 QuicSpdySession* const client_session = client_->client()->session(); 1762 QuicSpdySession* const client_session = client_->client()->session();
1763 QuicDispatcher* dispatcher = 1763 QuicDispatcher* dispatcher =
1764 QuicServerPeer::GetDispatcher(server_thread_->server()); 1764 QuicServerPeer::GetDispatcher(server_thread_->server());
1765 auto server_session = static_cast<QuicSpdySession*>( 1765 auto server_session = static_cast<QuicSpdySession*>(
1766 dispatcher->session_map().begin()->second.get()); 1766 dispatcher->session_map().begin()->second.get());
1767 1767
1768 ExpectFlowControlsSynced(client_session->flow_controller(), 1768 ExpectFlowControlsSynced(client_session->flow_controller(),
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 // interested in has been ACKed. This tests end-to-end ACK notification, and 1848 // interested in has been ACKed. This tests end-to-end ACK notification, and
1849 // demonstrates that retransmissions do not break this functionality. 1849 // demonstrates that retransmissions do not break this functionality.
1850 if (!BothSidesSupportStatelessRejects()) { 1850 if (!BothSidesSupportStatelessRejects()) {
1851 // TODO(jokulik): Until we support redundant SREJ packets, don't 1851 // TODO(jokulik): Until we support redundant SREJ packets, don't
1852 // drop handshake packets for stateless rejects. 1852 // drop handshake packets for stateless rejects.
1853 SetPacketLossPercentage(5); 1853 SetPacketLossPercentage(5);
1854 } 1854 }
1855 ASSERT_TRUE(Initialize()); 1855 ASSERT_TRUE(Initialize());
1856 1856
1857 // Wait for the server SHLO before upping the packet loss. 1857 // Wait for the server SHLO before upping the packet loss.
1858 client_->client()->WaitForCryptoHandshakeConfirmed(); 1858 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1859 SetPacketLossPercentage(30); 1859 SetPacketLossPercentage(30);
1860 client_writer_->set_fake_blocked_socket_percentage(10); 1860 client_writer_->set_fake_blocked_socket_percentage(10);
1861 1861
1862 // Create a POST request and send the headers only. 1862 // Create a POST request and send the headers only.
1863 SpdyHeaderBlock headers; 1863 SpdyHeaderBlock headers;
1864 headers[":method"] = "POST"; 1864 headers[":method"] = "POST";
1865 headers[":path"] = "/foo"; 1865 headers[":path"] = "/foo";
1866 headers[":scheme"] = "https"; 1866 headers[":scheme"] = "https";
1867 headers[":authority"] = server_hostname_; 1867 headers[":authority"] = server_hostname_;
1868 1868
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 EXPECT_EQ("", client_->SendSynchronousRequest("/foo")); 1920 EXPECT_EQ("", client_->SendSynchronousRequest("/foo"));
1921 EXPECT_TRUE(client_->response_headers()->empty()); 1921 EXPECT_TRUE(client_->response_headers()->empty());
1922 EXPECT_EQ(QUIC_PUBLIC_RESET, client_->connection_error()); 1922 EXPECT_EQ(QUIC_PUBLIC_RESET, client_->connection_error());
1923 } 1923 }
1924 1924
1925 // Send a public reset from the server for a different connection ID. 1925 // Send a public reset from the server for a different connection ID.
1926 // It should be ignored. 1926 // It should be ignored.
1927 TEST_P(EndToEndTest, ServerSendPublicResetWithDifferentConnectionId) { 1927 TEST_P(EndToEndTest, ServerSendPublicResetWithDifferentConnectionId) {
1928 ASSERT_TRUE(Initialize()); 1928 ASSERT_TRUE(Initialize());
1929 1929
1930 client_->client()->WaitForCryptoHandshakeConfirmed(); 1930 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1931 1931
1932 // Send the public reset. 1932 // Send the public reset.
1933 QuicConnectionId incorrect_connection_id = 1933 QuicConnectionId incorrect_connection_id =
1934 client_->client()->session()->connection()->connection_id() + 1; 1934 client_->client()->session()->connection()->connection_id() + 1;
1935 QuicPublicResetPacket header; 1935 QuicPublicResetPacket header;
1936 header.public_header.connection_id = incorrect_connection_id; 1936 header.public_header.connection_id = incorrect_connection_id;
1937 header.public_header.reset_flag = true; 1937 header.public_header.reset_flag = true;
1938 header.public_header.version_flag = false; 1938 header.public_header.version_flag = false;
1939 header.rejected_packet_number = 10101; 1939 header.rejected_packet_number = 10101;
1940 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), 1940 QuicFramer framer(server_supported_versions_, QuicTime::Zero(),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1985 // The connection should be unaffected. 1985 // The connection should be unaffected.
1986 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); 1986 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
1987 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); 1987 EXPECT_EQ("200", client_->response_headers()->find(":status")->second);
1988 } 1988 }
1989 1989
1990 // Send a version negotiation packet from the server for a different 1990 // Send a version negotiation packet from the server for a different
1991 // connection ID. It should be ignored. 1991 // connection ID. It should be ignored.
1992 TEST_P(EndToEndTest, ServerSendVersionNegotiationWithDifferentConnectionId) { 1992 TEST_P(EndToEndTest, ServerSendVersionNegotiationWithDifferentConnectionId) {
1993 ASSERT_TRUE(Initialize()); 1993 ASSERT_TRUE(Initialize());
1994 1994
1995 client_->client()->WaitForCryptoHandshakeConfirmed(); 1995 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
1996 1996
1997 // Send the version negotiation packet. 1997 // Send the version negotiation packet.
1998 QuicConnectionId incorrect_connection_id = 1998 QuicConnectionId incorrect_connection_id =
1999 client_->client()->session()->connection()->connection_id() + 1; 1999 client_->client()->session()->connection()->connection_id() + 1;
2000 std::unique_ptr<QuicEncryptedPacket> packet( 2000 std::unique_ptr<QuicEncryptedPacket> packet(
2001 QuicFramer::BuildVersionNegotiationPacket(incorrect_connection_id, 2001 QuicFramer::BuildVersionNegotiationPacket(incorrect_connection_id,
2002 server_supported_versions_)); 2002 server_supported_versions_));
2003 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; 2003 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor;
2004 client_->client()->session()->connection()->set_debug_visitor(&visitor); 2004 client_->client()->session()->connection()->set_debug_visitor(&visitor);
2005 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) 2005 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id))
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 // it. 2376 // it.
2377 uint32_t response_body_size = 2377 uint32_t response_body_size =
2378 2 * client_config_.GetInitialStreamFlowControlWindowToSend(); 2378 2 * client_config_.GetInitialStreamFlowControlWindowToSend();
2379 string response_body(response_body_size, 'a'); 2379 string response_body(response_body_size, 'a');
2380 2380
2381 StreamWithErrorFactory stream_factory(response_body); 2381 StreamWithErrorFactory stream_factory(response_body);
2382 SetSpdyStreamFactory(&stream_factory); 2382 SetSpdyStreamFactory(&stream_factory);
2383 2383
2384 ASSERT_TRUE(Initialize()); 2384 ASSERT_TRUE(Initialize());
2385 2385
2386 client_->client()->WaitForCryptoHandshakeConfirmed(); 2386 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
2387 2387
2388 // 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
2389 // and before the body is received, due to invalid content-length. 2389 // and before the body is received, due to invalid content-length.
2390 // 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
2391 // response. 2391 // response.
2392 SpdyHeaderBlock headers; 2392 SpdyHeaderBlock headers;
2393 headers[":method"] = "POST"; 2393 headers[":method"] = "POST";
2394 headers[":path"] = "/garbage"; 2394 headers[":path"] = "/garbage";
2395 headers[":scheme"] = "https"; 2395 headers[":scheme"] = "https";
2396 headers[":authority"] = server_hostname_; 2396 headers[":authority"] = server_hostname_;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2430 2430
2431 TEST_P(EndToEndTest, LargePostEarlyResponse) { 2431 TEST_P(EndToEndTest, LargePostEarlyResponse) {
2432 const uint32_t kWindowSize = 65536; 2432 const uint32_t kWindowSize = 65536;
2433 set_client_initial_stream_flow_control_receive_window(kWindowSize); 2433 set_client_initial_stream_flow_control_receive_window(kWindowSize);
2434 set_client_initial_session_flow_control_receive_window(kWindowSize); 2434 set_client_initial_session_flow_control_receive_window(kWindowSize);
2435 set_server_initial_stream_flow_control_receive_window(kWindowSize); 2435 set_server_initial_stream_flow_control_receive_window(kWindowSize);
2436 set_server_initial_session_flow_control_receive_window(kWindowSize); 2436 set_server_initial_session_flow_control_receive_window(kWindowSize);
2437 2437
2438 ASSERT_TRUE(Initialize()); 2438 ASSERT_TRUE(Initialize());
2439 2439
2440 client_->client()->WaitForCryptoHandshakeConfirmed(); 2440 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
2441 2441
2442 // POST to a URL that gets an early error response, after the headers are 2442 // POST to a URL that gets an early error response, after the headers are
2443 // received and before the body is received. 2443 // received and before the body is received.
2444 SpdyHeaderBlock headers; 2444 SpdyHeaderBlock headers;
2445 headers[":method"] = "POST"; 2445 headers[":method"] = "POST";
2446 headers[":path"] = "/foo"; 2446 headers[":path"] = "/foo";
2447 headers[":scheme"] = "https"; 2447 headers[":scheme"] = "https";
2448 headers[":authority"] = server_hostname_; 2448 headers[":authority"] = server_hostname_;
2449 headers["content-length"] = "-1"; 2449 headers["content-length"] = "-1";
2450 2450
2451 // Tell the client to not close the stream if it receives an early response. 2451 // Tell the client to not close the stream if it receives an early response.
2452 client_->set_allow_bidirectional_data(true); 2452 client_->set_allow_bidirectional_data(true);
2453 // Send the headers. 2453 // Send the headers.
2454 client_->SendMessage(headers, "", /*fin=*/false); 2454 client_->SendMessage(headers, "", /*fin=*/false);
2455 2455
2456 // Receive the response and let the server close writing. 2456 // Receive the response and let the server close writing.
2457 client_->WaitForInitialResponse(); 2457 client_->WaitForInitialResponse();
2458 EXPECT_EQ("500", client_->response_headers()->find(":status")->second); 2458 EXPECT_EQ("500", client_->response_headers()->find(":status")->second);
2459 2459
2460 // Receive the reset stream from server on early response. 2460 // Receive the reset stream from server on early response.
2461 QuicStream* stream = 2461 QuicStream* stream =
2462 client_->client()->session()->GetOrCreateStream(kClientDataStreamId1); 2462 client_->client()->session()->GetOrCreateStream(kClientDataStreamId1);
2463 // The stream is reset by server's reset stream. 2463 // The stream is reset by server's reset stream.
2464 EXPECT_EQ(stream, nullptr); 2464 EXPECT_EQ(stream, nullptr);
2465 } 2465 }
2466 2466
2467 TEST_P(EndToEndTest, Trailers) { 2467 TEST_P(EndToEndTest, Trailers) {
2468 // Test sending and receiving HTTP/2 Trailers (trailing HEADERS frames). 2468 // Test sending and receiving HTTP/2 Trailers (trailing HEADERS frames).
2469 ASSERT_TRUE(Initialize()); 2469 ASSERT_TRUE(Initialize());
2470 client_->client()->WaitForCryptoHandshakeConfirmed(); 2470 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
2471 2471
2472 // Set reordering to ensure that Trailers arriving before body is ok. 2472 // Set reordering to ensure that Trailers arriving before body is ok.
2473 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); 2473 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2));
2474 SetReorderPercentage(30); 2474 SetReorderPercentage(30);
2475 2475
2476 // Add a response with headers, body, and trailers. 2476 // Add a response with headers, body, and trailers.
2477 const string kBody = "body content"; 2477 const string kBody = "body content";
2478 2478
2479 SpdyHeaderBlock headers; 2479 SpdyHeaderBlock headers;
2480 headers[":status"] = "200"; 2480 headers[":status"] = "200";
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2542 } 2542 }
2543 }; 2543 };
2544 2544
2545 // Run all server push end to end tests with all supported versions. 2545 // Run all server push end to end tests with all supported versions.
2546 INSTANTIATE_TEST_CASE_P(EndToEndTestsServerPush, 2546 INSTANTIATE_TEST_CASE_P(EndToEndTestsServerPush,
2547 EndToEndTestServerPush, 2547 EndToEndTestServerPush,
2548 ::testing::ValuesIn(GetTestParams())); 2548 ::testing::ValuesIn(GetTestParams()));
2549 2549
2550 TEST_P(EndToEndTestServerPush, ServerPush) { 2550 TEST_P(EndToEndTestServerPush, ServerPush) {
2551 ASSERT_TRUE(Initialize()); 2551 ASSERT_TRUE(Initialize());
2552 client_->client()->WaitForCryptoHandshakeConfirmed(); 2552 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
2553 2553
2554 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok. 2554 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok.
2555 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); 2555 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2));
2556 SetReorderPercentage(30); 2556 SetReorderPercentage(30);
2557 2557
2558 // Add a response with headers, body, and push resources. 2558 // Add a response with headers, body, and push resources.
2559 const string kBody = "body content"; 2559 const string kBody = "body content";
2560 size_t kNumResources = 4; 2560 size_t kNumResources = 4;
2561 string push_urls[] = {"https://example.com/font.woff", 2561 string push_urls[] = {"https://example.com/font.woff",
2562 "https://example.com/script.js", 2562 "https://example.com/script.js",
(...skipping 26 matching lines...) Expand all
2589 EXPECT_NE(FLAGS_quic_headers_stream_release_sequencer_buffer, 2589 EXPECT_NE(FLAGS_quic_headers_stream_release_sequencer_buffer,
2590 QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer)); 2590 QuicStreamSequencerPeer::IsUnderlyingBufferAllocated(sequencer));
2591 } 2591 }
2592 2592
2593 TEST_P(EndToEndTestServerPush, ServerPushUnderLimit) { 2593 TEST_P(EndToEndTestServerPush, ServerPushUnderLimit) {
2594 // Tests that sending a request which has 4 push resources will trigger server 2594 // Tests that sending a request which has 4 push resources will trigger server
2595 // to push those 4 resources and client can handle pushed resources and match 2595 // to push those 4 resources and client can handle pushed resources and match
2596 // them with requests later. 2596 // them with requests later.
2597 ASSERT_TRUE(Initialize()); 2597 ASSERT_TRUE(Initialize());
2598 2598
2599 client_->client()->WaitForCryptoHandshakeConfirmed(); 2599 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
2600 2600
2601 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok. 2601 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok.
2602 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); 2602 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2));
2603 SetReorderPercentage(30); 2603 SetReorderPercentage(30);
2604 2604
2605 // Add a response with headers, body, and push resources. 2605 // Add a response with headers, body, and push resources.
2606 const string kBody = "body content"; 2606 const string kBody = "body content";
2607 size_t const kNumResources = 4; 2607 size_t const kNumResources = 4;
2608 string push_urls[] = { 2608 string push_urls[] = {
2609 "https://example.com/font.woff", "https://example.com/script.js", 2609 "https://example.com/font.woff", "https://example.com/script.js",
(...skipping 26 matching lines...) Expand all
2636 EXPECT_EQ(1u, client_->num_requests()); 2636 EXPECT_EQ(1u, client_->num_requests());
2637 EXPECT_EQ(1u + kNumResources, client_->num_responses()); 2637 EXPECT_EQ(1u + kNumResources, client_->num_responses());
2638 } 2638 }
2639 2639
2640 TEST_P(EndToEndTestServerPush, ServerPushOverLimitNonBlocking) { 2640 TEST_P(EndToEndTestServerPush, ServerPushOverLimitNonBlocking) {
2641 // Tests that when streams are not blocked by flow control or congestion 2641 // Tests that when streams are not blocked by flow control or congestion
2642 // control, pushing even more resources than max number of open outgoing 2642 // control, pushing even more resources than max number of open outgoing
2643 // streams should still work because all response streams get closed 2643 // streams should still work because all response streams get closed
2644 // immediately after pushing resources. 2644 // immediately after pushing resources.
2645 ASSERT_TRUE(Initialize()); 2645 ASSERT_TRUE(Initialize());
2646 client_->client()->WaitForCryptoHandshakeConfirmed(); 2646 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
2647 2647
2648 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok. 2648 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok.
2649 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); 2649 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2));
2650 SetReorderPercentage(30); 2650 SetReorderPercentage(30);
2651 2651
2652 // Add a response with headers, body, and push resources. 2652 // Add a response with headers, body, and push resources.
2653 const string kBody = "body content"; 2653 const string kBody = "body content";
2654 2654
2655 // One more resource than max number of outgoing stream of this session. 2655 // One more resource than max number of outgoing stream of this session.
2656 const size_t kNumResources = 1 + kNumMaxStreams; // 11. 2656 const size_t kNumResources = 1 + kNumMaxStreams; // 11.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2694 size_t kFlowControlWnd = 20 * 1024; // 20KB. 2694 size_t kFlowControlWnd = 20 * 1024; // 20KB.
2695 // Response body is larger than 1 flow controlblock window. 2695 // Response body is larger than 1 flow controlblock window.
2696 size_t kBodySize = kFlowControlWnd * 2; 2696 size_t kBodySize = kFlowControlWnd * 2;
2697 set_client_initial_stream_flow_control_receive_window(kFlowControlWnd); 2697 set_client_initial_stream_flow_control_receive_window(kFlowControlWnd);
2698 // Make sure conntection level flow control window is large enough not to 2698 // Make sure conntection level flow control window is large enough not to
2699 // block data being sent out though they will be blocked by stream level one. 2699 // block data being sent out though they will be blocked by stream level one.
2700 set_client_initial_session_flow_control_receive_window( 2700 set_client_initial_session_flow_control_receive_window(
2701 kBodySize * kNumMaxStreams + 1024); 2701 kBodySize * kNumMaxStreams + 1024);
2702 2702
2703 ASSERT_TRUE(Initialize()); 2703 ASSERT_TRUE(Initialize());
2704 client_->client()->WaitForCryptoHandshakeConfirmed(); 2704 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
2705 2705
2706 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok. 2706 // Set reordering to ensure that body arriving before PUSH_PROMISE is ok.
2707 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); 2707 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2));
2708 SetReorderPercentage(30); 2708 SetReorderPercentage(30);
2709 2709
2710 // Add a response with headers, body, and push resources. 2710 // Add a response with headers, body, and push resources.
2711 const string kBody = "body content"; 2711 const string kBody = "body content";
2712 2712
2713 const size_t kNumResources = kNumMaxStreams + 1; 2713 const size_t kNumResources = kNumMaxStreams + 1;
2714 string push_urls[11]; 2714 string push_urls[11];
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
2807 // This test tests a huge post with introduced packet loss from client to 2807 // This test tests a huge post with introduced packet loss from client to
2808 // server and body size greater than 4GB, making sure QUIC code does not break 2808 // server and body size greater than 4GB, making sure QUIC code does not break
2809 // for 32-bit builds. 2809 // for 32-bit builds.
2810 ServerStreamThatDropsBodyFactory stream_factory; 2810 ServerStreamThatDropsBodyFactory stream_factory;
2811 SetSpdyStreamFactory(&stream_factory); 2811 SetSpdyStreamFactory(&stream_factory);
2812 ASSERT_TRUE(Initialize()); 2812 ASSERT_TRUE(Initialize());
2813 // Set client's epoll server's time out to 0 to make this test be finished 2813 // Set client's epoll server's time out to 0 to make this test be finished
2814 // within a short time. 2814 // within a short time.
2815 client_->epoll_server()->set_timeout_in_us(0); 2815 client_->epoll_server()->set_timeout_in_us(0);
2816 2816
2817 client_->client()->WaitForCryptoHandshakeConfirmed(); 2817 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
2818 SetPacketLossPercentage(1); 2818 SetPacketLossPercentage(1);
2819 // 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
2820 // 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.
2821 const int kSizeBytes = 128 * 1024; 2821 const int kSizeBytes = 128 * 1024;
2822 // Request body size is 4G plus one more kSizeBytes. 2822 // Request body size is 4G plus one more kSizeBytes.
2823 int64_t request_body_size_bytes = pow(2, 32) + kSizeBytes; 2823 int64_t request_body_size_bytes = pow(2, 32) + kSizeBytes;
2824 ASSERT_LT(INT64_C(4294967296), request_body_size_bytes); 2824 ASSERT_LT(INT64_C(4294967296), request_body_size_bytes);
2825 string body(kSizeBytes, 'a'); 2825 string body(kSizeBytes, 'a');
2826 2826
2827 SpdyHeaderBlock headers; 2827 SpdyHeaderBlock headers;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2864 client_.reset(client); 2864 client_.reset(client);
2865 static EpollEvent event(EPOLLOUT, false); 2865 static EpollEvent event(EPOLLOUT, false);
2866 client_writer_->Initialize( 2866 client_writer_->Initialize(
2867 QuicConnectionPeer::GetHelper(client_->client()->session()->connection()), 2867 QuicConnectionPeer::GetHelper(client_->client()->session()->connection()),
2868 QuicConnectionPeer::GetAlarmFactory( 2868 QuicConnectionPeer::GetAlarmFactory(
2869 client_->client()->session()->connection()), 2869 client_->client()->session()->connection()),
2870 new ClientDelegate(client_->client())); 2870 new ClientDelegate(client_->client()));
2871 initialized_ = true; 2871 initialized_ = true;
2872 ASSERT_TRUE(client_->client()->connected()); 2872 ASSERT_TRUE(client_->client()->connected());
2873 2873
2874 client_->client()->WaitForCryptoHandshakeConfirmed(); 2874 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed());
2875 SetPacketLossPercentage(1); 2875 SetPacketLossPercentage(1);
2876 client_->SendRequest("/huge_response"); 2876 client_->SendRequest("/huge_response");
2877 client_->WaitForResponse(); 2877 client_->WaitForResponse();
2878 // TODO(fayang): Fix this test to work with stateless rejects. 2878 // TODO(fayang): Fix this test to work with stateless rejects.
2879 if (!BothSidesSupportStatelessRejects()) { 2879 if (!BothSidesSupportStatelessRejects()) {
2880 VerifyCleanConnection(true); 2880 VerifyCleanConnection(true);
2881 } 2881 }
2882 } 2882 }
2883 2883
2884 TEST_P(EndToEndTest, ReleaseHeadersStreamBufferWhenIdle) { 2884 TEST_P(EndToEndTest, ReleaseHeadersStreamBufferWhenIdle) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2940 client_->WaitForResponse(); 2940 client_->WaitForResponse();
2941 EXPECT_EQ(kBarResponseBody, client_->response_body()); 2941 EXPECT_EQ(kBarResponseBody, client_->response_body());
2942 QuicConnectionStats client_stats = 2942 QuicConnectionStats client_stats =
2943 client_->client()->session()->connection()->GetStats(); 2943 client_->client()->session()->connection()->GetStats();
2944 EXPECT_EQ(0u, client_stats.packets_lost); 2944 EXPECT_EQ(0u, client_stats.packets_lost);
2945 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); 2945 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos());
2946 } 2946 }
2947 } // namespace 2947 } // namespace
2948 } // namespace test 2948 } // namespace test
2949 } // namespace net 2949 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/tools/quic/quic_client_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698