Skip to content

Commit

Permalink
Use passthrough resolver when bufnet is used
Browse files Browse the repository at this point in the history
  • Loading branch information
ash2k committed May 29, 2024
1 parent 1e8c7ca commit c35baf5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func benchmark(b *testing.B, cOpt []grpc.DialOption, sOpt []grpc.ServerOption) {
ctx := context.Background()
dial := func(context.Context, string) (net.Conn, error) { return l.Dial() }
conn, err := grpc.NewClient(
"bufnet",
"passthrough:bufnet",
append([]grpc.DialOption{
grpc.WithContextDialer(dial),
grpc.WithTransportCredentials(insecure.NewCredentials()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ func newGrpcTest(t testing.TB, listener net.Listener, cOpt []grpc.DialOption, sO

cOpt = append(cOpt, grpc.WithTransportCredentials(insecure.NewCredentials()))

dialAddr := listener.Addr().String()

if l, ok := listener.(interface{ Dial() (net.Conn, error) }); ok {
dial := func(context.Context, string) (net.Conn, error) { return l.Dial() }
cOpt = append(cOpt, grpc.WithContextDialer(dial))
dialAddr = "passthrough:" + dialAddr
}

conn, err := grpc.NewClient(
listener.Addr().String(),
dialAddr,
cOpt...,
)
require.NoError(t, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func ctxDialer() func(context.Context, string) (net.Conn, error) {
}

func TestUnaryClientInterceptor(t *testing.T) {
clientConn, err := grpc.NewClient("fake:8906",
clientConn, err := grpc.NewClient("passthrough:fake",
grpc.WithContextDialer(ctxDialer()),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
Expand Down Expand Up @@ -375,7 +375,7 @@ func newMockClientStream(opts clientStreamOpts) *mockClientStream {

func createInterceptedStreamClient(t *testing.T, method string, opts clientStreamOpts) (grpc.ClientStream, *tracetest.SpanRecorder) {
mockStream := newMockClientStream(opts)
clientConn, err := grpc.NewClient("fake:8906",
clientConn, err := grpc.NewClient("passthrough:fake",
grpc.WithContextDialer(ctxDialer()),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
Expand Down Expand Up @@ -626,7 +626,7 @@ func TestStreamClientInterceptorOnUnidirectionalClientServerStream(t *testing.T)
func TestStreamClientInterceptorCancelContext(t *testing.T) {
defer goleak.VerifyNone(t)

clientConn, err := grpc.NewClient("fake:8906",
clientConn, err := grpc.NewClient("passthrough:fake",
grpc.WithContextDialer(ctxDialer()),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
Expand Down Expand Up @@ -687,7 +687,7 @@ func TestStreamClientInterceptorCancelContext(t *testing.T) {
func TestStreamClientInterceptorWithError(t *testing.T) {
defer goleak.VerifyNone(t)

clientConn, err := grpc.NewClient("fake:8906",
clientConn, err := grpc.NewClient("passthrough:fake",
grpc.WithContextDialer(ctxDialer()),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
Expand Down

0 comments on commit c35baf5

Please sign in to comment.