diff --git a/Makefile b/Makefile index f388b56..38960d0 100644 --- a/Makefile +++ b/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 ./... diff --git a/README.md b/README.md index 571a3e6..f4deeaa 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/cmd/eosio-api-healtcheck/main.go b/cmd/antelope-api-healtcheck/main.go similarity index 96% rename from cmd/eosio-api-healtcheck/main.go rename to cmd/antelope-api-healtcheck/main.go index 1259203..4779a82 100644 --- a/cmd/eosio-api-healtcheck/main.go +++ b/cmd/antelope-api-healtcheck/main.go @@ -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" ) diff --git a/debian/control b/debian/control index c70bf70..5c82d9e 100644 --- a/debian/control +++ b/debian/control @@ -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 -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 diff --git a/debian/copyright b/debian/copyright index 541e2ad..36b6a46 100644 --- a/debian/copyright +++ b/debian/copyright @@ -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 -Source: https://github.com/eosswedenorg/eos-api-healthcheck.git +Source: https://github.com/eosswedenorg/antelope-api-healthcheck.git Files: * Copyright: 2020-2022 Sw/eden diff --git a/go.mod b/go.mod index a6707b2..aeaec0b 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/eosswedenorg/eosio-api-healthcheck +module github.com/eosswedenorg/antelope-api-healthcheck go 1.16 diff --git a/internal/api/atomicasset.go b/internal/api/atomicasset.go index 6d1f434..99b1ab8 100644 --- a/internal/api/atomicasset.go +++ b/internal/api/atomicasset.go @@ -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 { diff --git a/internal/api/eosio_v1.go b/internal/api/eosio_v1.go index 5c13a18..e5c1e66 100644 --- a/internal/api/eosio_v1.go +++ b/internal/api/eosio_v1.go @@ -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, "") diff --git a/internal/api/eosio_v1_test.go b/internal/api/eosio_v1_test.go index 0acd42e..421d9fb 100644 --- a/internal/api/eosio_v1_test.go +++ b/internal/api/eosio_v1_test.go @@ -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() diff --git a/internal/api/eosio_v2.go b/internal/api/eosio_v2.go index 58cdd65..0db1e51 100644 --- a/internal/api/eosio_v2.go +++ b/internal/api/eosio_v2.go @@ -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, "") diff --git a/internal/api/eosio_v2_test.go b/internal/api/eosio_v2_test.go index 4f293ea..c03b6f3 100644 --- a/internal/api/eosio_v2_test.go +++ b/internal/api/eosio_v2_test.go @@ -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) diff --git a/internal/api/make.go b/internal/api/make.go index c26040b..2166f0a 100644 --- a/internal/api/make.go +++ b/internal/api/make.go @@ -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, } diff --git a/internal/server/parse_request.go b/internal/server/parse_request.go index ffbf92c..9ce88b2 100644 --- a/internal/server/parse_request.go +++ b/internal/server/parse_request.go @@ -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 { diff --git a/internal/server/parse_request_test.go b/internal/server/parse_request_test.go index 9ea83e7..d0ce82d 100644 --- a/internal/server/parse_request_test.go +++ b/internal/server/parse_request_test.go @@ -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) diff --git a/internal/server/server.go b/internal/server/server.go index bdc2fab..d050bab 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -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" ) diff --git a/scripts/info.sh b/scripts/info.sh index 925f69c..0453ab0 100644 --- a/scripts/info.sh +++ b/scripts/info.sh @@ -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." diff --git a/scripts/templates/config b/scripts/templates/config index f265cbf..0714348 100644 --- a/scripts/templates/config +++ b/scripts/templates/config @@ -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" \ No newline at end of file +ANTELOPE_API_HEALTCHECK_OPTS="--log-format=logfmt 127.0.0.1 1337" \ No newline at end of file diff --git a/scripts/templates/rc.conf b/scripts/templates/rc.conf index 854f26c..a5ca7e0 100644 --- a/scripts/templates/rc.conf +++ b/scripts/templates/rc.conf @@ -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 & diff --git a/scripts/templates/sysunit.service b/scripts/templates/sysunit.service index bf5e161..6352ff7 100644 --- a/scripts/templates/sysunit.service +++ b/scripts/templates/sysunit.service @@ -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] diff --git a/set-version.sh b/set-version.sh index 2decc8f..90ead14 100755 --- a/set-version.sh +++ b/set-version.sh @@ -48,7 +48,7 @@ if [ ${WRITE_DEBCHANGES} -ne 0 ]; then # Update debian changelog ex debian/changelog <