|
|
|
@ -1991,29 +1991,55 @@ func TestDNS_ServiceLookup_LargeResponses(t *testing.T) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
m := new(dns.Msg) |
|
|
|
|
m.SetQuestion("_"+longServiceName+"._master.service.consul.", dns.TypeSRV) |
|
|
|
|
|
|
|
|
|
c := new(dns.Client) |
|
|
|
|
addr, _ := srv.agent.config.ClientListener("", srv.agent.config.Ports.DNS) |
|
|
|
|
in, _, err := c.Exchange(m, addr.String()) |
|
|
|
|
if err != nil && err != dns.ErrTruncated { |
|
|
|
|
t.Fatalf("err: %v", err) |
|
|
|
|
// Register an equivalent prepared query.
|
|
|
|
|
{ |
|
|
|
|
args := &structs.PreparedQueryRequest{ |
|
|
|
|
Datacenter: "dc1", |
|
|
|
|
Op: structs.PreparedQueryCreate, |
|
|
|
|
Query: &structs.PreparedQuery{ |
|
|
|
|
Name: longServiceName, |
|
|
|
|
Service: structs.ServiceQuery{ |
|
|
|
|
Service: longServiceName, |
|
|
|
|
Tags: []string{"master"}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
var id string |
|
|
|
|
if err := srv.agent.RPC("PreparedQuery.Apply", args, &id); err != nil { |
|
|
|
|
t.Fatalf("err: %v", err) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Make sure the response size is RFC 1035-compliant for UDP messages
|
|
|
|
|
if in.Len() > 512 { |
|
|
|
|
t.Fatalf("Bad: %#v", in.Len()) |
|
|
|
|
// Look up the service directly and via prepared query.
|
|
|
|
|
questions := []string{ |
|
|
|
|
"_" + longServiceName + "._master.service.consul.", |
|
|
|
|
longServiceName + ".query.consul.", |
|
|
|
|
} |
|
|
|
|
for _, question := range questions { |
|
|
|
|
m := new(dns.Msg) |
|
|
|
|
m.SetQuestion(question, dns.TypeSRV) |
|
|
|
|
|
|
|
|
|
// We should only have two answers now
|
|
|
|
|
if len(in.Answer) != 2 { |
|
|
|
|
t.Fatalf("Bad: %#v", len(in.Answer)) |
|
|
|
|
} |
|
|
|
|
c := new(dns.Client) |
|
|
|
|
addr, _ := srv.agent.config.ClientListener("", srv.agent.config.Ports.DNS) |
|
|
|
|
in, _, err := c.Exchange(m, addr.String()) |
|
|
|
|
if err != nil && err != dns.ErrTruncated { |
|
|
|
|
t.Fatalf("err: %v", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Make sure the response size is RFC 1035-compliant for UDP messages
|
|
|
|
|
if in.Len() > 512 { |
|
|
|
|
t.Fatalf("Bad: %#v", in.Len()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// We should only have two answers now
|
|
|
|
|
if len(in.Answer) != 2 { |
|
|
|
|
t.Fatalf("Bad: %#v", len(in.Answer)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Check for the truncate bit
|
|
|
|
|
if !in.Truncated { |
|
|
|
|
t.Fatalf("should have truncate bit") |
|
|
|
|
// Check for the truncate bit
|
|
|
|
|
if !in.Truncated { |
|
|
|
|
t.Fatalf("should have truncate bit") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|