@@ -28,10 +28,15 @@ import (
28
28
"github.com/stretchr/testify/assert"
29
29
"github.com/stretchr/testify/require"
30
30
31
+ "google.golang.org/grpc"
32
+ "google.golang.org/grpc/credentials/insecure"
33
+
34
+ "vitess.io/vitess/go/vt/grpcclient"
31
35
"vitess.io/vitess/go/vt/topo"
32
36
"vitess.io/vitess/go/vt/vtenv"
33
37
"vitess.io/vitess/go/vt/vttablet/tabletserver/connpool"
34
38
"vitess.io/vitess/go/vt/vttablet/tabletserver/tabletenv"
39
+ "vitess.io/vitess/go/vt/vttablet/tabletserver/throttle/base"
35
40
"vitess.io/vitess/go/vt/vttablet/tabletserver/throttle/config"
36
41
"vitess.io/vitess/go/vt/vttablet/tabletserver/throttle/mysql"
37
42
"vitess.io/vitess/go/vt/vttablet/tmclient"
@@ -157,6 +162,21 @@ func newTestThrottler() *Throttler {
157
162
return throttler
158
163
}
159
164
165
+ func TestIsDialTCPError (t * testing.T ) {
166
+ // Verify that IsDialTCPError actually recognizes grpc dial errors
167
+ cc , err := grpcclient .DialContext (context .Background (), ":0" , true , grpc .WithTransportCredentials (insecure .NewCredentials ()))
168
+ require .NoError (t , err )
169
+ defer cc .Close ()
170
+
171
+ err = cc .Invoke (context .Background (), "/Fail" , nil , nil )
172
+
173
+ require .True (t , base .IsDialTCPError (err ))
174
+ require .True (t , base .IsDialTCPError (fmt .Errorf ("wrapped: %w" , err )))
175
+
176
+ nonDialErr := fmt .Errorf ("rpc error: code = NotFound desc = method not found" )
177
+ require .False (t , base .IsDialTCPError (nonDialErr ))
178
+ }
179
+
160
180
func TestIsAppThrottled (t * testing.T ) {
161
181
throttler := Throttler {
162
182
throttledApps : cache .New (cache .NoExpiration , 0 ),
0 commit comments