resolver: try servers in a random order on each resolution (closes #138)
check / check (push) Successful in 1m42s
check / check (push) Successful in 1m42s
Every resolution walked the root servers in a fixed order, so a.root-servers.net got every first query and its timeouts were paid on every lookup. Each list of servers the resolver walks is now walked in a random order from rand.Shuffle, chosen anew each time; a server that does not reply, refuses, or gives an error reply or a referral that leads no closer is still passed over for the next. When a referral names a zone's nameservers without their addresses, all of them are now looked up, not only the first that resolves, so the zone is not given up because the first nameserver whose address was found gave no usable reply. No test fails if the walk stops shuffling: which server a live query reached is not observable. Model: opus-5-5
This commit was merged in pull request #199.
This commit is contained in:
@@ -383,3 +383,37 @@ func liveResolveIPsAllowingEmpty(
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
// liveResolveNSIPs looks up the addresses of the nameservers named
|
||||
// names, retrying until there are at least atLeast of them: a name
|
||||
// whose lookup got no reply is left out of the result, not an error.
|
||||
func liveResolveNSIPs(
|
||||
t *testing.T,
|
||||
r *resolver.Resolver,
|
||||
names []string,
|
||||
atLeast int,
|
||||
) []string {
|
||||
t.Helper()
|
||||
|
||||
var out []string
|
||||
|
||||
livednstest.Retry(
|
||||
t,
|
||||
"ResolveNSIPs("+strings.Join(names, ", ")+")",
|
||||
func(ctx context.Context) error {
|
||||
ips := r.ResolveNSIPs(ctx, names)
|
||||
if len(ips) < atLeast {
|
||||
return fmt.Errorf(
|
||||
"%w: %d addresses, expected at least %d",
|
||||
livednstest.ErrNoAnswer, len(ips), atLeast,
|
||||
)
|
||||
}
|
||||
|
||||
out = ips
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user