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

Unified Diff: net/quic/quic_connection_test.cc

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_crypto_server_stream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_connection_test.cc
diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc
index 1c47f32ccfe8e369146450f9eb8bfe08f6c4d3e8..4dbbe13a578da3b0612750abc6ca28f6f1200e61 100644
--- a/net/quic/quic_connection_test.cc
+++ b/net/quic/quic_connection_test.cc
@@ -19,6 +19,7 @@
#include "net/quic/quic_utils.h"
#include "net/quic/test_tools/mock_clock.h"
#include "net/quic/test_tools/mock_random.h"
+#include "net/quic/test_tools/quic_config_peer.h"
#include "net/quic/test_tools/quic_connection_peer.h"
#include "net/quic/test_tools/quic_framer_peer.h"
#include "net/quic/test_tools/quic_packet_creator_peer.h"
@@ -1313,6 +1314,49 @@ TEST_P(QuicConnectionTest, LeastUnackedLower) {
ProcessStopWaitingPacket(&frame3);
}
+TEST_P(QuicConnectionTest, TooManySentPackets) {
+ EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
+
+ for (int i = 0; i < 1100; ++i) {
+ SendStreamDataToPeer(1, "foo", 3 * i, !kFin, nullptr);
+ }
+
+ // Ack packet 1, which leaves more than the limit outstanding.
+ EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
+ if (FLAGS_quic_too_many_outstanding_packets) {
+ EXPECT_CALL(visitor_,
+ OnConnectionClosed(QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS,
+ false));
+ }
+ // We're receive buffer limited, so the connection won't try to write more.
+ EXPECT_CALL(visitor_, OnCanWrite()).Times(0);
+
+ // Nack every packet except the last one, leaving a huge gap.
+ QuicAckFrame frame1 = InitAckFrame(1100);
+ for (QuicPacketSequenceNumber i = 1; i < 1100; ++i) {
+ NackPacket(i, &frame1);
+ }
+ ProcessAckPacket(&frame1);
+}
+
+TEST_P(QuicConnectionTest, TooManyReceivedPackets) {
+ EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
+
+ if (FLAGS_quic_too_many_outstanding_packets) {
+ EXPECT_CALL(visitor_,
+ OnConnectionClosed(QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS,
+ false));
+ }
+
+ // Miss every other packet for 1000 packets.
+ for (QuicPacketSequenceNumber i = 1; i < 1000; ++i) {
+ ProcessPacket(i * 2);
+ if (!connection_.connected()) {
+ break;
+ }
+ }
+}
+
TEST_P(QuicConnectionTest, LargestObservedLower) {
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
@@ -1514,7 +1558,8 @@ TEST_P(QuicConnectionTest, FECSending) {
// max_packet_length by 2 so that subsequent packets containing subsequent
// stream frames with non-zero offets will fit within the packet length.
size_t length = 2 + GetPacketLengthForOneStream(
- connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER,
+ connection_.version(), kIncludeVersion,
+ PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_SEQUENCE_NUMBER,
IN_FEC_GROUP, &payload_length);
creator->set_max_packet_length(length);
@@ -1534,7 +1579,8 @@ TEST_P(QuicConnectionTest, FECQueueing) {
QuicPacketCreator* creator =
QuicConnectionPeer::GetPacketCreator(&connection_);
size_t length = GetPacketLengthForOneStream(
- connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER,
+ connection_.version(), kIncludeVersion,
+ PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_SEQUENCE_NUMBER,
IN_FEC_GROUP, &payload_length);
creator->set_max_packet_length(length);
EXPECT_TRUE(creator->IsFecEnabled());
@@ -2906,7 +2952,8 @@ TEST_P(QuicConnectionTest, TestQueueLimitsOnSendStreamData) {
// All packets carry version info till version is negotiated.
size_t payload_length;
size_t length = GetPacketLengthForOneStream(
- connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER,
+ connection_.version(), kIncludeVersion,
+ PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_SEQUENCE_NUMBER,
NOT_IN_FEC_GROUP, &payload_length);
QuicConnectionPeer::GetPacketCreator(&connection_)->set_max_packet_length(
length);
@@ -2930,7 +2977,8 @@ TEST_P(QuicConnectionTest, LoopThroughSendingPackets) {
// max_packet_length by 2 so that subsequent packets containing subsequent
// stream frames with non-zero offets will fit within the packet length.
size_t length = 2 + GetPacketLengthForOneStream(
- connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER,
+ connection_.version(), kIncludeVersion,
+ PACKET_8BYTE_CONNECTION_ID, PACKET_1BYTE_SEQUENCE_NUMBER,
NOT_IN_FEC_GROUP, &payload_length);
QuicConnectionPeer::GetPacketCreator(&connection_)->set_max_packet_length(
length);
@@ -2944,6 +2992,58 @@ TEST_P(QuicConnectionTest, LoopThroughSendingPackets) {
.bytes_consumed);
}
+TEST_P(QuicConnectionTest, LoopThroughSendingPacketsWithTruncation) {
+ ValueRestore<bool> old_flag(&FLAGS_allow_truncated_connection_ids_for_quic,
+ true);
+
+ // Set up a larger payload than will fit in one packet.
+ const string payload(connection_.max_packet_length(), 'a');
+ EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)).Times(AnyNumber());
+
+ // Now send some packets with no truncation.
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2);
+ EXPECT_EQ(payload.size(),
+ connection_.SendStreamDataWithString(
+ 3, payload, 0, !kFin, nullptr).bytes_consumed);
+ // Track the size of the second packet here. The overhead will be the largest
+ // we see in this test, due to the non-truncated CID.
+ size_t non_truncated_packet_size = writer_->last_packet_size();
+
+ // Change to a 4 byte CID.
+ QuicConfig config;
+ QuicConfigPeer::SetReceivedBytesForConnectionId(&config, 4);
+ connection_.SetFromConfig(config);
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2);
+ EXPECT_EQ(payload.size(),
+ connection_.SendStreamDataWithString(
+ 3, payload, 0, !kFin, nullptr).bytes_consumed);
+ // Verify that we have 8 fewer bytes than in the non-truncated case. The
+ // first packet got 4 bytes of extra payload due to the truncation, and the
+ // headers here are also 4 byte smaller.
+ EXPECT_EQ(non_truncated_packet_size, writer_->last_packet_size() + 8);
+
+
+ // Change to a 1 byte CID.
+ QuicConfigPeer::SetReceivedBytesForConnectionId(&config, 1);
+ connection_.SetFromConfig(config);
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2);
+ EXPECT_EQ(payload.size(),
+ connection_.SendStreamDataWithString(
+ 3, payload, 0, !kFin, nullptr).bytes_consumed);
+ // Just like above, we save 7 bytes on payload, and 7 on truncation.
+ EXPECT_EQ(non_truncated_packet_size, writer_->last_packet_size() + 7 * 2);
+
+ // Change to a 0 byte CID.
+ QuicConfigPeer::SetReceivedBytesForConnectionId(&config, 0);
+ connection_.SetFromConfig(config);
+ EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2);
+ EXPECT_EQ(payload.size(),
+ connection_.SendStreamDataWithString(
+ 3, payload, 0, !kFin, nullptr).bytes_consumed);
+ // Just like above, we save 8 bytes on payload, and 8 on truncation.
+ EXPECT_EQ(non_truncated_packet_size, writer_->last_packet_size() + 8 * 2);
+}
+
TEST_P(QuicConnectionTest, SendDelayedAck) {
QuicTime ack_time = clock_.ApproximateNow().Add(DefaultDelayedAckTime());
EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
« no previous file with comments | « net/quic/quic_connection.cc ('k') | net/quic/quic_crypto_server_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698