1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-api-healthcheck synced 2026-06-18 05:00:03 +02:00

internal/api/eosio_v2.go: HTTP Errors are now handled in the eosapi. This changes the log message abit and return haproxy status from "Down" to "Fail"

This commit is contained in:
Henrik Hautakoski 2022-11-18 15:39:52 +01:00
parent 0b463e5111
commit 9102240837
No known key found for this signature in database
GPG key ID: 608414D93E862CCD
2 changed files with 3 additions and 9 deletions

View file

@ -52,12 +52,6 @@ func (e EosioV2) Call() (agentcheck.Response, string) {
return resp, err.Error()
}
// Check HTTP Status Code
if health.HTTPStatusCode > 299 {
resp := agentcheck.NewStatusMessageResponse(agentcheck.Down, "")
return resp, fmt.Sprintf("Taking offline because %v was received from backend", health.HTTPStatusCode)
}
// Fetch elasticsearch and nodeos block numbers from json.
var es_block int64 = 0
var node_block int64 = 0

View file

@ -47,7 +47,7 @@ func TestEosioV2JsonFailure(t *testing.T) {
assert.Equal(t, expected, check)
}
func TestEosioV2HTTP500Down(t *testing.T) {
func TestEosioV2HTTP500Failed(t *testing.T) {
var srv = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
res.WriteHeader(500)
@ -57,9 +57,9 @@ func TestEosioV2HTTP500Down(t *testing.T) {
api := NewEosioV2(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)
}