mirror of
https://github.com/status-im/consul.git
synced 2025-02-20 17:38:24 +00:00
Adds a new gRPC service and endpoint to return the list of supported consul dataplane features. The Consul Dataplane will use this API to customize its interaction with that particular server.
41 lines
825 B
Go
41 lines
825 B
Go
package dataplane
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/consul/proto-public/pbdataplane"
|
|
"github.com/stretchr/testify/require"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
func testClient(t *testing.T, server *Server) pbdataplane.DataplaneServiceClient {
|
|
t.Helper()
|
|
|
|
addr := RunTestServer(t, server)
|
|
|
|
conn, err := grpc.DialContext(context.Background(), addr.String(), grpc.WithInsecure())
|
|
require.NoError(t, err)
|
|
t.Cleanup(func() {
|
|
require.NoError(t, conn.Close())
|
|
})
|
|
|
|
return pbdataplane.NewDataplaneServiceClient(conn)
|
|
}
|
|
|
|
func RunTestServer(t *testing.T, server *Server) net.Addr {
|
|
t.Helper()
|
|
|
|
lis, err := net.Listen("tcp", "127.0.0.1:0")
|
|
require.NoError(t, err)
|
|
|
|
grpcServer := grpc.NewServer()
|
|
server.Register(grpcServer)
|
|
|
|
go grpcServer.Serve(lis)
|
|
t.Cleanup(grpcServer.Stop)
|
|
|
|
return lis.Addr()
|
|
}
|