@@ -22,7 +22,6 @@ import (
22
22
"encoding/json"
23
23
"net"
24
24
"testing"
25
- "time"
26
25
27
26
"google.golang.org/grpc"
28
27
"google.golang.org/grpc/credentials"
@@ -44,8 +43,6 @@ func Test(t *testing.T) {
44
43
grpctest .RunSubTests (t , s {})
45
44
}
46
45
47
- const defaultTestTimeout = 10 * time .Second
48
-
49
46
var noopRecvHandler = func (_ transport.ResourceUpdate , onDone func ()) error {
50
47
onDone ()
51
48
return nil
@@ -111,17 +108,10 @@ const testDialerCredsBuilderName = "test_dialer_creds"
111
108
// testDialerCredsBuilder implements the `Credentials` interface defined in
112
109
// package `xds/bootstrap` and encapsulates an insecure credential with a
113
110
// custom Dialer that specifies how to dial the xDS server.
114
- type testDialerCredsBuilder struct {
115
- // Closed with the custom Dialer is invoked.
116
- // Needs to be passed in by the test.
117
- dialCalled chan struct {}
118
- }
111
+ type testDialerCredsBuilder struct {}
119
112
120
113
func (t * testDialerCredsBuilder ) Build (json.RawMessage ) (credentials.Bundle , func (), error ) {
121
- return & testDialerCredsBundle {
122
- Bundle : insecure .NewBundle (),
123
- dialCalled : t .dialCalled ,
124
- }, func () {}, nil
114
+ return & testDialerCredsBundle {insecure .NewBundle ()}, func () {}, nil
125
115
}
126
116
127
117
func (t * testDialerCredsBuilder ) Name () string {
@@ -133,12 +123,10 @@ func (t *testDialerCredsBuilder) Name() string {
133
123
// that specifies how to dial the xDS server.
134
124
type testDialerCredsBundle struct {
135
125
credentials.Bundle
136
- dialCalled chan struct {}
137
126
}
138
127
139
- func (t * testDialerCredsBundle ) Dialer (_ context.Context , address string ) (net.Conn , error ) {
140
- close (t .dialCalled )
141
- return net .Dial ("tcp" , address )
128
+ func (t * testDialerCredsBundle ) Dialer (context.Context , string ) (net.Conn , error ) {
129
+ return nil , nil
142
130
}
143
131
144
132
func (s ) TestNewWithDialerFromCredentialsBundle (t * testing.T ) {
@@ -152,16 +140,17 @@ func (s) TestNewWithDialerFromCredentialsBundle(t *testing.T) {
152
140
internal .GRPCNewClient = customGRPCNewClient
153
141
defer func () { internal .GRPCNewClient = oldGRPCNewClient }()
154
142
155
- dialCalled := make (chan struct {})
156
- bootstrap .RegisterCredentials (& testDialerCredsBuilder {dialCalled : dialCalled })
143
+ bootstrap .RegisterCredentials (& testDialerCredsBuilder {})
157
144
serverCfg , err := internalbootstrap .ServerConfigForTesting (internalbootstrap.ServerConfigTestingOptions {
158
145
URI : "trafficdirector.googleapis.com:443" ,
159
146
ChannelCreds : []internalbootstrap.ChannelCreds {{Type : testDialerCredsBuilderName }},
160
147
})
161
148
if err != nil {
162
149
t .Fatalf ("Failed to create server config for testing: %v" , err )
163
150
}
164
-
151
+ if serverCfg .DialerOption () == nil {
152
+ t .Fatalf ("Dialer for xDS transport in server config for testing is nil, want non-nil" )
153
+ }
165
154
// Create a new transport.
166
155
opts := transport.Options {
167
156
ServerCfg : serverCfg ,
@@ -182,11 +171,6 @@ func (s) TestNewWithDialerFromCredentialsBundle(t *testing.T) {
182
171
if err != nil {
183
172
t .Fatalf ("transport.New(%v) failed: %v" , opts , err )
184
173
}
185
- select {
186
- case <- dialCalled :
187
- case <- time .After (defaultTestTimeout ):
188
- t .Fatal ("Timeout when waiting for Dialer() to be invoked" )
189
- }
190
174
// Verify there are three dial options passed to the custom grpc.NewClient.
191
175
// The first is opts.ServerCfg.CredsDialOption(), the second is
192
176
// grpc.WithKeepaliveParams(), and the third is opts.ServerCfg.DialerOption()
0 commit comments