Skip to content

Commit d9dcc72

Browse files
committed
Resolve feedbacks.
1 parent 40a85c3 commit d9dcc72

File tree

3 files changed

+7
-22
lines changed

3 files changed

+7
-22
lines changed

internal/resolver/dns/dns_resolver_test.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ func (s) TestResolveTimeout(t *testing.T) {
12331233
overrideResolveTimeoutDuration(t, timeoutDur)
12341234

12351235
// context with a bit larger
1236-
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
1236+
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
12371237
defer cancel()
12381238

12391239
// We are trying to resolve hostname which takes infinity time to resolve.
@@ -1249,23 +1249,13 @@ func (s) TestResolveTimeout(t *testing.T) {
12491249

12501250
// block testNetResolver.testNetResolver until timeout
12511251
_ = tr.lookupHostCh.SendContext(ctx, nil)
1252-
_, stateCh, errCh := buildResolverWithTestClientConn(t, target)
1253-
1254-
// wait until timeout
1255-
<-ctx.Done()
1256-
1257-
// unblock testNetResolver.lookupHostCh channel
1258-
if _, ok := tr.lookupHostCh.ReceiveOrFail(); !ok {
1259-
t.Fatalf("failed for lookup() call.")
1260-
}
1261-
1252+
_, _, errCh := buildResolverWithTestClientConn(t, target)
12621253
select {
1254+
case <-ctx.Done():
1255+
t.Fatal("Timeout when waiting for the DNS resolver to timeout")
12631256
case err := <-errCh:
1264-
if err == nil || !strings.Contains(err.Error(), "hostLookup timeout") {
1257+
if err == nil || !strings.Contains(err.Error(), "context deadline exceeded") {
12651258
t.Fatalf(`We expect to see timed out error`)
12661259
}
1267-
1268-
case <-stateCh:
1269-
t.Fatalf(`We expect to see timed out error`)
12701260
}
12711261
}

internal/resolver/dns/fake_net_resolver_test.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,7 @@ type testNetResolver struct {
4242
func (tr *testNetResolver) LookupHost(ctx context.Context, host string) ([]string, error) {
4343
if tr.lookupHostCh != nil {
4444
if err := tr.lookupHostCh.SendContext(ctx, nil); nil != err {
45-
return nil, &net.DNSError{
46-
Err: "hostLookup timeout",
47-
Name: host,
48-
Server: "fake",
49-
IsTemporary: true,
50-
}
45+
return nil, err
5146
}
5247
}
5348

resolver/dns/dns_resolver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737
// It must be called only at application startup, before any gRPC calls are made.
3838
// Modifying this value after initialization is not thread-safe.
3939
//
40-
// The default value is 10 seconds. Setting the timeout too low may result
40+
// The default value is 30 seconds. Setting the timeout too low may result
4141
// in premature timeouts during resolution, while setting it too high may
4242
// lead to unnecessary delays in service discovery. Choose a value appropriate
4343
// for your specific needs and network environment.

0 commit comments

Comments
 (0)