mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-06-16 04:44:55 +02:00
Rename project from eosio-api-healthcheck to antelope-api-healthcheck
This commit is contained in:
parent
e0a7a10662
commit
61cb49f8be
20 changed files with 115 additions and 115 deletions
4
Makefile
4
Makefile
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
PROGRAM_NAME = eosio-api-healthcheck
|
||||
PROGRAM_NAME = antelope-api-healthcheck
|
||||
export PROGRAM_VERSION = 1.2.6
|
||||
|
||||
GO = go
|
||||
|
|
@ -16,7 +16,7 @@ all: build
|
|||
build: build/$(PROGRAM_NAME)
|
||||
|
||||
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:
|
||||
$(GO) test -v ./...
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ import (
|
|||
"syscall"
|
||||
|
||||
"github.com/eosswedenorg-go/pid"
|
||||
"github.com/eosswedenorg/eosio-api-healthcheck/internal/server"
|
||||
"github.com/eosswedenorg/eosio-api-healthcheck/internal/utils"
|
||||
"github.com/eosswedenorg/antelope-api-healthcheck/internal/server"
|
||||
"github.com/eosswedenorg/antelope-api-healthcheck/internal/utils"
|
||||
log "github.com/inconshreveable/log15"
|
||||
"github.com/pborman/getopt/v2"
|
||||
)
|
||||
14
debian/control
vendored
14
debian/control
vendored
|
|
@ -1,19 +1,19 @@
|
|||
Source: eosio-api-healthcheck
|
||||
Source: antelope-api-healthcheck
|
||||
Section: introspection
|
||||
Build-Depends:
|
||||
debhelper (>= 11)
|
||||
Standards-Version: 4.5.0
|
||||
Vcs-Git: https://github.com/eosswedenorg/eos-api-healthcheck.git
|
||||
Vcs-Browser: https://github.com/eosswedenorg/eos-api-healthcheck
|
||||
Vcs-Git: https://github.com/eosswedenorg/antelope-api-healthcheck.git
|
||||
Vcs-Browser: https://github.com/eosswedenorg/antelope-api-healthcheck
|
||||
Priority: optional
|
||||
Maintainer: Henrik Hautakoski <henrik@eossweden.org>
|
||||
|
||||
Package: eosio-api-healthcheck
|
||||
Package: antelope-api-healthcheck
|
||||
Section: introspection
|
||||
Priority: optional
|
||||
Architecture: amd64
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Homepage: https://github.com/eosswedenorg/eos-api-healthcheck
|
||||
Description: HAproxy healthcheck program for EOSIO API.
|
||||
Homepage: https://github.com/eosswedenorg/antelope-api-healthcheck
|
||||
Description: HAproxy healthcheck program for Leap API.
|
||||
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
4
debian/copyright
vendored
|
|
@ -1,7 +1,7 @@
|
|||
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>
|
||||
Source: https://github.com/eosswedenorg/eos-api-healthcheck.git
|
||||
Source: https://github.com/eosswedenorg/antelope-api-healthcheck.git
|
||||
|
||||
Files: *
|
||||
Copyright: 2020-2022 Sw/eden
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -1,4 +1,4 @@
|
|||
module github.com/eosswedenorg/eosio-api-healthcheck
|
||||
module github.com/eosswedenorg/antelope-api-healthcheck
|
||||
|
||||
go 1.16
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/eosswedenorg-go/atomicasset"
|
||||
"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 {
|
||||
|
|
|
|||
|
|
@ -5,21 +5,21 @@ import (
|
|||
|
||||
"github.com/eosswedenorg-go/eosapi"
|
||||
"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
|
||||
client eosapi.Client
|
||||
block_time float64
|
||||
}
|
||||
|
||||
func EosioV1Factory(args ApiArguments) ApiInterface {
|
||||
return NewEosioV1(args.Url, args.Host, float64(args.NumBlocks/2))
|
||||
func AntelopeV1Factory(args ApiArguments) ApiInterface {
|
||||
return NewAntelopeV1(args.Url, args.Host, float64(args.NumBlocks/2))
|
||||
}
|
||||
|
||||
func NewEosioV1(url string, host string, block_time float64) EosioV1 {
|
||||
api := EosioV1{
|
||||
func NewAntelopeV1(url string, host string, block_time float64) AntelopeV1 {
|
||||
api := AntelopeV1{
|
||||
client: *eosapi.New(url),
|
||||
block_time: block_time,
|
||||
}
|
||||
|
|
@ -29,9 +29,9 @@ func NewEosioV1(url string, host string, block_time float64) EosioV1 {
|
|||
return api
|
||||
}
|
||||
|
||||
func (e EosioV1) LogInfo() LogParams {
|
||||
func (e AntelopeV1) LogInfo() LogParams {
|
||||
p := LogParams{
|
||||
"type", "eosio-v1",
|
||||
"type", "antelope-v1",
|
||||
"url", e.client.Url,
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ func (e EosioV1) LogInfo() LogParams {
|
|||
return p
|
||||
}
|
||||
|
||||
func (e EosioV1) Call() (agentcheck.Response, string) {
|
||||
func (e AntelopeV1) Call() (agentcheck.Response, string) {
|
||||
info, err := e.client.GetInfo()
|
||||
if err != nil {
|
||||
resp := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "")
|
||||
|
|
|
|||
|
|
@ -10,33 +10,33 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestEosioV1_Factory(t *testing.T) {
|
||||
api := EosioV1Factory(ApiArguments{
|
||||
func TestAntelopeV1_Factory(t *testing.T) {
|
||||
api := AntelopeV1Factory(ApiArguments{
|
||||
Url: "https://api.v1.example.com",
|
||||
Host: "host.example.com",
|
||||
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.Equal(t, expected.client.Url, api.(EosioV1).client.Url)
|
||||
assert.Equal(t, expected.client.Host, api.(EosioV1).client.Host)
|
||||
assert.Equal(t, expected.block_time, api.(EosioV1).block_time)
|
||||
assert.Equal(t, expected.client.Url, api.(AntelopeV1).client.Url)
|
||||
assert.Equal(t, expected.client.Host, api.(AntelopeV1).client.Host)
|
||||
assert.Equal(t, expected.block_time, api.(AntelopeV1).block_time)
|
||||
}
|
||||
|
||||
func TestEosioV1_LogInfo(t *testing.T) {
|
||||
api := NewEosioV1("https://api.v1.example.com", "host.example.com", 120)
|
||||
func TestAntelopeV1_LogInfo(t *testing.T) {
|
||||
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())
|
||||
}
|
||||
|
||||
func TestEosioV1_SetTime(t *testing.T) {
|
||||
func TestAntelopeV1_SetTime(t *testing.T) {
|
||||
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.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())
|
||||
}
|
||||
|
||||
func TestEosioV1_JsonFailure(t *testing.T) {
|
||||
func TestAntelopeV1_JsonFailure(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||
_, err := res.Write([]byte(`!//{invalid-json}!##`))
|
||||
assert.NoError(t, err)
|
||||
}))
|
||||
|
||||
api := NewEosioV1(srv.URL, "", 120)
|
||||
api := NewAntelopeV1(srv.URL, "", 120)
|
||||
check, _ := api.Call()
|
||||
|
||||
expected := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "")
|
||||
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) {
|
||||
res.WriteHeader(500)
|
||||
_, err := res.Write([]byte(`{}`))
|
||||
assert.NoError(t, err)
|
||||
}))
|
||||
|
||||
api := NewEosioV1(srv.URL, "", 120)
|
||||
api := NewAntelopeV1(srv.URL, "", 120)
|
||||
check, status := api.Call()
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func TestEosioV1_LaggingUp(t *testing.T) {
|
||||
func TestAntelopeV1_LaggingUp(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||
if req.URL.String() == "/v1/chain/get_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))
|
||||
check, status := api.Call()
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ func TestEosioV1_LaggingUp(t *testing.T) {
|
|||
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) {
|
||||
if req.URL.String() == "/v1/chain/get_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))
|
||||
check, status := api.Call()
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ func TestEosioV1_LaggingDown(t *testing.T) {
|
|||
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) {
|
||||
if req.URL.String() == "/v1/chain/get_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))
|
||||
check, status := api.Call()
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ func TestEosioV1_TimeInFutureUP(t *testing.T) {
|
|||
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) {
|
||||
if req.URL.String() == "/v1/chain/get_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))
|
||||
check, status := api.Call()
|
||||
|
||||
|
|
|
|||
|
|
@ -5,20 +5,20 @@ import (
|
|||
|
||||
"github.com/eosswedenorg-go/eosapi"
|
||||
"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
|
||||
offset int64
|
||||
}
|
||||
|
||||
func EosioV2Factory(args ApiArguments) ApiInterface {
|
||||
return NewEosioV2(args.Url, args.Host, int64(args.NumBlocks))
|
||||
func AntelopeV2Factory(args ApiArguments) ApiInterface {
|
||||
return NewAntelopeV2(args.Url, args.Host, int64(args.NumBlocks))
|
||||
}
|
||||
|
||||
func NewEosioV2(url string, host string, offset int64) EosioV2 {
|
||||
api := EosioV2{
|
||||
func NewAntelopeV2(url string, host string, offset int64) AntelopeV2 {
|
||||
api := AntelopeV2{
|
||||
client: *eosapi.New(url),
|
||||
offset: offset,
|
||||
}
|
||||
|
|
@ -28,9 +28,9 @@ func NewEosioV2(url string, host string, offset int64) EosioV2 {
|
|||
return api
|
||||
}
|
||||
|
||||
func (e EosioV2) LogInfo() LogParams {
|
||||
func (e AntelopeV2) LogInfo() LogParams {
|
||||
p := LogParams{
|
||||
"type", "eosio-v2",
|
||||
"type", "antelope-v2",
|
||||
"url", e.client.Url,
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ func (e EosioV2) LogInfo() LogParams {
|
|||
return p
|
||||
}
|
||||
|
||||
func (e EosioV2) Call() (agentcheck.Response, string) {
|
||||
func (e AntelopeV2) Call() (agentcheck.Response, string) {
|
||||
health, err := e.client.GetHealth()
|
||||
if err != nil {
|
||||
resp := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "")
|
||||
|
|
|
|||
|
|
@ -9,50 +9,50 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestEosioV2_Factory(t *testing.T) {
|
||||
api := EosioV2Factory(ApiArguments{
|
||||
func TestAntelopeV2_Factory(t *testing.T) {
|
||||
api := AntelopeV2Factory(ApiArguments{
|
||||
Url: "https://api.v2.example.com",
|
||||
Host: "host.example.com",
|
||||
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.Equal(t, expected.client.Url, api.(EosioV2).client.Url)
|
||||
assert.Equal(t, expected.client.Host, api.(EosioV2).client.Host)
|
||||
assert.Equal(t, expected.offset, api.(EosioV2).offset)
|
||||
assert.Equal(t, expected.client.Url, api.(AntelopeV2).client.Url)
|
||||
assert.Equal(t, expected.client.Host, api.(AntelopeV2).client.Host)
|
||||
assert.Equal(t, expected.offset, api.(AntelopeV2).offset)
|
||||
}
|
||||
|
||||
func TestEosioV2_LogInfo(t *testing.T) {
|
||||
api := NewEosioV2("https://api.v2.example.com", "host.example.com", 120)
|
||||
func TestAntelopeV2_LogInfo(t *testing.T) {
|
||||
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())
|
||||
}
|
||||
|
||||
func TestEosioV2_JsonFailure(t *testing.T) {
|
||||
func TestAntelopeV2_JsonFailure(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||
_, err := res.Write([]byte(`!//{invalid-json}!##`))
|
||||
assert.NoError(t, err)
|
||||
}))
|
||||
|
||||
api := NewEosioV2(srv.URL, "", 120)
|
||||
api := NewAntelopeV2(srv.URL, "", 120)
|
||||
check, _ := api.Call()
|
||||
|
||||
expected := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "")
|
||||
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) {
|
||||
res.WriteHeader(500)
|
||||
_, err := res.Write([]byte(`{}`))
|
||||
assert.NoError(t, err)
|
||||
}))
|
||||
|
||||
api := NewEosioV2(srv.URL, "", 120)
|
||||
api := NewAntelopeV2(srv.URL, "", 120)
|
||||
check, status := api.Call()
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func TestEosioV2_LaggingUp(t *testing.T) {
|
||||
func TestAntelopeV2_LaggingUp(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||
if req.URL.String() == "/v2/health" {
|
||||
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()
|
||||
|
||||
assert.Equal(t, "OK", status)
|
||||
|
|
@ -108,7 +108,7 @@ func TestEosioV2_LaggingUp(t *testing.T) {
|
|||
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) {
|
||||
if req.URL.String() == "/v2/health" {
|
||||
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()
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func TestEosioV2_LaggingESInFutureUP(t *testing.T) {
|
||||
func TestAntelopeV2_LaggingESInFutureUP(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||
if req.URL.String() == "/v2/health" {
|
||||
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()
|
||||
|
||||
assert.Equal(t, "OK", status)
|
||||
|
|
@ -202,7 +202,7 @@ func TestEosioV2_LaggingESInFutureUP(t *testing.T) {
|
|||
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) {
|
||||
if req.URL.String() == "/v2/health" {
|
||||
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()
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func TestEosioV2_ElasticsFailed(t *testing.T) {
|
||||
func TestAntelopeV2_ElasticsFailed(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||
if req.URL.String() == "/v2/health" {
|
||||
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()
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func TestEosioV2_NodeosRPCFailed(t *testing.T) {
|
||||
func TestAntelopeV2_NodeosRPCFailed(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||
if req.URL.String() == "/v2/health" {
|
||||
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()
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func TestEosioV2_ElasticsNodeosRPCFailed(t *testing.T) {
|
||||
func TestAntelopeV2_ElasticsNodeosRPCFailed(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||
if req.URL.String() == "/v2/health" {
|
||||
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()
|
||||
|
||||
assert.Equal(t, "Failed to get Elasticsearch and/or nodeos block numbers (es: 0, eos: 0)", status)
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import (
|
|||
|
||||
func Make(name string, args ApiArguments) (ApiInterface, error) {
|
||||
factories := map[string]Factory{
|
||||
"v1": EosioV1Factory,
|
||||
"v2": EosioV2Factory,
|
||||
"v1": AntelopeV1Factory,
|
||||
"v2": AntelopeV2Factory,
|
||||
"atomic": AtomicAssetFactory,
|
||||
"debug": DebugApiFactory,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/eosswedenorg/eosio-api-healthcheck/internal/api"
|
||||
"github.com/eosswedenorg/antelope-api-healthcheck/internal/api"
|
||||
)
|
||||
|
||||
func ParseArguments(args []string) api.ApiArguments {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package server
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/eosswedenorg/eosio-api-healthcheck/internal/api"
|
||||
"github.com/eosswedenorg/antelope-api-healthcheck/internal/api"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -21,54 +21,54 @@ func TestParseRequest_WithInvalidParams(t *testing.T) {
|
|||
assert.Nil(t, api)
|
||||
}
|
||||
|
||||
// EosioV1
|
||||
// AntelopeV1
|
||||
// --------------------------------
|
||||
|
||||
func TestParseRequest_EosioV1(t *testing.T) {
|
||||
expected := api.NewEosioV1("http://api.example.com", "", 5)
|
||||
func TestParseRequest_AntelopeV1(t *testing.T) {
|
||||
expected := api.NewAntelopeV1("http://api.example.com", "", 5)
|
||||
|
||||
api, err := ParseRequest("v1|http://api.example.com")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, expected.LogInfo(), api.LogInfo())
|
||||
}
|
||||
|
||||
func TestParseRequest_EosioV1WithBlockNumber(t *testing.T) {
|
||||
expected := api.NewEosioV1("http://api.example.com", "", 1000)
|
||||
func TestParseRequest_AntelopeV1WithBlockNumber(t *testing.T) {
|
||||
expected := api.NewAntelopeV1("http://api.example.com", "", 1000)
|
||||
|
||||
api, err := ParseRequest("v1|http://api.example.com|2000")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, expected.LogInfo(), api.LogInfo())
|
||||
}
|
||||
|
||||
func TestParseRequest_EosioV1Full(t *testing.T) {
|
||||
expected := api.NewEosioV1("http://api.example.com", "http://host.example.com", 500)
|
||||
func TestParseRequest_AntelopeV1Full(t *testing.T) {
|
||||
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")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, expected.LogInfo(), api.LogInfo())
|
||||
}
|
||||
|
||||
// EosioV2
|
||||
// AntelopeV2
|
||||
// --------------------------------
|
||||
|
||||
func TestParseRequest_EosioV2(t *testing.T) {
|
||||
expected := api.NewEosioV2("http://api.v2.example.com", "", 10)
|
||||
func TestParseRequest_AntelopeV2(t *testing.T) {
|
||||
expected := api.NewAntelopeV2("http://api.v2.example.com", "", 10)
|
||||
|
||||
api, err := ParseRequest("v2|http://api.v2.example.com")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, expected.LogInfo(), api.LogInfo())
|
||||
}
|
||||
|
||||
func TestParseRequest_EosioV2WithOffset(t *testing.T) {
|
||||
expected := api.NewEosioV2("http://api.v2.example.com", "", 1000)
|
||||
func TestParseRequest_AntelopeV2WithOffset(t *testing.T) {
|
||||
expected := api.NewAntelopeV2("http://api.v2.example.com", "", 1000)
|
||||
|
||||
api, err := ParseRequest("v2|http://api.v2.example.com|1000")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, expected.LogInfo(), api.LogInfo())
|
||||
}
|
||||
|
||||
func TestParseRequest_EosioV2Full(t *testing.T) {
|
||||
expected := api.NewEosioV2("http://api.v2.example.com", "http://host.example.com", 1000)
|
||||
func TestParseRequest_AntelopeV2Full(t *testing.T) {
|
||||
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")
|
||||
assert.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/eosswedenorg-go/haproxy/agentcheck"
|
||||
"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"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Info
|
||||
PROGRAM_NAME=eosio-api-healthcheck
|
||||
PROGRAM_DESCRIPTION="HAproxy healthcheck program for EOSIO API."
|
||||
PROGRAM_NAME=antelope-api-healthcheck
|
||||
PROGRAM_DESCRIPTION="HAproxy healthcheck program for Antelope Leap API."
|
||||
|
|
|
|||
|
|
@ -4,4 +4,4 @@
|
|||
|
||||
# Command line flags to pass to {{ PROGRAM_NAME }}
|
||||
# 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"
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
#!/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 }}
|
||||
|
|
@ -15,14 +15,14 @@
|
|||
|
||||
name="{{ RC_NAME }}"
|
||||
desc="{{ PROGRAM_DESCRIPTION }}"
|
||||
logfile="${eosio_api_healthcheck_logfile:-{{ LOG_FILE }}}"
|
||||
logfile="${antelope_api_healthcheck_logfile:-{{ LOG_FILE }}}"
|
||||
pidfile="{{ PID_FILE }}"
|
||||
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"
|
||||
|
||||
eosio_api_healthcheck_start()
|
||||
antelope_api_healthcheck_start()
|
||||
{
|
||||
echo "Starting ${name}"
|
||||
${command} ${command_args} 2>&1 &
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ After=network.target
|
|||
[Service]
|
||||
EnvironmentFile=-/etc/sysconfig/{{ PROGRAM_NAME }}
|
||||
Type=simple
|
||||
ExecStart={{ PROGRAM }} $EOSIO_API_HEALTCHECK_OPTS
|
||||
ExecStart={{ PROGRAM }} $ANTELOPE_API_HEALTCHECK_OPTS
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ if [ ${WRITE_DEBCHANGES} -ne 0 ]; then
|
|||
# Update debian changelog
|
||||
ex debian/changelog <<EOF
|
||||
1 insert
|
||||
eosio-api-healthcheck (${VERSION}) unstable; urgency=medium
|
||||
antelope-api-healthcheck (${VERSION}) unstable; urgency=medium
|
||||
|
||||
*
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue