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

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

Issue 2176323002: Deprecate FLAGS_quic_disable_pre_30. Remove QUIC versions [25-29]. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@127879468
Patch Set: 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/quic_connection.h" 5 #include "net/quic/quic_connection.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <memory> 8 #include <memory>
9 #include <ostream> 9 #include <ostream>
10 #include <utility> 10 #include <utility>
(...skipping 1983 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 // Block the connection to queue the packet. 1994 // Block the connection to queue the packet.
1995 BlockOnNextWrite(); 1995 BlockOnNextWrite();
1996 1996
1997 QuicStreamId stream_id = 2; 1997 QuicStreamId stream_id = 2;
1998 connection_.SendStreamDataWithString(stream_id, "foo", 0, !kFin, nullptr); 1998 connection_.SendStreamDataWithString(stream_id, "foo", 0, !kFin, nullptr);
1999 1999
2000 // Now that there is a queued packet, reset the stream. 2000 // Now that there is a queued packet, reset the stream.
2001 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14); 2001 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14);
2002 2002
2003 // Unblock the connection and verify that the RST_STREAM is sent and the data 2003 // Unblock the connection and verify that the RST_STREAM is sent and the data
2004 // packet is sent on QUIC_VERSION_29 or later versions. 2004 // packet is sent.
2005 if (version() > QUIC_VERSION_28) { 2005 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AtLeast(2));
2006 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
2007 .Times(AtLeast(2));
2008 } else {
2009 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2010 }
2011 writer_->SetWritable(); 2006 writer_->SetWritable();
2012 connection_.OnCanWrite(); 2007 connection_.OnCanWrite();
2013 EXPECT_EQ(1u, writer_->frame_count()); 2008 EXPECT_EQ(1u, writer_->frame_count());
2014 EXPECT_EQ(1u, writer_->rst_stream_frames().size()); 2009 EXPECT_EQ(1u, writer_->rst_stream_frames().size());
2015 } 2010 }
2016 2011
2017 TEST_P(QuicConnectionTest, DoNotRetransmitForResetStreamOnNack) { 2012 TEST_P(QuicConnectionTest, DoNotRetransmitForResetStreamOnNack) {
2018 QuicStreamId stream_id = 2; 2013 QuicStreamId stream_id = 2;
2019 QuicPacketNumber last_packet; 2014 QuicPacketNumber last_packet;
2020 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet); 2015 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet);
(...skipping 16 matching lines...) Expand all
2037 TEST_P(QuicConnectionTest, RetransmitForQuicRstStreamNoErrorOnNack) { 2032 TEST_P(QuicConnectionTest, RetransmitForQuicRstStreamNoErrorOnNack) {
2038 QuicStreamId stream_id = 2; 2033 QuicStreamId stream_id = 2;
2039 QuicPacketNumber last_packet; 2034 QuicPacketNumber last_packet;
2040 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet); 2035 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet);
2041 SendStreamDataToPeer(stream_id, "foos", 3, !kFin, &last_packet); 2036 SendStreamDataToPeer(stream_id, "foos", 3, !kFin, &last_packet);
2042 SendStreamDataToPeer(stream_id, "fooos", 7, !kFin, &last_packet); 2037 SendStreamDataToPeer(stream_id, "fooos", 7, !kFin, &last_packet);
2043 2038
2044 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 2039 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2045 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14); 2040 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14);
2046 2041
2047 // Lose a packet, ensure it triggers retransmission on QUIC_VERSION_29 2042 // Lose a packet, ensure it triggers retransmission.
2048 // or later versions.
2049 QuicAckFrame nack_two = InitAckFrame(last_packet); 2043 QuicAckFrame nack_two = InitAckFrame(last_packet);
2050 NackPacket(last_packet - 1, &nack_two); 2044 NackPacket(last_packet - 1, &nack_two);
2051 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2045 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2052 SendAlgorithmInterface::CongestionVector lost_packets; 2046 SendAlgorithmInterface::CongestionVector lost_packets;
2053 lost_packets.push_back(std::make_pair(last_packet - 1, kMaxPacketSize)); 2047 lost_packets.push_back(std::make_pair(last_packet - 1, kMaxPacketSize));
2054 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _, _)) 2048 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _, _))
2055 .WillOnce(SetArgPointee<4>(lost_packets)); 2049 .WillOnce(SetArgPointee<4>(lost_packets));
2056 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 2050 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
2057 if (version() > QUIC_VERSION_28) { 2051 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AtLeast(1));
2058 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
2059 .Times(AtLeast(1));
2060 } else {
2061 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0);
2062 }
2063 ProcessAckPacket(&nack_two); 2052 ProcessAckPacket(&nack_two);
2064 } 2053 }
2065 2054
2066 TEST_P(QuicConnectionTest, DoNotRetransmitForResetStreamOnRTO) { 2055 TEST_P(QuicConnectionTest, DoNotRetransmitForResetStreamOnRTO) {
2067 QuicStreamId stream_id = 2; 2056 QuicStreamId stream_id = 2;
2068 QuicPacketNumber last_packet; 2057 QuicPacketNumber last_packet;
2069 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet); 2058 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet);
2070 2059
2071 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 2060 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2072 connection_.SendRstStream(stream_id, QUIC_ERROR_PROCESSING_STREAM, 14); 2061 connection_.SendRstStream(stream_id, QUIC_ERROR_PROCESSING_STREAM, 14);
(...skipping 11 matching lines...) Expand all
2084 connection_.SetMaxTailLossProbes(kDefaultPathId, 0); 2073 connection_.SetMaxTailLossProbes(kDefaultPathId, 0);
2085 2074
2086 QuicStreamId stream_id = 2; 2075 QuicStreamId stream_id = 2;
2087 QuicPacketNumber last_packet; 2076 QuicPacketNumber last_packet;
2088 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet); 2077 SendStreamDataToPeer(stream_id, "foo", 0, !kFin, &last_packet);
2089 2078
2090 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 2079 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2091 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14); 2080 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14);
2092 2081
2093 // Fire the RTO and verify that the RST_STREAM is resent, the stream data 2082 // Fire the RTO and verify that the RST_STREAM is resent, the stream data
2094 // is only sent on QUIC_VERSION_29 or later versions. 2083 // is sent.
2095 if (version() > QUIC_VERSION_28) { 2084 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AtLeast(2));
2096 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
2097 .Times(AtLeast(2));
2098 } else {
2099 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2100 }
2101 clock_.AdvanceTime(DefaultRetransmissionTime()); 2085 clock_.AdvanceTime(DefaultRetransmissionTime());
2102 connection_.GetRetransmissionAlarm()->Fire(); 2086 connection_.GetRetransmissionAlarm()->Fire();
2103 EXPECT_EQ(1u, writer_->frame_count()); 2087 EXPECT_EQ(1u, writer_->frame_count());
2104 ASSERT_EQ(1u, writer_->rst_stream_frames().size()); 2088 ASSERT_EQ(1u, writer_->rst_stream_frames().size());
2105 EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id); 2089 EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id);
2106 } 2090 }
2107 2091
2108 TEST_P(QuicConnectionTest, DoNotSendPendingRetransmissionForResetStream) { 2092 TEST_P(QuicConnectionTest, DoNotSendPendingRetransmissionForResetStream) {
2109 QuicStreamId stream_id = 2; 2093 QuicStreamId stream_id = 2;
2110 QuicPacketNumber last_packet; 2094 QuicPacketNumber last_packet;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2150 lost_packets.push_back(std::make_pair(last_packet - 1, kMaxPacketSize)); 2134 lost_packets.push_back(std::make_pair(last_packet - 1, kMaxPacketSize));
2151 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _, _)) 2135 EXPECT_CALL(*loss_algorithm_, DetectLosses(_, _, _, _, _))
2152 .WillOnce(SetArgPointee<4>(lost_packets)); 2136 .WillOnce(SetArgPointee<4>(lost_packets));
2153 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 2137 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
2154 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); 2138 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0);
2155 ProcessAckPacket(&ack); 2139 ProcessAckPacket(&ack);
2156 2140
2157 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14); 2141 connection_.SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 14);
2158 2142
2159 // Unblock the connection and verify that the RST_STREAM is sent and the 2143 // Unblock the connection and verify that the RST_STREAM is sent and the
2160 // second data packet or a retransmit is only sent on QUIC_VERSION_29 or 2144 // second data packet or a retransmit is sent.
2161 // later versions. 2145 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AtLeast(2));
2162 if (version() > QUIC_VERSION_28) {
2163 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
2164 .Times(AtLeast(2));
2165 } else {
2166 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
2167 }
2168 writer_->SetWritable(); 2146 writer_->SetWritable();
2169 connection_.OnCanWrite(); 2147 connection_.OnCanWrite();
2170 EXPECT_EQ(1u, writer_->frame_count()); 2148 EXPECT_EQ(1u, writer_->frame_count());
2171 if (version() > QUIC_VERSION_28) { 2149 EXPECT_EQ(0u, writer_->rst_stream_frames().size());
2172 EXPECT_EQ(0u, writer_->rst_stream_frames().size());
2173 } else {
2174 EXPECT_EQ(1u, writer_->rst_stream_frames().size());
2175 EXPECT_EQ(stream_id, writer_->rst_stream_frames().front().stream_id);
2176 }
2177 } 2150 }
2178 2151
2179 TEST_P(QuicConnectionTest, DiscardRetransmit) { 2152 TEST_P(QuicConnectionTest, DiscardRetransmit) {
2180 FLAGS_quic_always_write_queued_retransmissions = false; 2153 FLAGS_quic_always_write_queued_retransmissions = false;
2181 QuicPacketNumber last_packet; 2154 QuicPacketNumber last_packet;
2182 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1 2155 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); // Packet 1
2183 SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2 2156 SendStreamDataToPeer(1, "foos", 3, !kFin, &last_packet); // Packet 2
2184 SendStreamDataToPeer(1, "fooos", 7, !kFin, &last_packet); // Packet 3 2157 SendStreamDataToPeer(1, "fooos", 7, !kFin, &last_packet); // Packet 3
2185 2158
2186 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2159 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
(...skipping 2821 matching lines...) Expand 10 before | Expand all | Expand 10 after
5008 frame1_.data_length = data->length(); 4981 frame1_.data_length = data->length();
5009 4982
5010 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _, 4983 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_MAYBE_CORRUPTED_MEMORY, _,
5011 ConnectionCloseSource::FROM_SELF)); 4984 ConnectionCloseSource::FROM_SELF));
5012 ProcessFramePacket(QuicFrame(&frame1_)); 4985 ProcessFramePacket(QuicFrame(&frame1_));
5013 } 4986 }
5014 4987
5015 } // namespace 4988 } // namespace
5016 } // namespace test 4989 } // namespace test
5017 } // namespace net 4990 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698