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

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

Issue 605163004: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0925
Patch Set: Created 6 years, 2 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_client_session_test.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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 namespace { 62 namespace {
63 63
64 const size_t kMaxStreamsForTest = 10; 64 const size_t kMaxStreamsForTest = 10;
65 65
66 class QuicServerSessionTest : public ::testing::TestWithParam<QuicVersion> { 66 class QuicServerSessionTest : public ::testing::TestWithParam<QuicVersion> {
67 protected: 67 protected:
68 QuicServerSessionTest() 68 QuicServerSessionTest()
69 : crypto_config_(QuicCryptoServerConfig::TESTING, 69 : crypto_config_(QuicCryptoServerConfig::TESTING,
70 QuicRandom::GetInstance()) { 70 QuicRandom::GetInstance()) {
71 config_.SetDefaults(); 71 config_.SetDefaults();
72 config_.set_max_streams_per_connection(kMaxStreamsForTest, 72 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest,
73 kMaxStreamsForTest); 73 kMaxStreamsForTest);
74 config_.SetInitialFlowControlWindowToSend( 74 config_.SetInitialFlowControlWindowToSend(
75 kInitialSessionFlowControlWindowForTest); 75 kInitialSessionFlowControlWindowForTest);
76 config_.SetInitialStreamFlowControlWindowToSend( 76 config_.SetInitialStreamFlowControlWindowToSend(
77 kInitialStreamFlowControlWindowForTest); 77 kInitialStreamFlowControlWindowForTest);
78 config_.SetInitialSessionFlowControlWindowToSend( 78 config_.SetInitialSessionFlowControlWindowToSend(
79 kInitialSessionFlowControlWindowForTest); 79 kInitialSessionFlowControlWindowForTest);
80 80
81 connection_ = 81 connection_ =
82 new StrictMock<MockConnection>(true, SupportedVersions(GetParam())); 82 new StrictMock<MockConnection>(true, SupportedVersions(GetParam()));
83 session_.reset(new QuicServerSession(config_, connection_, &owner_)); 83 session_.reset(new QuicServerSession(config_, connection_, &owner_));
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 EXPECT_EQ(1u, session_->GetNumOpenStreams()); 191 EXPECT_EQ(1u, session_->GetNumOpenStreams());
192 EXPECT_TRUE(connection_->connected()); 192 EXPECT_TRUE(connection_->connected());
193 } 193 }
194 194
195 TEST_P(QuicServerSessionTest, MaxOpenStreams) { 195 TEST_P(QuicServerSessionTest, MaxOpenStreams) {
196 ValueRestore<bool> old_flag(&FLAGS_quic_allow_more_open_streams, true); 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 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 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. 199 // stream limit to deal with rare cases where a client FIN/RST is lost.
200 200
201 // The slightly increased stream limit is set during config negotiation. 201 // The slightly increased stream limit is set during config negotiation. It
202 // should be either an increase of 10 over negotiated limit, or a fixed
203 // percentage scaling, whichever is larger. Test both before continuing.
202 EXPECT_EQ(kMaxStreamsForTest, session_->get_max_open_streams()); 204 EXPECT_EQ(kMaxStreamsForTest, session_->get_max_open_streams());
203 session_->OnConfigNegotiated(); 205 session_->OnConfigNegotiated();
204 EXPECT_EQ(kMaxStreamsMultiplier * kMaxStreamsForTest, 206 EXPECT_LT(kMaxStreamsMultiplier * kMaxStreamsForTest,
207 kMaxStreamsForTest + kMaxStreamsMinimumIncrement);
208 EXPECT_EQ(kMaxStreamsForTest + kMaxStreamsMinimumIncrement,
205 session_->get_max_open_streams()); 209 session_->get_max_open_streams());
206
207 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 210 EXPECT_EQ(0u, session_->GetNumOpenStreams());
208 QuicStreamId stream_id = kClientDataStreamId1; 211 QuicStreamId stream_id = kClientDataStreamId1;
209 // Open the max configured number of streams, should be no problem. 212 // Open the max configured number of streams, should be no problem.
210 for (size_t i = 0; i < kMaxStreamsForTest; ++i) { 213 for (size_t i = 0; i < kMaxStreamsForTest; ++i) {
211 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream(session_.get(), 214 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream(session_.get(),
212 stream_id)); 215 stream_id));
213 stream_id += 2; 216 stream_id += 2;
214 } 217 }
215 218
216 // Open one more stream: server should accept slightly more than the 219 // Open more streams: server should accept slightly more than the limit.
217 // configured limit. 220 for (size_t i = 0; i < kMaxStreamsMinimumIncrement; ++i) {
218 EXPECT_TRUE( 221 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream(session_.get(),
219 QuicServerSessionPeer::GetIncomingDataStream(session_.get(), stream_id)); 222 stream_id));
223 stream_id += 2;
224 }
220 225
221 // Now violate the server's internal stream limit. 226 // Now violate the server's internal stream limit.
222 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS)); 227 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS));
223 stream_id += 2; 228 stream_id += 2;
224 EXPECT_FALSE( 229 EXPECT_FALSE(
225 QuicServerSessionPeer::GetIncomingDataStream(session_.get(), stream_id)); 230 QuicServerSessionPeer::GetIncomingDataStream(session_.get(), stream_id));
226 } 231 }
227 232
228 TEST_P(QuicServerSessionTest, MaxOpenStreamsImplicit) { 233 TEST_P(QuicServerSessionTest, MaxOpenStreamsImplicit) {
229 ValueRestore<bool> old_flag(&FLAGS_quic_allow_more_open_streams, true); 234 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 235 // 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 236 // 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 237 // negotiated stream limit to deal with rare cases where a client FIN/RST is
233 // lost. 238 // lost.
234 239
235 // The slightly increased stream limit is set during config negotiation. 240 // The slightly increased stream limit is set during config negotiation.
236 EXPECT_EQ(kMaxStreamsForTest, session_->get_max_open_streams()); 241 EXPECT_EQ(kMaxStreamsForTest, session_->get_max_open_streams());
237 session_->OnConfigNegotiated(); 242 session_->OnConfigNegotiated();
238 EXPECT_EQ(kMaxStreamsMultiplier * kMaxStreamsForTest, 243 EXPECT_LT(kMaxStreamsMultiplier * kMaxStreamsForTest,
244 kMaxStreamsForTest + kMaxStreamsMinimumIncrement);
245 EXPECT_EQ(kMaxStreamsForTest + kMaxStreamsMinimumIncrement,
239 session_->get_max_open_streams()); 246 session_->get_max_open_streams());
240 247
241 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 248 EXPECT_EQ(0u, session_->GetNumOpenStreams());
242 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream( 249 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream(
243 session_.get(), kClientDataStreamId1)); 250 session_.get(), kClientDataStreamId1));
244 // Implicitly open streams up to the server's limit. 251 // Implicitly open streams up to the server's limit.
245 const int kActualMaxStreams = kMaxStreamsMultiplier * kMaxStreamsForTest; 252 const int kActualMaxStreams =
253 kMaxStreamsForTest + kMaxStreamsMinimumIncrement;
246 const int kMaxValidStreamId = 254 const int kMaxValidStreamId =
247 kClientDataStreamId1 + (kActualMaxStreams - 1) * 2; 255 kClientDataStreamId1 + (kActualMaxStreams - 1) * 2;
248 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream( 256 EXPECT_TRUE(QuicServerSessionPeer::GetIncomingDataStream(
249 session_.get(), kMaxValidStreamId)); 257 session_.get(), kMaxValidStreamId));
250 258
251 // Opening a further stream will result in connection close. 259 // Opening a further stream will result in connection close.
252 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS)); 260 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS));
253 EXPECT_FALSE(QuicServerSessionPeer::GetIncomingDataStream( 261 EXPECT_FALSE(QuicServerSessionPeer::GetIncomingDataStream(
254 session_.get(), kMaxValidStreamId + 2)); 262 session_.get(), kMaxValidStreamId + 2));
255 } 263 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 EXPECT_CALL(*crypto_stream, 367 EXPECT_CALL(*crypto_stream,
360 SendServerConfigUpdate(EqualsProto(expected_network_params))) 368 SendServerConfigUpdate(EqualsProto(expected_network_params)))
361 .Times(1); 369 .Times(1);
362 session_->OnCongestionWindowChange(now); 370 session_->OnCongestionWindowChange(now);
363 } 371 }
364 372
365 } // namespace 373 } // namespace
366 } // namespace test 374 } // namespace test
367 } // namespace tools 375 } // namespace tools
368 } // namespace net 376 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_client_session_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698