Skip to content

Commit 9095071

Browse files
milantracygvisor-bot
authored andcommitted
Deflake //pkg/tcpip/stack:bridge_test.
It is a test bug, where FindFDBEntry in test may query a MAC address before it is populated in bridge's fdbTable. In the test, the entry was initialized once, let's refresh FDB entry in the for loop. PiperOrigin-RevId: 825181738
1 parent d93c5f5 commit 9095071

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/tcpip/stack/bridge_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,15 @@ func TestBridgeFDB(t *testing.T) {
243243
// FDB.
244244
var e stack.BridgeFDBEntry
245245
start := time.Now()
246-
for e = bridgeEndpoint.FindFDBEntry(veth2.LinkAddress()); len(e.PortLinkAddress()) == 0 && time.Since(start) < 30*time.Second; {
246+
for {
247+
e = bridgeEndpoint.FindFDBEntry(veth2.LinkAddress())
248+
if len(e.PortLinkAddress()) != 0 {
249+
break
250+
}
251+
if time.Since(start) > 30*time.Second {
252+
t.Fatalf("failed to find FDB entry for %s after 30 seconds", veth2.LinkAddress())
253+
}
254+
time.Sleep(time.Second)
247255
}
248256
if e.PortLinkAddress() != veth1.LinkAddress() {
249257
t.Fatalf("bridgeEndpoint.FindFDBEntry(%s) = %s, want = %s", veth2.LinkAddress(), e.PortLinkAddress(), veth1.LinkAddress())

0 commit comments

Comments
 (0)