Do not drop too many packages in PacketDroppingTestWriter.
After each dropped package, succeed in writing at least two packages before
dropping another one (unless fake drop percentage is 100). This is to avoid
test flakiness due to too many dropped packages. For example, if both the
server and the client happen to drop every other package, no probe ack will ever
be received. See https://crbug.com/1095063 for more context.
Without this change, I can reproduce the following errors in AckNotifierWithPacketLossAndBlockedSocket tests:
- in the internal code base, test flakiness (QUIC_TOO_MANY_RTOS errors),
- in Chromium debug build, test flakiness (QUIC_TOO_MANY_RTOS errors),
- in Chromium MSAN build, both test flakiness and test timeouts.
With this change, I ran all of AckNotifierWithPacketLossAndBlockedSocket in Chromium in both setups, and all of EndToEndTests with internal tools, each of them 1000 times, and they all passed.
Test-only change
PiperOrigin-RevId: 319202623
Change-Id: I8aedcf3e790a947d3d6fa341f6064a7465156472
diff --git a/quic/test_tools/packet_dropping_test_writer.h b/quic/test_tools/packet_dropping_test_writer.h
index f066e91..47a3216 100644
--- a/quic/test_tools/packet_dropping_test_writer.h
+++ b/quic/test_tools/packet_dropping_test_writer.h
@@ -73,7 +73,14 @@
void OnCanWrite();
// The percent of time a packet is simulated as being lost.
- void set_fake_packet_loss_percentage(int32_t fake_packet_loss_percentage);
+ // If |fake_packet_loss_percentage| is 100, then all packages are lost.
+ // Otherwise actual percentage will be lower than
+ // |fake_packet_loss_percentage|, because every dropped package is followed by
+ // a minimum number of successfully written packets.
+ void set_fake_packet_loss_percentage(int32_t fake_packet_loss_percentage) {
+ QuicWriterMutexLock lock(&config_mutex_);
+ fake_packet_loss_percentage_ = fake_packet_loss_percentage;
+ }
// Simulate dropping the first n packets unconditionally.
// Subsequent packets will be lost at fake_packet_loss_percentage_ if set.
@@ -159,6 +166,7 @@
DelayedPacketList delayed_packets_;
QuicByteCount cur_buffer_size_;
uint64_t num_calls_to_write_;
+ int32_t num_consecutive_succesful_writes_;
QuicMutex config_mutex_;
int32_t fake_packet_loss_percentage_ QUIC_GUARDED_BY(config_mutex_);
@@ -168,7 +176,6 @@
QuicTime::Delta fake_packet_delay_ QUIC_GUARDED_BY(config_mutex_);
QuicBandwidth fake_bandwidth_ QUIC_GUARDED_BY(config_mutex_);
QuicByteCount buffer_size_ QUIC_GUARDED_BY(config_mutex_);
- int32_t num_consecutive_packet_lost_ QUIC_GUARDED_BY(config_mutex_);
};
} // namespace test