Merge pull request #14286 from VladSaioc/bugfix-goroutine-leak

Fixed goroutine leak in server/etcdserver/raft_test.go
This commit is contained in:
Benjamin Wang
2022-08-03 06:02:54 +08:00
committed by GitHub

View File

@ -168,12 +168,8 @@ 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{}
select {
case <-srv.r.applyc:
case <-time.After(time.Second):
t.Fatalf("failed to receive toApply struct")
}
stop := func() {
srv.r.stopped <- struct{}{} srv.r.stopped <- struct{}{}
select { select {
case <-srv.r.done: case <-srv.r.done:
@ -182,6 +178,16 @@ func TestStopRaftWhenWaitingForApplyDone(t *testing.T) {
} }
} }
select {
case <-srv.r.applyc:
case <-time.After(time.Second):
stop()
t.Fatalf("failed to receive toApply struct")
}
stop()
}
// TestConfigChangeBlocksApply ensures toApply blocks if committed entries contain config-change. // TestConfigChangeBlocksApply ensures toApply blocks if committed entries contain config-change.
func TestConfigChangeBlocksApply(t *testing.T) { func TestConfigChangeBlocksApply(t *testing.T) {
n := newNopReadyNode() n := newNopReadyNode()