mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
integration: update tests for new grpc reconnection interface
This commit is contained in:
parent
62f8ec25c0
commit
7abc8f21eb
@ -909,30 +909,15 @@ func TestTLSGRPCRejectInsecureClient(t *testing.T) {
|
||||
}
|
||||
defer client.Close()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Second)
|
||||
conn := client.ActiveConnection()
|
||||
st, err := conn.State()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if st != grpc.Ready {
|
||||
t.Fatalf("expected Ready, got %v", st)
|
||||
}
|
||||
|
||||
// rpc will fail to handshake, triggering a connection state change
|
||||
donec := make(chan error, 1)
|
||||
go func() {
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Second)
|
||||
reqput := &pb.PutRequest{Key: []byte("foo"), Value: []byte("bar")}
|
||||
_, perr := toGRPC(client).KV.Put(ctx, reqput)
|
||||
cancel()
|
||||
donec <- perr
|
||||
}()
|
||||
|
||||
st, err = conn.WaitForStateChange(ctx, st)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error waiting for change (%v)", err)
|
||||
} else if st == grpc.Ready {
|
||||
t.Fatalf("expected failure state, got %v", st)
|
||||
}
|
||||
cancel()
|
||||
if perr := <-donec; perr == nil {
|
||||
t.Fatalf("expected client error on put")
|
||||
}
|
||||
|
@ -983,7 +983,7 @@ func TestV3WatchClose(t *testing.T) {
|
||||
clus := NewClusterV3(t, &ClusterConfig{Size: 1})
|
||||
defer clus.Terminate(t)
|
||||
|
||||
c := clus.RandClient()
|
||||
c := clus.Client(0)
|
||||
wapi := toGRPC(c).Watch
|
||||
|
||||
var wg sync.WaitGroup
|
||||
@ -1007,6 +1007,7 @@ func TestV3WatchClose(t *testing.T) {
|
||||
ws.Recv()
|
||||
}()
|
||||
}
|
||||
c.ActiveConnection().Close()
|
||||
|
||||
clus.Members[0].DropConnections()
|
||||
wg.Wait()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user