-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed error on system health status. bumped version to 0.1.1
- Loading branch information
Showing
6 changed files
with
123 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ MAINTAINER Acaleph <[email protected]> | |
ADD https://dl.bintray.com/mitchellh/consul/0.4.1_linux_amd64.zip /tmp/consul.zip | ||
RUN cd /bin && unzip /tmp/consul.zip && chmod +x /bin/consul && rm /tmp/consul.zip | ||
|
||
ADD http://dl.bintray.com/darkcrux/generic/consul-alerts-0.1.0-linux-amd64.tar /tmp/consul-alerts.tar | ||
ADD http://dl.bintray.com/darkcrux/generic/consul-alerts-0.1.1-linux-amd64.tar /tmp/consul-alerts.tar | ||
RUN cd /bin && tar -xf /tmp/consul-alerts.tar && chmod +x /bin/consul-alerts && rm /tmp/consul-alerts.tar | ||
|
||
EXPOSE 9000 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package consul | ||
|
||
import ( | ||
"strconv" | ||
"testing" | ||
) | ||
|
||
func TestLoadCustomValueForString(t *testing.T) { | ||
var strVar string | ||
input := "test-data" | ||
data := []byte(input) | ||
loadCustomValue(&strVar, data, ConfigTypeString) | ||
if strVar != "test-data" { | ||
t.Errorf("unable to parse %s to string", input) | ||
} | ||
} | ||
|
||
func TestLoadCustomValueForBool(t *testing.T) { | ||
var boolVar bool | ||
input := []string{ | ||
"true", | ||
"false", | ||
"True", | ||
"False", | ||
"TRUE", | ||
"FALSE", | ||
} | ||
|
||
for i, in := range input { | ||
data := []byte(in) | ||
loadCustomValue(&boolVar, data, ConfigTypeBool) | ||
if i%2 == 0 && !boolVar { | ||
t.Errorf("unable to parse %s to boolean", in) | ||
} | ||
} | ||
|
||
} | ||
|
||
func TestLoadCustomValueForInt(t *testing.T) { | ||
var intVar int | ||
input := "235" | ||
data := []byte(input) | ||
loadCustomValue(&intVar, data, ConfigTypeInt) | ||
if in, _ := strconv.Atoi(input); in != intVar { | ||
t.Errorf("unable to parse %s to int", input) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package notifier | ||
|
||
import "testing" | ||
|
||
func TestMessageIsCritical(t *testing.T) { | ||
message := Message{Status: "critical"} | ||
if !message.IsCritical() { | ||
t.Error("message should be critical") | ||
} | ||
} | ||
|
||
func TestMessageIsWarning(t *testing.T) { | ||
message := Message{Status: "warning"} | ||
if !message.IsWarning() { | ||
t.Error("message should be warning") | ||
} | ||
} | ||
|
||
func TestMessageIsPassing(t *testing.T) { | ||
message := Message{Status: "passing"} | ||
if !message.IsPassing() { | ||
t.Error("message should be passing") | ||
} | ||
} | ||
|
||
func TestSystemIsHealthy(t *testing.T) { | ||
messages := Messages{ | ||
Message{Status: "passing"}, | ||
Message{Status: "passing"}, | ||
Message{Status: "passing"}, | ||
Message{Status: "passing"}, | ||
Message{Status: "passing"}, | ||
} | ||
stat, pass, warn, fail := messages.Summary() | ||
if stat != SYSTEM_HEALTHY || pass != 5 || warn != 0 || fail != 0 { | ||
t.Errorf("system should be healthy, status=%s, pass=%d, warn=%d, fail=%d", stat, pass, warn, fail) | ||
} | ||
} | ||
|
||
func TestSystemIsCritical(t *testing.T) { | ||
messages := Messages{ | ||
Message{Status: "passing"}, | ||
Message{Status: "passing"}, | ||
Message{Status: "critical"}, | ||
Message{Status: "passing"}, | ||
Message{Status: "warning"}, | ||
} | ||
stat, pass, warn, fail := messages.Summary() | ||
if stat != SYSTEM_CRITICAL || pass != 3 || warn != 1 || fail != 1 { | ||
t.Errorf("system should be critical, status=%s, pass=%d, warn=%d, fail=%d", stat, pass, warn, fail) | ||
} | ||
} | ||
|
||
func TestSystemIsUnstable(t *testing.T) { | ||
messages := Messages{ | ||
Message{Status: "warning"}, | ||
Message{Status: "passing"}, | ||
Message{Status: "warning"}, | ||
Message{Status: "warning"}, | ||
Message{Status: "passing"}, | ||
} | ||
stat, pass, warn, fail := messages.Summary() | ||
if stat != SYSTEM_UNSTABLE || pass != 2 || warn != 3 || fail != 0 { | ||
t.Errorf("system should be unstable, status=%s, pass=%d, warn=%d, fail=%d", stat, pass, warn, fail) | ||
} | ||
} |