agent: Fixing bug in dns service filtering

This commit is contained in:
Armon Dadgar 2014-02-23 18:04:12 -08:00
parent 38317d4890
commit 8fdbf95452
2 changed files with 21 additions and 1 deletions

View File

@ -384,6 +384,7 @@ func (d *DNSServer) filterServiceNodes(nodes structs.CheckServiceNodes) structs.
node.Node.Node, check.CheckID, check.Name, node.Service.Service) node.Node.Node, check.CheckID, check.Name, node.Service.Service)
nodes[i], nodes[n-1] = nodes[n-1], structs.CheckServiceNode{} nodes[i], nodes[n-1] = nodes[n-1], structs.CheckServiceNode{}
n-- n--
i--
} }
} }
} }

View File

@ -332,7 +332,7 @@ func TestDNS_ServiceLookup_FilterCritical(t *testing.T) {
// Wait for leader // Wait for leader
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
// Register node // Register nodes
args := &structs.RegisterRequest{ args := &structs.RegisterRequest{
Datacenter: "dc1", Datacenter: "dc1",
Node: "foo", Node: "foo",
@ -353,6 +353,25 @@ func TestDNS_ServiceLookup_FilterCritical(t *testing.T) {
t.Fatalf("err: %v", err) t.Fatalf("err: %v", err)
} }
args2 := &structs.RegisterRequest{
Datacenter: "dc1",
Node: "bar",
Address: "127.0.0.2",
Service: &structs.NodeService{
Service: "db",
Tag: "master",
Port: 12345,
},
Check: &structs.HealthCheck{
CheckID: "serf",
Name: "serf",
Status: structs.HealthCritical,
},
}
if err := srv.agent.RPC("Catalog.Register", args2, &out); err != nil {
t.Fatalf("err: %v", err)
}
m := new(dns.Msg) m := new(dns.Msg)
m.SetQuestion("db.service.consul.", dns.TypeANY) m.SetQuestion("db.service.consul.", dns.TypeANY)