Chromium Code Reviews| 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 <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 const char kBarResponseBody[] = "Palm hearts are pretty delicious, also."; | 89 const char kBarResponseBody[] = "Palm hearts are pretty delicious, also."; |
| 90 const float kSessionToStreamRatio = 1.5; | 90 const float kSessionToStreamRatio = 1.5; |
| 91 | 91 |
| 92 // Run all tests with the cross products of all versions. | 92 // Run all tests with the cross products of all versions. |
| 93 struct TestParams { | 93 struct TestParams { |
| 94 TestParams(const QuicVersionVector& client_supported_versions, | 94 TestParams(const QuicVersionVector& client_supported_versions, |
| 95 const QuicVersionVector& server_supported_versions, | 95 const QuicVersionVector& server_supported_versions, |
| 96 QuicVersion negotiated_version, | 96 QuicVersion negotiated_version, |
| 97 bool client_supports_stateless_rejects, | 97 bool client_supports_stateless_rejects, |
| 98 bool server_uses_stateless_rejects_if_peer_supported, | 98 bool server_uses_stateless_rejects_if_peer_supported, |
| 99 QuicTag congestion_control_tag) | 99 QuicTag congestion_control_tag, |
| 100 bool disable_hpack_dynamic_table) | |
| 100 : client_supported_versions(client_supported_versions), | 101 : client_supported_versions(client_supported_versions), |
| 101 server_supported_versions(server_supported_versions), | 102 server_supported_versions(server_supported_versions), |
| 102 negotiated_version(negotiated_version), | 103 negotiated_version(negotiated_version), |
| 103 client_supports_stateless_rejects(client_supports_stateless_rejects), | 104 client_supports_stateless_rejects(client_supports_stateless_rejects), |
| 104 server_uses_stateless_rejects_if_peer_supported( | 105 server_uses_stateless_rejects_if_peer_supported( |
| 105 server_uses_stateless_rejects_if_peer_supported), | 106 server_uses_stateless_rejects_if_peer_supported), |
| 106 congestion_control_tag(congestion_control_tag) {} | 107 congestion_control_tag(congestion_control_tag), |
| 108 disable_hpack_dynamic_table(disable_hpack_dynamic_table) {} | |
| 107 | 109 |
| 108 friend ostream& operator<<(ostream& os, const TestParams& p) { | 110 friend ostream& operator<<(ostream& os, const TestParams& p) { |
| 109 os << "{ server_supported_versions: " | 111 os << "{ server_supported_versions: " |
| 110 << QuicVersionVectorToString(p.server_supported_versions); | 112 << QuicVersionVectorToString(p.server_supported_versions); |
| 111 os << " client_supported_versions: " | 113 os << " client_supported_versions: " |
| 112 << QuicVersionVectorToString(p.client_supported_versions); | 114 << QuicVersionVectorToString(p.client_supported_versions); |
| 113 os << " negotiated_version: " << QuicVersionToString(p.negotiated_version); | 115 os << " negotiated_version: " << QuicVersionToString(p.negotiated_version); |
| 114 os << " client_supports_stateless_rejects: " | 116 os << " client_supports_stateless_rejects: " |
| 115 << p.client_supports_stateless_rejects; | 117 << p.client_supports_stateless_rejects; |
| 116 os << " server_uses_stateless_rejects_if_peer_supported: " | 118 os << " server_uses_stateless_rejects_if_peer_supported: " |
| 117 << p.server_uses_stateless_rejects_if_peer_supported; | 119 << p.server_uses_stateless_rejects_if_peer_supported; |
| 118 os << " congestion_control_tag: " | 120 os << " congestion_control_tag: " |
| 119 << QuicUtils::TagToString(p.congestion_control_tag) << " }"; | 121 << QuicUtils::TagToString(p.congestion_control_tag); |
| 122 os << " disable_hpack_dynamic_table: " << p.disable_hpack_dynamic_table | |
| 123 << " }"; | |
| 120 return os; | 124 return os; |
| 121 } | 125 } |
| 122 | 126 |
| 123 QuicVersionVector client_supported_versions; | 127 QuicVersionVector client_supported_versions; |
| 124 QuicVersionVector server_supported_versions; | 128 QuicVersionVector server_supported_versions; |
| 125 QuicVersion negotiated_version; | 129 QuicVersion negotiated_version; |
| 126 bool client_supports_stateless_rejects; | 130 bool client_supports_stateless_rejects; |
| 127 bool server_uses_stateless_rejects_if_peer_supported; | 131 bool server_uses_stateless_rejects_if_peer_supported; |
| 128 QuicTag congestion_control_tag; | 132 QuicTag congestion_control_tag; |
| 133 bool disable_hpack_dynamic_table; | |
| 129 }; | 134 }; |
| 130 | 135 |
| 131 // Constructs various test permutations. | 136 // Constructs various test permutations. |
| 132 vector<TestParams> GetTestParams() { | 137 vector<TestParams> GetTestParams() { |
| 133 // Divide the versions into buckets in which the intra-frame format | 138 // Divide the versions into buckets in which the intra-frame format |
| 134 // is compatible. When clients encounter QUIC version negotiation | 139 // is compatible. When clients encounter QUIC version negotiation |
| 135 // they simply retransmit all packets using the new version's | 140 // they simply retransmit all packets using the new version's |
| 136 // QUIC framing. However, they are unable to change the intra-frame | 141 // QUIC framing. However, they are unable to change the intra-frame |
| 137 // layout (for example to change SPDY/4 headers to SPDY/3). So | 142 // layout (for example to change SPDY/4 headers to SPDY/3). So |
| 138 // these tests need to ensure that clients are never attempting | 143 // these tests need to ensure that clients are never attempting |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 149 // version negotiation across the version 26 boundary. | 154 // version negotiation across the version 26 boundary. |
| 150 version_buckets[1].push_back(version); | 155 version_buckets[1].push_back(version); |
| 151 } | 156 } |
| 152 } | 157 } |
| 153 | 158 |
| 154 vector<TestParams> params; | 159 vector<TestParams> params; |
| 155 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { | 160 for (bool server_uses_stateless_rejects_if_peer_supported : {true, false}) { |
| 156 for (bool client_supports_stateless_rejects : {true, false}) { | 161 for (bool client_supports_stateless_rejects : {true, false}) { |
| 157 // TODO(rtenneti): Add kTBBR after BBR code is checked in. | 162 // TODO(rtenneti): Add kTBBR after BBR code is checked in. |
| 158 for (const QuicTag congestion_control_tag : {kRENO, kQBIC}) { | 163 for (const QuicTag congestion_control_tag : {kRENO, kQBIC}) { |
| 159 const int kMaxEnabledOptions = 4; | 164 for (bool disable_hpack_dynamic_table : {true, false}) { |
| 160 int enabled_options = 0; | 165 const int kMaxEnabledOptions = 5; |
| 161 if (congestion_control_tag != kQBIC) { | 166 int enabled_options = 0; |
| 162 ++enabled_options; | 167 if (congestion_control_tag != kQBIC) { |
| 163 } | 168 ++enabled_options; |
| 164 if (client_supports_stateless_rejects) { | 169 } |
| 165 ++enabled_options; | 170 if (disable_hpack_dynamic_table) { |
| 166 } | 171 ++enabled_options; |
| 167 if (server_uses_stateless_rejects_if_peer_supported) { | 172 } |
| 168 ++enabled_options; | 173 if (client_supports_stateless_rejects) { |
| 169 } | 174 ++enabled_options; |
| 170 CHECK_GE(kMaxEnabledOptions, enabled_options); | 175 } |
| 176 if (server_uses_stateless_rejects_if_peer_supported) { | |
| 177 ++enabled_options; | |
| 178 } | |
| 179 CHECK_GE(kMaxEnabledOptions, enabled_options); | |
| 171 | 180 |
| 172 // Run tests with no options, a single option, or all the options | 181 // Run tests with no options, a single option, or all the options |
| 173 // enabled to avoid a combinatorial explosion. | 182 // enabled to avoid a combinatorial explosion. |
| 174 if (enabled_options > 1 && enabled_options < kMaxEnabledOptions) { | 183 if (enabled_options > 1 && enabled_options < kMaxEnabledOptions) { |
| 175 continue; | |
| 176 } | |
| 177 | |
| 178 for (const QuicVersionVector& client_versions : version_buckets) { | |
| 179 CHECK(!client_versions.empty()); | |
| 180 // Add an entry for server and client supporting all versions. | |
| 181 params.push_back(TestParams( | |
| 182 client_versions, all_supported_versions, client_versions.front(), | |
| 183 client_supports_stateless_rejects, | |
| 184 server_uses_stateless_rejects_if_peer_supported, | |
| 185 congestion_control_tag)); | |
| 186 | |
| 187 // Run version negotiation tests tests with no options, or all | |
| 188 // the options enabled to avoid a combinatorial explosion. | |
| 189 if (enabled_options > 0 && enabled_options < kMaxEnabledOptions) { | |
| 190 continue; | 184 continue; |
| 191 } | 185 } |
| 192 | 186 |
| 193 // Test client supporting all versions and server supporting 1 | 187 for (const QuicVersionVector& client_versions : version_buckets) { |
| 194 // version. Simulate an old server and exercise version downgrade | 188 CHECK(!client_versions.empty()); |
| 195 // in the client. Protocol negotiation should occur. Skip the i = | 189 // Add an entry for server and client supporting all versions. |
| 196 // 0 case because it is essentially the same as the default case. | 190 params.push_back(TestParams( |
| 197 for (size_t i = 1; i < client_versions.size(); ++i) { | 191 client_versions, all_supported_versions, |
| 198 QuicVersionVector server_supported_versions; | 192 client_versions.front(), client_supports_stateless_rejects, |
| 199 server_supported_versions.push_back(client_versions[i]); | 193 server_uses_stateless_rejects_if_peer_supported, |
| 200 params.push_back( | 194 congestion_control_tag, disable_hpack_dynamic_table)); |
| 201 TestParams(client_versions, server_supported_versions, | 195 |
| 202 server_supported_versions.front(), | 196 // Run version negotiation tests tests with no options, or all |
|
ramant (doing other things)
2016/04/11 18:17:49
overly nit: should "tests tests" be "tests"?
| |
| 203 client_supports_stateless_rejects, | 197 // the options enabled to avoid a combinatorial explosion. |
| 204 server_uses_stateless_rejects_if_peer_supported, | 198 if (enabled_options > 0 && enabled_options < kMaxEnabledOptions) { |
| 205 congestion_control_tag)); | 199 continue; |
| 200 } | |
| 201 | |
| 202 // Test client supporting all versions and server supporting 1 | |
| 203 // version. Simulate an old server and exercise version downgrade | |
| 204 // in the client. Protocol negotiation should occur. Skip the i = | |
| 205 // 0 case because it is essentially the same as the default case. | |
| 206 for (size_t i = 1; i < client_versions.size(); ++i) { | |
| 207 QuicVersionVector server_supported_versions; | |
| 208 server_supported_versions.push_back(client_versions[i]); | |
| 209 params.push_back(TestParams( | |
| 210 client_versions, server_supported_versions, | |
| 211 server_supported_versions.front(), | |
| 212 client_supports_stateless_rejects, | |
| 213 server_uses_stateless_rejects_if_peer_supported, | |
| 214 congestion_control_tag, disable_hpack_dynamic_table)); | |
| 215 } | |
| 206 } | 216 } |
| 207 } | 217 } |
| 208 } | 218 } |
| 209 } | 219 } |
| 210 } | 220 } |
| 211 return params; | 221 return params; |
| 212 } | 222 } |
| 213 | 223 |
| 214 class ServerDelegate : public PacketDroppingTestWriter::Delegate { | 224 class ServerDelegate : public PacketDroppingTestWriter::Delegate { |
| 215 public: | 225 public: |
| (...skipping 2382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2598 client_->client()->WaitForCryptoHandshakeConfirmed(); | 2608 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 2599 SetPacketLossPercentage(1); | 2609 SetPacketLossPercentage(1); |
| 2600 client_->SendRequest("/huge_response"); | 2610 client_->SendRequest("/huge_response"); |
| 2601 client_->WaitForResponse(); | 2611 client_->WaitForResponse(); |
| 2602 VerifyCleanConnection(false); | 2612 VerifyCleanConnection(false); |
| 2603 } | 2613 } |
| 2604 | 2614 |
| 2605 } // namespace | 2615 } // namespace |
| 2606 } // namespace test | 2616 } // namespace test |
| 2607 } // namespace net | 2617 } // namespace net |
| OLD | NEW |