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 <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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 os << "{ server_supported_versions: " | 102 os << "{ server_supported_versions: " |
103 << QuicVersionVectorToString(p.server_supported_versions); | 103 << QuicVersionVectorToString(p.server_supported_versions); |
104 os << " client_supported_versions: " | 104 os << " client_supported_versions: " |
105 << QuicVersionVectorToString(p.client_supported_versions); | 105 << QuicVersionVectorToString(p.client_supported_versions); |
106 os << " negotiated_version: " << QuicVersionToString(p.negotiated_version); | 106 os << " negotiated_version: " << QuicVersionToString(p.negotiated_version); |
107 os << " client_supports_stateless_rejects: " | 107 os << " client_supports_stateless_rejects: " |
108 << p.client_supports_stateless_rejects; | 108 << p.client_supports_stateless_rejects; |
109 os << " server_uses_stateless_rejects_if_peer_supported: " | 109 os << " server_uses_stateless_rejects_if_peer_supported: " |
110 << p.server_uses_stateless_rejects_if_peer_supported; | 110 << p.server_uses_stateless_rejects_if_peer_supported; |
111 os << " congestion_control_tag: " | 111 os << " congestion_control_tag: " |
112 << QuicUtils::TagToString(p.congestion_control_tag); | 112 << QuicTagToString(p.congestion_control_tag); |
113 os << " disable_hpack_dynamic_table: " << p.disable_hpack_dynamic_table; | 113 os << " disable_hpack_dynamic_table: " << p.disable_hpack_dynamic_table; |
114 os << " force_hol_blocking: " << p.force_hol_blocking; | 114 os << " force_hol_blocking: " << p.force_hol_blocking; |
115 os << " use_cheap_stateless_reject: " << p.use_cheap_stateless_reject | 115 os << " use_cheap_stateless_reject: " << p.use_cheap_stateless_reject |
116 << " }"; | 116 << " }"; |
117 return os; | 117 return os; |
118 } | 118 } |
119 | 119 |
120 QuicVersionVector client_supported_versions; | 120 QuicVersionVector client_supported_versions; |
121 QuicVersionVector server_supported_versions; | 121 QuicVersionVector server_supported_versions; |
122 QuicVersion negotiated_version; | 122 QuicVersion negotiated_version; |
123 bool client_supports_stateless_rejects; | 123 bool client_supports_stateless_rejects; |
124 bool server_uses_stateless_rejects_if_peer_supported; | 124 bool server_uses_stateless_rejects_if_peer_supported; |
125 QuicTag congestion_control_tag; | 125 QuicTag congestion_control_tag; |
126 bool disable_hpack_dynamic_table; | 126 bool disable_hpack_dynamic_table; |
127 bool force_hol_blocking; | 127 bool force_hol_blocking; |
128 bool use_cheap_stateless_reject; | 128 bool use_cheap_stateless_reject; |
129 }; | 129 }; |
130 | 130 |
131 // Constructs various test permutations. | 131 // Constructs various test permutations. |
132 std::vector<TestParams> GetTestParams() { | 132 std::vector<TestParams> GetTestParams() { |
133 // Divide the versions into buckets in which the intra-frame format | 133 // Divide the versions into buckets in which the intra-frame format |
134 // is compatible. When clients encounter QUIC version negotiation | 134 // is compatible. When clients encounter QUIC version negotiation |
135 // they simply retransmit all packets using the new version's | 135 // they simply retransmit all packets using the new version's |
136 // QUIC framing. However, they are unable to change the intra-frame | 136 // QUIC framing. However, they are unable to change the intra-frame |
137 // layout (for example to change HTTP/2 headers to SPDY/3). So | 137 // layout (for example to change HTTP/2 headers to SPDY/3). So |
138 // these tests need to ensure that clients are never attempting | 138 // these tests need to ensure that clients are never attempting |
139 // to do 0-RTT across incompatible versions. Chromium only supports | 139 // to do 0-RTT across incompatible versions. Chromium only supports |
140 // a single version at a time anyway. :) | 140 // a single version at a time anyway. :) |
141 QuicVersionVector all_supported_versions = AllSupportedVersions(); | 141 QuicVersionVector all_supported_versions = AllSupportedVersions(); |
142 QuicVersionVector version_buckets[3]; | 142 // Even though this currently has one element, it may well get another |
| 143 // with future versions of QUIC, so don't remove it. |
| 144 QuicVersionVector version_buckets[1]; |
143 | 145 |
144 for (const QuicVersion version : all_supported_versions) { | 146 for (const QuicVersion version : all_supported_versions) { |
145 if (version <= QUIC_VERSION_32) { | 147 // Versions: 34+ |
146 // Versions: 31-32 | 148 // QUIC_VERSION_34 deprecates entropy and uses new ack and stop waiting |
147 // v31 adds a hash of the CHLO into the proof signature. | 149 // wire formats. |
148 version_buckets[0].push_back(version); | 150 version_buckets[0].push_back(version); |
149 } else if (version <= QUIC_VERSION_33) { | |
150 // Versions: 33 | |
151 // v33 adds a diversification nonce into the hkdf. | |
152 version_buckets[1].push_back(version); | |
153 } else { | |
154 // Versions: 34+ | |
155 // QUIC_VERSION_34 deprecates entropy and uses new ack and stop waiting | |
156 // wire formats. | |
157 version_buckets[2].push_back(version); | |
158 } | |
159 } | 151 } |
160 | 152 |
161 // This must be kept in sync with the number of nested for-loops below as it | 153 // This must be kept in sync with the number of nested for-loops below as it |
162 // is used to prune the number of tests that are run. | 154 // is used to prune the number of tests that are run. |
163 const int kMaxEnabledOptions = 5; | 155 const int kMaxEnabledOptions = 5; |
164 int max_enabled_options = 0; | 156 int max_enabled_options = 0; |
165 std::vector<TestParams> params; | 157 std::vector<TestParams> params; |
166 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { | 158 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { |
167 for (bool client_supports_stateless_rejects : {true, false}) { | 159 for (bool client_supports_stateless_rejects : {true, false}) { |
168 for (const QuicTag congestion_control_tag : {kRENO, kTBBR, kQBIC}) { | 160 for (const QuicTag congestion_control_tag : {kRENO, kTBBR, kQBIC}) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 270 |
279 class EndToEndTest : public ::testing::TestWithParam<TestParams> { | 271 class EndToEndTest : public ::testing::TestWithParam<TestParams> { |
280 protected: | 272 protected: |
281 EndToEndTest() | 273 EndToEndTest() |
282 : initialized_(false), | 274 : initialized_(false), |
283 server_address_(IPEndPoint(Loopback4(), 0)), | 275 server_address_(IPEndPoint(Loopback4(), 0)), |
284 server_hostname_("test.example.com"), | 276 server_hostname_("test.example.com"), |
285 client_writer_(nullptr), | 277 client_writer_(nullptr), |
286 server_writer_(nullptr), | 278 server_writer_(nullptr), |
287 server_started_(false), | 279 server_started_(false), |
288 strike_register_no_startup_period_(false), | |
289 chlo_multiplier_(0), | 280 chlo_multiplier_(0), |
290 stream_factory_(nullptr), | 281 stream_factory_(nullptr), |
291 support_server_push_(false) { | 282 support_server_push_(false) { |
292 client_supported_versions_ = GetParam().client_supported_versions; | 283 client_supported_versions_ = GetParam().client_supported_versions; |
293 server_supported_versions_ = GetParam().server_supported_versions; | 284 server_supported_versions_ = GetParam().server_supported_versions; |
294 negotiated_version_ = GetParam().negotiated_version; | 285 negotiated_version_ = GetParam().negotiated_version; |
295 | 286 |
296 VLOG(1) << "Using Configuration: " << GetParam(); | 287 VLOG(1) << "Using Configuration: " << GetParam(); |
297 | 288 |
298 // Use different flow control windows for client/server. | 289 // Use different flow control windows for client/server. |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 StopServer(); | 425 StopServer(); |
435 } | 426 } |
436 | 427 |
437 void StartServer() { | 428 void StartServer() { |
438 FLAGS_quic_use_cheap_stateless_rejects = | 429 FLAGS_quic_use_cheap_stateless_rejects = |
439 GetParam().use_cheap_stateless_reject; | 430 GetParam().use_cheap_stateless_reject; |
440 | 431 |
441 auto test_server = | 432 auto test_server = |
442 new QuicTestServer(CryptoTestUtils::ProofSourceForTesting(), | 433 new QuicTestServer(CryptoTestUtils::ProofSourceForTesting(), |
443 server_config_, server_supported_versions_); | 434 server_config_, server_supported_versions_); |
444 server_thread_.reset(new ServerThread(test_server, server_address_, | 435 server_thread_.reset(new ServerThread(test_server, server_address_)); |
445 strike_register_no_startup_period_)); | |
446 if (chlo_multiplier_ != 0) { | 436 if (chlo_multiplier_ != 0) { |
447 server_thread_->server()->SetChloMultiplier(chlo_multiplier_); | 437 server_thread_->server()->SetChloMultiplier(chlo_multiplier_); |
448 } | 438 } |
449 server_thread_->Initialize(); | 439 server_thread_->Initialize(); |
450 server_address_ = | 440 server_address_ = |
451 IPEndPoint(server_address_.address(), server_thread_->GetPort()); | 441 IPEndPoint(server_address_.address(), server_thread_->GetPort()); |
452 QuicDispatcher* dispatcher = | 442 QuicDispatcher* dispatcher = |
453 QuicServerPeer::GetDispatcher(server_thread_->server()); | 443 QuicServerPeer::GetDispatcher(server_thread_->server()); |
454 QuicDispatcherPeer::UseWriter(dispatcher, server_writer_); | 444 QuicDispatcherPeer::UseWriter(dispatcher, server_writer_); |
455 | 445 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 std::unique_ptr<ServerThread> server_thread_; | 562 std::unique_ptr<ServerThread> server_thread_; |
573 std::unique_ptr<QuicTestClient> client_; | 563 std::unique_ptr<QuicTestClient> client_; |
574 PacketDroppingTestWriter* client_writer_; | 564 PacketDroppingTestWriter* client_writer_; |
575 PacketDroppingTestWriter* server_writer_; | 565 PacketDroppingTestWriter* server_writer_; |
576 bool server_started_; | 566 bool server_started_; |
577 QuicConfig client_config_; | 567 QuicConfig client_config_; |
578 QuicConfig server_config_; | 568 QuicConfig server_config_; |
579 QuicVersionVector client_supported_versions_; | 569 QuicVersionVector client_supported_versions_; |
580 QuicVersionVector server_supported_versions_; | 570 QuicVersionVector server_supported_versions_; |
581 QuicVersion negotiated_version_; | 571 QuicVersion negotiated_version_; |
582 bool strike_register_no_startup_period_; | |
583 size_t chlo_multiplier_; | 572 size_t chlo_multiplier_; |
584 QuicTestServer::StreamFactory* stream_factory_; | 573 QuicTestServer::StreamFactory* stream_factory_; |
585 bool support_server_push_; | 574 bool support_server_push_; |
586 bool force_hol_blocking_; | 575 bool force_hol_blocking_; |
587 }; | 576 }; |
588 | 577 |
589 // Run all end to end tests with all supported versions. | 578 // Run all end to end tests with all supported versions. |
590 INSTANTIATE_TEST_CASE_P(EndToEndTests, | 579 INSTANTIATE_TEST_CASE_P(EndToEndTests, |
591 EndToEndTest, | 580 EndToEndTest, |
592 ::testing::ValuesIn(GetTestParams())); | 581 ::testing::ValuesIn(GetTestParams())); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 headers[":method"] = "POST"; | 840 headers[":method"] = "POST"; |
852 headers[":path"] = "/foo"; | 841 headers[":path"] = "/foo"; |
853 headers[":scheme"] = "https"; | 842 headers[":scheme"] = "https"; |
854 headers[":authority"] = server_hostname_; | 843 headers[":authority"] = server_hostname_; |
855 | 844 |
856 EXPECT_EQ(kFooResponseBody, | 845 EXPECT_EQ(kFooResponseBody, |
857 client_->SendCustomSynchronousRequest(headers, body)); | 846 client_->SendCustomSynchronousRequest(headers, body)); |
858 } | 847 } |
859 | 848 |
860 TEST_P(EndToEndTest, LargePostZeroRTTFailure) { | 849 TEST_P(EndToEndTest, LargePostZeroRTTFailure) { |
861 // Have the server accept 0-RTT without waiting a startup period. | |
862 strike_register_no_startup_period_ = true; | |
863 | |
864 // Send a request and then disconnect. This prepares the client to attempt | 850 // Send a request and then disconnect. This prepares the client to attempt |
865 // a 0-RTT handshake for the next request. | 851 // a 0-RTT handshake for the next request. |
866 ASSERT_TRUE(Initialize()); | 852 ASSERT_TRUE(Initialize()); |
867 | 853 |
868 string body; | 854 string body; |
869 GenerateBody(&body, 20480); | 855 GenerateBody(&body, 20480); |
870 SpdyHeaderBlock headers; | 856 SpdyHeaderBlock headers; |
871 headers[":method"] = "POST"; | 857 headers[":method"] = "POST"; |
872 headers[":path"] = "/foo"; | 858 headers[":path"] = "/foo"; |
873 headers[":scheme"] = "https"; | 859 headers[":scheme"] = "https"; |
(...skipping 14 matching lines...) Expand all Loading... |
888 | 874 |
889 client_->Disconnect(); | 875 client_->Disconnect(); |
890 | 876 |
891 // The 0-RTT handshake should succeed. | 877 // The 0-RTT handshake should succeed. |
892 client_->Connect(); | 878 client_->Connect(); |
893 client_->WaitForInitialResponse(); | 879 client_->WaitForInitialResponse(); |
894 ASSERT_TRUE(client_->client()->connected()); | 880 ASSERT_TRUE(client_->client()->connected()); |
895 EXPECT_EQ(kFooResponseBody, | 881 EXPECT_EQ(kFooResponseBody, |
896 client_->SendCustomSynchronousRequest(headers, body)); | 882 client_->SendCustomSynchronousRequest(headers, body)); |
897 | 883 |
898 if (negotiated_version_ <= QUIC_VERSION_32) { | 884 EXPECT_EQ(1, client_->client()->session()->GetNumSentClientHellos()); |
899 EXPECT_EQ(expected_num_hellos_latest_session, | 885 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); |
900 client_->client()->session()->GetNumSentClientHellos()); | |
901 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); | |
902 } else { | |
903 EXPECT_EQ(1, client_->client()->session()->GetNumSentClientHellos()); | |
904 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); | |
905 } | |
906 | 886 |
907 client_->Disconnect(); | 887 client_->Disconnect(); |
908 | 888 |
909 // Restart the server so that the 0-RTT handshake will take 1 RTT. | 889 // Restart the server so that the 0-RTT handshake will take 1 RTT. |
910 StopServer(); | 890 StopServer(); |
911 server_writer_ = new PacketDroppingTestWriter(); | 891 server_writer_ = new PacketDroppingTestWriter(); |
912 StartServer(); | 892 StartServer(); |
913 | 893 |
914 client_->Connect(); | 894 client_->Connect(); |
915 ASSERT_TRUE(client_->client()->connected()); | 895 ASSERT_TRUE(client_->client()->connected()); |
916 EXPECT_EQ(kFooResponseBody, | 896 EXPECT_EQ(kFooResponseBody, |
917 client_->SendCustomSynchronousRequest(headers, body)); | 897 client_->SendCustomSynchronousRequest(headers, body)); |
918 // In the non-stateless case, the same session is used for both | 898 // In the non-stateless case, the same session is used for both |
919 // hellos, so the number of hellos sent on that session is 2. In | 899 // hellos, so the number of hellos sent on that session is 2. In |
920 // the stateless case, the first client session will be completely | 900 // the stateless case, the first client session will be completely |
921 // torn down after the reject. The number of hellos sent on the | 901 // torn down after the reject. The number of hellos sent on the |
922 // latest session is 1. | 902 // latest session is 1. |
923 EXPECT_EQ(expected_num_hellos_latest_session, | 903 EXPECT_EQ(expected_num_hellos_latest_session, |
924 client_->client()->session()->GetNumSentClientHellos()); | 904 client_->client()->session()->GetNumSentClientHellos()); |
925 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); | 905 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); |
926 | 906 |
927 VerifyCleanConnection(false); | 907 VerifyCleanConnection(false); |
928 } | 908 } |
929 | 909 |
930 TEST_P(EndToEndTest, SynchronousRequestZeroRTTFailure) { | 910 TEST_P(EndToEndTest, SynchronousRequestZeroRTTFailure) { |
931 // Have the server accept 0-RTT without waiting a startup period. | |
932 strike_register_no_startup_period_ = true; | |
933 | |
934 // Send a request and then disconnect. This prepares the client to attempt | 911 // Send a request and then disconnect. This prepares the client to attempt |
935 // a 0-RTT handshake for the next request. | 912 // a 0-RTT handshake for the next request. |
936 ASSERT_TRUE(Initialize()); | 913 ASSERT_TRUE(Initialize()); |
937 | 914 |
938 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 915 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
939 // In the non-stateless case, the same session is used for both | 916 // In the non-stateless case, the same session is used for both |
940 // hellos, so the number of hellos sent on that session is 2. In | 917 // hellos, so the number of hellos sent on that session is 2. In |
941 // the stateless case, the first client session will be completely | 918 // the stateless case, the first client session will be completely |
942 // torn down after the reject. The number of hellos on that second | 919 // torn down after the reject. The number of hellos on that second |
943 // latest session is 1. | 920 // latest session is 1. |
944 const int expected_num_hellos_latest_session = | 921 const int expected_num_hellos_latest_session = |
945 BothSidesSupportStatelessRejects() ? 1 : 2; | 922 BothSidesSupportStatelessRejects() ? 1 : 2; |
946 EXPECT_EQ(expected_num_hellos_latest_session, | 923 EXPECT_EQ(expected_num_hellos_latest_session, |
947 client_->client()->session()->GetNumSentClientHellos()); | 924 client_->client()->session()->GetNumSentClientHellos()); |
948 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); | 925 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); |
949 | 926 |
950 client_->Disconnect(); | 927 client_->Disconnect(); |
951 | 928 |
952 // The 0-RTT handshake should succeed. | 929 // The 0-RTT handshake should succeed. |
953 client_->Connect(); | 930 client_->Connect(); |
954 client_->WaitForInitialResponse(); | 931 client_->WaitForInitialResponse(); |
955 ASSERT_TRUE(client_->client()->connected()); | 932 ASSERT_TRUE(client_->client()->connected()); |
956 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 933 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
957 | 934 |
958 if (negotiated_version_ <= QUIC_VERSION_32) { | 935 EXPECT_EQ(1, client_->client()->session()->GetNumSentClientHellos()); |
959 EXPECT_EQ(expected_num_hellos_latest_session, | 936 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); |
960 client_->client()->session()->GetNumSentClientHellos()); | |
961 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); | |
962 } else { | |
963 EXPECT_EQ(1, client_->client()->session()->GetNumSentClientHellos()); | |
964 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); | |
965 } | |
966 | 937 |
967 client_->Disconnect(); | 938 client_->Disconnect(); |
968 | 939 |
969 // Restart the server so that the 0-RTT handshake will take 1 RTT. | 940 // Restart the server so that the 0-RTT handshake will take 1 RTT. |
970 StopServer(); | 941 StopServer(); |
971 server_writer_ = new PacketDroppingTestWriter(); | 942 server_writer_ = new PacketDroppingTestWriter(); |
972 StartServer(); | 943 StartServer(); |
973 | 944 |
974 client_->Connect(); | 945 client_->Connect(); |
975 ASSERT_TRUE(client_->client()->connected()); | 946 ASSERT_TRUE(client_->client()->connected()); |
976 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 947 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
977 // In the non-stateless case, the same session is used for both | 948 // In the non-stateless case, the same session is used for both |
978 // hellos, so the number of hellos sent on that session is 2. In | 949 // hellos, so the number of hellos sent on that session is 2. In |
979 // the stateless case, the first client session will be completely | 950 // the stateless case, the first client session will be completely |
980 // torn down after the reject. The number of hellos sent on the | 951 // torn down after the reject. The number of hellos sent on the |
981 // latest session is 1. | 952 // latest session is 1. |
982 EXPECT_EQ(expected_num_hellos_latest_session, | 953 EXPECT_EQ(expected_num_hellos_latest_session, |
983 client_->client()->session()->GetNumSentClientHellos()); | 954 client_->client()->session()->GetNumSentClientHellos()); |
984 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); | 955 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); |
985 | 956 |
986 VerifyCleanConnection(false); | 957 VerifyCleanConnection(false); |
987 } | 958 } |
988 | 959 |
989 TEST_P(EndToEndTest, LargePostSynchronousRequest) { | 960 TEST_P(EndToEndTest, LargePostSynchronousRequest) { |
990 // Have the server accept 0-RTT without waiting a startup period. | |
991 strike_register_no_startup_period_ = true; | |
992 | |
993 // Send a request and then disconnect. This prepares the client to attempt | 961 // Send a request and then disconnect. This prepares the client to attempt |
994 // a 0-RTT handshake for the next request. | 962 // a 0-RTT handshake for the next request. |
995 ASSERT_TRUE(Initialize()); | 963 ASSERT_TRUE(Initialize()); |
996 | 964 |
997 string body; | 965 string body; |
998 GenerateBody(&body, 20480); | 966 GenerateBody(&body, 20480); |
999 SpdyHeaderBlock headers; | 967 SpdyHeaderBlock headers; |
1000 headers[":method"] = "POST"; | 968 headers[":method"] = "POST"; |
1001 headers[":path"] = "/foo"; | 969 headers[":path"] = "/foo"; |
1002 headers[":scheme"] = "https"; | 970 headers[":scheme"] = "https"; |
(...skipping 14 matching lines...) Expand all Loading... |
1017 | 985 |
1018 client_->Disconnect(); | 986 client_->Disconnect(); |
1019 | 987 |
1020 // The 0-RTT handshake should succeed. | 988 // The 0-RTT handshake should succeed. |
1021 client_->Connect(); | 989 client_->Connect(); |
1022 client_->WaitForInitialResponse(); | 990 client_->WaitForInitialResponse(); |
1023 ASSERT_TRUE(client_->client()->connected()); | 991 ASSERT_TRUE(client_->client()->connected()); |
1024 EXPECT_EQ(kFooResponseBody, | 992 EXPECT_EQ(kFooResponseBody, |
1025 client_->SendCustomSynchronousRequest(headers, body)); | 993 client_->SendCustomSynchronousRequest(headers, body)); |
1026 | 994 |
1027 if (negotiated_version_ <= QUIC_VERSION_32) { | 995 EXPECT_EQ(1, client_->client()->session()->GetNumSentClientHellos()); |
1028 EXPECT_EQ(expected_num_hellos_latest_session, | 996 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); |
1029 client_->client()->session()->GetNumSentClientHellos()); | |
1030 EXPECT_EQ(2, client_->client()->GetNumSentClientHellos()); | |
1031 } else { | |
1032 EXPECT_EQ(1, client_->client()->session()->GetNumSentClientHellos()); | |
1033 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); | |
1034 } | |
1035 | 997 |
1036 client_->Disconnect(); | 998 client_->Disconnect(); |
1037 | 999 |
1038 // Restart the server so that the 0-RTT handshake will take 1 RTT. | 1000 // Restart the server so that the 0-RTT handshake will take 1 RTT. |
1039 StopServer(); | 1001 StopServer(); |
1040 server_writer_ = new PacketDroppingTestWriter(); | 1002 server_writer_ = new PacketDroppingTestWriter(); |
1041 StartServer(); | 1003 StartServer(); |
1042 | 1004 |
1043 client_->Connect(); | 1005 client_->Connect(); |
1044 ASSERT_TRUE(client_->client()->connected()); | 1006 ASSERT_TRUE(client_->client()->connected()); |
(...skipping 1909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2954 protected: | 2916 protected: |
2955 PacketReorderingWriter* reorder_writer_; | 2917 PacketReorderingWriter* reorder_writer_; |
2956 }; | 2918 }; |
2957 | 2919 |
2958 INSTANTIATE_TEST_CASE_P(EndToEndBufferedPacketsTests, | 2920 INSTANTIATE_TEST_CASE_P(EndToEndBufferedPacketsTests, |
2959 EndToEndBufferedPacketsTest, | 2921 EndToEndBufferedPacketsTest, |
2960 testing::ValuesIn(GetTestParams())); | 2922 testing::ValuesIn(GetTestParams())); |
2961 | 2923 |
2962 TEST_P(EndToEndBufferedPacketsTest, Buffer0RttRequest) { | 2924 TEST_P(EndToEndBufferedPacketsTest, Buffer0RttRequest) { |
2963 ASSERT_TRUE(Initialize()); | 2925 ASSERT_TRUE(Initialize()); |
2964 if (negotiated_version_ <= QUIC_VERSION_32) { | |
2965 // Since no 0-rtt for v32 and under, and this test relies on 0-rtt, skip | |
2966 // this test if QUIC doesn't do 0-rtt. | |
2967 return; | |
2968 } | |
2969 // Finish one request to make sure handshake established. | 2926 // Finish one request to make sure handshake established. |
2970 client_->SendSynchronousRequest("/foo"); | 2927 client_->SendSynchronousRequest("/foo"); |
2971 // Disconnect for next 0-rtt request. | 2928 // Disconnect for next 0-rtt request. |
2972 client_->Disconnect(); | 2929 client_->Disconnect(); |
2973 | 2930 |
2974 // Client get valid STK now. Do a 0-rtt request. | 2931 // Client get valid STK now. Do a 0-rtt request. |
2975 // Buffer a CHLO till another packets sent out. | 2932 // Buffer a CHLO till another packets sent out. |
2976 reorder_writer_->SetDelay(1); | 2933 reorder_writer_->SetDelay(1); |
2977 // Only send out a CHLO. | 2934 // Only send out a CHLO. |
2978 client_->client()->Initialize(); | 2935 client_->client()->Initialize(); |
(...skipping 11 matching lines...) Expand all Loading... |
2990 client_->WaitForResponse(); | 2947 client_->WaitForResponse(); |
2991 EXPECT_EQ(kBarResponseBody, client_->response_body()); | 2948 EXPECT_EQ(kBarResponseBody, client_->response_body()); |
2992 QuicConnectionStats client_stats = | 2949 QuicConnectionStats client_stats = |
2993 client_->client()->session()->connection()->GetStats(); | 2950 client_->client()->session()->connection()->GetStats(); |
2994 EXPECT_EQ(0u, client_stats.packets_lost); | 2951 EXPECT_EQ(0u, client_stats.packets_lost); |
2995 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); | 2952 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); |
2996 } | 2953 } |
2997 } // namespace | 2954 } // namespace |
2998 } // namespace test | 2955 } // namespace test |
2999 } // namespace net | 2956 } // namespace net |
OLD | NEW |