Skip to content

Commit

Permalink
node-neigh: Add retry for concurrent arping test case
Browse files Browse the repository at this point in the history
The test became notoriously flaky. It seems that some goroutines were
lagging behind with the updates and they were overwritting the new MAC
addr entry with the obsolete.

To fix this, retry multiple times until the correct entry is found.

Signed-off-by: Martynas Pumputis <m@lambda.lt>
  • Loading branch information
brb authored and christarazi committed Jun 22, 2021
1 parent 128f0f8 commit 8260f9d
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions pkg/datapath/linux/node_linux_test.go
Expand Up @@ -1188,23 +1188,28 @@ func (s *linuxPrivilegedIPv4OnlyTestSuite) TestArpPingHandling(c *check.C) {
c.Assert(err, check.IsNil)
return nil
})

// Check that MAC has been changed in the neigh table
time.Sleep(500 * time.Millisecond)
neighs, err = netlink.NeighList(veth0.Attrs().Index, netlink.FAMILY_V4)
c.Assert(err, check.IsNil)
found = false
for _, n := range neighs {
if n.IP.Equal(ip1) && n.State == netlink.NUD_PERMANENT {
c.Assert(n.HardwareAddr.String(), check.Equals, mac.String())
c.Assert(neighHwAddr(ip1.String()), check.Equals, mac.String())
c.Assert(neighRefCount(ip1.String()), check.Equals, 1)
found = true
break
var found bool
err := testutils.WaitUntilWithSleep(func() bool {
neighs, err = netlink.NeighList(veth0.Attrs().Index, netlink.FAMILY_V4)
c.Assert(err, check.IsNil)
found = false
for _, n := range neighs {
if n.IP.Equal(ip1) && n.State == netlink.NUD_PERMANENT &&
n.HardwareAddr.String() == mac.String() &&
neighHwAddr(ip1.String()) == mac.String() &&
neighRefCount(ip1.String()) == 1 {
found = true
return true
}
}
}
return false
}, 5*time.Second, 200*time.Millisecond)
c.Assert(err, check.IsNil)
c.Assert(found, check.Equals, true)

}

// Cleanup
close(done)
wg.Wait()
Expand Down

0 comments on commit 8260f9d

Please sign in to comment.