Compare commits
2 Commits
6e0dfabcff
...
4eb0a6360f
| Author | SHA1 | Date | |
|---|---|---|---|
| 4eb0a6360f | |||
| 040b9148de |
@@ -35,12 +35,17 @@ type OverallResult struct {
|
|||||||
|
|
||||||
func determineOverallStatus(results map[string]Result) Status {
|
func determineOverallStatus(results map[string]Result) Status {
|
||||||
hasUnhealthy := false
|
hasUnhealthy := false
|
||||||
|
hasSMTPUnhealthy := false
|
||||||
hasDegraded := false
|
hasDegraded := false
|
||||||
|
|
||||||
for _, result := range results {
|
for name, result := range results {
|
||||||
switch result.Status {
|
switch result.Status {
|
||||||
case StatusUnhealthy:
|
case StatusUnhealthy:
|
||||||
hasUnhealthy = true
|
if name == "smtp" {
|
||||||
|
hasSMTPUnhealthy = true
|
||||||
|
} else {
|
||||||
|
hasUnhealthy = true
|
||||||
|
}
|
||||||
case StatusDegraded:
|
case StatusDegraded:
|
||||||
hasDegraded = true
|
hasDegraded = true
|
||||||
}
|
}
|
||||||
@@ -49,7 +54,7 @@ func determineOverallStatus(results map[string]Result) Status {
|
|||||||
if hasUnhealthy {
|
if hasUnhealthy {
|
||||||
return StatusUnhealthy
|
return StatusUnhealthy
|
||||||
}
|
}
|
||||||
if hasDegraded {
|
if hasDegraded || hasSMTPUnhealthy {
|
||||||
return StatusDegraded
|
return StatusDegraded
|
||||||
}
|
}
|
||||||
return StatusHealthy
|
return StatusHealthy
|
||||||
|
|||||||
@@ -57,10 +57,15 @@ func TestDetermineOverallStatus(t *testing.T) {
|
|||||||
results: map[string]Result{"db": {Status: StatusUnhealthy}, "smtp": {Status: StatusHealthy}},
|
results: map[string]Result{"db": {Status: StatusUnhealthy}, "smtp": {Status: StatusHealthy}},
|
||||||
expected: StatusUnhealthy,
|
expected: StatusUnhealthy,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "smtp unhealthy downgrades overall to degraded",
|
||||||
|
results: map[string]Result{"db": {Status: StatusHealthy}, "smtp": {Status: StatusUnhealthy}},
|
||||||
|
expected: StatusDegraded,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "mixed degraded and unhealthy",
|
name: "mixed degraded and unhealthy",
|
||||||
results: map[string]Result{"db": {Status: StatusDegraded}, "smtp": {Status: StatusUnhealthy}},
|
results: map[string]Result{"db": {Status: StatusDegraded}, "smtp": {Status: StatusUnhealthy}},
|
||||||
expected: StatusUnhealthy,
|
expected: StatusDegraded,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "empty results",
|
name: "empty results",
|
||||||
|
|||||||
Reference in New Issue
Block a user