Fix goroutine leaks in TestCommitPagination

raft: fix goroutine leaks in TestCommitPagination

The goroutine created with n.run() will leak if we forget to call n.Stop().

We can replay the goroutine leaks by using [goleak](https://github.com/uber-go/goleak):

```
$ cd raft &&  env go test -short -v -timeout=3m --race -run=TestCommitPagination.
... ...
raft2021/12/27 20:47:15 INFO: raft.node: 1 elected leader 1 at term 1
    leaks.go:78: found unexpected goroutines:
        [Goroutine 20 in state select, with go.etcd.io/etcd/raft/v3.(*node).run on top of the stack:
        goroutine 20 [select]:
        go.etcd.io/etcd/raft/v3.(*node).run(0xc00036f260)
                /home/yuanting/work/dev/goprojects/etcd/raft/node.go:344 +0xc1d
        created by go.etcd.io/etcd/raft/v3.TestCommitPagination
                /home/yuanting/work/dev/goprojects/etcd/raft/node_test.go:920 +0x554
        ]
--- FAIL: TestCommitPagination (0.45s)
FAIL
FAIL    go.etcd.io/etcd/raft/v3 0.508s
FAIL
```
This commit is contained in:
Ting Yuan 2021-12-27 20:55:02 +08:00 committed by GitHub
parent 69279532f4
commit df8efd3853
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -945,6 +945,7 @@ func TestCommitPagination(t *testing.T) {
}
s.Append(rd.Entries)
n.Advance()
n.Stop()
}
type ignoreSizeHintMemStorage struct {