From f311ada60e24cda8de5e3c3082a99e63a34480b2 Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Wed, 15 Oct 2014 10:08:13 -0700 Subject: [PATCH] agent: Default health checks to critical. Fixes #341 --- command/agent/structs.go | 2 +- command/agent/structs_test.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 command/agent/structs_test.go diff --git a/command/agent/structs.go b/command/agent/structs.go index 2370c3936a6e..e2028237106d 100644 --- a/command/agent/structs.go +++ b/command/agent/structs.go @@ -46,7 +46,7 @@ func (c *CheckDefinition) HealthCheck(node string) *structs.HealthCheck { Node: node, CheckID: c.ID, Name: c.Name, - Status: structs.HealthUnknown, + Status: structs.HealthCritical, Notes: c.Notes, } if health.CheckID == "" && health.Name != "" { diff --git a/command/agent/structs_test.go b/command/agent/structs_test.go new file mode 100644 index 000000000000..f21f69fd745f --- /dev/null +++ b/command/agent/structs_test.go @@ -0,0 +1,16 @@ +package agent + +import ( + "github.com/hashicorp/consul/consul/structs" + "testing" +) + +func TestAgentStructs_HealthCheck(t *testing.T) { + def := CheckDefinition{} + check := def.HealthCheck("node1") + + // Health checks default to critical state + if check.Status != structs.HealthCritical { + t.Fatalf("bad: %v", check.Status) + } +}