|
|
|
@ -277,3 +277,94 @@ func TestCatalog_Registration(t *testing.T) {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestCatalog_EnableTagOverride(t *testing.T) {
|
|
|
|
|
t.Parallel()
|
|
|
|
|
c, s := makeClient(t)
|
|
|
|
|
defer s.Stop()
|
|
|
|
|
|
|
|
|
|
catalog := c.Catalog()
|
|
|
|
|
|
|
|
|
|
service := &AgentService{
|
|
|
|
|
ID: "redis1",
|
|
|
|
|
Service: "redis",
|
|
|
|
|
Tags: []string{"master", "v1"},
|
|
|
|
|
Port: 8000,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reg := &CatalogRegistration{
|
|
|
|
|
Datacenter: "dc1",
|
|
|
|
|
Node: "foobar",
|
|
|
|
|
Address: "192.168.10.10",
|
|
|
|
|
Service: service,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
testutil.WaitForResult(func() (bool, error) {
|
|
|
|
|
if _, err := catalog.Register(reg, nil); err != nil {
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
node, _, err := catalog.Node("foobar", nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if _, ok := node.Services["redis1"]; !ok {
|
|
|
|
|
return false, fmt.Errorf("missing service: redis1")
|
|
|
|
|
}
|
|
|
|
|
if node.Services["redis1"].EnableTagOverride != false {
|
|
|
|
|
return false, fmt.Errorf("tag override set")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
services, _, err := catalog.Service("redis", "", nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(services) < 1 || services[0].ServiceName != "redis" {
|
|
|
|
|
return false, fmt.Errorf("missing service: redis")
|
|
|
|
|
}
|
|
|
|
|
if services[0].ServiceEnableTagOverride != false {
|
|
|
|
|
return false, fmt.Errorf("tag override set")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true, nil
|
|
|
|
|
}, func(err error) {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
service.EnableTagOverride = true
|
|
|
|
|
testutil.WaitForResult(func() (bool, error) {
|
|
|
|
|
if _, err := catalog.Register(reg, nil); err != nil {
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
node, _, err := catalog.Node("foobar", nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if _, ok := node.Services["redis1"]; !ok {
|
|
|
|
|
return false, fmt.Errorf("missing service: redis1")
|
|
|
|
|
}
|
|
|
|
|
if node.Services["redis1"].EnableTagOverride != true {
|
|
|
|
|
return false, fmt.Errorf("tag override not set")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
services, _, err := catalog.Service("redis", "", nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(services) < 1 || services[0].ServiceName != "redis" {
|
|
|
|
|
return false, fmt.Errorf("missing service: redis")
|
|
|
|
|
}
|
|
|
|
|
if services[0].ServiceEnableTagOverride != true {
|
|
|
|
|
return false, fmt.Errorf("tag override not set")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true, nil
|
|
|
|
|
}, func(err error) {
|
|
|
|
|
t.Fatalf("err: %s", err)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|