MCPcopy
hub / github.com/chaozh/MIT-6.824 / TestFailAgree2B

Function TestFailAgree2B

src/raft/test_test.go:180–212  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

178}
179
180func TestFailAgree2B(t *testing.T) {
181 servers := 3
182 cfg := make_config(t, servers, false, false)
183 defer cfg.cleanup()
184
185 cfg.begin("Test (2B): agreement despite follower disconnection")
186
187 cfg.one(101, servers, false)
188
189 // disconnect one follower from the network.
190 leader := cfg.checkOneLeader()
191 cfg.disconnect((leader + 1) % servers)
192
193 // the leader and remaining follower should be
194 // able to agree despite the disconnected follower.
195 cfg.one(102, servers-1, false)
196 cfg.one(103, servers-1, false)
197 time.Sleep(RaftElectionTimeout)
198 cfg.one(104, servers-1, false)
199 cfg.one(105, servers-1, false)
200
201 // re-connect
202 cfg.connect((leader + 1) % servers)
203
204 // the full set of servers should preserve
205 // previous agreements, and be able to agree
206 // on new commands.
207 cfg.one(106, servers, true)
208 time.Sleep(RaftElectionTimeout)
209 cfg.one(107, servers, true)
210
211 cfg.end()
212}
213
214func TestFailNoAgree2B(t *testing.T) {
215 servers := 5

Callers

nothing calls this directly

Calls 8

oneMethod · 0.80
checkOneLeaderMethod · 0.80
make_configFunction · 0.70
cleanupMethod · 0.45
beginMethod · 0.45
disconnectMethod · 0.45
connectMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected