mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: drain leaky goroutines before test completed
Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
parent
ff2304879e
commit
51c99dd3fd
@ -48,6 +48,7 @@ func TestCheckLeasePutsKeys(t *testing.T) {
|
|||||||
|
|
||||||
tp, _ := auth.NewTokenProvider(zaptest.NewLogger(t), tokenTypeSimple, dummyIndexWaiter, simpleTokenTTLDefault)
|
tp, _ := auth.NewTokenProvider(zaptest.NewLogger(t), tokenTypeSimple, dummyIndexWaiter, simpleTokenTTLDefault)
|
||||||
as := auth.NewAuthStore(lg, b, tp, bcrypt.MinCost)
|
as := auth.NewAuthStore(lg, b, tp, bcrypt.MinCost)
|
||||||
|
defer as.AuthDisable()
|
||||||
|
|
||||||
aa := authApplierV3{as: as}
|
aa := authApplierV3{as: as}
|
||||||
assert.NoError(t, aa.checkLeasePutsKeys(lease.NewLease(lease.LeaseID(1), 3600)), "auth is disabled, should allow puts")
|
assert.NoError(t, aa.checkLeasePutsKeys(lease.NewLease(lease.LeaseID(1), 3600)), "auth is disabled, should allow puts")
|
||||||
|
@ -47,6 +47,9 @@ func TestHashKVHandler(t *testing.T) {
|
|||||||
assert.NoError(t, be.Close())
|
assert.NoError(t, be.Close())
|
||||||
}()
|
}()
|
||||||
etcdSrv.kv = mvcc.New(zap.NewNop(), be, &lease.FakeLessor{}, nil, nil, mvcc.StoreConfig{})
|
etcdSrv.kv = mvcc.New(zap.NewNop(), be, &lease.FakeLessor{}, nil, nil, mvcc.StoreConfig{})
|
||||||
|
defer func() {
|
||||||
|
assert.NoError(t, etcdSrv.kv.Close())
|
||||||
|
}()
|
||||||
ph := &hashKVHandler{
|
ph := &hashKVHandler{
|
||||||
lg: zap.NewNop(),
|
lg: zap.NewNop(),
|
||||||
server: etcdSrv,
|
server: etcdSrv,
|
||||||
|
@ -197,7 +197,7 @@ func TestConfigChangeBlocksApply(t *testing.T) {
|
|||||||
updateLead: func(uint64) {},
|
updateLead: func(uint64) {},
|
||||||
updateLeadership: func(bool) {},
|
updateLeadership: func(bool) {},
|
||||||
})
|
})
|
||||||
defer srv.r.Stop()
|
defer srv.r.stop()
|
||||||
|
|
||||||
n.readyc <- raft.Ready{
|
n.readyc <- raft.Ready{
|
||||||
SoftState: &raft.SoftState{RaftState: raft.StateFollower},
|
SoftState: &raft.SoftState{RaftState: raft.StateFollower},
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
"go.etcd.io/etcd/etcdserver/api/membership"
|
"go.etcd.io/etcd/etcdserver/api/membership"
|
||||||
"go.etcd.io/etcd/etcdserver/api/rafthttp"
|
"go.etcd.io/etcd/etcdserver/api/rafthttp"
|
||||||
"go.etcd.io/etcd/etcdserver/api/snap"
|
"go.etcd.io/etcd/etcdserver/api/snap"
|
||||||
@ -967,6 +968,9 @@ func TestSnapshot(t *testing.T) {
|
|||||||
defer func() {
|
defer func() {
|
||||||
os.RemoveAll(tmpPath)
|
os.RemoveAll(tmpPath)
|
||||||
}()
|
}()
|
||||||
|
defer func() {
|
||||||
|
assert.NoError(t, be.Close())
|
||||||
|
}()
|
||||||
|
|
||||||
s := raft.NewMemoryStorage()
|
s := raft.NewMemoryStorage()
|
||||||
s.Append([]raftpb.Entry{{Index: 1}})
|
s.Append([]raftpb.Entry{{Index: 1}})
|
||||||
@ -985,6 +989,9 @@ func TestSnapshot(t *testing.T) {
|
|||||||
v2store: st,
|
v2store: st,
|
||||||
}
|
}
|
||||||
srv.kv = mvcc.New(zap.NewExample(), be, &lease.FakeLessor{}, nil, &srv.consistIndex, mvcc.StoreConfig{})
|
srv.kv = mvcc.New(zap.NewExample(), be, &lease.FakeLessor{}, nil, &srv.consistIndex, mvcc.StoreConfig{})
|
||||||
|
defer func() {
|
||||||
|
assert.NoError(t, srv.kv.Close())
|
||||||
|
}()
|
||||||
srv.be = be
|
srv.be = be
|
||||||
|
|
||||||
ch := make(chan struct{}, 2)
|
ch := make(chan struct{}, 2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user