Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: net/quic/quic_server_session_base_test.cc

Issue 2101353003: Add a new kMIDS (Max Incoming Dynamic Streams) config option, to eventually replace kMSPC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_protocol.cc ('k') | net/quic/quic_session.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/quic/quic_server_session_base.h" 5 #include "net/quic/quic_server_session_base.h"
6 6
7 #include <cstdint> 7 #include <cstdint>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 class QuicServerSessionBaseTest : public ::testing::TestWithParam<QuicVersion> { 124 class QuicServerSessionBaseTest : public ::testing::TestWithParam<QuicVersion> {
125 protected: 125 protected:
126 QuicServerSessionBaseTest() 126 QuicServerSessionBaseTest()
127 : crypto_config_(QuicCryptoServerConfig::TESTING, 127 : crypto_config_(QuicCryptoServerConfig::TESTING,
128 QuicRandom::GetInstance(), 128 QuicRandom::GetInstance(),
129 CryptoTestUtils::ProofSourceForTesting()), 129 CryptoTestUtils::ProofSourceForTesting()),
130 compressed_certs_cache_( 130 compressed_certs_cache_(
131 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize) { 131 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize) {
132 FLAGS_quic_always_log_bugs_for_tests = true; 132 FLAGS_quic_always_log_bugs_for_tests = true;
133 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest); 133 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest);
134 config_.SetMaxIncomingDynamicStreamsToSend(kMaxStreamsForTest);
135 QuicConfigPeer::SetReceivedMaxIncomingDynamicStreams(&config_,
136 kMaxStreamsForTest);
134 config_.SetInitialStreamFlowControlWindowToSend( 137 config_.SetInitialStreamFlowControlWindowToSend(
135 kInitialStreamFlowControlWindowForTest); 138 kInitialStreamFlowControlWindowForTest);
136 config_.SetInitialSessionFlowControlWindowToSend( 139 config_.SetInitialSessionFlowControlWindowToSend(
137 kInitialSessionFlowControlWindowForTest); 140 kInitialSessionFlowControlWindowForTest);
138 141
139 connection_ = new StrictMock<MockQuicConnection>( 142 connection_ = new StrictMock<MockQuicConnection>(
140 &helper_, &alarm_factory_, Perspective::IS_SERVER, 143 &helper_, &alarm_factory_, Perspective::IS_SERVER,
141 SupportedVersions(GetParam())); 144 SupportedVersions(GetParam()));
142 session_.reset(new TestServerSession(config_, connection_, &owner_, 145 session_.reset(new TestServerSession(config_, connection_, &owner_,
143 &session_helper_, &crypto_config_, 146 &session_helper_, &crypto_config_,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // The stream should never be opened, now that the reset is received. 263 // The stream should never be opened, now that the reset is received.
261 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); 264 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams());
262 EXPECT_TRUE(connection_->connected()); 265 EXPECT_TRUE(connection_->connected());
263 } 266 }
264 267
265 TEST_P(QuicServerSessionBaseTest, MaxOpenStreams) { 268 TEST_P(QuicServerSessionBaseTest, MaxOpenStreams) {
266 // Test that the server refuses if a client attempts to open too many data 269 // Test that the server refuses if a client attempts to open too many data
267 // streams. The server accepts slightly more than the negotiated stream limit 270 // streams. The server accepts slightly more than the negotiated stream limit
268 // to deal with rare cases where a client FIN/RST is lost. 271 // to deal with rare cases where a client FIN/RST is lost.
269 272
273 if (GetParam() <= QUIC_VERSION_34) {
274 EXPECT_EQ(kMaxStreamsForTest, session_->max_open_incoming_streams());
275 }
276
270 // The slightly increased stream limit is set during config negotiation. It 277 // The slightly increased stream limit is set during config negotiation. It
271 // is either an increase of 10 over negotiated limit, or a fixed percentage 278 // is either an increase of 10 over negotiated limit, or a fixed percentage
272 // scaling, whichever is larger. Test both before continuing. 279 // scaling, whichever is larger. Test both before continuing.
273 EXPECT_EQ(kMaxStreamsForTest, session_->max_open_incoming_streams());
274 session_->OnConfigNegotiated(); 280 session_->OnConfigNegotiated();
275 EXPECT_LT(kMaxStreamsMultiplier * kMaxStreamsForTest, 281 EXPECT_LT(kMaxStreamsMultiplier * kMaxStreamsForTest,
276 kMaxStreamsForTest + kMaxStreamsMinimumIncrement); 282 kMaxStreamsForTest + kMaxStreamsMinimumIncrement);
277 EXPECT_EQ(kMaxStreamsForTest + kMaxStreamsMinimumIncrement, 283 EXPECT_EQ(kMaxStreamsForTest + kMaxStreamsMinimumIncrement,
278 session_->max_open_incoming_streams()); 284 session_->max_open_incoming_streams());
279 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); 285 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams());
280 QuicStreamId stream_id = kClientDataStreamId1; 286 QuicStreamId stream_id = kClientDataStreamId1;
281 // Open the max configured number of streams, should be no problem. 287 // Open the max configured number of streams, should be no problem.
282 for (size_t i = 0; i < kMaxStreamsForTest; ++i) { 288 for (size_t i = 0; i < kMaxStreamsForTest; ++i) {
283 EXPECT_TRUE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( 289 EXPECT_TRUE(QuicServerSessionBasePeer::GetOrCreateDynamicStream(
(...skipping 21 matching lines...) Expand all
305 // Even if the connection remains open, the stream creation should fail. 311 // Even if the connection remains open, the stream creation should fail.
306 EXPECT_FALSE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( 312 EXPECT_FALSE(QuicServerSessionBasePeer::GetOrCreateDynamicStream(
307 session_.get(), stream_id)); 313 session_.get(), stream_id));
308 } 314 }
309 315
310 TEST_P(QuicServerSessionBaseTest, MaxAvailableStreams) { 316 TEST_P(QuicServerSessionBaseTest, MaxAvailableStreams) {
311 // Test that the server closes the connection if a client makes too many data 317 // Test that the server closes the connection if a client makes too many data
312 // streams available. The server accepts slightly more than the negotiated 318 // streams available. The server accepts slightly more than the negotiated
313 // stream limit to deal with rare cases where a client FIN/RST is lost. 319 // stream limit to deal with rare cases where a client FIN/RST is lost.
314 320
315 // The slightly increased stream limit is set during config negotiation. 321 if (GetParam() <= QUIC_VERSION_34) {
316 EXPECT_EQ(kMaxStreamsForTest, session_->max_open_incoming_streams()); 322 // The slightly increased stream limit is set during config negotiation.
323 EXPECT_EQ(kMaxStreamsForTest, session_->max_open_incoming_streams());
324 }
317 session_->OnConfigNegotiated(); 325 session_->OnConfigNegotiated();
318 const size_t kAvailableStreamLimit = session_->MaxAvailableStreams(); 326 const size_t kAvailableStreamLimit = session_->MaxAvailableStreams();
319 EXPECT_EQ( 327 EXPECT_EQ(
320 session_->max_open_incoming_streams() * kMaxAvailableStreamsMultiplier, 328 session_->max_open_incoming_streams() * kMaxAvailableStreamsMultiplier,
321 session_->MaxAvailableStreams()); 329 session_->MaxAvailableStreams());
322 // The protocol specification requires that there can be at least 10 times 330 // The protocol specification requires that there can be at least 10 times
323 // as many available streams as the connection's maximum open streams. 331 // as many available streams as the connection's maximum open streams.
324 EXPECT_LE(10 * kMaxStreamsForTest, kAvailableStreamLimit); 332 EXPECT_LE(10 * kMaxStreamsForTest, kAvailableStreamLimit);
325 333
326 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); 334 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams());
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 EXPECT_FALSE( 564 EXPECT_FALSE(
557 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); 565 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get()));
558 session_->OnConfigNegotiated(); 566 session_->OnConfigNegotiated();
559 EXPECT_FALSE( 567 EXPECT_FALSE(
560 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); 568 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get()));
561 } 569 }
562 570
563 } // namespace 571 } // namespace
564 } // namespace test 572 } // namespace test
565 } // namespace net 573 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_protocol.cc ('k') | net/quic/quic_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698