Merge pull request #14286 from VladSaioc/bugfix-goroutine-leak
Fixed goroutine leak in server/etcdserver/raft_test.go
This commit is contained in:
@ -168,18 +168,24 @@ func TestStopRaftWhenWaitingForApplyDone(t *testing.T) {
|
|||||||
srv := &EtcdServer{lgMu: new(sync.RWMutex), lg: zaptest.NewLogger(t), r: *r}
|
srv := &EtcdServer{lgMu: new(sync.RWMutex), lg: zaptest.NewLogger(t), r: *r}
|
||||||
srv.r.start(nil)
|
srv.r.start(nil)
|
||||||
n.readyc <- raft.Ready{}
|
n.readyc <- raft.Ready{}
|
||||||
|
|
||||||
|
stop := func() {
|
||||||
|
srv.r.stopped <- struct{}{}
|
||||||
|
select {
|
||||||
|
case <-srv.r.done:
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
t.Fatalf("failed to stop raft loop")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-srv.r.applyc:
|
case <-srv.r.applyc:
|
||||||
case <-time.After(time.Second):
|
case <-time.After(time.Second):
|
||||||
|
stop()
|
||||||
t.Fatalf("failed to receive toApply struct")
|
t.Fatalf("failed to receive toApply struct")
|
||||||
}
|
}
|
||||||
|
|
||||||
srv.r.stopped <- struct{}{}
|
stop()
|
||||||
select {
|
|
||||||
case <-srv.r.done:
|
|
||||||
case <-time.After(time.Second):
|
|
||||||
t.Fatalf("failed to stop raft loop")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestConfigChangeBlocksApply ensures toApply blocks if committed entries contain config-change.
|
// TestConfigChangeBlocksApply ensures toApply blocks if committed entries contain config-change.
|
||||||
|
Reference in New Issue
Block a user