From 8ad6657a22b0eaaef7d1b4a31553e826a87e9190 Mon Sep 17 00:00:00 2001 From: Nayana Bidari Date: Mon, 19 Apr 2021 14:41:44 -0700 Subject: [PATCH] Fix TCP RACK flaky unit tests. - Added delay to increase the RTT: In DSACK tests with RACK enabled and low RTT, TLP can be detected before sending ACK and the tests flake. Increasing the RTT will ensure that TLP does not happen before the ACK is sent. - Fix TestRACKOnePacketTailLoss: The ACK does not contain DSACK, which means either the original or retransmission (probe) was lost and SACKRecovery count must be incremented. Before: http://sponge2/c9bd51de-f72f-481c-a7f3-e782e7524883 After: http://sponge2/1307a796-103a-4a45-b699-e8d239220ed1 PiperOrigin-RevId: 369305720 --- pkg/tcpip/transport/tcp/tcp_rack_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/tcpip/transport/tcp/tcp_rack_test.go b/pkg/tcpip/transport/tcp/tcp_rack_test.go index 5cdd5b588..81e7dc36e 100644 --- a/pkg/tcpip/transport/tcp/tcp_rack_test.go +++ b/pkg/tcpip/transport/tcp/tcp_rack_test.go @@ -33,6 +33,7 @@ const ( tsOptionSize = 12 maxTCPOptionSize = 40 mtu = header.TCPMinimumSize + header.IPv4MinimumSize + maxTCPOptionSize + maxPayload + latency = 5 * time.Millisecond ) func setStackRACKPermitted(t *testing.T, c *context.Context) { @@ -182,6 +183,9 @@ func sendAndReceiveWithSACK(t *testing.T, c *context.Context, numPackets int, en for i := 0; i < numPackets; i++ { c.ReceiveAndCheckPacketWithOptions(data, bytesRead, maxPayload, tsOptionSize) bytesRead += maxPayload + // This delay is added to increase RTT as low RTT can cause TLP + // before sending ACK. + time.Sleep(latency) } return data @@ -479,7 +483,7 @@ func TestRACKOnePacketTailLoss(t *testing.T) { }{ // #3 was retransmitted as TLP. {tcpStats.FastRetransmit, "stats.TCP.FastRetransmit", 0}, - {tcpStats.SACKRecovery, "stats.TCP.SACKRecovery", 0}, + {tcpStats.SACKRecovery, "stats.TCP.SACKRecovery", 1}, {tcpStats.TLPRecovery, "stats.TCP.TLPRecovery", 0}, // RTO should not have fired. {tcpStats.Timeouts, "stats.TCP.Timeouts", 0},