瀏覽代碼

integration: add lock and election services to proxy tests

Anthony Romano 8 年之前
父節點
當前提交
00da3ca725

+ 4 - 0
integration/cluster.go

@@ -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
 }

+ 4 - 0
integration/cluster_direct.go

@@ -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()),
 	}
 }
 

+ 4 - 0
integration/cluster_proxy.go

@@ -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

+ 2 - 2
integration/v3election_grpc_test.go

@@ -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{})

+ 1 - 1
integration/v3lock_grpc_test.go

@@ -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)