From d3c86781abdff20e4d6675d93268f9befca028a4 Mon Sep 17 00:00:00 2001 From: Lucas Manning Date: Tue, 17 Jan 2023 15:05:17 -0800 Subject: [PATCH] Fix flaky link resolution test. mointorableEndpoint was flaking because of a race between the pending packet from the failed write and the new write. We don't actually need the new write to show that link resolution worked. PiperOrigin-RevId: 502699348 --- pkg/tcpip/tests/integration/link_resolution_test.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/tcpip/tests/integration/link_resolution_test.go b/pkg/tcpip/tests/integration/link_resolution_test.go index 53dfe2700..9e87834cd 100644 --- a/pkg/tcpip/tests/integration/link_resolution_test.go +++ b/pkg/tcpip/tests/integration/link_resolution_test.go @@ -1828,7 +1828,7 @@ func TestUpdateCachedNeighborEntry(t *testing.T) { // Send packet to neighbor (start link resolution & resolve, then send // packet). Send twice to use cached address the second time. for i := 0; i < 2; i++ { - writePacket(t, r) + go writePacket(t, r) if err := host1NICMonitorable.waitForLinkAddress(utils.LinkAddr2, time.Second); err != nil { t.Fatalf("host1NIC.waitForLinkAddress(%s): %s", utils.LinkAddr2, err) } @@ -1838,8 +1838,8 @@ func TestUpdateCachedNeighborEntry(t *testing.T) { host1Stack.RemoveNeighbor(host1NICID, header.IPv4ProtocolNumber, neighborAddr) host2Stack.DisableNIC(host2NICID) - // Send packet to neighbor that's no longer reachable (should fail). - writePacket(t, r) + // Send a packet to the neighbor that's no longer reachable (should fail). + go writePacket(t, r) if err := host1NICMonitorable.waitForLinkAddress(utils.LinkAddr2, time.Second); err == nil { t.Fatalf("got host1NIC.waitForLinkAddress(%s) = nil, want err", utils.LinkAddr2) } @@ -1848,8 +1848,7 @@ func TestUpdateCachedNeighborEntry(t *testing.T) { host2Stack.EnableNIC(host2NICID) host2NICSettable.setLinkAddress(utils.LinkAddr3) - // Send packet to neighbor (start link resolution and then send packet). - writePacket(t, r) + // Pending packet should eventually reach the new neighbor. if err := host1NICMonitorable.waitForLinkAddress(utils.LinkAddr3, 5*time.Second); err != nil { t.Fatalf("host1NIC.waitForLinkAddress(%s): %s", utils.LinkAddr3, err) }