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

Side by Side Diff: net/quic/quic_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/quic/quic_session.cc ('k') | net/quic/quic_stream_factory.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"
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 571
572 TEST_P(QuicSessionTest, DoNotSendGoAwayTwice) { 572 TEST_P(QuicSessionTest, DoNotSendGoAwayTwice) {
573 EXPECT_CALL(*connection_, 573 EXPECT_CALL(*connection_,
574 SendGoAway(QUIC_PEER_GOING_AWAY, 0u, "Going Away.")).Times(1); 574 SendGoAway(QUIC_PEER_GOING_AWAY, 0u, "Going Away.")).Times(1);
575 session_.SendGoAway(QUIC_PEER_GOING_AWAY, "Going Away."); 575 session_.SendGoAway(QUIC_PEER_GOING_AWAY, "Going Away.");
576 EXPECT_TRUE(session_.goaway_sent()); 576 EXPECT_TRUE(session_.goaway_sent());
577 session_.SendGoAway(QUIC_PEER_GOING_AWAY, "Going Away."); 577 session_.SendGoAway(QUIC_PEER_GOING_AWAY, "Going Away.");
578 } 578 }
579 579
580 TEST_P(QuicSessionTest, IncreasedTimeoutAfterCryptoHandshake) { 580 TEST_P(QuicSessionTest, IncreasedTimeoutAfterCryptoHandshake) {
581 // Add 1 to the connection timeout on the server side. 581 EXPECT_EQ((FLAGS_quic_unified_timeouts ?
582 EXPECT_EQ(kDefaultInitialTimeoutSecs + 1, 582 kInitialIdleTimeoutSecs : kDefaultIdleTimeoutSecs) + 1,
583 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds()); 583 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds());
584 CryptoHandshakeMessage msg; 584 CryptoHandshakeMessage msg;
585 session_.GetCryptoStream()->OnHandshakeMessage(msg); 585 session_.GetCryptoStream()->OnHandshakeMessage(msg);
586 EXPECT_EQ(kMaximumIdleTimeoutSecs + 1, 586 EXPECT_EQ(kMaximumIdleTimeoutSecs + 1,
587 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds()); 587 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds());
588 } 588 }
589 589
590 TEST_P(QuicSessionTest, RstStreamBeforeHeadersDecompressed) { 590 TEST_P(QuicSessionTest, RstStreamBeforeHeadersDecompressed) {
591 // Send two bytes of payload. 591 // Send two bytes of payload.
592 QuicStreamFrame data1(kClientDataStreamId1, false, 0, MakeIOVector("HT")); 592 QuicStreamFrame data1(kClientDataStreamId1, false, 0, MakeIOVector("HT"));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 625
626 // Processing of second invalid stream reset should not result in the 626 // Processing of second invalid stream reset should not result in the
627 // connection being closed for a second time. 627 // connection being closed for a second time.
628 QuicRstStreamFrame rst2(kLargeInvalidStreamId, QUIC_STREAM_NO_ERROR, 0); 628 QuicRstStreamFrame rst2(kLargeInvalidStreamId, QUIC_STREAM_NO_ERROR, 0);
629 session_.OnRstStream(rst2); 629 session_.OnRstStream(rst2);
630 } 630 }
631 631
632 TEST_P(QuicSessionTest, HandshakeUnblocksFlowControlBlockedStream) { 632 TEST_P(QuicSessionTest, HandshakeUnblocksFlowControlBlockedStream) {
633 // Test that if a stream is flow control blocked, then on receipt of the SHLO 633 // Test that if a stream is flow control blocked, then on receipt of the SHLO
634 // containing a suitable send window offset, the stream becomes unblocked. 634 // containing a suitable send window offset, the stream becomes unblocked.
635 if (version() <= QUIC_VERSION_16) {
636 return;
637 }
638 635
639 // Ensure that Writev consumes all the data it is given (simulate no socket 636 // Ensure that Writev consumes all the data it is given (simulate no socket
640 // blocking). 637 // blocking).
641 session_.set_writev_consumes_all_data(true); 638 session_.set_writev_consumes_all_data(true);
642 639
643 // Create a stream, and send enough data to make it flow control blocked. 640 // Create a stream, and send enough data to make it flow control blocked.
644 TestStream* stream2 = session_.CreateOutgoingDataStream(); 641 TestStream* stream2 = session_.CreateOutgoingDataStream();
645 string body(kDefaultFlowControlSendWindow, '.'); 642 string body(kDefaultFlowControlSendWindow, '.');
646 EXPECT_FALSE(stream2->flow_controller()->IsBlocked()); 643 EXPECT_FALSE(stream2->flow_controller()->IsBlocked());
647 stream2->SendBody(body, false); 644 stream2->SendBody(body, false);
648 EXPECT_TRUE(stream2->flow_controller()->IsBlocked()); 645 EXPECT_TRUE(stream2->flow_controller()->IsBlocked());
649 646
650 // Now complete the crypto handshake, resulting in an increased flow control 647 // Now complete the crypto handshake, resulting in an increased flow control
651 // send window. 648 // send window.
652 CryptoHandshakeMessage msg; 649 CryptoHandshakeMessage msg;
653 session_.GetCryptoStream()->OnHandshakeMessage(msg); 650 session_.GetCryptoStream()->OnHandshakeMessage(msg);
654 651
655 // Stream is now unblocked. 652 // Stream is now unblocked.
656 EXPECT_FALSE(stream2->flow_controller()->IsBlocked()); 653 EXPECT_FALSE(stream2->flow_controller()->IsBlocked());
657 } 654 }
658 655
659 TEST_P(QuicSessionTest, InvalidFlowControlWindowInHandshake) { 656 TEST_P(QuicSessionTest, InvalidFlowControlWindowInHandshake) {
660 // TODO(rjshade): Remove this test when removing QUIC_VERSION_19. 657 // TODO(rjshade): Remove this test when removing QUIC_VERSION_19.
661 // Test that receipt of an invalid (< default) flow control window from 658 // Test that receipt of an invalid (< default) flow control window from
662 // the peer results in the connection being torn down. 659 // the peer results in the connection being torn down.
663 if (version() <= QUIC_VERSION_16 || version() > QUIC_VERSION_19) { 660 if (version() > QUIC_VERSION_19) {
664 return; 661 return;
665 } 662 }
666 663
667 uint32 kInvalidWindow = kDefaultFlowControlSendWindow - 1; 664 uint32 kInvalidWindow = kDefaultFlowControlSendWindow - 1;
668 QuicConfigPeer::SetReceivedInitialFlowControlWindow(session_.config(), 665 QuicConfigPeer::SetReceivedInitialFlowControlWindow(session_.config(),
669 kInvalidWindow); 666 kInvalidWindow);
670 667
671 EXPECT_CALL(*connection_, 668 EXPECT_CALL(*connection_,
672 SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW)).Times(2); 669 SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW)).Times(2);
673 session_.OnConfigNegotiated(); 670 session_.OnConfigNegotiated();
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 847
851 EXPECT_EQ(kInitialConnectionBytesConsumed + kByteOffset, 848 EXPECT_EQ(kInitialConnectionBytesConsumed + kByteOffset,
852 session_.flow_controller()->bytes_consumed()); 849 session_.flow_controller()->bytes_consumed());
853 EXPECT_EQ(kInitialConnectionHighestReceivedOffset + kByteOffset, 850 EXPECT_EQ(kInitialConnectionHighestReceivedOffset + kByteOffset,
854 session_.flow_controller()->highest_received_byte_offset()); 851 session_.flow_controller()->highest_received_byte_offset());
855 } 852 }
856 853
857 TEST_P(QuicSessionTest, FlowControlWithInvalidFinalOffset) { 854 TEST_P(QuicSessionTest, FlowControlWithInvalidFinalOffset) {
858 // Test that if we receive a stream RST with a highest byte offset that 855 // Test that if we receive a stream RST with a highest byte offset that
859 // violates flow control, that we close the connection. 856 // violates flow control, that we close the connection.
860 if (version() <= QUIC_VERSION_16) {
861 return;
862 }
863
864 const uint64 kLargeOffset = kInitialSessionFlowControlWindowForTest + 1; 857 const uint64 kLargeOffset = kInitialSessionFlowControlWindowForTest + 1;
865 EXPECT_CALL(*connection_, 858 EXPECT_CALL(*connection_,
866 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA)) 859 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA))
867 .Times(2); 860 .Times(2);
868 861
869 // Check that stream frame + FIN results in connection close. 862 // Check that stream frame + FIN results in connection close.
870 TestStream* stream = session_.CreateOutgoingDataStream(); 863 TestStream* stream = session_.CreateOutgoingDataStream();
871 stream->Reset(QUIC_STREAM_CANCELLED); 864 stream->Reset(QUIC_STREAM_CANCELLED);
872 QuicStreamFrame frame(stream->id(), true, kLargeOffset, IOVector()); 865 QuicStreamFrame frame(stream->id(), true, kLargeOffset, IOVector());
873 vector<QuicStreamFrame> frames; 866 vector<QuicStreamFrame> frames;
(...skipping 17 matching lines...) Expand all
891 // Initially both stream and connection flow control are enabled. 884 // Initially both stream and connection flow control are enabled.
892 TestStream* stream = session_.CreateOutgoingDataStream(); 885 TestStream* stream = session_.CreateOutgoingDataStream();
893 EXPECT_TRUE(stream->flow_controller()->IsEnabled()); 886 EXPECT_TRUE(stream->flow_controller()->IsEnabled());
894 EXPECT_TRUE(session_.flow_controller()->IsEnabled()); 887 EXPECT_TRUE(session_.flow_controller()->IsEnabled());
895 888
896 // Version 18 implies that stream flow control is enabled, but connection 889 // Version 18 implies that stream flow control is enabled, but connection
897 // level is disabled. 890 // level is disabled.
898 session_.OnSuccessfulVersionNegotiation(QUIC_VERSION_18); 891 session_.OnSuccessfulVersionNegotiation(QUIC_VERSION_18);
899 EXPECT_FALSE(session_.flow_controller()->IsEnabled()); 892 EXPECT_FALSE(session_.flow_controller()->IsEnabled());
900 EXPECT_TRUE(stream->flow_controller()->IsEnabled()); 893 EXPECT_TRUE(stream->flow_controller()->IsEnabled());
901
902 // Version 16 means all flow control is disabled.
903 session_.OnSuccessfulVersionNegotiation(QUIC_VERSION_16);
904 EXPECT_FALSE(session_.flow_controller()->IsEnabled());
905 EXPECT_FALSE(stream->flow_controller()->IsEnabled());
906 } 894 }
907 895
908 TEST_P(QuicSessionTest, WindowUpdateUnblocksHeadersStream) { 896 TEST_P(QuicSessionTest, WindowUpdateUnblocksHeadersStream) {
909 // Test that a flow control blocked headers stream gets unblocked on recipt of 897 // Test that a flow control blocked headers stream gets unblocked on recipt of
910 // a WINDOW_UPDATE frame. Regression test for b/17413860. 898 // a WINDOW_UPDATE frame. Regression test for b/17413860.
911 if (version() < QUIC_VERSION_21) { 899 if (version() < QUIC_VERSION_21) {
912 return; 900 return;
913 } 901 }
914 902
915 // Set the headers stream to be flow control blocked. 903 // Set the headers stream to be flow control blocked.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 } 945 }
958 946
959 // Called after any new data is received by the session, and triggers the call 947 // Called after any new data is received by the session, and triggers the call
960 // to close the connection. 948 // to close the connection.
961 session_.PostProcessAfterData(); 949 session_.PostProcessAfterData();
962 } 950 }
963 951
964 } // namespace 952 } // namespace
965 } // namespace test 953 } // namespace test
966 } // namespace net 954 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_session.cc ('k') | net/quic/quic_stream_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698