Skip to content

Commit fb80979

Browse files
ghananigansgvisor-bot
authored andcommitted
Increase timeouts for NDP tests' async events
Increase the timeout to 1s when waiting for async NDP events to help reduce flakiness. This will not significantly increase test times as the async events continue to receive an event on a channel. The increased timeout allows more time for an event to be sent on the channel as the previous timeout of 100ms caused some flakes. Test: Existing tests pass PiperOrigin-RevId: 291420936
1 parent 390bb9c commit fb80979

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

pkg/tcpip/stack/ndp_test.go

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ import (
3535
)
3636

3737
const (
38-
addr1 = tcpip.Address("\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01")
39-
addr2 = tcpip.Address("\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02")
40-
addr3 = tcpip.Address("\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03")
41-
linkAddr1 = tcpip.LinkAddress("\x02\x02\x03\x04\x05\x06")
42-
linkAddr2 = tcpip.LinkAddress("\x02\x02\x03\x04\x05\x07")
43-
linkAddr3 = tcpip.LinkAddress("\x02\x02\x03\x04\x05\x08")
44-
defaultTimeout = 100 * time.Millisecond
38+
addr1 = tcpip.Address("\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01")
39+
addr2 = tcpip.Address("\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02")
40+
addr3 = tcpip.Address("\x0a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03")
41+
linkAddr1 = tcpip.LinkAddress("\x02\x02\x03\x04\x05\x06")
42+
linkAddr2 = tcpip.LinkAddress("\x02\x02\x03\x04\x05\x07")
43+
linkAddr3 = tcpip.LinkAddress("\x02\x02\x03\x04\x05\x08")
44+
defaultTimeout = 100 * time.Millisecond
45+
defaultAsyncEventTimeout = time.Second
4546
)
4647

4748
var (
@@ -1086,7 +1087,7 @@ func TestRouterDiscovery(t *testing.T) {
10861087
// Wait for the normal lifetime plus an extra bit for the
10871088
// router to get invalidated. If we don't get an invalidation
10881089
// event after this time, then something is wrong.
1089-
expectAsyncRouterInvalidationEvent(llAddr2, l2LifetimeSeconds*time.Second+defaultTimeout)
1090+
expectAsyncRouterInvalidationEvent(llAddr2, l2LifetimeSeconds*time.Second+defaultAsyncEventTimeout)
10901091

10911092
// Rx an RA from lladdr2 with huge lifetime.
10921093
e.InjectInbound(header.IPv6ProtocolNumber, raBuf(llAddr2, 1000))
@@ -1103,7 +1104,7 @@ func TestRouterDiscovery(t *testing.T) {
11031104
// Wait for the normal lifetime plus an extra bit for the
11041105
// router to get invalidated. If we don't get an invalidation
11051106
// event after this time, then something is wrong.
1106-
expectAsyncRouterInvalidationEvent(llAddr3, l3LifetimeSeconds*time.Second+defaultTimeout)
1107+
expectAsyncRouterInvalidationEvent(llAddr3, l3LifetimeSeconds*time.Second+defaultAsyncEventTimeout)
11071108
}
11081109

11091110
// TestRouterDiscoveryMaxRouters tests that only
@@ -1342,7 +1343,7 @@ func TestPrefixDiscovery(t *testing.T) {
13421343
if diff := checkPrefixEvent(e, subnet2, false); diff != "" {
13431344
t.Errorf("prefix event mismatch (-want +got):\n%s", diff)
13441345
}
1345-
case <-time.After(time.Duration(lifetime)*time.Second + defaultTimeout):
1346+
case <-time.After(time.Duration(lifetime)*time.Second + defaultAsyncEventTimeout):
13461347
t.Fatal("timed out waiting for prefix discovery event")
13471348
}
13481349

@@ -1681,7 +1682,7 @@ func TestAutoGenAddr(t *testing.T) {
16811682
if diff := checkAutoGenAddrEvent(e, addr1, invalidatedAddr); diff != "" {
16821683
t.Errorf("auto-gen addr event mismatch (-want +got):\n%s", diff)
16831684
}
1684-
case <-time.After(newMinVLDuration + defaultTimeout):
1685+
case <-time.After(newMinVLDuration + defaultAsyncEventTimeout):
16851686
t.Fatal("timed out waiting for addr auto gen event")
16861687
}
16871688
if contains(s.NICInfo()[1].ProtocolAddresses, addr1) {
@@ -1987,7 +1988,7 @@ func TestAutoGenAddrTimerDeprecation(t *testing.T) {
19871988
expectPrimaryAddr(addr1)
19881989

19891990
// Wait for addr of prefix1 to be deprecated.
1990-
expectAutoGenAddrEventAfter(addr1, deprecatedAddr, newMinVLDuration-time.Second+defaultTimeout)
1991+
expectAutoGenAddrEventAfter(addr1, deprecatedAddr, newMinVLDuration-time.Second+defaultAsyncEventTimeout)
19911992
if !contains(s.NICInfo()[nicID].ProtocolAddresses, addr1) {
19921993
t.Fatalf("should not have %s in the list of addresses", addr1)
19931994
}
@@ -2027,7 +2028,7 @@ func TestAutoGenAddrTimerDeprecation(t *testing.T) {
20272028
expectPrimaryAddr(addr1)
20282029

20292030
// Wait for addr of prefix1 to be deprecated.
2030-
expectAutoGenAddrEventAfter(addr1, deprecatedAddr, newMinVLDuration-time.Second+defaultTimeout)
2031+
expectAutoGenAddrEventAfter(addr1, deprecatedAddr, newMinVLDuration-time.Second+defaultAsyncEventTimeout)
20312032
if !contains(s.NICInfo()[nicID].ProtocolAddresses, addr1) {
20322033
t.Fatalf("should not have %s in the list of addresses", addr1)
20332034
}
@@ -2041,7 +2042,7 @@ func TestAutoGenAddrTimerDeprecation(t *testing.T) {
20412042
}
20422043

20432044
// Wait for addr of prefix1 to be invalidated.
2044-
expectAutoGenAddrEventAfter(addr1, invalidatedAddr, time.Second+defaultTimeout)
2045+
expectAutoGenAddrEventAfter(addr1, invalidatedAddr, time.Second+defaultAsyncEventTimeout)
20452046
if contains(s.NICInfo()[nicID].ProtocolAddresses, addr1) {
20462047
t.Fatalf("should not have %s in the list of addresses", addr1)
20472048
}
@@ -2073,7 +2074,7 @@ func TestAutoGenAddrTimerDeprecation(t *testing.T) {
20732074
if diff := checkAutoGenAddrEvent(e, addr2, invalidatedAddr); diff != "" {
20742075
t.Errorf("auto-gen addr event mismatch (-want +got):\n%s", diff)
20752076
}
2076-
case <-time.After(defaultTimeout):
2077+
case <-time.After(defaultAsyncEventTimeout):
20772078
t.Fatal("timed out waiting for addr auto gen event")
20782079
}
20792080
} else if diff := checkAutoGenAddrEvent(e, addr2, invalidatedAddr); diff == "" {
@@ -2088,7 +2089,7 @@ func TestAutoGenAddrTimerDeprecation(t *testing.T) {
20882089
t.Fatalf("got unexpected auto-generated event")
20892090
}
20902091

2091-
case <-time.After(newMinVLDuration + defaultTimeout):
2092+
case <-time.After(newMinVLDuration + defaultAsyncEventTimeout):
20922093
t.Fatal("timed out waiting for addr auto gen event")
20932094
}
20942095
if contains(s.NICInfo()[nicID].ProtocolAddresses, addr1) {
@@ -2213,7 +2214,7 @@ func TestAutoGenAddrFiniteToInfiniteToFiniteVL(t *testing.T) {
22132214
t.Errorf("auto-gen addr event mismatch (-want +got):\n%s", diff)
22142215
}
22152216

2216-
case <-time.After(minVLSeconds*time.Second + defaultTimeout):
2217+
case <-time.After(minVLSeconds*time.Second + defaultAsyncEventTimeout):
22172218
t.Fatal("timeout waiting for addr auto gen event")
22182219
}
22192220
})
@@ -2701,7 +2702,7 @@ func TestAutoGenAddrWithOpaqueIID(t *testing.T) {
27012702
if diff := checkAutoGenAddrEvent(e, addr1, invalidatedAddr); diff != "" {
27022703
t.Errorf("auto-gen addr event mismatch (-want +got):\n%s", diff)
27032704
}
2704-
case <-time.After(validLifetimeSecondPrefix1*time.Second + defaultTimeout):
2705+
case <-time.After(validLifetimeSecondPrefix1*time.Second + defaultAsyncEventTimeout):
27052706
t.Fatal("timed out waiting for addr auto gen event")
27062707
}
27072708
if contains(s.NICInfo()[nicID].ProtocolAddresses, addr1) {
@@ -3325,12 +3326,12 @@ func TestRouterSolicitation(t *testing.T) {
33253326
// times.
33263327
remaining := test.maxRtrSolicit
33273328
if remaining > 0 {
3328-
waitForPkt(test.effectiveMaxRtrSolicitDelay + defaultTimeout)
3329+
waitForPkt(test.effectiveMaxRtrSolicitDelay + defaultAsyncEventTimeout)
33293330
remaining--
33303331
}
33313332
for ; remaining > 0; remaining-- {
33323333
waitForNothing(test.effectiveRtrSolicitInt - defaultTimeout)
3333-
waitForPkt(2 * defaultTimeout)
3334+
waitForPkt(defaultAsyncEventTimeout)
33343335
}
33353336

33363337
// Make sure no more RS.
@@ -3411,9 +3412,9 @@ func TestStopStartSolicitingRouters(t *testing.T) {
34113412

34123413
// Disable forwarding which should start router solicitations.
34133414
s.SetForwarding(false)
3414-
waitForPkt(delay + defaultTimeout)
3415-
waitForPkt(interval + defaultTimeout)
3416-
waitForPkt(interval + defaultTimeout)
3415+
waitForPkt(delay + defaultAsyncEventTimeout)
3416+
waitForPkt(interval + defaultAsyncEventTimeout)
3417+
waitForPkt(interval + defaultAsyncEventTimeout)
34173418
select {
34183419
case <-e.C:
34193420
t.Fatal("unexpectedly got an extra packet after sending out the expected RSs")

0 commit comments

Comments
 (0)