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 <list> | 8 #include <list> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "net/quic/crypto/null_encrypter.h" | 22 #include "net/quic/crypto/null_encrypter.h" |
23 #include "net/quic/quic_client_session_base.h" | 23 #include "net/quic/quic_client_session_base.h" |
24 #include "net/quic/quic_flags.h" | 24 #include "net/quic/quic_flags.h" |
25 #include "net/quic/quic_framer.h" | 25 #include "net/quic/quic_framer.h" |
26 #include "net/quic/quic_packet_creator.h" | 26 #include "net/quic/quic_packet_creator.h" |
27 #include "net/quic/quic_protocol.h" | 27 #include "net/quic/quic_protocol.h" |
28 #include "net/quic/quic_server_id.h" | 28 #include "net/quic/quic_server_id.h" |
29 #include "net/quic/quic_session.h" | 29 #include "net/quic/quic_session.h" |
30 #include "net/quic/quic_utils.h" | 30 #include "net/quic/quic_utils.h" |
31 #include "net/quic/test_tools/crypto_test_utils.h" | 31 #include "net/quic/test_tools/crypto_test_utils.h" |
| 32 #include "net/quic/test_tools/quic_config_peer.h" |
32 #include "net/quic/test_tools/quic_connection_peer.h" | 33 #include "net/quic/test_tools/quic_connection_peer.h" |
33 #include "net/quic/test_tools/quic_flow_controller_peer.h" | 34 #include "net/quic/test_tools/quic_flow_controller_peer.h" |
34 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" | 35 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" |
35 #include "net/quic/test_tools/quic_session_peer.h" | 36 #include "net/quic/test_tools/quic_session_peer.h" |
36 #include "net/quic/test_tools/quic_spdy_session_peer.h" | 37 #include "net/quic/test_tools/quic_spdy_session_peer.h" |
37 #include "net/quic/test_tools/quic_test_utils.h" | 38 #include "net/quic/test_tools/quic_test_utils.h" |
38 #include "net/quic/test_tools/reliable_quic_stream_peer.h" | 39 #include "net/quic/test_tools/reliable_quic_stream_peer.h" |
39 #include "net/test/gtest_util.h" | 40 #include "net/test/gtest_util.h" |
40 #include "net/tools/epoll_server/epoll_server.h" | 41 #include "net/tools/epoll_server/epoll_server.h" |
41 #include "net/tools/quic/quic_epoll_connection_helper.h" | 42 #include "net/tools/quic/quic_epoll_connection_helper.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 93 |
93 // Run all tests with the cross products of all versions. | 94 // Run all tests with the cross products of all versions. |
94 struct TestParams { | 95 struct TestParams { |
95 TestParams(const QuicVersionVector& client_supported_versions, | 96 TestParams(const QuicVersionVector& client_supported_versions, |
96 const QuicVersionVector& server_supported_versions, | 97 const QuicVersionVector& server_supported_versions, |
97 QuicVersion negotiated_version, | 98 QuicVersion negotiated_version, |
98 bool client_supports_stateless_rejects, | 99 bool client_supports_stateless_rejects, |
99 bool server_uses_stateless_rejects_if_peer_supported, | 100 bool server_uses_stateless_rejects_if_peer_supported, |
100 QuicTag congestion_control_tag, | 101 QuicTag congestion_control_tag, |
101 bool auto_tune_flow_control_window, | 102 bool auto_tune_flow_control_window, |
102 bool disable_hpack_dynamic_table) | 103 bool disable_hpack_dynamic_table, |
| 104 bool force_hol_blocking) |
103 : client_supported_versions(client_supported_versions), | 105 : client_supported_versions(client_supported_versions), |
104 server_supported_versions(server_supported_versions), | 106 server_supported_versions(server_supported_versions), |
105 negotiated_version(negotiated_version), | 107 negotiated_version(negotiated_version), |
106 client_supports_stateless_rejects(client_supports_stateless_rejects), | 108 client_supports_stateless_rejects(client_supports_stateless_rejects), |
107 server_uses_stateless_rejects_if_peer_supported( | 109 server_uses_stateless_rejects_if_peer_supported( |
108 server_uses_stateless_rejects_if_peer_supported), | 110 server_uses_stateless_rejects_if_peer_supported), |
109 congestion_control_tag(congestion_control_tag), | 111 congestion_control_tag(congestion_control_tag), |
110 auto_tune_flow_control_window(auto_tune_flow_control_window), | 112 auto_tune_flow_control_window(auto_tune_flow_control_window), |
111 disable_hpack_dynamic_table(disable_hpack_dynamic_table) {} | 113 disable_hpack_dynamic_table(disable_hpack_dynamic_table), |
| 114 force_hol_blocking(force_hol_blocking) {} |
112 | 115 |
113 friend ostream& operator<<(ostream& os, const TestParams& p) { | 116 friend ostream& operator<<(ostream& os, const TestParams& p) { |
114 os << "{ server_supported_versions: " | 117 os << "{ server_supported_versions: " |
115 << QuicVersionVectorToString(p.server_supported_versions); | 118 << QuicVersionVectorToString(p.server_supported_versions); |
116 os << " client_supported_versions: " | 119 os << " client_supported_versions: " |
117 << QuicVersionVectorToString(p.client_supported_versions); | 120 << QuicVersionVectorToString(p.client_supported_versions); |
118 os << " negotiated_version: " << QuicVersionToString(p.negotiated_version); | 121 os << " negotiated_version: " << QuicVersionToString(p.negotiated_version); |
119 os << " client_supports_stateless_rejects: " | 122 os << " client_supports_stateless_rejects: " |
120 << p.client_supports_stateless_rejects; | 123 << p.client_supports_stateless_rejects; |
121 os << " server_uses_stateless_rejects_if_peer_supported: " | 124 os << " server_uses_stateless_rejects_if_peer_supported: " |
122 << p.server_uses_stateless_rejects_if_peer_supported; | 125 << p.server_uses_stateless_rejects_if_peer_supported; |
123 os << " congestion_control_tag: " | 126 os << " congestion_control_tag: " |
124 << QuicUtils::TagToString(p.congestion_control_tag); | 127 << QuicUtils::TagToString(p.congestion_control_tag); |
125 os << " auto_tune_flow_control_window: " << p.auto_tune_flow_control_window; | 128 os << " auto_tune_flow_control_window: " << p.auto_tune_flow_control_window; |
126 os << " disable_hpack_dynamic_table: " << p.disable_hpack_dynamic_table | 129 os << " disable_hpack_dynamic_table: " << p.disable_hpack_dynamic_table; |
127 << " }"; | 130 os << " force_hol_blocking: " << p.force_hol_blocking << " }"; |
128 return os; | 131 return os; |
129 } | 132 } |
130 | 133 |
131 QuicVersionVector client_supported_versions; | 134 QuicVersionVector client_supported_versions; |
132 QuicVersionVector server_supported_versions; | 135 QuicVersionVector server_supported_versions; |
133 QuicVersion negotiated_version; | 136 QuicVersion negotiated_version; |
134 bool client_supports_stateless_rejects; | 137 bool client_supports_stateless_rejects; |
135 bool server_uses_stateless_rejects_if_peer_supported; | 138 bool server_uses_stateless_rejects_if_peer_supported; |
136 QuicTag congestion_control_tag; | 139 QuicTag congestion_control_tag; |
137 bool auto_tune_flow_control_window; | 140 bool auto_tune_flow_control_window; |
138 bool disable_hpack_dynamic_table; | 141 bool disable_hpack_dynamic_table; |
| 142 bool force_hol_blocking; |
139 }; | 143 }; |
140 | 144 |
141 // Constructs various test permutations. | 145 // Constructs various test permutations. |
142 vector<TestParams> GetTestParams() { | 146 vector<TestParams> GetTestParams() { |
143 // Divide the versions into buckets in which the intra-frame format | 147 // Divide the versions into buckets in which the intra-frame format |
144 // is compatible. When clients encounter QUIC version negotiation | 148 // is compatible. When clients encounter QUIC version negotiation |
145 // they simply retransmit all packets using the new version's | 149 // they simply retransmit all packets using the new version's |
146 // QUIC framing. However, they are unable to change the intra-frame | 150 // QUIC framing. However, they are unable to change the intra-frame |
147 // layout (for example to change SPDY/4 headers to SPDY/3). So | 151 // layout (for example to change SPDY/4 headers to SPDY/3). So |
148 // these tests need to ensure that clients are never attempting | 152 // these tests need to ensure that clients are never attempting |
(...skipping 25 matching lines...) Expand all Loading... |
174 | 178 |
175 // This must be kept in sync with the number of nested for-loops below as it | 179 // This must be kept in sync with the number of nested for-loops below as it |
176 // is used to prune the number of tests that are run. | 180 // is used to prune the number of tests that are run. |
177 const int kMaxEnabledOptions = 5; | 181 const int kMaxEnabledOptions = 5; |
178 int max_enabled_options = 0; | 182 int max_enabled_options = 0; |
179 vector<TestParams> params; | 183 vector<TestParams> params; |
180 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { | 184 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { |
181 for (bool client_supports_stateless_rejects : {true, false}) { | 185 for (bool client_supports_stateless_rejects : {true, false}) { |
182 for (const QuicTag congestion_control_tag : {kRENO, kQBIC}) { | 186 for (const QuicTag congestion_control_tag : {kRENO, kQBIC}) { |
183 for (bool auto_tune_flow_control_window : {true, false}) { | 187 for (bool auto_tune_flow_control_window : {true, false}) { |
184 for (bool disable_hpack_dynamic_table : {true, false}) { | 188 for (bool disable_hpack_dynamic_table : {false}) { |
185 int enabled_options = 0; | 189 for (bool force_hol_blocking : {true, false}) { |
186 if (congestion_control_tag != kQBIC) { | 190 int enabled_options = 0; |
187 ++enabled_options; | 191 if (force_hol_blocking) { |
188 } | 192 ++enabled_options; |
189 if (auto_tune_flow_control_window) { | 193 } |
190 ++enabled_options; | 194 if (congestion_control_tag != kQBIC) { |
191 } | 195 ++enabled_options; |
192 if (disable_hpack_dynamic_table) { | 196 } |
193 ++enabled_options; | 197 if (auto_tune_flow_control_window) { |
194 } | 198 ++enabled_options; |
195 if (client_supports_stateless_rejects) { | 199 } |
196 ++enabled_options; | 200 if (disable_hpack_dynamic_table) { |
197 } | 201 ++enabled_options; |
198 if (server_uses_stateless_rejects_if_peer_supported) { | 202 } |
199 ++enabled_options; | 203 if (client_supports_stateless_rejects) { |
200 } | 204 ++enabled_options; |
201 CHECK_GE(kMaxEnabledOptions, enabled_options); | 205 } |
202 if (enabled_options > max_enabled_options) { | 206 if (server_uses_stateless_rejects_if_peer_supported) { |
203 max_enabled_options = enabled_options; | 207 ++enabled_options; |
204 } | 208 } |
| 209 CHECK_GE(kMaxEnabledOptions, enabled_options); |
| 210 if (enabled_options > max_enabled_options) { |
| 211 max_enabled_options = enabled_options; |
| 212 } |
205 | 213 |
206 // Run tests with no options, a single option, or all the options | 214 // Run tests with no options, a single option, or all the options |
207 // enabled to avoid a combinatorial explosion. | 215 // enabled to avoid a combinatorial explosion. |
208 if (enabled_options > 1 && enabled_options < kMaxEnabledOptions) { | 216 if (enabled_options > 1 && enabled_options < kMaxEnabledOptions) { |
209 continue; | |
210 } | |
211 | |
212 for (const QuicVersionVector& client_versions : version_buckets) { | |
213 if (client_versions.front() < QUIC_VERSION_30 && | |
214 FLAGS_quic_disable_pre_30) { | |
215 continue; | |
216 } | |
217 CHECK(!client_versions.empty()); | |
218 // Add an entry for server and client supporting all versions. | |
219 params.push_back(TestParams( | |
220 client_versions, all_supported_versions, | |
221 client_versions.front(), client_supports_stateless_rejects, | |
222 server_uses_stateless_rejects_if_peer_supported, | |
223 congestion_control_tag, auto_tune_flow_control_window, | |
224 disable_hpack_dynamic_table)); | |
225 | |
226 // Run version negotiation tests tests with no options, or all | |
227 // the options enabled to avoid a combinatorial explosion. | |
228 if (enabled_options > 0 && enabled_options < kMaxEnabledOptions) { | |
229 continue; | 217 continue; |
230 } | 218 } |
231 | 219 |
232 // Test client supporting all versions and server supporting 1 | 220 for (const QuicVersionVector& client_versions : version_buckets) { |
233 // version. Simulate an old server and exercise version downgrade | 221 if (client_versions.front() < QUIC_VERSION_30 && |
234 // in the client. Protocol negotiation should occur. Skip the i = | |
235 // 0 case because it is essentially the same as the default case. | |
236 for (size_t i = 1; i < client_versions.size(); ++i) { | |
237 if (client_versions[i] < QUIC_VERSION_30 && | |
238 FLAGS_quic_disable_pre_30) { | 222 FLAGS_quic_disable_pre_30) { |
239 continue; | 223 continue; |
240 } | 224 } |
241 QuicVersionVector server_supported_versions; | 225 CHECK(!client_versions.empty()); |
242 server_supported_versions.push_back(client_versions[i]); | 226 // Add an entry for server and client supporting all versions. |
243 params.push_back(TestParams( | 227 params.push_back(TestParams( |
244 client_versions, server_supported_versions, | 228 client_versions, all_supported_versions, |
245 server_supported_versions.front(), | 229 client_versions.front(), client_supports_stateless_rejects, |
246 client_supports_stateless_rejects, | |
247 server_uses_stateless_rejects_if_peer_supported, | 230 server_uses_stateless_rejects_if_peer_supported, |
248 congestion_control_tag, auto_tune_flow_control_window, | 231 congestion_control_tag, auto_tune_flow_control_window, |
249 disable_hpack_dynamic_table)); | 232 disable_hpack_dynamic_table, force_hol_blocking)); |
| 233 |
| 234 // Run version negotiation tests tests with no options, or all |
| 235 // the options enabled to avoid a combinatorial explosion. |
| 236 if (enabled_options > 0 && |
| 237 enabled_options < kMaxEnabledOptions) { |
| 238 continue; |
| 239 } |
| 240 |
| 241 // Test client supporting all versions and server |
| 242 // supporting 1 version. Simulate an old server and |
| 243 // exercise version downgrade in the client. Protocol |
| 244 // negotiation should occur. Skip the i = 0 case |
| 245 // because it is essentially the same as the default |
| 246 // case. |
| 247 for (size_t i = 1; i < client_versions.size(); ++i) { |
| 248 if (client_versions[i] < QUIC_VERSION_30 && |
| 249 FLAGS_quic_disable_pre_30) { |
| 250 continue; |
| 251 } |
| 252 QuicVersionVector server_supported_versions; |
| 253 server_supported_versions.push_back(client_versions[i]); |
| 254 params.push_back(TestParams( |
| 255 client_versions, server_supported_versions, |
| 256 server_supported_versions.front(), |
| 257 client_supports_stateless_rejects, |
| 258 server_uses_stateless_rejects_if_peer_supported, |
| 259 congestion_control_tag, auto_tune_flow_control_window, |
| 260 disable_hpack_dynamic_table, force_hol_blocking)); |
| 261 } |
250 } | 262 } |
251 } | 263 } |
252 } | 264 } |
253 } | 265 } |
254 } | 266 } |
255 } | 267 } |
256 CHECK_EQ(kMaxEnabledOptions, max_enabled_options); | 268 CHECK_EQ(kMaxEnabledOptions, max_enabled_options); |
257 } | 269 } |
258 return params; | 270 return params; |
259 } | 271 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 if (GetParam().client_supports_stateless_rejects) { | 407 if (GetParam().client_supports_stateless_rejects) { |
396 copt.push_back(kSREJ); | 408 copt.push_back(kSREJ); |
397 } | 409 } |
398 if (GetParam().auto_tune_flow_control_window) { | 410 if (GetParam().auto_tune_flow_control_window) { |
399 copt.push_back(kAFCW); | 411 copt.push_back(kAFCW); |
400 copt.push_back(kIFW5); | 412 copt.push_back(kIFW5); |
401 } | 413 } |
402 if (GetParam().disable_hpack_dynamic_table) { | 414 if (GetParam().disable_hpack_dynamic_table) { |
403 copt.push_back(kDHDT); | 415 copt.push_back(kDHDT); |
404 } | 416 } |
| 417 if (GetParam().force_hol_blocking) { |
| 418 client_config_.SetForceHolBlocking(); |
| 419 QuicConfigPeer::SetReceivedForceHolBlocking(&server_config_); |
| 420 } |
405 client_config_.SetConnectionOptionsToSend(copt); | 421 client_config_.SetConnectionOptionsToSend(copt); |
406 | 422 |
407 // Start the server first, because CreateQuicClient() attempts | 423 // Start the server first, because CreateQuicClient() attempts |
408 // to connect to the server. | 424 // to connect to the server. |
409 StartServer(); | 425 StartServer(); |
410 | 426 |
411 client_.reset(CreateQuicClient(client_writer_)); | 427 client_.reset(CreateQuicClient(client_writer_)); |
412 static EpollEvent event(EPOLLOUT, false); | 428 static EpollEvent event(EPOLLOUT, false); |
413 client_writer_->Initialize( | 429 client_writer_->Initialize( |
414 reinterpret_cast<QuicEpollConnectionHelper*>( | 430 reinterpret_cast<QuicEpollConnectionHelper*>( |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 bool server_started_; | 588 bool server_started_; |
573 QuicConfig client_config_; | 589 QuicConfig client_config_; |
574 QuicConfig server_config_; | 590 QuicConfig server_config_; |
575 QuicVersionVector client_supported_versions_; | 591 QuicVersionVector client_supported_versions_; |
576 QuicVersionVector server_supported_versions_; | 592 QuicVersionVector server_supported_versions_; |
577 QuicVersion negotiated_version_; | 593 QuicVersion negotiated_version_; |
578 bool strike_register_no_startup_period_; | 594 bool strike_register_no_startup_period_; |
579 size_t chlo_multiplier_; | 595 size_t chlo_multiplier_; |
580 QuicTestServer::StreamFactory* stream_factory_; | 596 QuicTestServer::StreamFactory* stream_factory_; |
581 bool support_server_push_; | 597 bool support_server_push_; |
| 598 bool force_hol_blocking_; |
582 }; | 599 }; |
583 | 600 |
584 // Run all end to end tests with all supported versions. | 601 // Run all end to end tests with all supported versions. |
585 INSTANTIATE_TEST_CASE_P(EndToEndTests, | 602 INSTANTIATE_TEST_CASE_P(EndToEndTests, |
586 EndToEndTest, | 603 EndToEndTest, |
587 ::testing::ValuesIn(GetTestParams())); | 604 ::testing::ValuesIn(GetTestParams())); |
588 | 605 |
589 TEST_P(EndToEndTest, SimpleRequestResponse) { | 606 TEST_P(EndToEndTest, SimpleRequestResponse) { |
590 ASSERT_TRUE(Initialize()); | 607 ASSERT_TRUE(Initialize()); |
591 | 608 |
(...skipping 2225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2817 client_->WaitForResponse(); | 2834 client_->WaitForResponse(); |
2818 // TODO(fayang): Fix this test to work with stateless rejects. | 2835 // TODO(fayang): Fix this test to work with stateless rejects. |
2819 if (!BothSidesSupportStatelessRejects()) { | 2836 if (!BothSidesSupportStatelessRejects()) { |
2820 VerifyCleanConnection(true); | 2837 VerifyCleanConnection(true); |
2821 } | 2838 } |
2822 } | 2839 } |
2823 | 2840 |
2824 } // namespace | 2841 } // namespace |
2825 } // namespace test | 2842 } // namespace test |
2826 } // namespace net | 2843 } // namespace net |
OLD | NEW |