mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-06-16 04:44:55 +02:00
internal/api/eosio_v1.go: HTTP Errors are now handled in eosapi. This changes the log message abit and return haproxy status from "Down" to "Fail"
This commit is contained in:
parent
9102240837
commit
a17e2929e3
2 changed files with 3 additions and 12 deletions
|
|
@ -53,15 +53,6 @@ func (e EosioV1) Call() (agentcheck.Response, string) {
|
|||
return resp, err.Error()
|
||||
}
|
||||
|
||||
// Check HTTP Status Code
|
||||
if info.HTTPStatusCode > 299 {
|
||||
|
||||
resp := agentcheck.NewStatusMessageResponse(agentcheck.Down, "")
|
||||
|
||||
msg := "Taking offline because %v was received from backend"
|
||||
return resp, fmt.Sprintf(msg, info.HTTPStatusCode)
|
||||
}
|
||||
|
||||
// Validate head block.
|
||||
diff := e.GetTime().Sub(info.HeadBlockTime).Seconds()
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func TestEosioV1JsonFailure(t *testing.T) {
|
|||
assert.Equal(t, expected, check)
|
||||
}
|
||||
|
||||
func TestEosioV1HTTP500Down(t *testing.T) {
|
||||
func TestEosioV1HTTP500Failed(t *testing.T) {
|
||||
|
||||
var srv = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||
res.WriteHeader(500)
|
||||
|
|
@ -70,9 +70,9 @@ func TestEosioV1HTTP500Down(t *testing.T) {
|
|||
api := NewEosioV1(srv.URL, "", 120)
|
||||
check, status := api.Call()
|
||||
|
||||
assert.Equal(t, "Taking offline because 500 was received from backend", status)
|
||||
assert.Equal(t, "server returned HTTP 500 Internal Server Error", status)
|
||||
|
||||
expected := agentcheck.NewStatusMessageResponse(agentcheck.Down, "")
|
||||
expected := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "")
|
||||
assert.Equal(t, expected, check)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue