1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-api-healthcheck synced 2026-07-03 11:53:43 +02:00

Rename project from eosio-api-healthcheck to antelope-api-healthcheck

This commit is contained in:
Henrik Hautakoski 2022-11-25 12:38:30 +01:00
parent e0a7a10662
commit 61cb49f8be
No known key found for this signature in database
GPG key ID: 608414D93E862CCD
20 changed files with 115 additions and 115 deletions

View file

@ -1,5 +1,5 @@
PROGRAM_NAME = eosio-api-healthcheck PROGRAM_NAME = antelope-api-healthcheck
export PROGRAM_VERSION = 1.2.6 export PROGRAM_VERSION = 1.2.6
GO = go GO = go
@ -16,7 +16,7 @@ all: build
build: build/$(PROGRAM_NAME) build: build/$(PROGRAM_NAME)
build/$(PROGRAM_NAME) : $(SOURCES) build/$(PROGRAM_NAME) : $(SOURCES)
$(GO) build -o $@ $(GOBUILDFLAGS) cmd/eosio-api-healtcheck/main.go $(GO) build -o $@ $(GOBUILDFLAGS) cmd/antelope-api-healtcheck/main.go
test: test:
$(GO) test -v ./... $(GO) test -v ./...

View file

@ -1,6 +1,6 @@
# EOSIO API Healthcheck for HAProxy # Antelope API Healthcheck for HAProxy
This program implements EOSIO healthcheck for HAProxy over TCP. This program implements Antelope healthcheck for HAProxy over TCP.
## Compiling ## Compiling

View file

@ -7,8 +7,8 @@ import (
"syscall" "syscall"
"github.com/eosswedenorg-go/pid" "github.com/eosswedenorg-go/pid"
"github.com/eosswedenorg/eosio-api-healthcheck/internal/server" "github.com/eosswedenorg/antelope-api-healthcheck/internal/server"
"github.com/eosswedenorg/eosio-api-healthcheck/internal/utils" "github.com/eosswedenorg/antelope-api-healthcheck/internal/utils"
log "github.com/inconshreveable/log15" log "github.com/inconshreveable/log15"
"github.com/pborman/getopt/v2" "github.com/pborman/getopt/v2"
) )

14
debian/control vendored
View file

@ -1,19 +1,19 @@
Source: eosio-api-healthcheck Source: antelope-api-healthcheck
Section: introspection Section: introspection
Build-Depends: Build-Depends:
debhelper (>= 11) debhelper (>= 11)
Standards-Version: 4.5.0 Standards-Version: 4.5.0
Vcs-Git: https://github.com/eosswedenorg/eos-api-healthcheck.git Vcs-Git: https://github.com/eosswedenorg/antelope-api-healthcheck.git
Vcs-Browser: https://github.com/eosswedenorg/eos-api-healthcheck Vcs-Browser: https://github.com/eosswedenorg/antelope-api-healthcheck
Priority: optional Priority: optional
Maintainer: Henrik Hautakoski <henrik@eossweden.org> Maintainer: Henrik Hautakoski <henrik@eossweden.org>
Package: eosio-api-healthcheck Package: antelope-api-healthcheck
Section: introspection Section: introspection
Priority: optional Priority: optional
Architecture: amd64 Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends} Depends: ${shlibs:Depends}, ${misc:Depends}
Homepage: https://github.com/eosswedenorg/eos-api-healthcheck Homepage: https://github.com/eosswedenorg/antelope-api-healthcheck
Description: HAproxy healthcheck program for EOSIO API. Description: HAproxy healthcheck program for Leap API.
This package provides all the files needed to This package provides all the files needed to
run the eos-api-healthcheck TCP Server run the antelope-api-healthcheck TCP Server

4
debian/copyright vendored
View file

@ -1,7 +1,7 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: eosio-api-healthcheck Upstream-Name: antelope-api-healthcheck
Upstream-Contact: Henrik Hautakoski <henrik@eossweden.org> Upstream-Contact: Henrik Hautakoski <henrik@eossweden.org>
Source: https://github.com/eosswedenorg/eos-api-healthcheck.git Source: https://github.com/eosswedenorg/antelope-api-healthcheck.git
Files: * Files: *
Copyright: 2020-2022 Sw/eden Copyright: 2020-2022 Sw/eden

2
go.mod
View file

@ -1,4 +1,4 @@
module github.com/eosswedenorg/eosio-api-healthcheck module github.com/eosswedenorg/antelope-api-healthcheck
go 1.16 go 1.16

View file

@ -5,7 +5,7 @@ import (
"github.com/eosswedenorg-go/atomicasset" "github.com/eosswedenorg-go/atomicasset"
"github.com/eosswedenorg-go/haproxy/agentcheck" "github.com/eosswedenorg-go/haproxy/agentcheck"
"github.com/eosswedenorg/eosio-api-healthcheck/internal/utils" "github.com/eosswedenorg/antelope-api-healthcheck/internal/utils"
) )
type AtomicAsset struct { type AtomicAsset struct {

View file

@ -5,21 +5,21 @@ import (
"github.com/eosswedenorg-go/eosapi" "github.com/eosswedenorg-go/eosapi"
"github.com/eosswedenorg-go/haproxy/agentcheck" "github.com/eosswedenorg-go/haproxy/agentcheck"
"github.com/eosswedenorg/eosio-api-healthcheck/internal/utils" "github.com/eosswedenorg/antelope-api-healthcheck/internal/utils"
) )
type EosioV1 struct { type AntelopeV1 struct {
utils.Time utils.Time
client eosapi.Client client eosapi.Client
block_time float64 block_time float64
} }
func EosioV1Factory(args ApiArguments) ApiInterface { func AntelopeV1Factory(args ApiArguments) ApiInterface {
return NewEosioV1(args.Url, args.Host, float64(args.NumBlocks/2)) return NewAntelopeV1(args.Url, args.Host, float64(args.NumBlocks/2))
} }
func NewEosioV1(url string, host string, block_time float64) EosioV1 { func NewAntelopeV1(url string, host string, block_time float64) AntelopeV1 {
api := EosioV1{ api := AntelopeV1{
client: *eosapi.New(url), client: *eosapi.New(url),
block_time: block_time, block_time: block_time,
} }
@ -29,9 +29,9 @@ func NewEosioV1(url string, host string, block_time float64) EosioV1 {
return api return api
} }
func (e EosioV1) LogInfo() LogParams { func (e AntelopeV1) LogInfo() LogParams {
p := LogParams{ p := LogParams{
"type", "eosio-v1", "type", "antelope-v1",
"url", e.client.Url, "url", e.client.Url,
} }
@ -44,7 +44,7 @@ func (e EosioV1) LogInfo() LogParams {
return p return p
} }
func (e EosioV1) Call() (agentcheck.Response, string) { func (e AntelopeV1) Call() (agentcheck.Response, string) {
info, err := e.client.GetInfo() info, err := e.client.GetInfo()
if err != nil { if err != nil {
resp := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "") resp := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "")

View file

@ -10,33 +10,33 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestEosioV1_Factory(t *testing.T) { func TestAntelopeV1_Factory(t *testing.T) {
api := EosioV1Factory(ApiArguments{ api := AntelopeV1Factory(ApiArguments{
Url: "https://api.v1.example.com", Url: "https://api.v1.example.com",
Host: "host.example.com", Host: "host.example.com",
NumBlocks: 120, NumBlocks: 120,
}) })
expected := NewEosioV1("https://api.v1.example.com", "host.example.com", 60) expected := NewAntelopeV1("https://api.v1.example.com", "host.example.com", 60)
assert.IsType(t, expected, api) assert.IsType(t, expected, api)
assert.Equal(t, expected.client.Url, api.(EosioV1).client.Url) assert.Equal(t, expected.client.Url, api.(AntelopeV1).client.Url)
assert.Equal(t, expected.client.Host, api.(EosioV1).client.Host) assert.Equal(t, expected.client.Host, api.(AntelopeV1).client.Host)
assert.Equal(t, expected.block_time, api.(EosioV1).block_time) assert.Equal(t, expected.block_time, api.(AntelopeV1).block_time)
} }
func TestEosioV1_LogInfo(t *testing.T) { func TestAntelopeV1_LogInfo(t *testing.T) {
api := NewEosioV1("https://api.v1.example.com", "host.example.com", 120) api := NewAntelopeV1("https://api.v1.example.com", "host.example.com", 120)
expected := LogParams{"type", "eosio-v1", "url", "https://api.v1.example.com", "host", "host.example.com", "block_time", float64(120)} expected := LogParams{"type", "antelope-v1", "url", "https://api.v1.example.com", "host", "host.example.com", "block_time", float64(120)}
assert.Equal(t, expected, api.LogInfo()) assert.Equal(t, expected, api.LogInfo())
} }
func TestEosioV1_SetTime(t *testing.T) { func TestAntelopeV1_SetTime(t *testing.T) {
expected := time.Date(2022, 2, 24, 13, 38, 0, 0, time.UTC) expected := time.Date(2022, 2, 24, 13, 38, 0, 0, time.UTC)
api := NewEosioV1("", "", 60) api := NewAntelopeV1("", "", 60)
// Assert that time is NOW (+-10 seconds) // Assert that time is NOW (+-10 seconds)
assert.InDelta(t, api.GetTime().Unix(), time.Now().In(time.UTC).Unix(), float64(10)) assert.InDelta(t, api.GetTime().Unix(), time.Now().In(time.UTC).Unix(), float64(10))
@ -44,27 +44,27 @@ func TestEosioV1_SetTime(t *testing.T) {
assert.Equal(t, expected, api.GetTime()) assert.Equal(t, expected, api.GetTime())
} }
func TestEosioV1_JsonFailure(t *testing.T) { func TestAntelopeV1_JsonFailure(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
_, err := res.Write([]byte(`!//{invalid-json}!##`)) _, err := res.Write([]byte(`!//{invalid-json}!##`))
assert.NoError(t, err) assert.NoError(t, err)
})) }))
api := NewEosioV1(srv.URL, "", 120) api := NewAntelopeV1(srv.URL, "", 120)
check, _ := api.Call() check, _ := api.Call()
expected := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "") expected := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "")
assert.Equal(t, expected, check) assert.Equal(t, expected, check)
} }
func TestEosioV1_HTTP500Failed(t *testing.T) { func TestAntelopeV1_HTTP500Failed(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
res.WriteHeader(500) res.WriteHeader(500)
_, err := res.Write([]byte(`{}`)) _, err := res.Write([]byte(`{}`))
assert.NoError(t, err) assert.NoError(t, err)
})) }))
api := NewEosioV1(srv.URL, "", 120) api := NewAntelopeV1(srv.URL, "", 120)
check, status := api.Call() check, status := api.Call()
assert.Equal(t, "server returned HTTP 500 Internal Server Error", status) assert.Equal(t, "server returned HTTP 500 Internal Server Error", status)
@ -73,7 +73,7 @@ func TestEosioV1_HTTP500Failed(t *testing.T) {
assert.Equal(t, expected, check) assert.Equal(t, expected, check)
} }
func TestEosioV1_LaggingUp(t *testing.T) { func TestAntelopeV1_LaggingUp(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v1/chain/get_info" { if req.URL.String() == "/v1/chain/get_info" {
info := `{ info := `{
@ -87,7 +87,7 @@ func TestEosioV1_LaggingUp(t *testing.T) {
} }
})) }))
api := NewEosioV1(srv.URL, "", 60) api := NewAntelopeV1(srv.URL, "", 60)
api.SetTime(time.Date(2022, 2, 24, 13, 38, 0, 0, time.UTC)) api.SetTime(time.Date(2022, 2, 24, 13, 38, 0, 0, time.UTC))
check, status := api.Call() check, status := api.Call()
@ -97,7 +97,7 @@ func TestEosioV1_LaggingUp(t *testing.T) {
assert.Equal(t, expected, check) assert.Equal(t, expected, check)
} }
func TestEosioV1_LaggingDown(t *testing.T) { func TestAntelopeV1_LaggingDown(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v1/chain/get_info" { if req.URL.String() == "/v1/chain/get_info" {
info := `{ info := `{
@ -111,7 +111,7 @@ func TestEosioV1_LaggingDown(t *testing.T) {
} }
})) }))
api := NewEosioV1(srv.URL, "", 60) api := NewAntelopeV1(srv.URL, "", 60)
api.SetTime(time.Date(2018, time.January, 1, 13, 38, 2, 0, time.UTC)) api.SetTime(time.Date(2018, time.January, 1, 13, 38, 2, 0, time.UTC))
check, status := api.Call() check, status := api.Call()
@ -121,7 +121,7 @@ func TestEosioV1_LaggingDown(t *testing.T) {
assert.Equal(t, expected, check) assert.Equal(t, expected, check)
} }
func TestEosioV1_TimeInFutureUP(t *testing.T) { func TestAntelopeV1_TimeInFutureUP(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v1/chain/get_info" { if req.URL.String() == "/v1/chain/get_info" {
info := `{ info := `{
@ -135,7 +135,7 @@ func TestEosioV1_TimeInFutureUP(t *testing.T) {
} }
})) }))
api := NewEosioV1(srv.URL, "", 120) api := NewAntelopeV1(srv.URL, "", 120)
api.SetTime(time.Date(2020, 9, 22, 9, 30, 0, 0, time.UTC)) api.SetTime(time.Date(2020, 9, 22, 9, 30, 0, 0, time.UTC))
check, status := api.Call() check, status := api.Call()
@ -145,7 +145,7 @@ func TestEosioV1_TimeInFutureUP(t *testing.T) {
assert.Equal(t, expected, check) assert.Equal(t, expected, check)
} }
func TestEosioV1_TimeInFutureDown(t *testing.T) { func TestAntelopeV1_TimeInFutureDown(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v1/chain/get_info" { if req.URL.String() == "/v1/chain/get_info" {
info := `{ info := `{
@ -159,7 +159,7 @@ func TestEosioV1_TimeInFutureDown(t *testing.T) {
} }
})) }))
api := NewEosioV1(srv.URL, "", 120) api := NewAntelopeV1(srv.URL, "", 120)
api.SetTime(time.Date(2019, time.April, 14, 12, 0, 0, 0, time.UTC)) api.SetTime(time.Date(2019, time.April, 14, 12, 0, 0, 0, time.UTC))
check, status := api.Call() check, status := api.Call()

View file

@ -5,20 +5,20 @@ import (
"github.com/eosswedenorg-go/eosapi" "github.com/eosswedenorg-go/eosapi"
"github.com/eosswedenorg-go/haproxy/agentcheck" "github.com/eosswedenorg-go/haproxy/agentcheck"
"github.com/eosswedenorg/eosio-api-healthcheck/internal/utils" "github.com/eosswedenorg/antelope-api-healthcheck/internal/utils"
) )
type EosioV2 struct { type AntelopeV2 struct {
client eosapi.Client client eosapi.Client
offset int64 offset int64
} }
func EosioV2Factory(args ApiArguments) ApiInterface { func AntelopeV2Factory(args ApiArguments) ApiInterface {
return NewEosioV2(args.Url, args.Host, int64(args.NumBlocks)) return NewAntelopeV2(args.Url, args.Host, int64(args.NumBlocks))
} }
func NewEosioV2(url string, host string, offset int64) EosioV2 { func NewAntelopeV2(url string, host string, offset int64) AntelopeV2 {
api := EosioV2{ api := AntelopeV2{
client: *eosapi.New(url), client: *eosapi.New(url),
offset: offset, offset: offset,
} }
@ -28,9 +28,9 @@ func NewEosioV2(url string, host string, offset int64) EosioV2 {
return api return api
} }
func (e EosioV2) LogInfo() LogParams { func (e AntelopeV2) LogInfo() LogParams {
p := LogParams{ p := LogParams{
"type", "eosio-v2", "type", "antelope-v2",
"url", e.client.Url, "url", e.client.Url,
} }
@ -43,7 +43,7 @@ func (e EosioV2) LogInfo() LogParams {
return p return p
} }
func (e EosioV2) Call() (agentcheck.Response, string) { func (e AntelopeV2) Call() (agentcheck.Response, string) {
health, err := e.client.GetHealth() health, err := e.client.GetHealth()
if err != nil { if err != nil {
resp := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "") resp := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "")

View file

@ -9,50 +9,50 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestEosioV2_Factory(t *testing.T) { func TestAntelopeV2_Factory(t *testing.T) {
api := EosioV2Factory(ApiArguments{ api := AntelopeV2Factory(ApiArguments{
Url: "https://api.v2.example.com", Url: "https://api.v2.example.com",
Host: "host.example.com", Host: "host.example.com",
NumBlocks: 120, NumBlocks: 120,
}) })
expected := NewEosioV2("https://api.v2.example.com", "host.example.com", 120) expected := NewAntelopeV2("https://api.v2.example.com", "host.example.com", 120)
assert.IsType(t, expected, api) assert.IsType(t, expected, api)
assert.Equal(t, expected.client.Url, api.(EosioV2).client.Url) assert.Equal(t, expected.client.Url, api.(AntelopeV2).client.Url)
assert.Equal(t, expected.client.Host, api.(EosioV2).client.Host) assert.Equal(t, expected.client.Host, api.(AntelopeV2).client.Host)
assert.Equal(t, expected.offset, api.(EosioV2).offset) assert.Equal(t, expected.offset, api.(AntelopeV2).offset)
} }
func TestEosioV2_LogInfo(t *testing.T) { func TestAntelopeV2_LogInfo(t *testing.T) {
api := NewEosioV2("https://api.v2.example.com", "host.example.com", 120) api := NewAntelopeV2("https://api.v2.example.com", "host.example.com", 120)
expected := LogParams{"type", "eosio-v2", "url", "https://api.v2.example.com", "host", "host.example.com", "offset", int64(120)} expected := LogParams{"type", "antelope-v2", "url", "https://api.v2.example.com", "host", "host.example.com", "offset", int64(120)}
assert.Equal(t, expected, api.LogInfo()) assert.Equal(t, expected, api.LogInfo())
} }
func TestEosioV2_JsonFailure(t *testing.T) { func TestAntelopeV2_JsonFailure(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
_, err := res.Write([]byte(`!//{invalid-json}!##`)) _, err := res.Write([]byte(`!//{invalid-json}!##`))
assert.NoError(t, err) assert.NoError(t, err)
})) }))
api := NewEosioV2(srv.URL, "", 120) api := NewAntelopeV2(srv.URL, "", 120)
check, _ := api.Call() check, _ := api.Call()
expected := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "") expected := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "")
assert.Equal(t, expected, check) assert.Equal(t, expected, check)
} }
func TestEosioV2_HTTP500Failed(t *testing.T) { func TestAntelopeV2_HTTP500Failed(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
res.WriteHeader(500) res.WriteHeader(500)
_, err := res.Write([]byte(`{}`)) _, err := res.Write([]byte(`{}`))
assert.NoError(t, err) assert.NoError(t, err)
})) }))
api := NewEosioV2(srv.URL, "", 120) api := NewAntelopeV2(srv.URL, "", 120)
check, status := api.Call() check, status := api.Call()
assert.Equal(t, "server returned HTTP 500 Internal Server Error", status) assert.Equal(t, "server returned HTTP 500 Internal Server Error", status)
@ -61,7 +61,7 @@ func TestEosioV2_HTTP500Failed(t *testing.T) {
assert.Equal(t, expected, check) assert.Equal(t, expected, check)
} }
func TestEosioV2_LaggingUp(t *testing.T) { func TestAntelopeV2_LaggingUp(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v2/health" { if req.URL.String() == "/v2/health" {
info := `{ info := `{
@ -99,7 +99,7 @@ func TestEosioV2_LaggingUp(t *testing.T) {
} }
})) }))
api := NewEosioV2(srv.URL, "", 500) api := NewAntelopeV2(srv.URL, "", 500)
check, status := api.Call() check, status := api.Call()
assert.Equal(t, "OK", status) assert.Equal(t, "OK", status)
@ -108,7 +108,7 @@ func TestEosioV2_LaggingUp(t *testing.T) {
assert.Equal(t, expected, check) assert.Equal(t, expected, check)
} }
func TestEosioV2_LaggingDown(t *testing.T) { func TestAntelopeV2_LaggingDown(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v2/health" { if req.URL.String() == "/v2/health" {
info := `{ info := `{
@ -146,7 +146,7 @@ func TestEosioV2_LaggingDown(t *testing.T) {
} }
})) }))
api := NewEosioV2(srv.URL, "", 499) api := NewAntelopeV2(srv.URL, "", 499)
check, status := api.Call() check, status := api.Call()
assert.Equal(t, "Taking offline because Elastic is 500 blocks behind", status) assert.Equal(t, "Taking offline because Elastic is 500 blocks behind", status)
@ -155,7 +155,7 @@ func TestEosioV2_LaggingDown(t *testing.T) {
assert.Equal(t, expected, check) assert.Equal(t, expected, check)
} }
func TestEosioV2_LaggingESInFutureUP(t *testing.T) { func TestAntelopeV2_LaggingESInFutureUP(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v2/health" { if req.URL.String() == "/v2/health" {
info := `{ info := `{
@ -193,7 +193,7 @@ func TestEosioV2_LaggingESInFutureUP(t *testing.T) {
} }
})) }))
api := NewEosioV2(srv.URL, "", 200) api := NewAntelopeV2(srv.URL, "", 200)
check, status := api.Call() check, status := api.Call()
assert.Equal(t, "OK", status) assert.Equal(t, "OK", status)
@ -202,7 +202,7 @@ func TestEosioV2_LaggingESInFutureUP(t *testing.T) {
assert.Equal(t, expected, check) assert.Equal(t, expected, check)
} }
func TestEosioV2_LaggingESInFutureDown(t *testing.T) { func TestAntelopeV2_LaggingESInFutureDown(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v2/health" { if req.URL.String() == "/v2/health" {
info := `{ info := `{
@ -240,7 +240,7 @@ func TestEosioV2_LaggingESInFutureDown(t *testing.T) {
} }
})) }))
api := NewEosioV2(srv.URL, "", 200) api := NewAntelopeV2(srv.URL, "", 200)
check, status := api.Call() check, status := api.Call()
assert.Equal(t, "Taking offline because Elastic is 201 blocks into the future", status) assert.Equal(t, "Taking offline because Elastic is 201 blocks into the future", status)
@ -249,7 +249,7 @@ func TestEosioV2_LaggingESInFutureDown(t *testing.T) {
assert.Equal(t, expected, check) assert.Equal(t, expected, check)
} }
func TestEosioV2_ElasticsFailed(t *testing.T) { func TestAntelopeV2_ElasticsFailed(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v2/health" { if req.URL.String() == "/v2/health" {
info := `{ info := `{
@ -287,7 +287,7 @@ func TestEosioV2_ElasticsFailed(t *testing.T) {
} }
})) }))
api := NewEosioV2(srv.URL, "", 500) api := NewAntelopeV2(srv.URL, "", 500)
check, status := api.Call() check, status := api.Call()
assert.Equal(t, "Failed to get Elasticsearch and/or nodeos block numbers (es: 0, eos: 263148621)", status) assert.Equal(t, "Failed to get Elasticsearch and/or nodeos block numbers (es: 0, eos: 263148621)", status)
@ -296,7 +296,7 @@ func TestEosioV2_ElasticsFailed(t *testing.T) {
assert.Equal(t, expected, check) assert.Equal(t, expected, check)
} }
func TestEosioV2_NodeosRPCFailed(t *testing.T) { func TestAntelopeV2_NodeosRPCFailed(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v2/health" { if req.URL.String() == "/v2/health" {
info := `{ info := `{
@ -334,7 +334,7 @@ func TestEosioV2_NodeosRPCFailed(t *testing.T) {
} }
})) }))
api := NewEosioV2(srv.URL, "", 500) api := NewAntelopeV2(srv.URL, "", 500)
check, status := api.Call() check, status := api.Call()
assert.Equal(t, "Failed to get Elasticsearch and/or nodeos block numbers (es: 263148121, eos: 0)", status) assert.Equal(t, "Failed to get Elasticsearch and/or nodeos block numbers (es: 263148121, eos: 0)", status)
@ -343,7 +343,7 @@ func TestEosioV2_NodeosRPCFailed(t *testing.T) {
assert.Equal(t, expected, check) assert.Equal(t, expected, check)
} }
func TestEosioV2_ElasticsNodeosRPCFailed(t *testing.T) { func TestAntelopeV2_ElasticsNodeosRPCFailed(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if req.URL.String() == "/v2/health" { if req.URL.String() == "/v2/health" {
info := `{ info := `{
@ -371,7 +371,7 @@ func TestEosioV2_ElasticsNodeosRPCFailed(t *testing.T) {
} }
})) }))
api := NewEosioV2(srv.URL, "", 500) api := NewAntelopeV2(srv.URL, "", 500)
check, status := api.Call() check, status := api.Call()
assert.Equal(t, "Failed to get Elasticsearch and/or nodeos block numbers (es: 0, eos: 0)", status) assert.Equal(t, "Failed to get Elasticsearch and/or nodeos block numbers (es: 0, eos: 0)", status)

View file

@ -6,8 +6,8 @@ import (
func Make(name string, args ApiArguments) (ApiInterface, error) { func Make(name string, args ApiArguments) (ApiInterface, error) {
factories := map[string]Factory{ factories := map[string]Factory{
"v1": EosioV1Factory, "v1": AntelopeV1Factory,
"v2": EosioV2Factory, "v2": AntelopeV2Factory,
"atomic": AtomicAssetFactory, "atomic": AtomicAssetFactory,
"debug": DebugApiFactory, "debug": DebugApiFactory,
} }

View file

@ -5,7 +5,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/eosswedenorg/eosio-api-healthcheck/internal/api" "github.com/eosswedenorg/antelope-api-healthcheck/internal/api"
) )
func ParseArguments(args []string) api.ApiArguments { func ParseArguments(args []string) api.ApiArguments {

View file

@ -3,7 +3,7 @@ package server
import ( import (
"testing" "testing"
"github.com/eosswedenorg/eosio-api-healthcheck/internal/api" "github.com/eosswedenorg/antelope-api-healthcheck/internal/api"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
@ -21,54 +21,54 @@ func TestParseRequest_WithInvalidParams(t *testing.T) {
assert.Nil(t, api) assert.Nil(t, api)
} }
// EosioV1 // AntelopeV1
// -------------------------------- // --------------------------------
func TestParseRequest_EosioV1(t *testing.T) { func TestParseRequest_AntelopeV1(t *testing.T) {
expected := api.NewEosioV1("http://api.example.com", "", 5) expected := api.NewAntelopeV1("http://api.example.com", "", 5)
api, err := ParseRequest("v1|http://api.example.com") api, err := ParseRequest("v1|http://api.example.com")
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, expected.LogInfo(), api.LogInfo()) assert.Equal(t, expected.LogInfo(), api.LogInfo())
} }
func TestParseRequest_EosioV1WithBlockNumber(t *testing.T) { func TestParseRequest_AntelopeV1WithBlockNumber(t *testing.T) {
expected := api.NewEosioV1("http://api.example.com", "", 1000) expected := api.NewAntelopeV1("http://api.example.com", "", 1000)
api, err := ParseRequest("v1|http://api.example.com|2000") api, err := ParseRequest("v1|http://api.example.com|2000")
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, expected.LogInfo(), api.LogInfo()) assert.Equal(t, expected.LogInfo(), api.LogInfo())
} }
func TestParseRequest_EosioV1Full(t *testing.T) { func TestParseRequest_AntelopeV1Full(t *testing.T) {
expected := api.NewEosioV1("http://api.example.com", "http://host.example.com", 500) expected := api.NewAntelopeV1("http://api.example.com", "http://host.example.com", 500)
api, err := ParseRequest("v1|http://api.example.com|1000|http://host.example.com") api, err := ParseRequest("v1|http://api.example.com|1000|http://host.example.com")
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, expected.LogInfo(), api.LogInfo()) assert.Equal(t, expected.LogInfo(), api.LogInfo())
} }
// EosioV2 // AntelopeV2
// -------------------------------- // --------------------------------
func TestParseRequest_EosioV2(t *testing.T) { func TestParseRequest_AntelopeV2(t *testing.T) {
expected := api.NewEosioV2("http://api.v2.example.com", "", 10) expected := api.NewAntelopeV2("http://api.v2.example.com", "", 10)
api, err := ParseRequest("v2|http://api.v2.example.com") api, err := ParseRequest("v2|http://api.v2.example.com")
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, expected.LogInfo(), api.LogInfo()) assert.Equal(t, expected.LogInfo(), api.LogInfo())
} }
func TestParseRequest_EosioV2WithOffset(t *testing.T) { func TestParseRequest_AntelopeV2WithOffset(t *testing.T) {
expected := api.NewEosioV2("http://api.v2.example.com", "", 1000) expected := api.NewAntelopeV2("http://api.v2.example.com", "", 1000)
api, err := ParseRequest("v2|http://api.v2.example.com|1000") api, err := ParseRequest("v2|http://api.v2.example.com|1000")
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, expected.LogInfo(), api.LogInfo()) assert.Equal(t, expected.LogInfo(), api.LogInfo())
} }
func TestParseRequest_EosioV2Full(t *testing.T) { func TestParseRequest_AntelopeV2Full(t *testing.T) {
expected := api.NewEosioV2("http://api.v2.example.com", "http://host.example.com", 1000) expected := api.NewAntelopeV2("http://api.v2.example.com", "http://host.example.com", 1000)
api, err := ParseRequest("v2|http://api.v2.example.com|1000|http://host.example.com") api, err := ParseRequest("v2|http://api.v2.example.com|1000|http://host.example.com")
assert.NoError(t, err) assert.NoError(t, err)

View file

@ -5,7 +5,7 @@ import (
"github.com/eosswedenorg-go/haproxy/agentcheck" "github.com/eosswedenorg-go/haproxy/agentcheck"
"github.com/eosswedenorg-go/tcp_server" "github.com/eosswedenorg-go/tcp_server"
"github.com/eosswedenorg/eosio-api-healthcheck/internal/api" "github.com/eosswedenorg/antelope-api-healthcheck/internal/api"
log "github.com/inconshreveable/log15" log "github.com/inconshreveable/log15"
) )

View file

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# Info # Info
PROGRAM_NAME=eosio-api-healthcheck PROGRAM_NAME=antelope-api-healthcheck
PROGRAM_DESCRIPTION="HAproxy healthcheck program for EOSIO API." PROGRAM_DESCRIPTION="HAproxy healthcheck program for Antelope Leap API."

View file

@ -4,4 +4,4 @@
# Command line flags to pass to {{ PROGRAM_NAME }} # Command line flags to pass to {{ PROGRAM_NAME }}
# Positional agruments are IP to listen to, then port number. # Positional agruments are IP to listen to, then port number.
EOSIO_API_HEALTCHECK_OPTS="--log-format=logfmt 127.0.0.1 1337" ANTELOPE_API_HEALTCHECK_OPTS="--log-format=logfmt 127.0.0.1 1337"

View file

@ -1,11 +1,11 @@
#!/bin/sh #!/bin/sh
# #
# Add the following lines to /etc/rc.conf to configure eosio_api_healthcheck: # Add the following lines to /etc/rc.conf to configure antelope_api_healthcheck:
# #
# eosio_api_healthcheck_args : arguments to the command. # antelope_api_healthcheck_args : arguments to the command.
# #
# eosio_api_healthcheck_logfile : file to log to (default /var/log/${name}.log) # antelope_api_healthcheck_logfile : file to log to (default /var/log/${name}.log)
# #
# PROVIDE: {{ RC_NAME }} # PROVIDE: {{ RC_NAME }}
@ -15,14 +15,14 @@
name="{{ RC_NAME }}" name="{{ RC_NAME }}"
desc="{{ PROGRAM_DESCRIPTION }}" desc="{{ PROGRAM_DESCRIPTION }}"
logfile="${eosio_api_healthcheck_logfile:-{{ LOG_FILE }}}" logfile="${antelope_api_healthcheck_logfile:-{{ LOG_FILE }}}"
pidfile="{{ PID_FILE }}" pidfile="{{ PID_FILE }}"
command="{{ PROGRAM }}" command="{{ PROGRAM }}"
command_args="-p ${pidfile} -l ${logfile} ${eosio_api_healthcheck_args}" command_args="-p ${pidfile} -l ${logfile} ${antelope_api_healthcheck_args}"
start_cmd="${name}_start" start_cmd="${name}_start"
eosio_api_healthcheck_start() antelope_api_healthcheck_start()
{ {
echo "Starting ${name}" echo "Starting ${name}"
${command} ${command_args} 2>&1 & ${command} ${command_args} 2>&1 &

View file

@ -5,7 +5,7 @@ After=network.target
[Service] [Service]
EnvironmentFile=-/etc/sysconfig/{{ PROGRAM_NAME }} EnvironmentFile=-/etc/sysconfig/{{ PROGRAM_NAME }}
Type=simple Type=simple
ExecStart={{ PROGRAM }} $EOSIO_API_HEALTCHECK_OPTS ExecStart={{ PROGRAM }} $ANTELOPE_API_HEALTCHECK_OPTS
Restart=on-failure Restart=on-failure
[Install] [Install]

View file

@ -48,7 +48,7 @@ if [ ${WRITE_DEBCHANGES} -ne 0 ]; then
# Update debian changelog # Update debian changelog
ex debian/changelog <<EOF ex debian/changelog <<EOF
1 insert 1 insert
eosio-api-healthcheck (${VERSION}) unstable; urgency=medium antelope-api-healthcheck (${VERSION}) unstable; urgency=medium
* *