OLD | NEW |
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 <string> | 6 #include <string> |
7 #include <sys/epoll.h> | 7 #include <sys/epoll.h> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 use_fec != 0, | 132 use_fec != 0, |
133 congestion_control_tag)); | 133 congestion_control_tag)); |
134 | 134 |
135 // Test client supporting all versions and server supporting 1 version. | 135 // Test client supporting all versions and server supporting 1 version. |
136 // Simulate an old server and exercise version downgrade in the client. | 136 // Simulate an old server and exercise version downgrade in the client. |
137 // Protocol negotiation should occur. Skip the i = 0 case because it is | 137 // Protocol negotiation should occur. Skip the i = 0 case because it is |
138 // essentially the same as the default case. | 138 // essentially the same as the default case. |
139 for (size_t i = 1; i < all_supported_versions.size(); ++i) { | 139 for (size_t i = 1; i < all_supported_versions.size(); ++i) { |
140 QuicVersionVector server_supported_versions; | 140 QuicVersionVector server_supported_versions; |
141 server_supported_versions.push_back(all_supported_versions[i]); | 141 server_supported_versions.push_back(all_supported_versions[i]); |
142 if (all_supported_versions[i] >= QUIC_VERSION_18) { | |
143 // Until flow control is globally rolled out and we remove | |
144 // QUIC_VERSION_16, the server MUST support at least one QUIC | |
145 // version that does not use flow control. | |
146 server_supported_versions.push_back(QUIC_VERSION_16); | |
147 } | |
148 params.push_back(TestParams(all_supported_versions, | 142 params.push_back(TestParams(all_supported_versions, |
149 server_supported_versions, | 143 server_supported_versions, |
150 server_supported_versions[0], | 144 server_supported_versions[0], |
151 use_pacing != 0, | 145 use_pacing != 0, |
152 use_fec != 0, | 146 use_fec != 0, |
153 congestion_control_tag)); | 147 congestion_control_tag)); |
154 } | 148 } |
155 } | 149 } |
156 } | 150 } |
157 } | 151 } |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 HttpConstants::POST, "/foo"); | 680 HttpConstants::POST, "/foo"); |
687 request.AddBody(body, true); | 681 request.AddBody(body, true); |
688 | 682 |
689 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 683 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
690 EXPECT_EQ(2, client_->client()->session()->GetNumSentClientHellos()); | 684 EXPECT_EQ(2, client_->client()->session()->GetNumSentClientHellos()); |
691 | 685 |
692 client_->Disconnect(); | 686 client_->Disconnect(); |
693 | 687 |
694 // The 0-RTT handshake should succeed. | 688 // The 0-RTT handshake should succeed. |
695 client_->Connect(); | 689 client_->Connect(); |
696 if (client_supported_versions_[0] >= QUIC_VERSION_18 && | |
697 negotiated_version_ <= QUIC_VERSION_16) { | |
698 // If the version negotiation has resulted in a downgrade, then the client | |
699 // must wait for the handshake to complete before sending any data. | |
700 // Otherwise it may have queued frames which will trigger a | |
701 // DFATAL when they are serialized after the downgrade. | |
702 client_->client()->WaitForCryptoHandshakeConfirmed(); | |
703 } | |
704 client_->WaitForResponseForMs(-1); | 690 client_->WaitForResponseForMs(-1); |
705 ASSERT_TRUE(client_->client()->connected()); | 691 ASSERT_TRUE(client_->client()->connected()); |
706 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 692 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
707 EXPECT_EQ(1, client_->client()->session()->GetNumSentClientHellos()); | 693 EXPECT_EQ(1, client_->client()->session()->GetNumSentClientHellos()); |
708 | 694 |
709 client_->Disconnect(); | 695 client_->Disconnect(); |
710 | 696 |
711 // Restart the server so that the 0-RTT handshake will take 1 RTT. | 697 // Restart the server so that the 0-RTT handshake will take 1 RTT. |
712 StopServer(); | 698 StopServer(); |
713 server_writer_ = new PacketDroppingTestWriter(); | 699 server_writer_ = new PacketDroppingTestWriter(); |
714 StartServer(); | 700 StartServer(); |
715 | 701 |
716 client_->Connect(); | 702 client_->Connect(); |
717 if (client_supported_versions_[0] >= QUIC_VERSION_18 && | |
718 negotiated_version_ <= QUIC_VERSION_16) { | |
719 // If the version negotiation has resulted in a downgrade, then the client | |
720 // must wait for the handshake to complete before sending any data. | |
721 // Otherwise it may have queued frames which will trigger a | |
722 // DFATAL when they are serialized after the downgrade. | |
723 client_->client()->WaitForCryptoHandshakeConfirmed(); | |
724 } | |
725 ASSERT_TRUE(client_->client()->connected()); | 703 ASSERT_TRUE(client_->client()->connected()); |
726 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 704 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
727 EXPECT_EQ(2, client_->client()->session()->GetNumSentClientHellos()); | 705 EXPECT_EQ(2, client_->client()->session()->GetNumSentClientHellos()); |
728 VerifyCleanConnection(false); | 706 VerifyCleanConnection(false); |
729 } | 707 } |
730 | 708 |
731 TEST_P(EndToEndTest, CorrectlyConfiguredFec) { | 709 TEST_P(EndToEndTest, CorrectlyConfiguredFec) { |
732 ASSERT_TRUE(Initialize()); | 710 ASSERT_TRUE(Initialize()); |
733 client_->client()->WaitForCryptoHandshakeConfirmed(); | 711 client_->client()->WaitForCryptoHandshakeConfirmed(); |
734 server_thread_->WaitForCryptoHandshakeConfirmed(); | 712 server_thread_->WaitForCryptoHandshakeConfirmed(); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 | 841 |
864 // By default the stream protects itself from writes after terminte is set. | 842 // By default the stream protects itself from writes after terminte is set. |
865 // Override this to test the server handling buggy clients. | 843 // Override this to test the server handling buggy clients. |
866 ReliableQuicStreamPeer::SetWriteSideClosed( | 844 ReliableQuicStreamPeer::SetWriteSideClosed( |
867 false, client_->GetOrCreateStream()); | 845 false, client_->GetOrCreateStream()); |
868 | 846 |
869 EXPECT_DFATAL(client_->SendData("eep", true), "Fin already buffered"); | 847 EXPECT_DFATAL(client_->SendData("eep", true), "Fin already buffered"); |
870 } | 848 } |
871 | 849 |
872 TEST_P(EndToEndTest, Timeout) { | 850 TEST_P(EndToEndTest, Timeout) { |
873 client_config_.set_idle_connection_state_lifetime( | 851 client_config_.SetIdleConnectionStateLifetime( |
874 QuicTime::Delta::FromMicroseconds(500), | 852 QuicTime::Delta::FromMicroseconds(500), |
875 QuicTime::Delta::FromMicroseconds(500)); | 853 QuicTime::Delta::FromMicroseconds(500)); |
876 // Note: we do NOT ASSERT_TRUE: we may time out during initial handshake: | 854 // Note: we do NOT ASSERT_TRUE: we may time out during initial handshake: |
877 // that's enough to validate timeout in this case. | 855 // that's enough to validate timeout in this case. |
878 Initialize(); | 856 Initialize(); |
879 while (client_->client()->connected()) { | 857 while (client_->client()->connected()) { |
880 client_->client()->WaitForEvents(); | 858 client_->client()->WaitForEvents(); |
881 } | 859 } |
882 } | 860 } |
883 | 861 |
884 TEST_P(EndToEndTest, NegotiateMaxOpenStreams) { | 862 TEST_P(EndToEndTest, NegotiateMaxOpenStreams) { |
885 // Negotiate 1 max open stream. | 863 // Negotiate 1 max open stream. |
886 client_config_.set_max_streams_per_connection(1, 1); | 864 client_config_.SetMaxStreamsPerConnection(1, 1); |
887 ASSERT_TRUE(Initialize()); | 865 ASSERT_TRUE(Initialize()); |
888 client_->client()->WaitForCryptoHandshakeConfirmed(); | 866 client_->client()->WaitForCryptoHandshakeConfirmed(); |
889 | 867 |
890 // Make the client misbehave after negotiation. | 868 // Make the client misbehave after negotiation. |
891 QuicSessionPeer::SetMaxOpenStreams(client_->client()->session(), 10); | 869 QuicSessionPeer::SetMaxOpenStreams(client_->client()->session(), 10); |
892 | 870 |
893 HTTPMessage request(HttpConstants::HTTP_1_1, | 871 HTTPMessage request(HttpConstants::HTTP_1_1, |
894 HttpConstants::POST, "/foo"); | 872 HttpConstants::POST, "/foo"); |
895 request.AddHeader("content-length", "3"); | 873 request.AddHeader("content-length", "3"); |
896 request.set_has_complete_message(false); | 874 request.set_has_complete_message(false); |
(...skipping 28 matching lines...) Expand all Loading... |
925 } | 903 } |
926 | 904 |
927 EXPECT_EQ(expected_congestion_control_type, | 905 EXPECT_EQ(expected_congestion_control_type, |
928 QuicSentPacketManagerPeer::GetCongestionControlAlgorithm( | 906 QuicSentPacketManagerPeer::GetCongestionControlAlgorithm( |
929 *GetSentPacketManagerFromFirstServerSession()) | 907 *GetSentPacketManagerFromFirstServerSession()) |
930 ->GetCongestionControlType()); | 908 ->GetCongestionControlType()); |
931 } | 909 } |
932 | 910 |
933 TEST_P(EndToEndTest, LimitMaxOpenStreams) { | 911 TEST_P(EndToEndTest, LimitMaxOpenStreams) { |
934 // Server limits the number of max streams to 2. | 912 // Server limits the number of max streams to 2. |
935 server_config_.set_max_streams_per_connection(2, 2); | 913 server_config_.SetMaxStreamsPerConnection(2, 2); |
936 // Client tries to negotiate for 10. | 914 // Client tries to negotiate for 10. |
937 client_config_.set_max_streams_per_connection(10, 5); | 915 client_config_.SetMaxStreamsPerConnection(10, 5); |
938 | 916 |
939 ASSERT_TRUE(Initialize()); | 917 ASSERT_TRUE(Initialize()); |
940 client_->client()->WaitForCryptoHandshakeConfirmed(); | 918 client_->client()->WaitForCryptoHandshakeConfirmed(); |
941 QuicConfig* client_negotiated_config = client_->client()->session()->config(); | 919 QuicConfig* client_negotiated_config = client_->client()->session()->config(); |
942 EXPECT_EQ(2u, client_negotiated_config->max_streams_per_connection()); | 920 EXPECT_EQ(2u, client_negotiated_config->MaxStreamsPerConnection()); |
943 } | 921 } |
944 | 922 |
945 TEST_P(EndToEndTest, LimitCongestionWindowAndRTT) { | 923 TEST_P(EndToEndTest, LimitCongestionWindowAndRTT) { |
946 // Client tries to request twice the server's max initial window, and the | 924 // Client tries to request twice the server's max initial window, and the |
947 // server limits it to the max. | 925 // server limits it to the max. |
948 client_config_.SetInitialCongestionWindowToSend(2 * kMaxInitialWindow); | 926 client_config_.SetInitialCongestionWindowToSend(2 * kMaxInitialWindow); |
949 client_config_.SetInitialRoundTripTimeUsToSend(1000); | 927 client_config_.SetInitialRoundTripTimeUsToSend(1000); |
950 | 928 |
951 ASSERT_TRUE(Initialize()); | 929 ASSERT_TRUE(Initialize()); |
952 client_->client()->WaitForCryptoHandshakeConfirmed(); | 930 client_->client()->WaitForCryptoHandshakeConfirmed(); |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 QuicSession* session = dispatcher->session_map().begin()->second; | 1363 QuicSession* session = dispatcher->session_map().begin()->second; |
1386 EXPECT_EQ(0u, QuicSessionPeer::GetLocallyClosedStreamsHighestOffset( | 1364 EXPECT_EQ(0u, QuicSessionPeer::GetLocallyClosedStreamsHighestOffset( |
1387 session).size()); | 1365 session).size()); |
1388 server_thread_->Resume(); | 1366 server_thread_->Resume(); |
1389 } | 1367 } |
1390 | 1368 |
1391 } // namespace | 1369 } // namespace |
1392 } // namespace test | 1370 } // namespace test |
1393 } // namespace tools | 1371 } // namespace tools |
1394 } // namespace net | 1372 } // namespace net |
OLD | NEW |