Skip to content

Commit

Permalink
client/integration: try to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nolouch committed Sep 17, 2018
1 parent c15fb60 commit 6ea5419
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
10 changes: 5 additions & 5 deletions clientv3/integration/kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
7 changes: 3 additions & 4 deletions clientv3/integration/lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion clientv3/integration/network_partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion etcdserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions integration/v3_lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 6ea5419

Please sign in to comment.