GH-3798: Wrap DNS request validation in a retry

pull/4023/head
Matt Keeler 7 years ago
parent 8830b1a9fa
commit 283a7942c4

@ -1925,7 +1925,7 @@ func TestDNS_PreparedQueryNearIP(t *testing.T) {
err := a.RPC("PreparedQuery.Apply", args, &id) err := a.RPC("PreparedQuery.Apply", args, &id)
require.NoError(t, err) require.NoError(t, err)
} }
retry.Run(t, func(r *retry.R) {
m :=new(dns.Msg) m :=new(dns.Msg)
m.SetQuestion("some.query.we.like.query.consul.", dns.TypeA) m.SetQuestion("some.query.we.like.query.consul.", dns.TypeA)
m.SetEdns0(4096, false) m.SetEdns0(4096, false)
@ -1943,16 +1943,24 @@ func TestDNS_PreparedQueryNearIP(t *testing.T) {
c := new(dns.Client) c := new(dns.Client)
in, _, err := c.Exchange(m, a.DNSAddr()) in, _, err := c.Exchange(m, a.DNSAddr())
require.NoErrorf(t, err, "Error with call to dns.Client.Exchange: %s", err) if err != nil {
r.Fatalf("Error with call to dns.Client.Exchange: %s", err)
}
require.Equalf(t, len(serviceNodes), len(in.Answer), "Expecting %d A RRs in response, Actual found was %d", len(serviceNodes), len(in.Answer)) if len(serviceNodes) != len(in.Answer) {
r.Fatalf("Expecting %d A RRs in response, Actual found was %d", len(serviceNodes), len(in.Answer))
}
for i, rr := range in.Answer { for i, rr := range in.Answer {
aRec, ok := rr.(*dns.A); if aRec, ok := rr.(*dns.A); ok {
require.Truef(t, ok, "DNS Answer contained a non A RR") if actual := aRec.A.String(); serviceNodes[i].address != actual {
actual := aRec.A.String() r.Fatalf("Expecting A RR #%d = %s, Actual RR was %s", i, serviceNodes[i].address, actual)
require.Equalf(t, serviceNodes[i].address, actual, "Expecting A RR #%d = %s, Actual RR was %s", i, serviceNodes[i].address, actual) }
} else {
r.Fatalf("DNS Answer container a non-A RR")
} }
}
})
} }
func TestDNS_ServiceLookup_PreparedQueryNamePeriod(t *testing.T) { func TestDNS_ServiceLookup_PreparedQueryNamePeriod(t *testing.T) {

Loading…
Cancel
Save