Skip to content

Commit

Permalink
Fix /status for archive mode (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergekh2 authored May 29, 2024
1 parent e161dac commit e6a4ea2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
15 changes: 15 additions & 0 deletions core/node/rpc/archiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package rpc_test

import (
"context"
"io"
"net"
"net/http"
"sync"
"testing"
"time"
Expand All @@ -22,6 +24,7 @@ import (
"github.com/river-build/river/core/node/storage"
"github.com/river-build/river/core/node/testutils/dbtestutils"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func fillUserSettingsStreamWithData(
Expand Down Expand Up @@ -378,6 +381,15 @@ func TestArchive100StreamsWithData(t *testing.T) {
require.Zero(stats.FailedOpsCount)
}

func httpGet(t *testing.T, url string) string {
resp, err := http.Get(url)
require.NoError(t, err)
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)
return string(body)
}

func TestArchiveContinuous(t *testing.T) {
tester := newServiceTesterAndStart(t, 1)
ctx := tester.ctx
Expand All @@ -404,6 +416,9 @@ func TestArchiveContinuous(t *testing.T) {
arch.Archiver.WaitForStart()
require.Len(arch.ExitSignal(), 0)

status := httpGet(t, "http://"+listener.Addr().String()+"/status")
require.Contains(status, "OK")

require.EventuallyWithT(
func(c *assert.CollectT) {
num, err := arch.Storage().GetMaxArchivedMiniblockNumber(ctx, streamId)
Expand Down
6 changes: 5 additions & 1 deletion core/node/rpc/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ import (
)

func (s *Service) getStatusReponse() *statusinfo.StatusResponse {
var addr string
if s.wallet != nil {
addr = s.wallet.Address.Hex()
}
return &statusinfo.StatusResponse{
Status: s.GetStatus(),
InstanceId: s.instanceId,
Address: s.wallet.Address.Hex(),
Address: addr,
Version: version.GetFullVersion(),
StartTime: s.startTime.UTC().Format(time.RFC3339),
Uptime: time.Since(s.startTime).String(),
Expand Down

0 comments on commit e6a4ea2

Please sign in to comment.