mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
integration: add lock and election services to proxy tests
This commit is contained in:
parent
713e006bc6
commit
00da3ca725
@ -935,4 +935,8 @@ type grpcAPI struct {
|
||||
Maintenance pb.MaintenanceClient
|
||||
// Auth is the authentication API for the client's connection.
|
||||
Auth pb.AuthClient
|
||||
// Lock is the lock API for the client's connection.
|
||||
Lock lockpb.LockClient
|
||||
// Election is the election API for the client's connection.
|
||||
Election epb.ElectionClient
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ package integration
|
||||
|
||||
import (
|
||||
"github.com/coreos/etcd/clientv3"
|
||||
"github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb"
|
||||
"github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb"
|
||||
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
|
||||
)
|
||||
|
||||
@ -29,6 +31,8 @@ func toGRPC(c *clientv3.Client) grpcAPI {
|
||||
pb.NewWatchClient(c.ActiveConnection()),
|
||||
pb.NewMaintenanceClient(c.ActiveConnection()),
|
||||
pb.NewAuthClient(c.ActiveConnection()),
|
||||
v3lockpb.NewLockClient(c.ActiveConnection()),
|
||||
v3electionpb.NewElectionClient(c.ActiveConnection()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,8 @@ func toGRPC(c *clientv3.Client) grpcAPI {
|
||||
lp, lpch := grpcproxy.NewLeaseProxy(c)
|
||||
mp := grpcproxy.NewMaintenanceProxy(c)
|
||||
clp, _ := grpcproxy.NewClusterProxy(c, "", "") // without registering proxy URLs
|
||||
lockp := grpcproxy.NewLockProxy(c)
|
||||
electp := grpcproxy.NewElectionProxy(c)
|
||||
|
||||
grpc := grpcAPI{
|
||||
adapter.ClusterServerToClusterClient(clp),
|
||||
@ -66,6 +68,8 @@ func toGRPC(c *clientv3.Client) grpcAPI {
|
||||
adapter.WatchServerToWatchClient(wp),
|
||||
adapter.MaintenanceServerToMaintenanceClient(mp),
|
||||
pb.NewAuthClient(c.ActiveConnection()),
|
||||
adapter.LockServerToLockClient(lockp),
|
||||
adapter.ElectionServerToElectionClient(electp),
|
||||
}
|
||||
proxies[c] = grpcClientProxy{grpc: grpc, wdonec: wpch, kvdonec: kvpch, lpdonec: lpch}
|
||||
return grpc
|
||||
|
@ -41,7 +41,7 @@ func TestV3ElectionCampaign(t *testing.T) {
|
||||
t.Fatal(err2)
|
||||
}
|
||||
|
||||
lc := epb.NewElectionClient(clus.Client(0).ActiveConnection())
|
||||
lc := toGRPC(clus.Client(0)).Election
|
||||
req1 := &epb.CampaignRequest{Name: []byte("foo"), Lease: lease1.ID, Value: []byte("abc")}
|
||||
l1, lerr1 := lc.Campaign(context.TODO(), req1)
|
||||
if lerr1 != nil {
|
||||
@ -94,7 +94,7 @@ func TestV3ElectionObserve(t *testing.T) {
|
||||
clus := NewClusterV3(t, &ClusterConfig{Size: 1})
|
||||
defer clus.Terminate(t)
|
||||
|
||||
lc := epb.NewElectionClient(clus.Client(0).ActiveConnection())
|
||||
lc := toGRPC(clus.Client(0)).Election
|
||||
|
||||
// observe leadership events
|
||||
observec := make(chan struct{})
|
||||
|
@ -40,7 +40,7 @@ func TestV3LockLockWaiter(t *testing.T) {
|
||||
t.Fatal(err2)
|
||||
}
|
||||
|
||||
lc := lockpb.NewLockClient(clus.Client(0).ActiveConnection())
|
||||
lc := toGRPC(clus.Client(0)).Lock
|
||||
l1, lerr1 := lc.Lock(context.TODO(), &lockpb.LockRequest{Name: []byte("foo"), Lease: lease1.ID})
|
||||
if lerr1 != nil {
|
||||
t.Fatal(lerr1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user