| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "net/tools/quic/quic_server_session_base.h" | 5 #include "net/tools/quic/quic_server_session_base.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "net/quic/crypto/quic_crypto_server_config.h" | 8 #include "net/quic/crypto/quic_crypto_server_config.h" |
| 9 #include "net/quic/crypto/quic_random.h" | 9 #include "net/quic/crypto/quic_random.h" |
| 10 #include "net/quic/proto/cached_network_parameters.pb.h" | 10 #include "net/quic/proto/cached_network_parameters.pb.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 } | 230 } |
| 231 | 231 |
| 232 TEST_P(QuicServerSessionBaseTest, MaxOpenStreams) { | 232 TEST_P(QuicServerSessionBaseTest, MaxOpenStreams) { |
| 233 // Test that the server refuses if a client attempts to open too many data | 233 // Test that the server refuses if a client attempts to open too many data |
| 234 // streams. The server accepts slightly more than the negotiated stream limit | 234 // streams. The server accepts slightly more than the negotiated stream limit |
| 235 // to deal with rare cases where a client FIN/RST is lost. | 235 // to deal with rare cases where a client FIN/RST is lost. |
| 236 | 236 |
| 237 // The slightly increased stream limit is set during config negotiation. It | 237 // The slightly increased stream limit is set during config negotiation. It |
| 238 // is either an increase of 10 over negotiated limit, or a fixed percentage | 238 // is either an increase of 10 over negotiated limit, or a fixed percentage |
| 239 // scaling, whichever is larger. Test both before continuing. | 239 // scaling, whichever is larger. Test both before continuing. |
| 240 EXPECT_EQ(kMaxStreamsForTest, session_->get_max_open_streams()); | 240 EXPECT_EQ(kMaxStreamsForTest, session_->max_open_incoming_streams()); |
| 241 session_->OnConfigNegotiated(); | 241 session_->OnConfigNegotiated(); |
| 242 EXPECT_LT(kMaxStreamsMultiplier * kMaxStreamsForTest, | 242 EXPECT_LT(kMaxStreamsMultiplier * kMaxStreamsForTest, |
| 243 kMaxStreamsForTest + kMaxStreamsMinimumIncrement); | 243 kMaxStreamsForTest + kMaxStreamsMinimumIncrement); |
| 244 EXPECT_EQ(kMaxStreamsForTest + kMaxStreamsMinimumIncrement, | 244 EXPECT_EQ(kMaxStreamsForTest + kMaxStreamsMinimumIncrement, |
| 245 session_->get_max_open_streams()); | 245 session_->max_open_incoming_streams()); |
| 246 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 246 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
| 247 QuicStreamId stream_id = kClientDataStreamId1; | 247 QuicStreamId stream_id = kClientDataStreamId1; |
| 248 // Open the max configured number of streams, should be no problem. | 248 // Open the max configured number of streams, should be no problem. |
| 249 for (size_t i = 0; i < kMaxStreamsForTest; ++i) { | 249 for (size_t i = 0; i < kMaxStreamsForTest; ++i) { |
| 250 EXPECT_TRUE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( | 250 EXPECT_TRUE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( |
| 251 session_.get(), stream_id)); | 251 session_.get(), stream_id)); |
| 252 stream_id += 2; | 252 stream_id += 2; |
| 253 } | 253 } |
| 254 | 254 |
| 255 // Open more streams: server should accept slightly more than the limit. | 255 // Open more streams: server should accept slightly more than the limit. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 273 EXPECT_FALSE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( | 273 EXPECT_FALSE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( |
| 274 session_.get(), stream_id)); | 274 session_.get(), stream_id)); |
| 275 } | 275 } |
| 276 | 276 |
| 277 TEST_P(QuicServerSessionBaseTest, MaxAvailableStreams) { | 277 TEST_P(QuicServerSessionBaseTest, MaxAvailableStreams) { |
| 278 // Test that the server closes the connection if a client makes too many data | 278 // Test that the server closes the connection if a client makes too many data |
| 279 // streams available. The server accepts slightly more than the negotiated | 279 // streams available. The server accepts slightly more than the negotiated |
| 280 // stream limit to deal with rare cases where a client FIN/RST is lost. | 280 // stream limit to deal with rare cases where a client FIN/RST is lost. |
| 281 | 281 |
| 282 // The slightly increased stream limit is set during config negotiation. | 282 // The slightly increased stream limit is set during config negotiation. |
| 283 EXPECT_EQ(kMaxStreamsForTest, session_->get_max_open_streams()); | 283 EXPECT_EQ(kMaxStreamsForTest, session_->max_open_incoming_streams()); |
| 284 session_->OnConfigNegotiated(); | 284 session_->OnConfigNegotiated(); |
| 285 const size_t kAvailableStreamLimit = session_->get_max_available_streams(); | 285 const size_t kAvailableStreamLimit = session_->MaxAvailableStreams(); |
| 286 EXPECT_EQ(session_->get_max_open_streams() * kMaxAvailableStreamsMultiplier, | 286 EXPECT_EQ( |
| 287 session_->get_max_available_streams()); | 287 session_->max_open_incoming_streams() * kMaxAvailableStreamsMultiplier, |
| 288 session_->MaxAvailableStreams()); |
| 288 // The protocol specification requires that there can be at least 10 times | 289 // The protocol specification requires that there can be at least 10 times |
| 289 // as many available streams as the connection's maximum open streams. | 290 // as many available streams as the connection's maximum open streams. |
| 290 EXPECT_LE(10 * kMaxStreamsForTest, kAvailableStreamLimit); | 291 EXPECT_LE(10 * kMaxStreamsForTest, kAvailableStreamLimit); |
| 291 | 292 |
| 292 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 293 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
| 293 EXPECT_TRUE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( | 294 EXPECT_TRUE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( |
| 294 session_.get(), kClientDataStreamId1)); | 295 session_.get(), kClientDataStreamId1)); |
| 295 | 296 |
| 296 // Establish available streams up to the server's limit. | 297 // Establish available streams up to the server's limit. |
| 297 const int kLimitingStreamId = | 298 const int kLimitingStreamId = |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 EXPECT_FALSE( | 529 EXPECT_FALSE( |
| 529 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); | 530 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); |
| 530 session_->OnConfigNegotiated(); | 531 session_->OnConfigNegotiated(); |
| 531 EXPECT_FALSE( | 532 EXPECT_FALSE( |
| 532 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); | 533 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); |
| 533 } | 534 } |
| 534 | 535 |
| 535 } // namespace | 536 } // namespace |
| 536 } // namespace test | 537 } // namespace test |
| 537 } // namespace net | 538 } // namespace net |
| OLD | NEW |