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

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

Issue 2229023002: Track when QUIC connections are application limited. Protected by quic_enable_app_limited_check. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@129327247
Patch Set: git pull upper stream Created 4 years, 4 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
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 <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 EXPECT_CALL(*stream2, OnCanWrite()) 485 EXPECT_CALL(*stream2, OnCanWrite())
486 .WillOnce(DoAll(testing::IgnoreResult(Invoke(CreateFunctor( 486 .WillOnce(DoAll(testing::IgnoreResult(Invoke(CreateFunctor(
487 &TestSession::SendLargeFakeData, 487 &TestSession::SendLargeFakeData,
488 base::Unretained(&session_), stream2, 6000))), 488 base::Unretained(&session_), stream2, 6000))),
489 Invoke(&stream2_blocker, 489 Invoke(&stream2_blocker,
490 &StreamBlocker::MarkConnectionLevelWriteBlocked))); 490 &StreamBlocker::MarkConnectionLevelWriteBlocked)));
491 session_.OnCanWrite(); 491 session_.OnCanWrite();
492 } 492 }
493 493
494 TEST_P(QuicSessionTestServer, OnCanWriteBundlesStreams) { 494 TEST_P(QuicSessionTestServer, OnCanWriteBundlesStreams) {
495 FLAGS_quic_enable_app_limited_check = true;
496
495 // Encryption needs to be established before data can be sent. 497 // Encryption needs to be established before data can be sent.
496 CryptoHandshakeMessage msg; 498 CryptoHandshakeMessage msg;
497 session_.GetCryptoStream()->OnHandshakeMessage(msg); 499 session_.GetCryptoStream()->OnHandshakeMessage(msg);
498 500
499 // Drive congestion control manually. 501 // Drive congestion control manually.
500 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>; 502 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>;
501 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId, 503 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId,
502 send_algorithm); 504 send_algorithm);
503 505
504 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); 506 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
(...skipping 21 matching lines...) Expand all
526 Invoke(CreateFunctor(&TestSession::SendStreamData, 528 Invoke(CreateFunctor(&TestSession::SendStreamData,
527 base::Unretained(&session_), stream6)))); 529 base::Unretained(&session_), stream6))));
528 530
529 // Expect that we only send one packet, the writes from different streams 531 // Expect that we only send one packet, the writes from different streams
530 // should be bundled together. 532 // should be bundled together.
531 MockPacketWriter* writer = static_cast<MockPacketWriter*>( 533 MockPacketWriter* writer = static_cast<MockPacketWriter*>(
532 QuicConnectionPeer::GetWriter(session_.connection())); 534 QuicConnectionPeer::GetWriter(session_.connection()));
533 EXPECT_CALL(*writer, WritePacket(_, _, _, _, _)) 535 EXPECT_CALL(*writer, WritePacket(_, _, _, _, _))
534 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0))); 536 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0)));
535 EXPECT_CALL(*send_algorithm, OnPacketSent(_, _, _, _, _)); 537 EXPECT_CALL(*send_algorithm, OnPacketSent(_, _, _, _, _));
538 EXPECT_CALL(*send_algorithm, OnApplicationLimited(_));
536 session_.OnCanWrite(); 539 session_.OnCanWrite();
537 EXPECT_FALSE(session_.WillingAndAbleToWrite()); 540 EXPECT_FALSE(session_.WillingAndAbleToWrite());
538 } 541 }
539 542
540 TEST_P(QuicSessionTestServer, OnCanWriteCongestionControlBlocks) { 543 TEST_P(QuicSessionTestServer, OnCanWriteCongestionControlBlocks) {
544 FLAGS_quic_enable_app_limited_check = true;
545
541 InSequence s; 546 InSequence s;
542 547
543 // Drive congestion control manually. 548 // Drive congestion control manually.
544 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>; 549 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>;
545 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId, 550 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId,
546 send_algorithm); 551 send_algorithm);
547 552
548 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); 553 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
549 TestStream* stream4 = session_.CreateOutgoingDynamicStream(kDefaultPriority); 554 TestStream* stream4 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
550 TestStream* stream6 = session_.CreateOutgoingDynamicStream(kDefaultPriority); 555 TestStream* stream6 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
(...skipping 20 matching lines...) Expand all
571 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _)) 576 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _))
572 .WillOnce(Return(QuicTime::Delta::Infinite())); 577 .WillOnce(Return(QuicTime::Delta::Infinite()));
573 session_.OnCanWrite(); 578 session_.OnCanWrite();
574 EXPECT_TRUE(session_.WillingAndAbleToWrite()); 579 EXPECT_TRUE(session_.WillingAndAbleToWrite());
575 580
576 // stream4->OnCanWrite is called once the connection stops being 581 // stream4->OnCanWrite is called once the connection stops being
577 // congestion-control blocked. 582 // congestion-control blocked.
578 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _)) 583 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _))
579 .WillOnce(Return(QuicTime::Delta::Zero())); 584 .WillOnce(Return(QuicTime::Delta::Zero()));
580 EXPECT_CALL(*stream4, OnCanWrite()); 585 EXPECT_CALL(*stream4, OnCanWrite());
586 EXPECT_CALL(*send_algorithm, OnApplicationLimited(_));
581 session_.OnCanWrite(); 587 session_.OnCanWrite();
582 EXPECT_FALSE(session_.WillingAndAbleToWrite()); 588 EXPECT_FALSE(session_.WillingAndAbleToWrite());
583 } 589 }
584 590
591 TEST_P(QuicSessionTestServer, OnCanWriteWriterBlocks) {
592 FLAGS_quic_enable_app_limited_check = true;
593
594 // Drive congestion control manually in order to ensure that
595 // application-limited signaling is handled correctly.
596 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>;
597 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId,
598 send_algorithm);
599 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _))
600 .WillRepeatedly(Return(QuicTime::Delta::Zero()));
601
602 // Drive packet writer manually.
603 MockPacketWriter* writer = static_cast<MockPacketWriter*>(
604 QuicConnectionPeer::GetWriter(session_.connection()));
605 EXPECT_CALL(*writer, IsWriteBlocked()).WillRepeatedly(Return(true));
606 EXPECT_CALL(*writer, IsWriteBlockedDataBuffered())
607 .WillRepeatedly(Return(true));
608 EXPECT_CALL(*writer, WritePacket(_, _, _, _, _)).Times(0);
609
610 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
611
612 session_.MarkConnectionLevelWriteBlocked(stream2->id());
613
614 EXPECT_CALL(*stream2, OnCanWrite()).Times(0);
615 EXPECT_CALL(*send_algorithm, OnApplicationLimited(_)).Times(0);
616
617 session_.OnCanWrite();
618 EXPECT_TRUE(session_.WillingAndAbleToWrite());
619 }
620
585 TEST_P(QuicSessionTestServer, BufferedHandshake) { 621 TEST_P(QuicSessionTestServer, BufferedHandshake) {
586 EXPECT_FALSE(session_.HasPendingHandshake()); // Default value. 622 EXPECT_FALSE(session_.HasPendingHandshake()); // Default value.
587 623
588 // Test that blocking other streams does not change our status. 624 // Test that blocking other streams does not change our status.
589 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); 625 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
590 StreamBlocker stream2_blocker(&session_, stream2->id()); 626 StreamBlocker stream2_blocker(&session_, stream2->id());
591 stream2_blocker.MarkConnectionLevelWriteBlocked(); 627 stream2_blocker.MarkConnectionLevelWriteBlocked();
592 EXPECT_FALSE(session_.HasPendingHandshake()); 628 EXPECT_FALSE(session_.HasPendingHandshake());
593 629
594 TestStream* stream3 = session_.CreateOutgoingDynamicStream(kDefaultPriority); 630 TestStream* stream3 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 CloseStream(stream6->id()); 673 CloseStream(stream6->id());
638 674
639 InSequence s; 675 InSequence s;
640 EXPECT_CALL(*stream2, OnCanWrite()); 676 EXPECT_CALL(*stream2, OnCanWrite());
641 EXPECT_CALL(*stream4, OnCanWrite()); 677 EXPECT_CALL(*stream4, OnCanWrite());
642 session_.OnCanWrite(); 678 session_.OnCanWrite();
643 EXPECT_FALSE(session_.WillingAndAbleToWrite()); 679 EXPECT_FALSE(session_.WillingAndAbleToWrite());
644 } 680 }
645 681
646 TEST_P(QuicSessionTestServer, OnCanWriteLimitsNumWritesIfFlowControlBlocked) { 682 TEST_P(QuicSessionTestServer, OnCanWriteLimitsNumWritesIfFlowControlBlocked) {
683 FLAGS_quic_enable_app_limited_check = true;
684
685 // Drive congestion control manually in order to ensure that
686 // application-limited signaling is handled correctly.
687 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>;
688 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), kDefaultPathId,
689 send_algorithm);
690 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _))
691 .WillRepeatedly(Return(QuicTime::Delta::Zero()));
692
647 // Ensure connection level flow control blockage. 693 // Ensure connection level flow control blockage.
648 QuicFlowControllerPeer::SetSendWindowOffset(session_.flow_controller(), 0); 694 QuicFlowControllerPeer::SetSendWindowOffset(session_.flow_controller(), 0);
649 EXPECT_TRUE(session_.flow_controller()->IsBlocked()); 695 EXPECT_TRUE(session_.flow_controller()->IsBlocked());
650 EXPECT_TRUE(session_.IsConnectionFlowControlBlocked()); 696 EXPECT_TRUE(session_.IsConnectionFlowControlBlocked());
651 EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); 697 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
652 698
653 // Mark the crypto and headers streams as write blocked, we expect them to be 699 // Mark the crypto and headers streams as write blocked, we expect them to be
654 // allowed to write later. 700 // allowed to write later.
655 session_.MarkConnectionLevelWriteBlocked(kCryptoStreamId); 701 session_.MarkConnectionLevelWriteBlocked(kCryptoStreamId);
656 session_.MarkConnectionLevelWriteBlocked(kHeadersStreamId); 702 session_.MarkConnectionLevelWriteBlocked(kHeadersStreamId);
657 703
658 // Create a data stream, and although it is write blocked we never expect it 704 // Create a data stream, and although it is write blocked we never expect it
659 // to be allowed to write as we are connection level flow control blocked. 705 // to be allowed to write as we are connection level flow control blocked.
660 TestStream* stream = session_.CreateOutgoingDynamicStream(kDefaultPriority); 706 TestStream* stream = session_.CreateOutgoingDynamicStream(kDefaultPriority);
661 session_.MarkConnectionLevelWriteBlocked(stream->id()); 707 session_.MarkConnectionLevelWriteBlocked(stream->id());
662 EXPECT_CALL(*stream, OnCanWrite()).Times(0); 708 EXPECT_CALL(*stream, OnCanWrite()).Times(0);
663 709
664 // The crypto and headers streams should be called even though we are 710 // The crypto and headers streams should be called even though we are
665 // connection flow control blocked. 711 // connection flow control blocked.
666 TestCryptoStream* crypto_stream = session_.GetCryptoStream(); 712 TestCryptoStream* crypto_stream = session_.GetCryptoStream();
667 EXPECT_CALL(*crypto_stream, OnCanWrite()); 713 EXPECT_CALL(*crypto_stream, OnCanWrite());
668 TestHeadersStream* headers_stream = new TestHeadersStream(&session_); 714 TestHeadersStream* headers_stream = new TestHeadersStream(&session_);
669 QuicSpdySessionPeer::SetHeadersStream(&session_, headers_stream); 715 QuicSpdySessionPeer::SetHeadersStream(&session_, headers_stream);
670 EXPECT_CALL(*headers_stream, OnCanWrite()); 716 EXPECT_CALL(*headers_stream, OnCanWrite());
671 717
718 // After the crypto and header streams perform a write, the connection will be
719 // blocked by the flow control, hence it should become application-limited.
720 EXPECT_CALL(*send_algorithm, OnApplicationLimited(_));
721
672 session_.OnCanWrite(); 722 session_.OnCanWrite();
673 EXPECT_FALSE(session_.WillingAndAbleToWrite()); 723 EXPECT_FALSE(session_.WillingAndAbleToWrite());
674 } 724 }
675 725
676 TEST_P(QuicSessionTestServer, SendGoAway) { 726 TEST_P(QuicSessionTestServer, SendGoAway) {
677 MockPacketWriter* writer = static_cast<MockPacketWriter*>( 727 MockPacketWriter* writer = static_cast<MockPacketWriter*>(
678 QuicConnectionPeer::GetWriter(session_.connection())); 728 QuicConnectionPeer::GetWriter(session_.connection()));
679 EXPECT_CALL(*writer, WritePacket(_, _, _, _, _)) 729 EXPECT_CALL(*writer, WritePacket(_, _, _, _, _))
680 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0))); 730 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0)));
681 EXPECT_CALL(*connection_, SendGoAway(_, _, _)) 731 EXPECT_CALL(*connection_, SendGoAway(_, _, _))
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 if (version() <= QUIC_VERSION_35) { 1253 if (version() <= QUIC_VERSION_35) {
1204 EXPECT_FALSE(session_.force_hol_blocking()); 1254 EXPECT_FALSE(session_.force_hol_blocking());
1205 } else { 1255 } else {
1206 EXPECT_TRUE(session_.force_hol_blocking()); 1256 EXPECT_TRUE(session_.force_hol_blocking());
1207 } 1257 }
1208 } 1258 }
1209 1259
1210 } // namespace 1260 } // namespace
1211 } // namespace test 1261 } // namespace test
1212 } // namespace net 1262 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_sent_packet_manager_interface.h ('k') | net/quic/test_tools/quic_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698