-
Notifications
You must be signed in to change notification settings - Fork 450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Algod: New health endpoint (k8s /ready
endpoint)
#4844
Merged
Merged
Changes from 68 commits
Commits
Show all changes
70 commits
Select commit
Hold shift + click to select a range
95512f0
init commit
ahangsu bbe6340
minor
ahangsu 78b107e
Merge branch 'master' into ready-endpoint
ahangsu 4c3b87c
revert back to only status ok 200
ahangsu c45de5b
bad hack
ahangsu b8a5174
Merge branch 'master' into ready-endpoint
ahangsu 9cd154c
Merge branch 'master' into ready-endpoint
ahangsu be5c418
start moving to common endpoint
ahangsu 7946207
comments
ahangsu c3b7a4e
Merge branch 'master' into ready-endpoint
ahangsu 5e1f430
rewriting...
ahangsu aa20108
rewriting... err msg
ahangsu a726d54
rewriting... finalize common handler stuffs
ahangsu 9674439
grammar police
ahangsu b5b0019
bark
ahangsu db9daf0
remove global var
ahangsu 17927d2
Merge branch 'master' into ready-endpoint
ahangsu b21bdbc
minor
ahangsu ddc4a46
Merge branch 'master' into ready-endpoint
ahangsu 4a73484
Merge branch 'master' into ready-endpoint
ahangsu 8f93f35
refactoring
ahangsu 0120c3a
remove 503 erroring after reading s.Initialize
ahangsu 20fd177
minor, returning 400 for not ready yet
ahangsu 6cd7a12
minor
ahangsu 6267200
Merge branch 'master' into ready-endpoint
ahangsu d020c0f
Merge branch 'master' into ready-endpoint
ahangsu 7eb3f91
expand NodeInterface with v2.NodeInterface
ahangsu e6cf96d
Merge branch 'master' into ready-endpoint
ahangsu e36e357
I should not use v2.Interface in common, NodeInterface need Status()
ahangsu 459a0db
a set of better than nothing mock test
ahangsu 353ac90
coverage on mockNode Status
ahangsu d309f45
partitiontest, remove some boilerplate stuffs
ahangsu ca64373
what a mess
ahangsu 1180e48
per will's discussion on readyness endpoint, catchuptime > 0 check
ahangsu b8bf0a5
remove previous wrong assumed test condition
ahangsu 088d50e
start a test that rolls a network and generate catchpoint at an interval
ahangsu c69c769
should be activating generating catchpoint file for fast catchup, com…
ahangsu b32e3d2
/ready should be rdy, a slew of fail with a catch up ready in the end
ahangsu dea1ee2
debugging against ci
ahangsu ab60064
activate one of the catchpoint test and see if same error occur
ahangsu fb30e73
revert activation
ahangsu 090dfd7
a random attempt like Tsachi's test
ahangsu 3d6f8e8
comments that explains the test
ahangsu 93cd788
NOTE to specify section that is ACTUALLY doing the test
ahangsu be65df1
Merge branch 'master' into ready-endpoint
ahangsu 7dc8f65
Merge branch 'master' into ready-endpoint
ahangsu 2f200f9
change fast catchup to sync time impl
ahangsu e7f24a2
update test comment
ahangsu 2a824b4
Merge branch 'master' into ready-endpoint
ahangsu 5936a8d
readiness from stat
ahangsu 65dc1d6
changing test condition, but seems my test case, round not proceed af…
ahangsu 26eda2b
I wonder if the wolf is coming, but seems a bug to me
ahangsu a9072b5
Merge branch 'master' into ready-endpoint
ahangsu 5c0f7b3
modify test a bit for debugging, looking for something interesting
ahangsu 2fb38ad
at least basic catchup ready test is workable, but why it is going wr…
ahangsu 310afbb
really at a loss what should I do
ahangsu f683267
revert some changes
ahangsu 8e46cfd
confirming that the /ready works
ahangsu 68b1658
TEST RELATED COMMIT, REVERT WHEN WE FIGURE OUT
ahangsu cd30760
thinking it might be test harness issue, managed to test readiness in…
ahangsu 391e87a
Revert "TEST RELATED COMMIT, REVERT WHEN WE FIGURE OUT"
ahangsu e45ecc4
extract out testing part for ready endpoint
ahangsu 6bddb4a
Merge branch 'master' into ready-endpoint
ahangsu 2eef1b1
Update test/e2e-go/features/catchup/catchpointCatchup_test.go
bbroder-algo a597669
Merge branch 'master' into ready-endpoint
ahangsu b559e61
400 err -> 503 err
ahangsu 07947fe
comment minor change
ahangsu 32c77bc
Merge branch 'master' into ready-endpoint
ahangsu 5a43128
Update catchup/service.go
bbroder-algo 3d949d3
reset log level of endpoint resp, maybe need another round of reapprove
ahangsu File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright (C) 2019-2023 Algorand, Inc. | ||
// This file is part of go-algorand | ||
// | ||
// go-algorand is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as | ||
// published by the Free Software Foundation, either version 3 of the | ||
// License, or (at your option) any later version. | ||
// | ||
// go-algorand is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
package test | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
|
||
"github.com/labstack/echo/v4" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/algorand/go-algorand/daemon/algod/api/server/common" | ||
"github.com/algorand/go-algorand/daemon/algod/api/server/lib" | ||
"github.com/algorand/go-algorand/logging" | ||
"github.com/algorand/go-algorand/node" | ||
"github.com/algorand/go-algorand/test/partitiontest" | ||
) | ||
|
||
func mockNodeStatusInRangeHelper( | ||
t *testing.T, statusCode MockNodeCatchupStatus, | ||
expectedErr error, expectedStatus node.StatusReport) { | ||
mockNodeInstance := makeMockNode(statusCode) | ||
status, err := mockNodeInstance.Status() | ||
if expectedErr != nil { | ||
require.Error(t, err, expectedErr) | ||
} else { | ||
require.Equal(t, expectedStatus, status) | ||
} | ||
} | ||
|
||
func TestMockNodeStatus(t *testing.T) { | ||
partitiontest.PartitionTest(t) | ||
|
||
mockNodeStatusInRangeHelper( | ||
t, CaughtUpAndReady, nil, cannedStatusReportCaughtUpAndReadyGolden) | ||
mockNodeStatusInRangeHelper( | ||
t, CatchingUpFast, nil, cannedStatusReportCatchingUpFastGolden) | ||
mockNodeStatusInRangeHelper( | ||
t, StoppedAtUnsupported, nil, cannedStatusReportStoppedAtUnsupportedGolden) | ||
mockNodeStatusInRangeHelper( | ||
t, 399, fmt.Errorf("catchup status out of scope error"), node.StatusReport{}) | ||
} | ||
|
||
func readyEndpointTestHelper( | ||
t *testing.T, node *mockNode, expectedCode int) { | ||
reqCtx := lib.ReqContext{ | ||
Node: node, | ||
Log: logging.NewLogger(), | ||
Shutdown: make(chan struct{}), | ||
} | ||
|
||
e := echo.New() | ||
req := httptest.NewRequest(http.MethodGet, "/", nil) | ||
rec := httptest.NewRecorder() | ||
c := e.NewContext(req, rec) | ||
|
||
common.Ready(reqCtx, c) | ||
require.Equal(t, expectedCode, rec.Code) | ||
} | ||
|
||
func TestReadyEndpoint(t *testing.T) { | ||
partitiontest.PartitionTest(t) | ||
|
||
mockNodeInstance := makeMockNode(CaughtUpAndReady) | ||
readyEndpointTestHelper(t, mockNodeInstance, http.StatusOK) | ||
|
||
mockNodeInstance.catchupStatus = CatchingUpFast | ||
readyEndpointTestHelper(t, mockNodeInstance, http.StatusServiceUnavailable) | ||
|
||
mockNodeInstance.catchupStatus = StoppedAtUnsupported | ||
readyEndpointTestHelper(t, mockNodeInstance, http.StatusInternalServerError) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes more sense to me as it's currently written.