mirror of https://github.com/status-im/consul.git
Revert "local state: drop retry loops from tests"
This reverts commit 2bdba8ab06
.
This commit is contained in:
parent
a3aa864d5b
commit
556bf3f85d
|
@ -123,8 +123,9 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
|
||||||
Node: a.Config.NodeName,
|
Node: a.Config.NodeName,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
retry.Run(t, func(r *retry.R) {
|
||||||
if err := a.RPC("Catalog.NodeServices", &req, &services); err != nil {
|
if err := a.RPC("Catalog.NodeServices", &req, &services); err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
r.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we sent along our node info when we synced.
|
// Make sure we sent along our node info when we synced.
|
||||||
|
@ -132,13 +133,13 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
|
||||||
addrs := services.NodeServices.Node.TaggedAddresses
|
addrs := services.NodeServices.Node.TaggedAddresses
|
||||||
meta := services.NodeServices.Node.Meta
|
meta := services.NodeServices.Node.Meta
|
||||||
delete(meta, structs.MetaSegmentKey) // Added later, not in config.
|
delete(meta, structs.MetaSegmentKey) // Added later, not in config.
|
||||||
verify.Values(t, "node id", id, a.Config.NodeID)
|
verify.Values(r, "node id", id, a.config.NodeID)
|
||||||
verify.Values(t, "tagged addrs", addrs, a.Config.TaggedAddresses)
|
verify.Values(r, "tagged addrs", addrs, a.config.TaggedAddresses)
|
||||||
verify.Values(t, "node meta", meta, a.Config.NodeMeta)
|
verify.Values(r, "node meta", meta, a.config.NodeMeta)
|
||||||
|
|
||||||
// We should have 6 services (consul included)
|
// We should have 6 services (consul included)
|
||||||
if len(services.NodeServices.Services) != 6 {
|
if len(services.NodeServices.Services) != 6 {
|
||||||
t.Fatalf("bad: %v", services.NodeServices.Services)
|
r.Fatalf("bad: %v", services.NodeServices.Services)
|
||||||
}
|
}
|
||||||
|
|
||||||
// All the services should match
|
// All the services should match
|
||||||
|
@ -147,34 +148,35 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
|
||||||
switch id {
|
switch id {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
if !reflect.DeepEqual(serv, srv1) {
|
if !reflect.DeepEqual(serv, srv1) {
|
||||||
t.Fatalf("bad: %v %v", serv, srv1)
|
r.Fatalf("bad: %v %v", serv, srv1)
|
||||||
}
|
}
|
||||||
case "redis":
|
case "redis":
|
||||||
if !reflect.DeepEqual(serv, srv2) {
|
if !reflect.DeepEqual(serv, srv2) {
|
||||||
t.Fatalf("bad: %#v %#v", serv, srv2)
|
r.Fatalf("bad: %#v %#v", serv, srv2)
|
||||||
}
|
}
|
||||||
case "web":
|
case "web":
|
||||||
if !reflect.DeepEqual(serv, srv3) {
|
if !reflect.DeepEqual(serv, srv3) {
|
||||||
t.Fatalf("bad: %v %v", serv, srv3)
|
r.Fatalf("bad: %v %v", serv, srv3)
|
||||||
}
|
}
|
||||||
case "api":
|
case "api":
|
||||||
if !reflect.DeepEqual(serv, srv5) {
|
if !reflect.DeepEqual(serv, srv5) {
|
||||||
t.Fatalf("bad: %v %v", serv, srv5)
|
r.Fatalf("bad: %v %v", serv, srv5)
|
||||||
}
|
}
|
||||||
case "cache":
|
case "cache":
|
||||||
if !reflect.DeepEqual(serv, srv6) {
|
if !reflect.DeepEqual(serv, srv6) {
|
||||||
t.Fatalf("bad: %v %v", serv, srv6)
|
r.Fatalf("bad: %v %v", serv, srv6)
|
||||||
}
|
}
|
||||||
case structs.ConsulServiceID:
|
case structs.ConsulServiceID:
|
||||||
// ignore
|
// ignore
|
||||||
default:
|
default:
|
||||||
t.Fatalf("unexpected service: %v", id)
|
r.Fatalf("unexpected service: %v", id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := servicesInSync(a.State, 5); err != nil {
|
if err := servicesInSync(a.State, 5); err != nil {
|
||||||
t.Fatal(err)
|
r.Fatal(err)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Remove one of the services
|
// Remove one of the services
|
||||||
a.State.RemoveService("api")
|
a.State.RemoveService("api")
|
||||||
|
@ -183,13 +185,14 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
retry.Run(t, func(r *retry.R) {
|
||||||
if err := a.RPC("Catalog.NodeServices", &req, &services); err != nil {
|
if err := a.RPC("Catalog.NodeServices", &req, &services); err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
r.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We should have 5 services (consul included)
|
// We should have 5 services (consul included)
|
||||||
if len(services.NodeServices.Services) != 5 {
|
if len(services.NodeServices.Services) != 5 {
|
||||||
t.Fatalf("bad: %v", services.NodeServices.Services)
|
r.Fatalf("bad: %v", services.NodeServices.Services)
|
||||||
}
|
}
|
||||||
|
|
||||||
// All the services should match
|
// All the services should match
|
||||||
|
@ -198,30 +201,31 @@ func TestAgentAntiEntropy_Services(t *testing.T) {
|
||||||
switch id {
|
switch id {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
if !reflect.DeepEqual(serv, srv1) {
|
if !reflect.DeepEqual(serv, srv1) {
|
||||||
t.Fatalf("bad: %v %v", serv, srv1)
|
r.Fatalf("bad: %v %v", serv, srv1)
|
||||||
}
|
}
|
||||||
case "redis":
|
case "redis":
|
||||||
if !reflect.DeepEqual(serv, srv2) {
|
if !reflect.DeepEqual(serv, srv2) {
|
||||||
t.Fatalf("bad: %#v %#v", serv, srv2)
|
r.Fatalf("bad: %#v %#v", serv, srv2)
|
||||||
}
|
}
|
||||||
case "web":
|
case "web":
|
||||||
if !reflect.DeepEqual(serv, srv3) {
|
if !reflect.DeepEqual(serv, srv3) {
|
||||||
t.Fatalf("bad: %v %v", serv, srv3)
|
r.Fatalf("bad: %v %v", serv, srv3)
|
||||||
}
|
}
|
||||||
case "cache":
|
case "cache":
|
||||||
if !reflect.DeepEqual(serv, srv6) {
|
if !reflect.DeepEqual(serv, srv6) {
|
||||||
t.Fatalf("bad: %v %v", serv, srv6)
|
r.Fatalf("bad: %v %v", serv, srv6)
|
||||||
}
|
}
|
||||||
case structs.ConsulServiceID:
|
case structs.ConsulServiceID:
|
||||||
// ignore
|
// ignore
|
||||||
default:
|
default:
|
||||||
t.Fatalf("unexpected service: %v", id)
|
r.Fatalf("unexpected service: %v", id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := servicesInSync(a.State, 4); err != nil {
|
if err := servicesInSync(a.State, 4); err != nil {
|
||||||
t.Fatal(err)
|
r.Fatal(err)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAgentAntiEntropy_EnableTagOverride(t *testing.T) {
|
func TestAgentAntiEntropy_EnableTagOverride(t *testing.T) {
|
||||||
|
@ -458,7 +462,8 @@ func TestAgentAntiEntropy_Services_ACLDeny(t *testing.T) {
|
||||||
acl_datacenter = "dc1"
|
acl_datacenter = "dc1"
|
||||||
acl_master_token = "root"
|
acl_master_token = "root"
|
||||||
acl_default_policy = "deny"
|
acl_default_policy = "deny"
|
||||||
acl_enforce_version_8 = true`}
|
acl_enforce_version_8 = true
|
||||||
|
`, NoInitialSync: true}
|
||||||
a.Start()
|
a.Start()
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
|
@ -682,13 +687,14 @@ func TestAgentAntiEntropy_Checks(t *testing.T) {
|
||||||
var checks structs.IndexedHealthChecks
|
var checks structs.IndexedHealthChecks
|
||||||
|
|
||||||
// Verify that we are in sync
|
// Verify that we are in sync
|
||||||
|
retry.Run(t, func(r *retry.R) {
|
||||||
if err := a.RPC("Health.NodeChecks", &req, &checks); err != nil {
|
if err := a.RPC("Health.NodeChecks", &req, &checks); err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
r.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We should have 5 checks (serf included)
|
// We should have 5 checks (serf included)
|
||||||
if len(checks.HealthChecks) != 5 {
|
if len(checks.HealthChecks) != 5 {
|
||||||
t.Fatalf("bad: %v", checks)
|
r.Fatalf("bad: %v", checks)
|
||||||
}
|
}
|
||||||
|
|
||||||
// All the checks should match
|
// All the checks should match
|
||||||
|
@ -697,26 +703,27 @@ func TestAgentAntiEntropy_Checks(t *testing.T) {
|
||||||
switch chk.CheckID {
|
switch chk.CheckID {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
if !reflect.DeepEqual(chk, chk1) {
|
if !reflect.DeepEqual(chk, chk1) {
|
||||||
t.Fatalf("bad: %v %v", chk, chk1)
|
r.Fatalf("bad: %v %v", chk, chk1)
|
||||||
}
|
}
|
||||||
case "redis":
|
case "redis":
|
||||||
if !reflect.DeepEqual(chk, chk2) {
|
if !reflect.DeepEqual(chk, chk2) {
|
||||||
t.Fatalf("bad: %v %v", chk, chk2)
|
r.Fatalf("bad: %v %v", chk, chk2)
|
||||||
}
|
}
|
||||||
case "web":
|
case "web":
|
||||||
if !reflect.DeepEqual(chk, chk3) {
|
if !reflect.DeepEqual(chk, chk3) {
|
||||||
t.Fatalf("bad: %v %v", chk, chk3)
|
r.Fatalf("bad: %v %v", chk, chk3)
|
||||||
}
|
}
|
||||||
case "cache":
|
case "cache":
|
||||||
if !reflect.DeepEqual(chk, chk5) {
|
if !reflect.DeepEqual(chk, chk5) {
|
||||||
t.Fatalf("bad: %v %v", chk, chk5)
|
r.Fatalf("bad: %v %v", chk, chk5)
|
||||||
}
|
}
|
||||||
case "serfHealth":
|
case "serfHealth":
|
||||||
// ignore
|
// ignore
|
||||||
default:
|
default:
|
||||||
t.Fatalf("unexpected check: %v", chk)
|
r.Fatalf("unexpected check: %v", chk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if err := checksInSync(a.State, 4); err != nil {
|
if err := checksInSync(a.State, 4); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -737,9 +744,9 @@ func TestAgentAntiEntropy_Checks(t *testing.T) {
|
||||||
addrs := services.NodeServices.Node.TaggedAddresses
|
addrs := services.NodeServices.Node.TaggedAddresses
|
||||||
meta := services.NodeServices.Node.Meta
|
meta := services.NodeServices.Node.Meta
|
||||||
delete(meta, structs.MetaSegmentKey) // Added later, not in config.
|
delete(meta, structs.MetaSegmentKey) // Added later, not in config.
|
||||||
verify.Values(t, "node id", id, a.Config.NodeID)
|
verify.Values(t, "node id", id, a.config.NodeID)
|
||||||
verify.Values(t, "tagged addrs", addrs, a.Config.TaggedAddresses)
|
verify.Values(t, "tagged addrs", addrs, a.config.TaggedAddresses)
|
||||||
verify.Values(t, "node meta", meta, a.Config.NodeMeta)
|
verify.Values(t, "node meta", meta, a.config.NodeMeta)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove one of the checks
|
// Remove one of the checks
|
||||||
|
@ -750,13 +757,14 @@ func TestAgentAntiEntropy_Checks(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that we are in sync
|
// Verify that we are in sync
|
||||||
|
retry.Run(t, func(r *retry.R) {
|
||||||
if err := a.RPC("Health.NodeChecks", &req, &checks); err != nil {
|
if err := a.RPC("Health.NodeChecks", &req, &checks); err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
r.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We should have 5 checks (serf included)
|
// We should have 5 checks (serf included)
|
||||||
if len(checks.HealthChecks) != 4 {
|
if len(checks.HealthChecks) != 4 {
|
||||||
t.Fatalf("bad: %v", checks)
|
r.Fatalf("bad: %v", checks)
|
||||||
}
|
}
|
||||||
|
|
||||||
// All the checks should match
|
// All the checks should match
|
||||||
|
@ -765,22 +773,23 @@ func TestAgentAntiEntropy_Checks(t *testing.T) {
|
||||||
switch chk.CheckID {
|
switch chk.CheckID {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
if !reflect.DeepEqual(chk, chk1) {
|
if !reflect.DeepEqual(chk, chk1) {
|
||||||
t.Fatalf("bad: %v %v", chk, chk1)
|
r.Fatalf("bad: %v %v", chk, chk1)
|
||||||
}
|
}
|
||||||
case "web":
|
case "web":
|
||||||
if !reflect.DeepEqual(chk, chk3) {
|
if !reflect.DeepEqual(chk, chk3) {
|
||||||
t.Fatalf("bad: %v %v", chk, chk3)
|
r.Fatalf("bad: %v %v", chk, chk3)
|
||||||
}
|
}
|
||||||
case "cache":
|
case "cache":
|
||||||
if !reflect.DeepEqual(chk, chk5) {
|
if !reflect.DeepEqual(chk, chk5) {
|
||||||
t.Fatalf("bad: %v %v", chk, chk5)
|
r.Fatalf("bad: %v %v", chk, chk5)
|
||||||
}
|
}
|
||||||
case "serfHealth":
|
case "serfHealth":
|
||||||
// ignore
|
// ignore
|
||||||
default:
|
default:
|
||||||
t.Fatalf("unexpected check: %v", chk)
|
r.Fatalf("unexpected check: %v", chk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if err := checksInSync(a.State, 3); err != nil {
|
if err := checksInSync(a.State, 3); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -793,7 +802,8 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
|
||||||
acl_datacenter = "dc1"
|
acl_datacenter = "dc1"
|
||||||
acl_master_token = "root"
|
acl_master_token = "root"
|
||||||
acl_default_policy = "deny"
|
acl_default_policy = "deny"
|
||||||
acl_enforce_version_8 = true`}
|
acl_enforce_version_8 = true
|
||||||
|
`, NoInitialSync: true}
|
||||||
a.Start()
|
a.Start()
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
|
@ -907,6 +917,7 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that we are in sync
|
// Verify that we are in sync
|
||||||
|
retry.Run(t, func(r *retry.R) {
|
||||||
req := structs.NodeSpecificRequest{
|
req := structs.NodeSpecificRequest{
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Node: a.Config.NodeName,
|
Node: a.Config.NodeName,
|
||||||
|
@ -916,12 +927,12 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
|
||||||
}
|
}
|
||||||
var checks structs.IndexedHealthChecks
|
var checks structs.IndexedHealthChecks
|
||||||
if err := a.RPC("Health.NodeChecks", &req, &checks); err != nil {
|
if err := a.RPC("Health.NodeChecks", &req, &checks); err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
r.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We should have 2 checks (serf included)
|
// We should have 2 checks (serf included)
|
||||||
if len(checks.HealthChecks) != 2 {
|
if len(checks.HealthChecks) != 2 {
|
||||||
t.Fatalf("bad: %v", checks)
|
r.Fatalf("bad: %v", checks)
|
||||||
}
|
}
|
||||||
|
|
||||||
// All the checks should match
|
// All the checks should match
|
||||||
|
@ -932,14 +943,15 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
|
||||||
t.Fatalf("should not be permitted")
|
t.Fatalf("should not be permitted")
|
||||||
case "api-check":
|
case "api-check":
|
||||||
if !reflect.DeepEqual(chk, chk2) {
|
if !reflect.DeepEqual(chk, chk2) {
|
||||||
t.Fatalf("bad: %v %v", chk, chk2)
|
r.Fatalf("bad: %v %v", chk, chk2)
|
||||||
}
|
}
|
||||||
case "serfHealth":
|
case "serfHealth":
|
||||||
// ignore
|
// ignore
|
||||||
default:
|
default:
|
||||||
t.Fatalf("unexpected check: %v", chk)
|
r.Fatalf("unexpected check: %v", chk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if err := checksInSync(a.State, 2); err != nil {
|
if err := checksInSync(a.State, 2); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -952,7 +964,7 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that we are in sync
|
// Verify that we are in sync
|
||||||
{
|
retry.Run(t, func(r *retry.R) {
|
||||||
req := structs.NodeSpecificRequest{
|
req := structs.NodeSpecificRequest{
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Node: a.Config.NodeName,
|
Node: a.Config.NodeName,
|
||||||
|
@ -962,12 +974,12 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
|
||||||
}
|
}
|
||||||
var checks structs.IndexedHealthChecks
|
var checks structs.IndexedHealthChecks
|
||||||
if err := a.RPC("Health.NodeChecks", &req, &checks); err != nil {
|
if err := a.RPC("Health.NodeChecks", &req, &checks); err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
r.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We should have 1 check (just serf)
|
// We should have 1 check (just serf)
|
||||||
if len(checks.HealthChecks) != 1 {
|
if len(checks.HealthChecks) != 1 {
|
||||||
t.Fatalf("bad: %v", checks)
|
r.Fatalf("bad: %v", checks)
|
||||||
}
|
}
|
||||||
|
|
||||||
// All the checks should match
|
// All the checks should match
|
||||||
|
@ -975,16 +987,16 @@ func TestAgentAntiEntropy_Checks_ACLDeny(t *testing.T) {
|
||||||
chk.CreateIndex, chk.ModifyIndex = 0, 0
|
chk.CreateIndex, chk.ModifyIndex = 0, 0
|
||||||
switch chk.CheckID {
|
switch chk.CheckID {
|
||||||
case "mysql-check":
|
case "mysql-check":
|
||||||
t.Fatalf("should not be permitted")
|
r.Fatalf("should not be permitted")
|
||||||
case "api-check":
|
case "api-check":
|
||||||
t.Fatalf("should be deleted")
|
r.Fatalf("should be deleted")
|
||||||
case "serfHealth":
|
case "serfHealth":
|
||||||
// ignore
|
// ignore
|
||||||
default:
|
default:
|
||||||
t.Fatalf("unexpected check: %v", chk)
|
r.Fatalf("unexpected check: %v", chk)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if err := checksInSync(a.State, 1); err != nil {
|
if err := checksInSync(a.State, 1); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -1050,7 +1062,7 @@ func TestAgentAntiEntropy_Check_DeferSync(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
a := &agent.TestAgent{Name: t.Name(), HCL: `
|
a := &agent.TestAgent{Name: t.Name(), HCL: `
|
||||||
check_update_interval = "500ms"
|
check_update_interval = "500ms"
|
||||||
`}
|
`, NoInitialSync: true}
|
||||||
a.Start()
|
a.Start()
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
|
@ -1231,7 +1243,8 @@ func TestAgentAntiEntropy_NodeInfo(t *testing.T) {
|
||||||
node_id = "40e4a748-2192-161a-0510-9bf59fe950b5"
|
node_id = "40e4a748-2192-161a-0510-9bf59fe950b5"
|
||||||
node_meta {
|
node_meta {
|
||||||
somekey = "somevalue"
|
somekey = "somevalue"
|
||||||
}`}
|
}
|
||||||
|
`, NoInitialSync: true}
|
||||||
a.Start()
|
a.Start()
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
|
@ -1255,8 +1268,10 @@ func TestAgentAntiEntropy_NodeInfo(t *testing.T) {
|
||||||
Node: a.Config.NodeName,
|
Node: a.Config.NodeName,
|
||||||
}
|
}
|
||||||
var services structs.IndexedNodeServices
|
var services structs.IndexedNodeServices
|
||||||
|
// Wait for the sync
|
||||||
|
retry.Run(t, func(r *retry.R) {
|
||||||
if err := a.RPC("Catalog.NodeServices", &req, &services); err != nil {
|
if err := a.RPC("Catalog.NodeServices", &req, &services); err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
r.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we synced our node info - this should have ridden on the
|
// Make sure we synced our node info - this should have ridden on the
|
||||||
|
@ -1265,11 +1280,12 @@ func TestAgentAntiEntropy_NodeInfo(t *testing.T) {
|
||||||
addrs := services.NodeServices.Node.TaggedAddresses
|
addrs := services.NodeServices.Node.TaggedAddresses
|
||||||
meta := services.NodeServices.Node.Meta
|
meta := services.NodeServices.Node.Meta
|
||||||
delete(meta, structs.MetaSegmentKey) // Added later, not in config.
|
delete(meta, structs.MetaSegmentKey) // Added later, not in config.
|
||||||
if id != a.Config.NodeID ||
|
if id != nodeID ||
|
||||||
!reflect.DeepEqual(addrs, a.Config.TaggedAddresses) ||
|
!reflect.DeepEqual(addrs, a.config.TaggedAddresses) ||
|
||||||
!reflect.DeepEqual(meta, a.Config.NodeMeta) {
|
!reflect.DeepEqual(meta, nodeMeta) {
|
||||||
t.Fatalf("bad: %v", services.NodeServices.Node)
|
r.Fatalf("bad: %v", services.NodeServices.Node)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Blow away the catalog version of the node info
|
// Blow away the catalog version of the node info
|
||||||
if err := a.RPC("Catalog.Register", args, &out); err != nil {
|
if err := a.RPC("Catalog.Register", args, &out); err != nil {
|
||||||
|
@ -1281,30 +1297,30 @@ func TestAgentAntiEntropy_NodeInfo(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for the sync - this should have been a sync of just the node info
|
// Wait for the sync - this should have been a sync of just the node info
|
||||||
|
retry.Run(t, func(r *retry.R) {
|
||||||
if err := a.RPC("Catalog.NodeServices", &req, &services); err != nil {
|
if err := a.RPC("Catalog.NodeServices", &req, &services); err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
r.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
id := services.NodeServices.Node.ID
|
id := services.NodeServices.Node.ID
|
||||||
addrs := services.NodeServices.Node.TaggedAddresses
|
addrs := services.NodeServices.Node.TaggedAddresses
|
||||||
meta := services.NodeServices.Node.Meta
|
meta := services.NodeServices.Node.Meta
|
||||||
delete(meta, structs.MetaSegmentKey) // Added later, not in config.
|
delete(meta, structs.MetaSegmentKey) // Added later, not in config.
|
||||||
if id != nodeID ||
|
if id != nodeID ||
|
||||||
!reflect.DeepEqual(addrs, a.Config.TaggedAddresses) ||
|
!reflect.DeepEqual(addrs, a.config.TaggedAddresses) ||
|
||||||
!reflect.DeepEqual(meta, nodeMeta) {
|
!reflect.DeepEqual(meta, nodeMeta) {
|
||||||
t.Fatalf("bad: %v", services.NodeServices.Node)
|
r.Fatalf("bad: %v", services.NodeServices.Node)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAgent_serviceTokens(t *testing.T) {
|
func TestAgent_serviceTokens(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
cfg := agent.TestConfig()
|
||||||
tokens := new(token.Store)
|
tokens := new(token.Store)
|
||||||
tokens.UpdateUserToken("default")
|
tokens.UpdateUserToken("default")
|
||||||
lcfg := agent.LocalConfig(config.DefaultRuntimeConfig(`bind_addr = "127.0.0.1" data_dir = "dummy"`))
|
l := local.NewState(config.DefaultRuntimeConfig(`bind_addr = "127.0.0.1" data_dir = "dummy"`), nil, tokens, make(chan struct{}, 1))
|
||||||
l := local.NewState(lcfg, nil, tokens, make(chan struct{}, 1))
|
|
||||||
|
|
||||||
l.AddService(&structs.NodeService{ID: "redis"}, "")
|
l.AddService(&structs.NodeService{ID: "redis"}, "")
|
||||||
|
|
||||||
|
@ -1329,10 +1345,10 @@ func TestAgent_serviceTokens(t *testing.T) {
|
||||||
func TestAgent_checkTokens(t *testing.T) {
|
func TestAgent_checkTokens(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
cfg := agent.TestConfig()
|
||||||
tokens := new(token.Store)
|
tokens := new(token.Store)
|
||||||
tokens.UpdateUserToken("default")
|
tokens.UpdateUserToken("default")
|
||||||
lcfg := agent.LocalConfig(config.DefaultRuntimeConfig(`bind_addr = "127.0.0.1" data_dir = "dummy"`))
|
l := local.NewState(config.DefaultRuntimeConfig(`bind_addr = "127.0.0.1" data_dir = "dummy"`), nil, tokens, make(chan struct{}, 1))
|
||||||
l := local.NewState(lcfg, nil, tokens, make(chan struct{}, 1))
|
|
||||||
|
|
||||||
// Returns default when no token is set
|
// Returns default when no token is set
|
||||||
l.AddCheck(&structs.HealthCheck{CheckID: types.CheckID("mem")}, "")
|
l.AddCheck(&structs.HealthCheck{CheckID: types.CheckID("mem")}, "")
|
||||||
|
@ -1355,8 +1371,7 @@ func TestAgent_checkTokens(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_checkCriticalTime(t *testing.T) {
|
func TestAgent_checkCriticalTime(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
lcfg := agent.LocalConfig(config.DefaultRuntimeConfig(`bind_addr = "127.0.0.1" data_dir = "dummy"`))
|
l := local.NewState(config.DefaultRuntimeConfig(`bind_addr = "127.0.0.1" data_dir = "dummy"`), nil, new(token.Store), make(chan struct{}, 1))
|
||||||
l := local.NewState(lcfg, nil, new(token.Store), make(chan struct{}, 1))
|
|
||||||
|
|
||||||
svc := &structs.NodeService{ID: "redis", Service: "redis", Port: 8000}
|
svc := &structs.NodeService{ID: "redis", Service: "redis", Port: 8000}
|
||||||
l.AddService(svc, "")
|
l.AddService(svc, "")
|
||||||
|
@ -1418,8 +1433,7 @@ func TestAgent_checkCriticalTime(t *testing.T) {
|
||||||
|
|
||||||
func TestAgent_AddCheckFailure(t *testing.T) {
|
func TestAgent_AddCheckFailure(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
lcfg := agent.LocalConfig(config.DefaultRuntimeConfig(`bind_addr = "127.0.0.1" data_dir = "dummy"`))
|
l := local.NewState(config.DefaultRuntimeConfig(`bind_addr = "127.0.0.1" data_dir = "dummy"`), nil, new(token.Store), make(chan struct{}, 1))
|
||||||
l := local.NewState(lcfg, nil, new(token.Store), make(chan struct{}, 1))
|
|
||||||
|
|
||||||
// Add a check for a service that does not exist and verify that it fails
|
// Add a check for a service that does not exist and verify that it fails
|
||||||
checkID := types.CheckID("redis:1")
|
checkID := types.CheckID("redis:1")
|
||||||
|
@ -1451,10 +1465,8 @@ func TestAgent_sendCoordinate(t *testing.T) {
|
||||||
`)
|
`)
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
t.Logf("%d %d %s",
|
t.Logf("%d %d %s", a.consulConfig().CoordinateUpdateBatchSize, a.consulConfig().CoordinateUpdateMaxBatches,
|
||||||
a.Config.ConsulCoordinateUpdateBatchSize,
|
a.consulConfig().CoordinateUpdatePeriod.String())
|
||||||
a.Config.ConsulCoordinateUpdateMaxBatches,
|
|
||||||
a.Config.ConsulCoordinateUpdatePeriod.String())
|
|
||||||
|
|
||||||
// Make sure the coordinate is present.
|
// Make sure the coordinate is present.
|
||||||
req := structs.DCSpecificRequest{
|
req := structs.DCSpecificRequest{
|
||||||
|
|
Loading…
Reference in New Issue