mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #6768 from gyuho/wtwt
clientv3/integration: close active connection to get ErrClientConnClosing
This commit is contained in:
commit
4575353693
@ -614,18 +614,19 @@ func TestWatchErrConnClosed(t *testing.T) {
|
|||||||
defer clus.Terminate(t)
|
defer clus.Terminate(t)
|
||||||
|
|
||||||
cli := clus.Client(0)
|
cli := clus.Client(0)
|
||||||
|
defer cli.Close()
|
||||||
wc := clientv3.NewWatcher(cli)
|
wc := clientv3.NewWatcher(cli)
|
||||||
|
|
||||||
donec := make(chan struct{})
|
donec := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
defer close(donec)
|
defer close(donec)
|
||||||
wc.Watch(context.TODO(), "foo")
|
ch := wc.Watch(context.TODO(), "foo")
|
||||||
if err := wc.Close(); err != nil && err != grpc.ErrClientConnClosing {
|
if wr := <-ch; grpc.ErrorDesc(wr.Err()) != grpc.ErrClientConnClosing.Error() {
|
||||||
t.Fatalf("expected %v, got %v", grpc.ErrClientConnClosing, err)
|
t.Fatalf("expected %v, got %v", grpc.ErrClientConnClosing, grpc.ErrorDesc(wr.Err()))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err := cli.Close(); err != nil {
|
if err := cli.ActiveConnection().Close(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
clus.TakeClient(0)
|
clus.TakeClient(0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user