mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Fixed goroutine leak in server/etcdserver/raft_test.go
Signed-off-by: VladSaioc <vladsaioc10@gmail.com>
This commit is contained in:
parent
046c46e52e
commit
6cded3d94c
@ -168,18 +168,24 @@ func TestStopRaftWhenWaitingForApplyDone(t *testing.T) {
|
||||
srv := &EtcdServer{lgMu: new(sync.RWMutex), lg: zaptest.NewLogger(t), r: *r}
|
||||
srv.r.start(nil)
|
||||
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 {
|
||||
case <-srv.r.applyc:
|
||||
case <-time.After(time.Second):
|
||||
stop()
|
||||
t.Fatalf("failed to receive toApply struct")
|
||||
}
|
||||
|
||||
srv.r.stopped <- struct{}{}
|
||||
select {
|
||||
case <-srv.r.done:
|
||||
case <-time.After(time.Second):
|
||||
t.Fatalf("failed to stop raft loop")
|
||||
}
|
||||
stop()
|
||||
}
|
||||
|
||||
// TestConfigChangeBlocksApply ensures toApply blocks if committed entries contain config-change.
|
||||
|
Loading…
x
Reference in New Issue
Block a user