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

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

Issue 444313002: Deprecate rolled out FLAGS_enable_quic_connection_flow_control_2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0807
Patch Set: Created 6 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
« no previous file with comments | « net/quic/quic_session.cc ('k') | net/quic/reliable_quic_stream_test.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 (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/quic_session.h" 5 #include "net/quic/quic_session.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "net/quic/crypto/crypto_protocol.h" 12 #include "net/quic/crypto/crypto_protocol.h"
13 #include "net/quic/quic_crypto_stream.h" 13 #include "net/quic/quic_crypto_stream.h"
14 #include "net/quic/quic_flags.h"
15 #include "net/quic/quic_protocol.h" 14 #include "net/quic/quic_protocol.h"
16 #include "net/quic/quic_utils.h" 15 #include "net/quic/quic_utils.h"
17 #include "net/quic/reliable_quic_stream.h" 16 #include "net/quic/reliable_quic_stream.h"
18 #include "net/quic/test_tools/quic_config_peer.h" 17 #include "net/quic/test_tools/quic_config_peer.h"
19 #include "net/quic/test_tools/quic_connection_peer.h" 18 #include "net/quic/test_tools/quic_connection_peer.h"
20 #include "net/quic/test_tools/quic_data_stream_peer.h" 19 #include "net/quic/test_tools/quic_data_stream_peer.h"
21 #include "net/quic/test_tools/quic_flow_controller_peer.h" 20 #include "net/quic/test_tools/quic_flow_controller_peer.h"
22 #include "net/quic/test_tools/quic_session_peer.h" 21 #include "net/quic/test_tools/quic_session_peer.h"
23 #include "net/quic/test_tools/quic_test_utils.h" 22 #include "net/quic/test_tools/quic_test_utils.h"
24 #include "net/quic/test_tools/reliable_quic_stream_peer.h" 23 #include "net/quic/test_tools/reliable_quic_stream_peer.h"
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 EXPECT_CALL(*stream4, OnCanWrite()); 523 EXPECT_CALL(*stream4, OnCanWrite());
525 session_.OnCanWrite(); 524 session_.OnCanWrite();
526 EXPECT_FALSE(session_.WillingAndAbleToWrite()); 525 EXPECT_FALSE(session_.WillingAndAbleToWrite());
527 } 526 }
528 527
529 TEST_P(QuicSessionTest, OnCanWriteLimitsNumWritesIfFlowControlBlocked) { 528 TEST_P(QuicSessionTest, OnCanWriteLimitsNumWritesIfFlowControlBlocked) {
530 if (version() < QUIC_VERSION_19) { 529 if (version() < QUIC_VERSION_19) {
531 return; 530 return;
532 } 531 }
533 532
534 ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control_2,
535 true);
536 // Ensure connection level flow control blockage. 533 // Ensure connection level flow control blockage.
537 QuicFlowControllerPeer::SetSendWindowOffset(session_.flow_controller(), 0); 534 QuicFlowControllerPeer::SetSendWindowOffset(session_.flow_controller(), 0);
538 EXPECT_TRUE(session_.flow_controller()->IsBlocked()); 535 EXPECT_TRUE(session_.flow_controller()->IsBlocked());
539 536
540 // Mark the crypto and headers streams as write blocked, we expect them to be 537 // Mark the crypto and headers streams as write blocked, we expect them to be
541 // allowed to write later. 538 // allowed to write later.
542 session_.MarkWriteBlocked(kCryptoStreamId, kHighestPriority); 539 session_.MarkWriteBlocked(kCryptoStreamId, kHighestPriority);
543 session_.MarkWriteBlocked(kHeadersStreamId, kHighestPriority); 540 session_.MarkWriteBlocked(kHeadersStreamId, kHighestPriority);
544 541
545 // Create a data stream, and although it is write blocked we never expect it 542 // Create a data stream, and although it is write blocked we never expect it
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 EXPECT_CALL(*connection_, 701 EXPECT_CALL(*connection_,
705 SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW)); 702 SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW));
706 session_.OnConfigNegotiated(); 703 session_.OnConfigNegotiated();
707 } 704 }
708 705
709 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingRstOutOfOrder) { 706 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingRstOutOfOrder) {
710 if (version() < QUIC_VERSION_19) { 707 if (version() < QUIC_VERSION_19) {
711 return; 708 return;
712 } 709 }
713 710
714 ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control_2,
715 true);
716 // Test that when we receive an out of order stream RST we correctly adjust 711 // Test that when we receive an out of order stream RST we correctly adjust
717 // our connection level flow control receive window. 712 // our connection level flow control receive window.
718 // On close, the stream should mark as consumed all bytes between the highest 713 // On close, the stream should mark as consumed all bytes between the highest
719 // byte consumed so far and the final byte offset from the RST frame. 714 // byte consumed so far and the final byte offset from the RST frame.
720 TestStream* stream = session_.CreateOutgoingDataStream(); 715 TestStream* stream = session_.CreateOutgoingDataStream();
721 716
722 const QuicStreamOffset kByteOffset = 717 const QuicStreamOffset kByteOffset =
723 1 + kInitialSessionFlowControlWindowForTest / 2; 718 1 + kInitialSessionFlowControlWindowForTest / 2;
724 719
725 // Expect no stream WINDOW_UPDATE frames, as stream read side closed. 720 // Expect no stream WINDOW_UPDATE frames, as stream read side closed.
726 EXPECT_CALL(*connection_, SendWindowUpdate(stream->id(), _)).Times(0); 721 EXPECT_CALL(*connection_, SendWindowUpdate(stream->id(), _)).Times(0);
727 // We do expect a connection level WINDOW_UPDATE when the stream is reset. 722 // We do expect a connection level WINDOW_UPDATE when the stream is reset.
728 EXPECT_CALL(*connection_, 723 EXPECT_CALL(*connection_,
729 SendWindowUpdate(0, kInitialSessionFlowControlWindowForTest + 724 SendWindowUpdate(0, kInitialSessionFlowControlWindowForTest +
730 kByteOffset)).Times(1); 725 kByteOffset)).Times(1);
731 726
732 QuicRstStreamFrame rst_frame(stream->id(), QUIC_STREAM_CANCELLED, 727 QuicRstStreamFrame rst_frame(stream->id(), QUIC_STREAM_CANCELLED,
733 kByteOffset); 728 kByteOffset);
734 session_.OnRstStream(rst_frame); 729 session_.OnRstStream(rst_frame);
735 session_.PostProcessAfterData(); 730 session_.PostProcessAfterData();
736 EXPECT_EQ(kByteOffset, session_.flow_controller()->bytes_consumed()); 731 EXPECT_EQ(kByteOffset, session_.flow_controller()->bytes_consumed());
737 } 732 }
738 733
739 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingFinAndLocalReset) { 734 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingFinAndLocalReset) {
740 if (version() < QUIC_VERSION_19) { 735 if (version() < QUIC_VERSION_19) {
741 return; 736 return;
742 } 737 }
743 738
744 ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control_2,
745 true);
746 // Test the situation where we receive a FIN on a stream, and before we fully 739 // Test the situation where we receive a FIN on a stream, and before we fully
747 // consume all the data from the sequencer buffer we locally RST the stream. 740 // consume all the data from the sequencer buffer we locally RST the stream.
748 // The bytes between highest consumed byte, and the final byte offset that we 741 // The bytes between highest consumed byte, and the final byte offset that we
749 // determined when the FIN arrived, should be marked as consumed at the 742 // determined when the FIN arrived, should be marked as consumed at the
750 // connection level flow controller when the stream is reset. 743 // connection level flow controller when the stream is reset.
751 TestStream* stream = session_.CreateOutgoingDataStream(); 744 TestStream* stream = session_.CreateOutgoingDataStream();
752 745
753 const QuicStreamOffset kByteOffset = 746 const QuicStreamOffset kByteOffset =
754 1 + kInitialSessionFlowControlWindowForTest / 2; 747 1 + kInitialSessionFlowControlWindowForTest / 2;
755 QuicStreamFrame frame(stream->id(), true, kByteOffset, IOVector()); 748 QuicStreamFrame frame(stream->id(), true, kByteOffset, IOVector());
(...skipping 26 matching lines...) Expand all
782 } 775 }
783 776
784 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingFinAfterRst) { 777 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingFinAfterRst) {
785 // Test that when we RST the stream (and tear down stream state), and then 778 // Test that when we RST the stream (and tear down stream state), and then
786 // receive a FIN from the peer, we correctly adjust our connection level flow 779 // receive a FIN from the peer, we correctly adjust our connection level flow
787 // control receive window. 780 // control receive window.
788 if (version() < QUIC_VERSION_19) { 781 if (version() < QUIC_VERSION_19) {
789 return; 782 return;
790 } 783 }
791 784
792 ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control_2,
793 true);
794 // Connection starts with some non-zero highest received byte offset, 785 // Connection starts with some non-zero highest received byte offset,
795 // due to other active streams. 786 // due to other active streams.
796 const uint64 kInitialConnectionBytesConsumed = 567; 787 const uint64 kInitialConnectionBytesConsumed = 567;
797 const uint64 kInitialConnectionHighestReceivedOffset = 1234; 788 const uint64 kInitialConnectionHighestReceivedOffset = 1234;
798 EXPECT_LT(kInitialConnectionBytesConsumed, 789 EXPECT_LT(kInitialConnectionBytesConsumed,
799 kInitialConnectionHighestReceivedOffset); 790 kInitialConnectionHighestReceivedOffset);
800 session_.flow_controller()->UpdateHighestReceivedOffset( 791 session_.flow_controller()->UpdateHighestReceivedOffset(
801 kInitialConnectionHighestReceivedOffset); 792 kInitialConnectionHighestReceivedOffset);
802 session_.flow_controller()->AddBytesConsumed(kInitialConnectionBytesConsumed); 793 session_.flow_controller()->AddBytesConsumed(kInitialConnectionBytesConsumed);
803 794
(...skipping 22 matching lines...) Expand all
826 } 817 }
827 818
828 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingRstAfterRst) { 819 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingRstAfterRst) {
829 // Test that when we RST the stream (and tear down stream state), and then 820 // Test that when we RST the stream (and tear down stream state), and then
830 // receive a RST from the peer, we correctly adjust our connection level flow 821 // receive a RST from the peer, we correctly adjust our connection level flow
831 // control receive window. 822 // control receive window.
832 if (version() < QUIC_VERSION_19) { 823 if (version() < QUIC_VERSION_19) {
833 return; 824 return;
834 } 825 }
835 826
836 ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control_2,
837 true);
838 // Connection starts with some non-zero highest received byte offset, 827 // Connection starts with some non-zero highest received byte offset,
839 // due to other active streams. 828 // due to other active streams.
840 const uint64 kInitialConnectionBytesConsumed = 567; 829 const uint64 kInitialConnectionBytesConsumed = 567;
841 const uint64 kInitialConnectionHighestReceivedOffset = 1234; 830 const uint64 kInitialConnectionHighestReceivedOffset = 1234;
842 EXPECT_LT(kInitialConnectionBytesConsumed, 831 EXPECT_LT(kInitialConnectionBytesConsumed,
843 kInitialConnectionHighestReceivedOffset); 832 kInitialConnectionHighestReceivedOffset);
844 session_.flow_controller()->UpdateHighestReceivedOffset( 833 session_.flow_controller()->UpdateHighestReceivedOffset(
845 kInitialConnectionHighestReceivedOffset); 834 kInitialConnectionHighestReceivedOffset);
846 session_.flow_controller()->AddBytesConsumed(kInitialConnectionBytesConsumed); 835 session_.flow_controller()->AddBytesConsumed(kInitialConnectionBytesConsumed);
847 836
(...skipping 14 matching lines...) Expand all
862 EXPECT_EQ(kInitialConnectionHighestReceivedOffset + kByteOffset, 851 EXPECT_EQ(kInitialConnectionHighestReceivedOffset + kByteOffset,
863 session_.flow_controller()->highest_received_byte_offset()); 852 session_.flow_controller()->highest_received_byte_offset());
864 } 853 }
865 854
866 TEST_P(QuicSessionTest, FlowControlWithInvalidFinalOffset) { 855 TEST_P(QuicSessionTest, FlowControlWithInvalidFinalOffset) {
867 // Test that if we receive a stream RST with a highest byte offset that 856 // Test that if we receive a stream RST with a highest byte offset that
868 // violates flow control, that we close the connection. 857 // violates flow control, that we close the connection.
869 if (version() <= QUIC_VERSION_16) { 858 if (version() <= QUIC_VERSION_16) {
870 return; 859 return;
871 } 860 }
872 ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control_2,
873 true);
874 861
875 const uint64 kLargeOffset = kInitialSessionFlowControlWindowForTest + 1; 862 const uint64 kLargeOffset = kInitialSessionFlowControlWindowForTest + 1;
876 EXPECT_CALL(*connection_, 863 EXPECT_CALL(*connection_,
877 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA)) 864 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA))
878 .Times(2); 865 .Times(2);
879 866
880 // Check that stream frame + FIN results in connection close. 867 // Check that stream frame + FIN results in connection close.
881 TestStream* stream = session_.CreateOutgoingDataStream(); 868 TestStream* stream = session_.CreateOutgoingDataStream();
882 stream->Reset(QUIC_STREAM_CANCELLED); 869 stream->Reset(QUIC_STREAM_CANCELLED);
883 QuicStreamFrame frame(stream->id(), true, kLargeOffset, IOVector()); 870 QuicStreamFrame frame(stream->id(), true, kLargeOffset, IOVector());
884 vector<QuicStreamFrame> frames; 871 vector<QuicStreamFrame> frames;
885 frames.push_back(frame); 872 frames.push_back(frame);
886 session_.OnStreamFrames(frames); 873 session_.OnStreamFrames(frames);
887 874
888 // Check that RST results in connection close. 875 // Check that RST results in connection close.
889 QuicRstStreamFrame rst_frame(stream->id(), QUIC_STREAM_CANCELLED, 876 QuicRstStreamFrame rst_frame(stream->id(), QUIC_STREAM_CANCELLED,
890 kLargeOffset); 877 kLargeOffset);
891 session_.OnRstStream(rst_frame); 878 session_.OnRstStream(rst_frame);
892 } 879 }
893 880
894 TEST_P(QuicSessionTest, VersionNegotiationDisablesFlowControl) { 881 TEST_P(QuicSessionTest, VersionNegotiationDisablesFlowControl) {
895 if (version() < QUIC_VERSION_19) { 882 if (version() < QUIC_VERSION_19) {
896 return; 883 return;
897 } 884 }
898 885
899 ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control_2,
900 true);
901 // Test that after successful version negotiation, flow control is disabled 886 // Test that after successful version negotiation, flow control is disabled
902 // appropriately at both the connection and stream level. 887 // appropriately at both the connection and stream level.
903 888
904 // Initially both stream and connection flow control are enabled. 889 // Initially both stream and connection flow control are enabled.
905 TestStream* stream = session_.CreateOutgoingDataStream(); 890 TestStream* stream = session_.CreateOutgoingDataStream();
906 EXPECT_TRUE(stream->flow_controller()->IsEnabled()); 891 EXPECT_TRUE(stream->flow_controller()->IsEnabled());
907 EXPECT_TRUE(session_.flow_controller()->IsEnabled()); 892 EXPECT_TRUE(session_.flow_controller()->IsEnabled());
908 893
909 // Version 18 implies that stream flow control is enabled, but connection 894 // Version 18 implies that stream flow control is enabled, but connection
910 // level is disabled. 895 // level is disabled.
911 session_.OnSuccessfulVersionNegotiation(QUIC_VERSION_18); 896 session_.OnSuccessfulVersionNegotiation(QUIC_VERSION_18);
912 EXPECT_FALSE(session_.flow_controller()->IsEnabled()); 897 EXPECT_FALSE(session_.flow_controller()->IsEnabled());
913 EXPECT_TRUE(stream->flow_controller()->IsEnabled()); 898 EXPECT_TRUE(stream->flow_controller()->IsEnabled());
914 899
915 // Version 16 means all flow control is disabled. 900 // Version 16 means all flow control is disabled.
916 session_.OnSuccessfulVersionNegotiation(QUIC_VERSION_16); 901 session_.OnSuccessfulVersionNegotiation(QUIC_VERSION_16);
917 EXPECT_FALSE(session_.flow_controller()->IsEnabled()); 902 EXPECT_FALSE(session_.flow_controller()->IsEnabled());
918 EXPECT_FALSE(stream->flow_controller()->IsEnabled()); 903 EXPECT_FALSE(stream->flow_controller()->IsEnabled());
919 } 904 }
920 905
921 } // namespace 906 } // namespace
922 } // namespace test 907 } // namespace test
923 } // namespace net 908 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_session.cc ('k') | net/quic/reliable_quic_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698