GH-3798: Wrap DNS request validation in a retry

This commit is contained in:
Matt Keeler 2018-04-11 16:00:15 -04:00
parent 059d0f07de
commit 300f7f388e
1 changed files with 36 additions and 28 deletions

View File

@ -1925,7 +1925,7 @@ func TestDNS_PreparedQueryNearIP(t *testing.T) {
err := a.RPC("PreparedQuery.Apply", args, &id)
require.NoError(t, err)
}
retry.Run(t, func(r *retry.R) {
m :=new(dns.Msg)
m.SetQuestion("some.query.we.like.query.consul.", dns.TypeA)
m.SetEdns0(4096, false)
@ -1943,16 +1943,24 @@ func TestDNS_PreparedQueryNearIP(t *testing.T) {
c := new(dns.Client)
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 {
aRec, ok := rr.(*dns.A);
require.Truef(t, ok, "DNS Answer contained a non A RR")
actual := aRec.A.String()
require.Equalf(t, serviceNodes[i].address, actual, "Expecting A RR #%d = %s, Actual RR was %s", i, serviceNodes[i].address, actual)
if aRec, ok := rr.(*dns.A); ok {
if actual := aRec.A.String(); serviceNodes[i].address != actual {
r.Fatalf("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) {