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

Side by Side Diff: net/tools/quic/quic_server_session_test.cc

Issue 557363003: Allow number of open QUIC streams to grow 10% beyond configured limit at (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@change_initial_RTT_estimate_75389539
Patch Set: Created 6 years, 3 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/tools/quic/quic_server_session.cc ('k') | no next file » | 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/tools/quic/quic_server_session.h" 5 #include "net/tools/quic/quic_server_session.h"
6 6
7 #include "net/quic/crypto/quic_crypto_server_config.h" 7 #include "net/quic/crypto/quic_crypto_server_config.h"
8 #include "net/quic/crypto/quic_random.h" 8 #include "net/quic/crypto/quic_random.h"
9 #include "net/quic/crypto/source_address_token.h" 9 #include "net/quic/crypto/source_address_token.h"
10 #include "net/quic/quic_connection.h" 10 #include "net/quic/quic_connection.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 return s->GetDataStream(id); 54 return s->GetDataStream(id);
55 } 55 }
56 static void SetCryptoStream(QuicServerSession* s, 56 static void SetCryptoStream(QuicServerSession* s,
57 QuicCryptoServerStream* crypto_stream) { 57 QuicCryptoServerStream* crypto_stream) {
58 s->crypto_stream_.reset(crypto_stream); 58 s->crypto_stream_.reset(crypto_stream);
59 } 59 }
60 }; 60 };
61 61
62 namespace { 62 namespace {
63 63
64 const size_t kMaxStreamsForTest = 10;
65
64 class QuicServerSessionTest : public ::testing::TestWithParam<QuicVersion> { 66 class QuicServerSessionTest : public ::testing::TestWithParam<QuicVersion> {
65 protected: 67 protected:
66 QuicServerSessionTest() 68 QuicServerSessionTest()
67 : crypto_config_(QuicCryptoServerConfig::TESTING, 69 : crypto_config_(QuicCryptoServerConfig::TESTING,
68 QuicRandom::GetInstance()) { 70 QuicRandom::GetInstance()) {
69 config_.SetDefaults(); 71 config_.SetDefaults();
70 config_.set_max_streams_per_connection(3, 3); 72 config_.set_max_streams_per_connection(kMaxStreamsForTest,
73 kMaxStreamsForTest);
71 config_.SetInitialFlowControlWindowToSend( 74 config_.SetInitialFlowControlWindowToSend(
72 kInitialSessionFlowControlWindowForTest); 75 kInitialSessionFlowControlWindowForTest);
73 config_.SetInitialStreamFlowControlWindowToSend( 76 config_.SetInitialStreamFlowControlWindowToSend(
74 kInitialStreamFlowControlWindowForTest); 77 kInitialStreamFlowControlWindowForTest);
75 config_.SetInitialSessionFlowControlWindowToSend( 78 config_.SetInitialSessionFlowControlWindowToSend(
76 kInitialSessionFlowControlWindowForTest); 79 kInitialSessionFlowControlWindowForTest);
77 80
78 connection_ = 81 connection_ =
79 new StrictMock<MockConnection>(true, SupportedVersions(GetParam())); 82 new StrictMock<MockConnection>(true, SupportedVersions(GetParam()));
80 session_.reset(new QuicServerSession(config_, connection_, &owner_)); 83 session_.reset(new QuicServerSession(config_, connection_, &owner_));
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 frames.push_back( 185 frames.push_back(
183 QuicStreamFrame(kClientDataStreamId1, false, 2, MakeIOVector("TP"))); 186 QuicStreamFrame(kClientDataStreamId1, false, 2, MakeIOVector("TP")));
184 frames.push_back( 187 frames.push_back(
185 QuicStreamFrame(kClientDataStreamId2, false, 2, MakeIOVector("TP"))); 188 QuicStreamFrame(kClientDataStreamId2, false, 2, MakeIOVector("TP")));
186 visitor_->OnStreamFrames(frames); 189 visitor_->OnStreamFrames(frames);
187 // The stream should never be opened, now that the reset is received. 190 // The stream should never be opened, now that the reset is received.
188 EXPECT_EQ(1u, session_->GetNumOpenStreams()); 191 EXPECT_EQ(1u, session_->GetNumOpenStreams());
189 EXPECT_TRUE(connection_->connected()); 192 EXPECT_TRUE(connection_->connected());
190 } 193 }
191 194
192 TEST_P(QuicServerSessionTest, MaxNumConnections) { 195 TEST_P(QuicServerSessionTest, MaxOpenStreams) {
196 ValueRestore<bool> old_flag(&FLAGS_quic_allow_more_open_streams, true);
197 // Test that the server closes the connection if a client attempts to open too
198 // many data streams. The server accepts slightly more than the negotiated
199 // stream limit to deal with rare cases where a client FIN/RST is lost.
200
201 // The slightly increased stream limit is set during config negotiation.
202 EXPECT_EQ(kMaxStreamsForTest, session_->get_max_open_streams());
203 session_->OnConfigNegotiated();
204 EXPECT_EQ(kMaxStreamsMultiplier * kMaxStreamsForTest,
205 session_->get_max_open_streams());
206
207 EXPECT_EQ(0u, session_->GetNumOpenStreams());
208 QuicStreamId stream_id = kClientDataStreamId1;
209 // Open the max configured number of streams, should be no problem.
210 for (size_t i = 0; i < kMaxStreamsForTest; ++i) {
211 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream(session_.get(),
212 stream_id));
213 stream_id += 2;
214 }
215
216 // Open one more stream: server should accept slightly more than the
217 // configured limit.
218 EXPECT_TRUE(
219 QuicServerSessionPeer::GetIncomingDataStream(session_.get(), stream_id));
220
221 // Now violate the server's internal stream limit.
222 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS));
223 stream_id += 2;
224 EXPECT_FALSE(
225 QuicServerSessionPeer::GetIncomingDataStream(session_.get(), stream_id));
226 }
227
228 TEST_P(QuicServerSessionTest, MaxOpenStreamsImplicit) {
229 ValueRestore<bool> old_flag(&FLAGS_quic_allow_more_open_streams, true);
230 // Test that the server closes the connection if a client attempts to open too
231 // many data streams implicitly. The server accepts slightly more than the
232 // negotiated stream limit to deal with rare cases where a client FIN/RST is
233 // lost.
234
235 // The slightly increased stream limit is set during config negotiation.
236 EXPECT_EQ(kMaxStreamsForTest, session_->get_max_open_streams());
237 session_->OnConfigNegotiated();
238 EXPECT_EQ(kMaxStreamsMultiplier * kMaxStreamsForTest,
239 session_->get_max_open_streams());
240
193 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 241 EXPECT_EQ(0u, session_->GetNumOpenStreams());
194 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream( 242 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream(
195 session_.get(), kClientDataStreamId1)); 243 session_.get(), kClientDataStreamId1));
244 // Implicitly open streams up to the server's limit.
245 const int kActualMaxStreams = kMaxStreamsMultiplier * kMaxStreamsForTest;
246 const int kMaxValidStreamId =
247 kClientDataStreamId1 + (kActualMaxStreams - 1) * 2;
196 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream( 248 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream(
197 session_.get(), kClientDataStreamId2)); 249 session_.get(), kMaxValidStreamId));
198 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream( 250
199 session_.get(), kClientDataStreamId3)); 251 // Opening a further stream will result in connection close.
200 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS)); 252 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS));
201 EXPECT_FALSE(QuicServerSessionPeer::GetIncomingDataStream( 253 EXPECT_FALSE(QuicServerSessionPeer::GetIncomingDataStream(
202 session_.get(), kClientDataStreamId4)); 254 session_.get(), kMaxValidStreamId + 2));
203 }
204
205 TEST_P(QuicServerSessionTest, MaxNumConnectionsImplicit) {
206 EXPECT_EQ(0u, session_->GetNumOpenStreams());
207 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream(
208 session_.get(), kClientDataStreamId1));
209 // Implicitly opens two more streams.
210 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS));
211 EXPECT_FALSE(QuicServerSessionPeer::GetIncomingDataStream(
212 session_.get(), kClientDataStreamId4));
213 } 255 }
214 256
215 TEST_P(QuicServerSessionTest, GetEvenIncomingError) { 257 TEST_P(QuicServerSessionTest, GetEvenIncomingError) {
216 // Incoming streams on the server session must be odd. 258 // Incoming streams on the server session must be odd.
217 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID)); 259 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID));
218 EXPECT_EQ(NULL, 260 EXPECT_EQ(NULL,
219 QuicServerSessionPeer::GetIncomingDataStream(session_.get(), 4)); 261 QuicServerSessionPeer::GetIncomingDataStream(session_.get(), 4));
220 } 262 }
221 263
222 TEST_P(QuicServerSessionTest, SetFecProtectionFromConfig) { 264 TEST_P(QuicServerSessionTest, SetFecProtectionFromConfig) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 EXPECT_CALL(*crypto_stream, 357 EXPECT_CALL(*crypto_stream,
316 SendServerConfigUpdate(EqualsProto(expected_network_params))) 358 SendServerConfigUpdate(EqualsProto(expected_network_params)))
317 .Times(1); 359 .Times(1);
318 session_->OnCongestionWindowChange(now); 360 session_->OnCongestionWindowChange(now);
319 } 361 }
320 362
321 } // namespace 363 } // namespace
322 } // namespace test 364 } // namespace test
323 } // namespace tools 365 } // namespace tools
324 } // namespace net 366 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_server_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698