mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raftExample: Allow closing raftexample node when snapshotting.
Fix race that made the raftExample test fail.
This commit is contained in:
parent
9563698f64
commit
3976d68ed3
2
Makefile
2
Makefile
@ -151,7 +151,7 @@ test:
|
||||
$(TEST_OPTS) ./test.sh 2>&1 | tee test-$(TEST_SUFFIX).log
|
||||
! egrep "(--- FAIL:|DATA RACE|panic: test timed out|appears to have leaked)" -B50 -A10 test-$(TEST_SUFFIX).log
|
||||
|
||||
test-small:
|
||||
test-smoke:
|
||||
$(info log-file: test-$(TEST_SUFFIX).log)
|
||||
PASSES="fmt build unit" ./test.sh 2<&1 | tee test-$(TEST_SUFFIX).log
|
||||
|
||||
|
@ -364,9 +364,13 @@ func (rc *raftNode) maybeTriggerSnapshot(applyDoneC <-chan struct{}) {
|
||||
return
|
||||
}
|
||||
|
||||
// wait until all committed entries are applied
|
||||
// wait until all committed entries are applied (or server is closed)
|
||||
if applyDoneC != nil {
|
||||
<-applyDoneC
|
||||
select {
|
||||
case <-applyDoneC:
|
||||
case <-rc.stopc:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("start snapshot [applied index: %d | last snapshot index: %d]", rc.appliedIndex, rc.snapshotIndex)
|
||||
|
@ -94,9 +94,11 @@ func (clus *cluster) Close() (err error) {
|
||||
}
|
||||
|
||||
func (clus *cluster) closeNoErrors(t *testing.T) {
|
||||
t.Log("closing cluster...")
|
||||
if err := clus.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log("closing cluster [done]")
|
||||
}
|
||||
|
||||
// TestProposeOnCommit starts three nodes and feeds commits back into the proposal
|
||||
|
Loading…
x
Reference in New Issue
Block a user