Skip to content

Commit

Permalink
Fix serf.TestSerf_RemoveFailed_eventsLeave flake
Browse files Browse the repository at this point in the history
The test was not sleeping long enough, and was frequently missing the 'EventMemberFailed' event. By
sleeping a bit logner this test seems to pass reliably.
  • Loading branch information
dnephin committed Jun 9, 2021
1 parent c99e25f commit ac85eef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions serf/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
// testEvents tests that the given node had the given sequence of events
// on the event channel.
func testEvents(t *testing.T, ch <-chan Event, node string, expected []EventType) {
t.Helper()
actual := make([]EventType, 0, len(expected))

TESTEVENTLOOP:
Expand Down
4 changes: 2 additions & 2 deletions serf/serf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ func TestSerf_RemoveFailed_eventsLeave(t *testing.T) {
t.Fatalf("err: %v", err)
}

time.Sleep(s2Config.MemberlistConfig.ProbeInterval * 3)
time.Sleep(s2Config.MemberlistConfig.ProbeInterval * 5)

if err := s1.RemoveFailedNode(s2Config.NodeName); err != nil {
t.Fatalf("err: %v", err)
Expand Down Expand Up @@ -2950,7 +2950,7 @@ func waitUntilNumNodes(t *testing.T, desiredNodes int, serfs ...*Serf) {
t.Helper()
for i, s := range serfs {
if n := s.NumNodes(); desiredNodes != n {
r.Fatalf("s%d got %d expected %d", (i + 1), n, desiredNodes)
r.Fatalf("s%d got %d expected %d", i+1, n, desiredNodes)
}
}
})
Expand Down

0 comments on commit ac85eef

Please sign in to comment.