Skip to content

Commit

Permalink
Change ingestion lag warn time
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya1702 committed Nov 18, 2024
1 parent e82e12c commit 0fc81d4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/services/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
const (
rpcHealthCheckSleepTime = 5 * time.Second
rpcHealthCheckMaxWaitTime = 60 * time.Second
ingestHealthCheckMaxWaitTime = 60 * time.Second
ingestHealthCheckMaxWaitTime = 90 * time.Second
)

type IngestService interface {
Expand Down
24 changes: 20 additions & 4 deletions internal/services/ingest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,16 @@ func TestIngest_LatestSyncedLedgerBehindRPC(t *testing.T) {
defer dbConnectionPool.Close()

models, _ := data.NewModels(dbConnectionPool)
mockAppTracker := apptracker.MockAppTracker{}
mockRPCService := RPCServiceMock{}
mockRouter := tssrouter.MockRouter{}
tssStore, _ := tssstore.NewStore(dbConnectionPool)
ingestService, _ := NewIngestService(models, "ingestionLedger", nil, &mockRPCService, &mockRouter, tssStore)

tssStore, err := tssstore.NewStore(dbConnectionPool)
require.NoError(t, err)

ingestService, err := NewIngestService(models, "ingestionLedger", &mockAppTracker, &mockRPCService, &mockRouter, tssStore)
require.NoError(t, err)

srcAccount := keypair.MustRandom().Address()
destAccount := keypair.MustRandom().Address()

Expand Down Expand Up @@ -283,6 +289,7 @@ func TestIngest_LatestSyncedLedgerBehindRPC(t *testing.T) {
OldestLedgerCloseTime: int64(1),
}
mockRPCService.On("GetTransactions", int64(50), "", 50).Return(mockResult, nil).Once()
//mockAppTracker.On("CaptureMessage", "ingestion service stale for over 1m0s").Maybe()

err = ingestService.Run(context.Background(), uint32(49), uint32(50))
require.NoError(t, err)
Expand All @@ -299,7 +306,9 @@ func TestTrackRPCServiceHealth_HealthyService(t *testing.T) {
mockRPCService := &RPCServiceMock{}
mockAppTracker := &apptracker.MockAppTracker{}
heartbeat := make(chan entities.RPCGetHealthResult, 1)
ctx := context.Background()

ctx, cancel := context.WithTimeout(context.Background(), 70*time.Second)
defer cancel()

healthResult := entities.RPCGetHealthResult{
Status: "healthy",
Expand All @@ -309,7 +318,14 @@ func TestTrackRPCServiceHealth_HealthyService(t *testing.T) {
}
mockRPCService.On("GetHealth").Return(healthResult, nil)

go trackRPCServiceHealth(ctx, heartbeat, mockAppTracker, mockRPCService)
go func() {
select {
case <-ctx.Done():
return
default:
trackRPCServiceHealth(context.Background(), heartbeat, nil, mockRPCService)
}
}()

select {
case result := <-heartbeat:
Expand Down

0 comments on commit 0fc81d4

Please sign in to comment.