client/integration: try to fix tests
This commit is contained in:
@ -439,6 +439,11 @@ func TestKVGetErrConnClosed(t *testing.T) {
|
||||
cli := clus.Client(0)
|
||||
|
||||
donec := make(chan struct{})
|
||||
if err := cli.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
clus.TakeClient(0)
|
||||
|
||||
go func() {
|
||||
defer close(donec)
|
||||
_, err := cli.Get(context.TODO(), "foo")
|
||||
@ -447,11 +452,6 @@ func TestKVGetErrConnClosed(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
if err := cli.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
clus.TakeClient(0)
|
||||
|
||||
select {
|
||||
case <-time.After(integration.RequestWaitTimeout):
|
||||
t.Fatal("kv.Get took too long")
|
||||
|
@ -291,6 +291,9 @@ func TestLeaseGrantErrConnClosed(t *testing.T) {
|
||||
|
||||
cli := clus.Client(0)
|
||||
clus.TakeClient(0)
|
||||
if err := cli.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
donec := make(chan struct{})
|
||||
go func() {
|
||||
@ -303,10 +306,6 @@ func TestLeaseGrantErrConnClosed(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
if err := cli.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
select {
|
||||
case <-time.After(integration.RequestWaitTimeout):
|
||||
t.Fatal("le.Grant took too long")
|
||||
|
@ -310,7 +310,7 @@ func TestDropReadUnderNetworkPartition(t *testing.T) {
|
||||
t.Fatalf("expected %v, got %v", rpctypes.ErrLeaderChanged, err)
|
||||
}
|
||||
|
||||
ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
|
||||
ctx, cancel = context.WithTimeout(context.TODO(), 10*time.Second)
|
||||
_, err = kvc.Get(ctx, "a")
|
||||
cancel()
|
||||
if err != nil {
|
||||
|
@ -946,8 +946,8 @@ func (s *EtcdServer) run() {
|
||||
s.leaderChangedMu.Lock()
|
||||
lc := s.leaderChanged
|
||||
s.leaderChanged = make(chan struct{})
|
||||
s.leaderChangedMu.Unlock()
|
||||
close(lc)
|
||||
s.leaderChangedMu.Unlock()
|
||||
}
|
||||
// TODO: remove the nil checking
|
||||
// current test utility does not provide the stats
|
||||
|
@ -565,14 +565,11 @@ func TestV3LeaseFailover(t *testing.T) {
|
||||
md := metadata.Pairs(rpctypes.MetadataRequireLeaderKey, rpctypes.MetadataHasLeader)
|
||||
mctx := metadata.NewOutgoingContext(context.Background(), md)
|
||||
ctx, cancel := context.WithCancel(mctx)
|
||||
defer cancel()
|
||||
lac, err := lc.LeaseKeepAlive(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() {
|
||||
lac.CloseSend()
|
||||
cancel()
|
||||
}()
|
||||
|
||||
// send keep alive to old leader until the old leader starts
|
||||
// to drop lease request.
|
||||
|
Reference in New Issue
Block a user