Skip to content

Commit

Permalink
Resolve feedbacks.
Browse files Browse the repository at this point in the history
  • Loading branch information
and1truong committed Mar 1, 2024
1 parent d9dcc72 commit a0ce76b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions internal/resolver/dns/dns_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ func overrideResolveTimeoutDuration(t *testing.T, dur time.Duration) {
t.Cleanup(func() { dnspublic.SetResolvingTimeout(origDur) })
}

// Test verifies that when the DNS resolver gets timeout error when net.Resolver
// Test verifies that the DNS resolver gets timeout error when net.Resolver
// takes too long to resolve a target.
func (s) TestResolveTimeout(t *testing.T) {
// Set DNS resolving timeout duration to 7ms
Expand All @@ -1242,13 +1242,11 @@ func (s) TestResolveTimeout(t *testing.T) {
// Define a testNetResolver with lookupHostCh, an unbuffered channel,
// so we can block the resolver until reaching timeout.
tr := &testNetResolver{
lookupHostCh: testutils.NewChannel(),
lookupHostCh: testutils.NewChannelWithSize(0),
hostLookupTable: map[string][]string{target: {"1.2.3.4"}},
}
overrideNetResolver(t, tr)

// block testNetResolver.testNetResolver until timeout
_ = tr.lookupHostCh.SendContext(ctx, nil)
_, _, errCh := buildResolverWithTestClientConn(t, target)
select {
case <-ctx.Done():
Expand Down
2 changes: 1 addition & 1 deletion internal/resolver/dns/fake_net_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type testNetResolver struct {

func (tr *testNetResolver) LookupHost(ctx context.Context, host string) ([]string, error) {
if tr.lookupHostCh != nil {
if err := tr.lookupHostCh.SendContext(ctx, nil); nil != err {
if err := tr.lookupHostCh.SendContext(ctx, nil); err != nil {
return nil, err
}
}
Expand Down

0 comments on commit a0ce76b

Please sign in to comment.