Reduce number of servers in TestServer_Expect_NonVoters (#6155)

pull/6165/head
Freddy 2019-07-17 11:35:33 -06:00 committed by GitHub
parent 59dbd070d7
commit 5526cfac8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 22 deletions

View File

@ -742,53 +742,41 @@ func TestServer_AvoidReBootstrap(t *testing.T) {
func TestServer_Expect_NonVoters(t *testing.T) { func TestServer_Expect_NonVoters(t *testing.T) {
t.Parallel() t.Parallel()
dir1, s1 := testServerDCExpectNonVoter(t, "dc1", 3) dir1, s1 := testServerDCExpectNonVoter(t, "dc1", 2)
defer os.RemoveAll(dir1) defer os.RemoveAll(dir1)
defer s1.Shutdown() defer s1.Shutdown()
dir2, s2 := testServerDCExpectNonVoter(t, "dc1", 3) dir2, s2 := testServerDCExpect(t, "dc1", 2)
defer os.RemoveAll(dir2) defer os.RemoveAll(dir2)
defer s2.Shutdown() defer s2.Shutdown()
dir3, s3 := testServerDCExpect(t, "dc1", 3) dir3, s3 := testServerDCExpect(t, "dc1", 2)
defer os.RemoveAll(dir3) defer os.RemoveAll(dir3)
defer s3.Shutdown() defer s3.Shutdown()
dir4, s4 := testServerDCExpect(t, "dc1", 3) // Join the first two servers.
defer os.RemoveAll(dir4)
defer s4.Shutdown()
dir5, s5 := testServerDCExpect(t, "dc1", 3)
defer os.RemoveAll(dir5)
defer s5.Shutdown()
// Join the first three servers.
joinLAN(t, s2, s1) joinLAN(t, s2, s1)
joinLAN(t, s3, s1)
// Should have no peers yet since the bootstrap didn't occur. // Should have no peers yet since the bootstrap didn't occur.
retry.Run(t, func(r *retry.R) { retry.Run(t, func(r *retry.R) {
r.Check(wantPeers(s1, 0)) r.Check(wantPeers(s1, 0))
r.Check(wantPeers(s2, 0)) r.Check(wantPeers(s2, 0))
r.Check(wantPeers(s3, 0))
}) })
// Join the fourth node. // Join the third node.
joinLAN(t, s4, s1) joinLAN(t, s3, s1)
joinLAN(t, s5, s1)
// Now we have three servers so we should bootstrap. // Now we have three servers so we should bootstrap.
retry.Run(t, func(r *retry.R) { retry.Run(t, func(r *retry.R) {
r.Check(wantPeers(s1, 3)) r.Check(wantPeers(s1, 2))
r.Check(wantPeers(s2, 3)) r.Check(wantPeers(s2, 2))
r.Check(wantPeers(s3, 3)) r.Check(wantPeers(s3, 2))
r.Check(wantPeers(s4, 3))
}) })
// Make sure a leader is elected // Make sure a leader is elected
testrpc.WaitForLeader(t, s1.RPC, "dc1") testrpc.WaitForLeader(t, s1.RPC, "dc1")
retry.Run(t, func(r *retry.R) { retry.Run(t, func(r *retry.R) {
r.Check(wantRaft([]*Server{s1, s2, s3, s4, s5})) r.Check(wantRaft([]*Server{s1, s2, s3}))
}) })
} }