Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fix TestNomad_BootstrapExpect_NonVoter test #14407

Merged
merged 2 commits into from
Aug 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 26 additions & 8 deletions nomad/serf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/hashicorp/nomad/testutil"
"github.com/hashicorp/raft"
"github.com/hashicorp/serf/serf"
"github.com/hashicorp/serf/testutil/retry"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -327,16 +326,35 @@ func TestNomad_BootstrapExpect_NonVoter(t *testing.T) {
})
defer cleanupS4()

// Start with 4th server for higher chance of success when joining servers.
servers := []*Server{s4, s3, s2, s1}

// Join with fourth server (now have quorum)
// Start with 4th server for higher chance of success
TestJoin(t, s4, s3, s2, s1)
TestJoin(t, servers...)

// Assert leadership with 4 peers
servers := []*Server{s1, s2, s3, s4}
for _, s := range servers {
testutil.WaitForLeader(t, s.RPC)
retry.Run(t, func(r *retry.R) { r.Check(wantPeers(s, 4)) })
}
expect := len(servers)
testutil.WaitForLeader(t, servers[0].RPC)
testutil.WaitForResult(func() (bool, error) {
// Retry the join to decrease flakiness
TestJoin(t, servers...)
for _, s := range servers {
peers, err := s.numPeers()
if err != nil {
return false, fmt.Errorf("failed to get number of peers: %v", err)
}
if peers != expect {
return false, fmt.Errorf("expected %d peers, got %d", expect, peers)
}
if len(s.localPeers) != expect {
return false, fmt.Errorf("expected %d local peers, got %d: %#v", expect, len(s.localPeers), s.localPeers)
}

}
return true, nil
}, func(err error) {
require.NoError(t, err)
})
}

func TestNomad_BadExpect(t *testing.T) {
Expand Down