Matt Keeler 7ce2b48cb7
Implement the ServerDiscovery.WatchServers gRPC endpoint (#12819)
* Implement the ServerDiscovery.WatchServers gRPC endpoint
* Fix the ConnectCA.Sign gRPC endpoints metadata forwarding.
* Unify public gRPC endpoints around the public.TraceID function for request_id logging
2022-04-21 12:56:18 -04:00

31 lines
496 B
Go

package testutils
import (
"net"
"testing"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
)
type GRPCService interface {
Register(*grpc.Server)
}
func RunTestServer(t *testing.T, services ...GRPCService) net.Addr {
t.Helper()
lis, err := net.Listen("tcp", "127.0.0.1:0")
require.NoError(t, err)
grpcServer := grpc.NewServer()
for _, svc := range services {
svc.Register(grpcServer)
}
go grpcServer.Serve(lis)
t.Cleanup(grpcServer.Stop)
return lis.Addr()
}