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

Side by Side Diff: net/quic/core/quic_session_test.cc

Issue 2856243003: Revert of Landing Recent QUIC changes until Sat Apr 29 00:22:04 2017 +0000 (Closed)
Patch Set: Created 3 years, 7 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/core/quic_session.cc ('k') | net/quic/core/quic_spdy_session.h » ('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 (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 "net/quic/core/quic_session.h" 5 #include "net/quic/core/quic_session.h"
6 6
7 #include <cstdint> 7 #include <cstdint>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 session()->config()->ToHandshakeMessage(&msg); 65 session()->config()->ToHandshakeMessage(&msg);
66 const QuicErrorCode error = 66 const QuicErrorCode error =
67 session()->config()->ProcessPeerHello(msg, CLIENT, &error_details); 67 session()->config()->ProcessPeerHello(msg, CLIENT, &error_details);
68 EXPECT_EQ(QUIC_NO_ERROR, error); 68 EXPECT_EQ(QUIC_NO_ERROR, error);
69 session()->OnConfigNegotiated(); 69 session()->OnConfigNegotiated();
70 session()->connection()->SetDefaultEncryptionLevel( 70 session()->connection()->SetDefaultEncryptionLevel(
71 ENCRYPTION_FORWARD_SECURE); 71 ENCRYPTION_FORWARD_SECURE);
72 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); 72 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED);
73 } 73 }
74 74
75 void set_encryption_established(bool value) {
76 encryption_established_ = value;
77 }
78
79 MOCK_METHOD0(OnCanWrite, void()); 75 MOCK_METHOD0(OnCanWrite, void());
80 }; 76 };
81 77
82 class TestHeadersStream : public QuicHeadersStream { 78 class TestHeadersStream : public QuicHeadersStream {
83 public: 79 public:
84 explicit TestHeadersStream(QuicSpdySession* session) 80 explicit TestHeadersStream(QuicSpdySession* session)
85 : QuicHeadersStream(session) {} 81 : QuicHeadersStream(session) {}
86 82
87 MOCK_METHOD0(OnCanWrite, void()); 83 MOCK_METHOD0(OnCanWrite, void());
88 }; 84 };
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 return stream; 152 return stream;
157 } 153 }
158 } 154 }
159 155
160 bool ShouldCreateIncomingDynamicStream(QuicStreamId /*id*/) override { 156 bool ShouldCreateIncomingDynamicStream(QuicStreamId /*id*/) override {
161 return true; 157 return true;
162 } 158 }
163 159
164 bool ShouldCreateOutgoingDynamicStream() override { return true; } 160 bool ShouldCreateOutgoingDynamicStream() override { return true; }
165 161
166 TestStream* MaybeCreateOutgoingDynamicStream(SpdyPriority priority) override {
167 return static_cast<TestStream*>(
168 QuicSpdySession::MaybeCreateOutgoingDynamicStream(priority));
169 }
170
171 std::unique_ptr<QuicStream> CreateStream(QuicStreamId id) override {
172 return QuicMakeUnique<TestStream>(id, this);
173 }
174
175 bool IsClosedStream(QuicStreamId id) { 162 bool IsClosedStream(QuicStreamId id) {
176 return QuicSession::IsClosedStream(id); 163 return QuicSession::IsClosedStream(id);
177 } 164 }
178 165
179 QuicStream* GetOrCreateDynamicStream(QuicStreamId stream_id) { 166 QuicStream* GetOrCreateDynamicStream(QuicStreamId stream_id) {
180 return QuicSpdySession::GetOrCreateDynamicStream(stream_id); 167 return QuicSpdySession::GetOrCreateDynamicStream(stream_id);
181 } 168 }
182 169
183 QuicConsumedData WritevData( 170 QuicConsumedData WritevData(
184 QuicStream* stream, 171 QuicStream* stream,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 "3Rs1UKCuBAF9g8rWNOFbxt8PSNSHFuIhOo2t6bJAVpCsMU5Laa6lewuTMYI8MzdQP" 256 "3Rs1UKCuBAF9g8rWNOFbxt8PSNSHFuIhOo2t6bJAVpCsMU5Laa6lewuTMYI8MzdQP"
270 "ARHKyW-koxuhMZHUnGBJAM1gJODe0cATO_KGoX4pbbFxxJ5IicRxOrWK_5rU3cdy6" 257 "ARHKyW-koxuhMZHUnGBJAM1gJODe0cATO_KGoX4pbbFxxJ5IicRxOrWK_5rU3cdy6"
271 "edlR9FsEdH6iujMcHkbE5l18ehJDwTWmBKBzVD87naobhMMrF6VvnDGxQVGp9Ir_b" 258 "edlR9FsEdH6iujMcHkbE5l18ehJDwTWmBKBzVD87naobhMMrF6VvnDGxQVGp9Ir_b"
272 "Rgj3RWUoPumQVCxtSOBdX0GlJOEcDTNCzQIm9BSfetog_eP_TfYubKudt5eMsXmN6" 259 "Rgj3RWUoPumQVCxtSOBdX0GlJOEcDTNCzQIm9BSfetog_eP_TfYubKudt5eMsXmN6"
273 "QnyXHeGeK2UINUzJ-D30AFcpqYgH9_1BvYSpi7fc7_ydBU8TaD8ZRxvtnzXqj0RfG" 260 "QnyXHeGeK2UINUzJ-D30AFcpqYgH9_1BvYSpi7fc7_ydBU8TaD8ZRxvtnzXqj0RfG"
274 "tuHghmv3aD-uzSYJ75XDdzKdizZ86IG6Fbn1XFhYZM-fbHhm3mVEXnyRW4ZuNOLFk" 261 "tuHghmv3aD-uzSYJ75XDdzKdizZ86IG6Fbn1XFhYZM-fbHhm3mVEXnyRW4ZuNOLFk"
275 "Fas6LMcVC6Q8QLlHYbXBpdNFuGbuZGUnav5C-2I_-46lL0NGg3GewxGKGHvHEfoyn" 262 "Fas6LMcVC6Q8QLlHYbXBpdNFuGbuZGUnav5C-2I_-46lL0NGg3GewxGKGHvHEfoyn"
276 "EFFlEYHsBQ98rXImL8ySDycdLEFvBPdtctPmWCfTxwmoSMLHU2SCVDhbqMWU5b0yr" 263 "EFFlEYHsBQ98rXImL8ySDycdLEFvBPdtctPmWCfTxwmoSMLHU2SCVDhbqMWU5b0yr"
277 "JBCScs_ejbKaqBDoB7ZGxTvqlrB__2ZmnHHjCr8RgMRtKNtIeuZAo "; 264 "JBCScs_ejbKaqBDoB7ZGxTvqlrB__2ZmnHHjCr8RgMRtKNtIeuZAo ";
278 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); 265 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1));
279 if (FLAGS_quic_reloadable_flag_quic_refactor_stream_creation) {
280 session_.GetMutableCryptoStream()->set_encryption_established(true);
281 }
282 } 266 }
283 267
284 void CheckClosedStreams() { 268 void CheckClosedStreams() {
285 for (QuicStreamId i = kCryptoStreamId; i < 100; i++) { 269 for (QuicStreamId i = kCryptoStreamId; i < 100; i++) {
286 if (!QuicContainsKey(closed_streams_, i)) { 270 if (!QuicContainsKey(closed_streams_, i)) {
287 EXPECT_FALSE(session_.IsClosedStream(i)) << " stream id: " << i; 271 EXPECT_FALSE(session_.IsClosedStream(i)) << " stream id: " << i;
288 } else { 272 } else {
289 EXPECT_TRUE(session_.IsClosedStream(i)) << " stream id: " << i; 273 EXPECT_TRUE(session_.IsClosedStream(i)) << " stream id: " << i;
290 } 274 }
291 } 275 }
292 } 276 }
293 277
294 void CloseStream(QuicStreamId id) { 278 void CloseStream(QuicStreamId id) {
295 EXPECT_CALL(*connection_, SendRstStream(id, _, _)); 279 EXPECT_CALL(*connection_, SendRstStream(id, _, _));
296 session_.CloseStream(id); 280 session_.CloseStream(id);
297 closed_streams_.insert(id); 281 closed_streams_.insert(id);
298 } 282 }
299 283
300 QuicVersion version() const { return connection_->version(); } 284 QuicVersion version() const { return connection_->version(); }
301 285
302 QuicStreamId GetNthClientInitiatedId(int n) {
303 return QuicSpdySessionPeer::GetNthClientInitiatedStreamId(session_, n);
304 }
305
306 QuicStreamId GetNthServerInitiatedId(int n) {
307 return QuicSpdySessionPeer::GetNthServerInitiatedStreamId(session_, n);
308 }
309
310 QuicStreamId NextId() { return QuicSpdySessionPeer::NextStreamId(session_); }
311
312 MockQuicConnectionHelper helper_; 286 MockQuicConnectionHelper helper_;
313 MockAlarmFactory alarm_factory_; 287 MockAlarmFactory alarm_factory_;
314 StrictMock<MockQuicConnection>* connection_; 288 StrictMock<MockQuicConnection>* connection_;
315 TestSession session_; 289 TestSession session_;
316 std::set<QuicStreamId> closed_streams_; 290 std::set<QuicStreamId> closed_streams_;
317 SpdyHeaderBlock headers_; 291 SpdyHeaderBlock headers_;
318 }; 292 };
319 293
320 class QuicSessionTestServer : public QuicSessionTestBase { 294 class QuicSessionTestServer : public QuicSessionTestBase {
321 protected: 295 protected:
(...skipping 27 matching lines...) Expand all
349 ASSERT_TRUE(session_.GetOrCreateDynamicStream(9) != nullptr); 323 ASSERT_TRUE(session_.GetOrCreateDynamicStream(9) != nullptr);
350 // Both 5 and 7 should be available. 324 // Both 5 and 7 should be available.
351 EXPECT_TRUE(QuicSessionPeer::IsStreamAvailable(&session_, 5)); 325 EXPECT_TRUE(QuicSessionPeer::IsStreamAvailable(&session_, 5));
352 EXPECT_TRUE(QuicSessionPeer::IsStreamAvailable(&session_, 7)); 326 EXPECT_TRUE(QuicSessionPeer::IsStreamAvailable(&session_, 7));
353 ASSERT_TRUE(session_.GetOrCreateDynamicStream(7) != nullptr); 327 ASSERT_TRUE(session_.GetOrCreateDynamicStream(7) != nullptr);
354 ASSERT_TRUE(session_.GetOrCreateDynamicStream(5) != nullptr); 328 ASSERT_TRUE(session_.GetOrCreateDynamicStream(5) != nullptr);
355 } 329 }
356 330
357 TEST_P(QuicSessionTestServer, IsClosedStreamLocallyCreated) { 331 TEST_P(QuicSessionTestServer, IsClosedStreamLocallyCreated) {
358 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); 332 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
359 EXPECT_EQ(GetNthServerInitiatedId(0), stream2->id()); 333 EXPECT_EQ(2u, stream2->id());
360 QuicSpdyStream* stream4 = 334 TestStream* stream4 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
361 session_.CreateOutgoingDynamicStream(kDefaultPriority); 335 EXPECT_EQ(4u, stream4->id());
362 EXPECT_EQ(GetNthServerInitiatedId(1), stream4->id());
363 336
364 CheckClosedStreams(); 337 CheckClosedStreams();
365 CloseStream(GetNthServerInitiatedId(0)); 338 CloseStream(4);
366 CheckClosedStreams(); 339 CheckClosedStreams();
367 CloseStream(GetNthServerInitiatedId(1)); 340 CloseStream(2);
368 CheckClosedStreams(); 341 CheckClosedStreams();
369 } 342 }
370 343
371 TEST_P(QuicSessionTestServer, IsClosedStreamPeerCreated) { 344 TEST_P(QuicSessionTestServer, IsClosedStreamPeerCreated) {
372 QuicStreamId stream_id1 = GetNthClientInitiatedId(0); 345 QuicStreamId stream_id1 = kClientDataStreamId1;
373 QuicStreamId stream_id2 = GetNthClientInitiatedId(1); 346 QuicStreamId stream_id2 = kClientDataStreamId2;
374 session_.GetOrCreateDynamicStream(stream_id1); 347 session_.GetOrCreateDynamicStream(stream_id1);
375 session_.GetOrCreateDynamicStream(stream_id2); 348 session_.GetOrCreateDynamicStream(stream_id2);
376 349
377 CheckClosedStreams(); 350 CheckClosedStreams();
378 CloseStream(stream_id1); 351 CloseStream(stream_id1);
379 CheckClosedStreams(); 352 CheckClosedStreams();
380 CloseStream(stream_id2); 353 CloseStream(stream_id2);
381 // Create a stream, and make another available. 354 // Create a stream, and make another available.
382 QuicStream* stream3 = session_.GetOrCreateDynamicStream(stream_id2 + 4); 355 QuicStream* stream3 = session_.GetOrCreateDynamicStream(stream_id2 + 4);
383 CheckClosedStreams(); 356 CheckClosedStreams();
384 // Close one, but make sure the other is still not closed 357 // Close one, but make sure the other is still not closed
385 CloseStream(stream3->id()); 358 CloseStream(stream3->id());
386 CheckClosedStreams(); 359 CheckClosedStreams();
387 } 360 }
388 361
389 TEST_P(QuicSessionTestServer, MaximumAvailableOpenedStreams) { 362 TEST_P(QuicSessionTestServer, MaximumAvailableOpenedStreams) {
390 QuicStreamId stream_id = GetNthClientInitiatedId(0); 363 QuicStreamId stream_id = kClientDataStreamId1;
391 session_.GetOrCreateDynamicStream(stream_id); 364 session_.GetOrCreateDynamicStream(stream_id);
392 EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0); 365 EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0);
393 EXPECT_NE(nullptr, 366 EXPECT_NE(nullptr,
394 session_.GetOrCreateDynamicStream( 367 session_.GetOrCreateDynamicStream(
395 stream_id + 2 * (session_.max_open_incoming_streams() - 1))); 368 stream_id + 2 * (session_.max_open_incoming_streams() - 1)));
396 } 369 }
397 370
398 TEST_P(QuicSessionTestServer, TooManyAvailableStreams) { 371 TEST_P(QuicSessionTestServer, TooManyAvailableStreams) {
399 QuicStreamId stream_id1 = GetNthClientInitiatedId(0); 372 QuicStreamId stream_id1 = kClientDataStreamId1;
400 QuicStreamId stream_id2; 373 QuicStreamId stream_id2;
401 EXPECT_NE(nullptr, session_.GetOrCreateDynamicStream(stream_id1)); 374 EXPECT_NE(nullptr, session_.GetOrCreateDynamicStream(stream_id1));
402 // A stream ID which is too large to create. 375 // A stream ID which is too large to create.
403 stream_id2 = GetNthClientInitiatedId(2 * session_.MaxAvailableStreams() + 4); 376 stream_id2 = stream_id1 + 2 * session_.MaxAvailableStreams() + 4;
404 EXPECT_CALL(*connection_, 377 EXPECT_CALL(*connection_,
405 CloseConnection(QUIC_TOO_MANY_AVAILABLE_STREAMS, _, _)); 378 CloseConnection(QUIC_TOO_MANY_AVAILABLE_STREAMS, _, _));
406 EXPECT_EQ(nullptr, session_.GetOrCreateDynamicStream(stream_id2)); 379 EXPECT_EQ(nullptr, session_.GetOrCreateDynamicStream(stream_id2));
407 } 380 }
408 381
409 TEST_P(QuicSessionTestServer, ManyAvailableStreams) { 382 TEST_P(QuicSessionTestServer, ManyAvailableStreams) {
410 // When max_open_streams_ is 200, should be able to create 200 streams 383 // When max_open_streams_ is 200, should be able to create 200 streams
411 // out-of-order, that is, creating the one with the largest stream ID first. 384 // out-of-order, that is, creating the one with the largest stream ID first.
412 QuicSessionPeer::SetMaxOpenIncomingStreams(&session_, 200); 385 QuicSessionPeer::SetMaxOpenIncomingStreams(&session_, 200);
413 QuicStreamId stream_id = GetNthClientInitiatedId(0); 386 QuicStreamId stream_id = kClientDataStreamId1;
414 // Create one stream. 387 // Create one stream.
415 session_.GetOrCreateDynamicStream(stream_id); 388 session_.GetOrCreateDynamicStream(stream_id);
416 EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0); 389 EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0);
417 // Create the largest stream ID of a threatened total of 200 streams. 390 // Create the largest stream ID of a threatened total of 200 streams.
418 session_.GetOrCreateDynamicStream(stream_id + 2 * (200 - 1)); 391 session_.GetOrCreateDynamicStream(stream_id + 2 * (200 - 1));
419 } 392 }
420 393
421 TEST_P(QuicSessionTestServer, DebugDFatalIfMarkingClosedStreamWriteBlocked) { 394 TEST_P(QuicSessionTestServer, DebugDFatalIfMarkingClosedStreamWriteBlocked) {
422 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); 395 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
423 QuicStreamId closed_stream_id = stream2->id(); 396 QuicStreamId closed_stream_id = stream2->id();
424 // Close the stream. 397 // Close the stream.
425 EXPECT_CALL(*connection_, SendRstStream(closed_stream_id, _, _)); 398 EXPECT_CALL(*connection_, SendRstStream(closed_stream_id, _, _));
426 stream2->Reset(QUIC_BAD_APPLICATION_PAYLOAD); 399 stream2->Reset(QUIC_BAD_APPLICATION_PAYLOAD);
427 string msg =
428 QuicStrCat("Marking unknown stream ", closed_stream_id, " blocked.");
429 EXPECT_QUIC_BUG(session_.MarkConnectionLevelWriteBlocked(closed_stream_id), 400 EXPECT_QUIC_BUG(session_.MarkConnectionLevelWriteBlocked(closed_stream_id),
430 msg); 401 "Marking unknown stream 2 blocked.");
431 } 402 }
432 403
433 TEST_P(QuicSessionTestServer, OnCanWrite) { 404 TEST_P(QuicSessionTestServer, OnCanWrite) {
434 session_.set_writev_consumes_all_data(true); 405 session_.set_writev_consumes_all_data(true);
435 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); 406 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
436 TestStream* stream4 = session_.CreateOutgoingDynamicStream(kDefaultPriority); 407 TestStream* stream4 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
437 TestStream* stream6 = session_.CreateOutgoingDynamicStream(kDefaultPriority); 408 TestStream* stream6 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
438 409
439 session_.MarkConnectionLevelWriteBlocked(stream2->id()); 410 session_.MarkConnectionLevelWriteBlocked(stream2->id());
440 session_.MarkConnectionLevelWriteBlocked(stream6->id()); 411 session_.MarkConnectionLevelWriteBlocked(stream6->id());
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 EXPECT_EQ(kInitialIdleTimeoutSecs + 3, 793 EXPECT_EQ(kInitialIdleTimeoutSecs + 3,
823 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds()); 794 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds());
824 CryptoHandshakeMessage msg; 795 CryptoHandshakeMessage msg;
825 session_.GetMutableCryptoStream()->OnHandshakeMessage(msg); 796 session_.GetMutableCryptoStream()->OnHandshakeMessage(msg);
826 EXPECT_EQ(kMaximumIdleTimeoutSecs + 3, 797 EXPECT_EQ(kMaximumIdleTimeoutSecs + 3,
827 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds()); 798 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds());
828 } 799 }
829 800
830 TEST_P(QuicSessionTestServer, RstStreamBeforeHeadersDecompressed) { 801 TEST_P(QuicSessionTestServer, RstStreamBeforeHeadersDecompressed) {
831 // Send two bytes of payload. 802 // Send two bytes of payload.
832 QuicStreamFrame data1(GetNthClientInitiatedId(0), false, 0, 803 QuicStreamFrame data1(kClientDataStreamId1, false, 0, QuicStringPiece("HT"));
833 QuicStringPiece("HT"));
834 session_.OnStreamFrame(data1); 804 session_.OnStreamFrame(data1);
835 EXPECT_EQ(1u, session_.GetNumOpenIncomingStreams()); 805 EXPECT_EQ(1u, session_.GetNumOpenIncomingStreams());
836 806
837 EXPECT_CALL(*connection_, SendRstStream(GetNthClientInitiatedId(0), _, _)); 807 EXPECT_CALL(*connection_, SendRstStream(kClientDataStreamId1, _, _));
838 QuicRstStreamFrame rst1(GetNthClientInitiatedId(0), 808 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM,
839 QUIC_ERROR_PROCESSING_STREAM, 0); 809 0);
840 session_.OnRstStream(rst1); 810 session_.OnRstStream(rst1);
841 EXPECT_EQ(0u, session_.GetNumOpenIncomingStreams()); 811 EXPECT_EQ(0u, session_.GetNumOpenIncomingStreams());
842 // Connection should remain alive. 812 // Connection should remain alive.
843 EXPECT_TRUE(connection_->connected()); 813 EXPECT_TRUE(connection_->connected());
844 } 814 }
845 815
846 TEST_P(QuicSessionTestServer, HandshakeUnblocksFlowControlBlockedStream) { 816 TEST_P(QuicSessionTestServer, HandshakeUnblocksFlowControlBlockedStream) {
847 // Test that if a stream is flow control blocked, then on receipt of the SHLO 817 // Test that if a stream is flow control blocked, then on receipt of the SHLO
848 // containing a suitable send window offset, the stream becomes unblocked. 818 // containing a suitable send window offset, the stream becomes unblocked.
849 819
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 EXPECT_FALSE(headers_stream->flow_controller()->IsBlocked()); 1148 EXPECT_FALSE(headers_stream->flow_controller()->IsBlocked());
1179 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); 1149 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
1180 EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); 1150 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
1181 } 1151 }
1182 1152
1183 TEST_P(QuicSessionTestServer, TooManyUnfinishedStreamsCauseServerRejectStream) { 1153 TEST_P(QuicSessionTestServer, TooManyUnfinishedStreamsCauseServerRejectStream) {
1184 // If a buggy/malicious peer creates too many streams that are not ended 1154 // If a buggy/malicious peer creates too many streams that are not ended
1185 // with a FIN or RST then we send an RST to refuse streams. 1155 // with a FIN or RST then we send an RST to refuse streams.
1186 const QuicStreamId kMaxStreams = 5; 1156 const QuicStreamId kMaxStreams = 5;
1187 QuicSessionPeer::SetMaxOpenIncomingStreams(&session_, kMaxStreams); 1157 QuicSessionPeer::SetMaxOpenIncomingStreams(&session_, kMaxStreams);
1188 const QuicStreamId kFirstStreamId = GetNthClientInitiatedId(0); 1158 const QuicStreamId kFirstStreamId = kClientDataStreamId1;
1189 const QuicStreamId kFinalStreamId = GetNthClientInitiatedId(kMaxStreams); 1159 const QuicStreamId kFinalStreamId = kClientDataStreamId1 + 2 * kMaxStreams;
1160
1190 // Create kMaxStreams data streams, and close them all without receiving a 1161 // Create kMaxStreams data streams, and close them all without receiving a
1191 // FIN or a RST_STREAM from the client. 1162 // FIN or a RST_STREAM from the client.
1192 const QuicStreamId kNextId = QuicSpdySessionPeer::NextStreamId(session_); 1163 for (QuicStreamId i = kFirstStreamId; i < kFinalStreamId; i += 2) {
1193 for (QuicStreamId i = kFirstStreamId; i < kFinalStreamId; i += kNextId) {
1194 QuicStreamFrame data1(i, false, 0, QuicStringPiece("HT")); 1164 QuicStreamFrame data1(i, false, 0, QuicStringPiece("HT"));
1195 session_.OnStreamFrame(data1); 1165 session_.OnStreamFrame(data1);
1196 // EXPECT_EQ(1u, session_.GetNumOpenStreams()); 1166 // EXPECT_EQ(1u, session_.GetNumOpenStreams());
1197 EXPECT_CALL(*connection_, SendRstStream(i, _, _)); 1167 EXPECT_CALL(*connection_, SendRstStream(i, _, _));
1198 session_.CloseStream(i); 1168 session_.CloseStream(i);
1199 } 1169 }
1200 1170
1201 EXPECT_CALL(*connection_, 1171 EXPECT_CALL(*connection_,
1202 SendRstStream(kFinalStreamId, QUIC_REFUSED_STREAM, _)) 1172 SendRstStream(kFinalStreamId, QUIC_REFUSED_STREAM, _))
1203 .Times(1); 1173 .Times(1);
1204 // Create one more data streams to exceed limit of open stream. 1174 // Create one more data streams to exceed limit of open stream.
1205 QuicStreamFrame data1(kFinalStreamId, false, 0, QuicStringPiece("HT")); 1175 QuicStreamFrame data1(kFinalStreamId, false, 0, QuicStringPiece("HT"));
1206 session_.OnStreamFrame(data1); 1176 session_.OnStreamFrame(data1);
1207 1177
1208 // Called after any new data is received by the session, and triggers the 1178 // Called after any new data is received by the session, and triggers the
1209 // call to close the connection. 1179 // call to close the connection.
1210 session_.PostProcessAfterData(); 1180 session_.PostProcessAfterData();
1211 } 1181 }
1212 1182
1213 TEST_P(QuicSessionTestServer, DrainingStreamsDoNotCountAsOpened) { 1183 TEST_P(QuicSessionTestServer, DrainingStreamsDoNotCountAsOpened) {
1214 // Verify that a draining stream (which has received a FIN but not consumed 1184 // Verify that a draining stream (which has received a FIN but not consumed
1215 // it) does not count against the open quota (because it is closed from the 1185 // it) does not count against the open quota (because it is closed from the
1216 // protocol point of view). 1186 // protocol point of view).
1217 EXPECT_CALL(*connection_, SendRstStream(_, QUIC_REFUSED_STREAM, _)).Times(0); 1187 EXPECT_CALL(*connection_, SendRstStream(_, QUIC_REFUSED_STREAM, _)).Times(0);
1218 const QuicStreamId kMaxStreams = 5; 1188 const QuicStreamId kMaxStreams = 5;
1219 QuicSessionPeer::SetMaxOpenIncomingStreams(&session_, kMaxStreams); 1189 QuicSessionPeer::SetMaxOpenIncomingStreams(&session_, kMaxStreams);
1220 1190
1221 // Create kMaxStreams + 1 data streams, and mark them draining. 1191 // Create kMaxStreams + 1 data streams, and mark them draining.
1222 const QuicStreamId kFirstStreamId = GetNthClientInitiatedId(0); 1192 const QuicStreamId kFirstStreamId = kClientDataStreamId1;
1223 const QuicStreamId kFinalStreamId = 1193 const QuicStreamId kFinalStreamId =
1224 GetNthClientInitiatedId(2 * kMaxStreams + 1); 1194 kClientDataStreamId1 + 2 * kMaxStreams + 1;
1225 for (QuicStreamId i = kFirstStreamId; i < kFinalStreamId; i += NextId()) { 1195 for (QuicStreamId i = kFirstStreamId; i < kFinalStreamId; i += 2) {
1226 QuicStreamFrame data1(i, true, 0, QuicStringPiece("HT")); 1196 QuicStreamFrame data1(i, true, 0, QuicStringPiece("HT"));
1227 session_.OnStreamFrame(data1); 1197 session_.OnStreamFrame(data1);
1228 EXPECT_EQ(1u, session_.GetNumOpenIncomingStreams()); 1198 EXPECT_EQ(1u, session_.GetNumOpenIncomingStreams());
1229 session_.StreamDraining(i); 1199 session_.StreamDraining(i);
1230 EXPECT_EQ(0u, session_.GetNumOpenIncomingStreams()); 1200 EXPECT_EQ(0u, session_.GetNumOpenIncomingStreams());
1231 } 1201 }
1232 1202
1233 // Called after any new data is received by the session, and triggers the call 1203 // Called after any new data is received by the session, and triggers the call
1234 // to close the connection. 1204 // to close the connection.
1235 session_.PostProcessAfterData(); 1205 session_.PostProcessAfterData();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 if (version() != QUIC_VERSION_36) { 1312 if (version() != QUIC_VERSION_36) {
1343 EXPECT_FALSE(session_.force_hol_blocking()); 1313 EXPECT_FALSE(session_.force_hol_blocking());
1344 } else { 1314 } else {
1345 EXPECT_TRUE(session_.force_hol_blocking()); 1315 EXPECT_TRUE(session_.force_hol_blocking());
1346 } 1316 }
1347 } 1317 }
1348 1318
1349 } // namespace 1319 } // namespace
1350 } // namespace test 1320 } // namespace test
1351 } // namespace net 1321 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_session.cc ('k') | net/quic/core/quic_spdy_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698