check / check (push) Canceled after 0s
The resolver lists in FailedTypes each record type whose query to a nameserver got no usable reply (none after two tries, an error reply, a referral, or a truncated reply whose TCP retry failed), and logs it with the reason. A nameserver that answered no type has failed, as before. The watcher saves such a type in failedTypes, keeping the previous check's records, leaves it out of the comparison with other nameservers on that check, and compares the kept records with the next answer. With nothing to keep, it is also in unknownTypes and not compared until it answers. Change messages leave out what was not compared. A nameserver whose A, AAAA or CNAME query failed is no answer when following a CNAME or resolving addresses. Model: opus-5-5
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
package resolver
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// TestClassifyResponse sets a nameserver's status from the results of
|
|
// its queries, built here. One that answered some record types, even
|
|
// with no records, has not failed when its query for another type timed
|
|
// out; one whose every query timed out has.
|
|
func TestClassifyResponse(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
results queryState
|
|
wantStatus string
|
|
wantError string
|
|
}{
|
|
{
|
|
"some types answered with no records, another timed out",
|
|
queryState{answered: true, gotTimeout: true},
|
|
StatusNoData, "",
|
|
},
|
|
{
|
|
"every query timed out",
|
|
queryState{gotTimeout: true},
|
|
StatusTimeout, "all queries timed out",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
resp := &NameserverResponse{Status: StatusOK}
|
|
classifyResponse(resp, tt.results)
|
|
|
|
assert.Equal(t, tt.wantStatus, resp.Status)
|
|
assert.Equal(t, tt.wantError, resp.Error)
|
|
})
|
|
}
|
|
}
|