Export the serf check ID
This commit is contained in:
parent
7a74f58141
commit
ea41b2bb26
|
@ -45,7 +45,7 @@ func TestHealth_ChecksInState(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// First check is automatically added for the server node
|
// First check is automatically added for the server node
|
||||||
if checks[0].CheckID != serfCheckID {
|
if checks[0].CheckID != SerfCheckID {
|
||||||
t.Fatalf("Bad: %v", checks[0])
|
t.Fatalf("Bad: %v", checks[0])
|
||||||
}
|
}
|
||||||
if checks[1].Name != "memory utilization" {
|
if checks[1].Name != "memory utilization" {
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
serfCheckID = "serfHealth"
|
SerfCheckID = "serfHealth"
|
||||||
serfCheckName = "Serf Health Status"
|
SerfCheckName = "Serf Health Status"
|
||||||
)
|
)
|
||||||
|
|
||||||
// monitorLeadership is used to monitor if we acquire or lose our role
|
// monitorLeadership is used to monitor if we acquire or lose our role
|
||||||
|
@ -173,7 +173,7 @@ func (s *Server) handleAliveMember(member serf.Member) error {
|
||||||
// Check if the serfCheck is in the passing state
|
// Check if the serfCheck is in the passing state
|
||||||
checks := state.NodeChecks(member.Name)
|
checks := state.NodeChecks(member.Name)
|
||||||
for _, check := range checks {
|
for _, check := range checks {
|
||||||
if check.CheckID == serfCheckID && check.Status == structs.HealthPassing {
|
if check.CheckID == SerfCheckID && check.Status == structs.HealthPassing {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,8 +189,8 @@ AFTER_CHECK:
|
||||||
Service: service,
|
Service: service,
|
||||||
Check: &structs.HealthCheck{
|
Check: &structs.HealthCheck{
|
||||||
Node: member.Name,
|
Node: member.Name,
|
||||||
CheckID: serfCheckID,
|
CheckID: SerfCheckID,
|
||||||
Name: serfCheckName,
|
Name: SerfCheckName,
|
||||||
Status: structs.HealthPassing,
|
Status: structs.HealthPassing,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ func (s *Server) handleFailedMember(member serf.Member) error {
|
||||||
// Check if the serfCheck is in the critical state
|
// Check if the serfCheck is in the critical state
|
||||||
checks := state.NodeChecks(member.Name)
|
checks := state.NodeChecks(member.Name)
|
||||||
for _, check := range checks {
|
for _, check := range checks {
|
||||||
if check.CheckID == serfCheckID && check.Status == structs.HealthCritical {
|
if check.CheckID == SerfCheckID && check.Status == structs.HealthCritical {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,8 +223,8 @@ func (s *Server) handleFailedMember(member serf.Member) error {
|
||||||
Address: member.Addr.String(),
|
Address: member.Addr.String(),
|
||||||
Check: &structs.HealthCheck{
|
Check: &structs.HealthCheck{
|
||||||
Node: member.Name,
|
Node: member.Name,
|
||||||
CheckID: serfCheckID,
|
CheckID: SerfCheckID,
|
||||||
Name: serfCheckName,
|
Name: SerfCheckName,
|
||||||
Status: structs.HealthCritical,
|
Status: structs.HealthCritical,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,10 +42,10 @@ func TestLeader_RegisterMember(t *testing.T) {
|
||||||
if len(checks) != 1 {
|
if len(checks) != 1 {
|
||||||
t.Fatalf("client missing check")
|
t.Fatalf("client missing check")
|
||||||
}
|
}
|
||||||
if checks[0].CheckID != serfCheckID {
|
if checks[0].CheckID != SerfCheckID {
|
||||||
t.Fatalf("bad check: %v", checks[0])
|
t.Fatalf("bad check: %v", checks[0])
|
||||||
}
|
}
|
||||||
if checks[0].Name != serfCheckName {
|
if checks[0].Name != SerfCheckName {
|
||||||
t.Fatalf("bad check: %v", checks[0])
|
t.Fatalf("bad check: %v", checks[0])
|
||||||
}
|
}
|
||||||
if checks[0].Status != structs.HealthPassing {
|
if checks[0].Status != structs.HealthPassing {
|
||||||
|
@ -102,10 +102,10 @@ func TestLeader_FailedMember(t *testing.T) {
|
||||||
if len(checks) != 1 {
|
if len(checks) != 1 {
|
||||||
t.Fatalf("client missing check")
|
t.Fatalf("client missing check")
|
||||||
}
|
}
|
||||||
if checks[0].CheckID != serfCheckID {
|
if checks[0].CheckID != SerfCheckID {
|
||||||
t.Fatalf("bad check: %v", checks[0])
|
t.Fatalf("bad check: %v", checks[0])
|
||||||
}
|
}
|
||||||
if checks[0].Name != serfCheckName {
|
if checks[0].Name != SerfCheckName {
|
||||||
t.Fatalf("bad check: %v", checks[0])
|
t.Fatalf("bad check: %v", checks[0])
|
||||||
}
|
}
|
||||||
if checks[0].Status != structs.HealthCritical {
|
if checks[0].Status != structs.HealthCritical {
|
||||||
|
|
|
@ -718,8 +718,8 @@ func TestCheckServiceNodes(t *testing.T) {
|
||||||
}
|
}
|
||||||
check = &structs.HealthCheck{
|
check = &structs.HealthCheck{
|
||||||
Node: "foo",
|
Node: "foo",
|
||||||
CheckID: serfCheckID,
|
CheckID: SerfCheckID,
|
||||||
Name: serfCheckName,
|
Name: SerfCheckName,
|
||||||
Status: structs.HealthPassing,
|
Status: structs.HealthPassing,
|
||||||
}
|
}
|
||||||
if err := store.EnsureCheck(check); err != nil {
|
if err := store.EnsureCheck(check); err != nil {
|
||||||
|
@ -743,7 +743,7 @@ func TestCheckServiceNodes(t *testing.T) {
|
||||||
if nodes[0].Checks[0].CheckID != "db" {
|
if nodes[0].Checks[0].CheckID != "db" {
|
||||||
t.Fatalf("Bad: %v", nodes[0])
|
t.Fatalf("Bad: %v", nodes[0])
|
||||||
}
|
}
|
||||||
if nodes[0].Checks[1].CheckID != serfCheckID {
|
if nodes[0].Checks[1].CheckID != SerfCheckID {
|
||||||
t.Fatalf("Bad: %v", nodes[0])
|
t.Fatalf("Bad: %v", nodes[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -764,7 +764,7 @@ func TestCheckServiceNodes(t *testing.T) {
|
||||||
if nodes[0].Checks[0].CheckID != "db" {
|
if nodes[0].Checks[0].CheckID != "db" {
|
||||||
t.Fatalf("Bad: %v", nodes[0])
|
t.Fatalf("Bad: %v", nodes[0])
|
||||||
}
|
}
|
||||||
if nodes[0].Checks[1].CheckID != serfCheckID {
|
if nodes[0].Checks[1].CheckID != SerfCheckID {
|
||||||
t.Fatalf("Bad: %v", nodes[0])
|
t.Fatalf("Bad: %v", nodes[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue