Skip to content

Commit

Permalink
Merge branch 'master' into desc-query-bound
Browse files Browse the repository at this point in the history
  • Loading branch information
tamirms authored Oct 8, 2024
2 parents 858ed71 + 7950d42 commit 6555e4d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ingest/cdp/producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ func TestBSBProducerCallerCancelsCtx(t *testing.T) {
BufferedStorageConfig: DefaultBufferedStorageBackendConfig(1),
}

pubConfig.BufferedStorageConfig.NumWorkers = 1

// the buffering runs async, test needs to stub datastore methods for potential invocation,
// but is race, since test also cancels the backend context which started the buffer,
// so, not deterministic, no assert on these.
Expand All @@ -205,15 +207,20 @@ func TestBSBProducerCallerCancelsCtx(t *testing.T) {
FilesPerPartition: 1,
})

mockDataStore.On("GetFile", mock.Anything, "FFFFFFFD--2.xdr.zstd").Return(makeSingleLCMBatch(2), nil)
mockDataStore.On("GetFile", mock.Anything, "FFFFFFFD--2.xdr.zstd").
Run(func(args mock.Arguments) {
cancel()
}).
Return(makeSingleLCMBatch(2), nil)
// this second attempt needs to be mocked, ledger buffer queues this 'next' sequence task automatically
// in getFromLedgerQueue after it receives "FFFFFFFD--2.xdr.zstd", the ctx is not checked then or in
// the async worker routine that receives the task.
mockDataStore.On("GetFile", mock.Anything, "FFFFFFFC--3.xdr.zstd").Return(makeSingleLCMBatch(3), nil)

appCallback := func(lcm xdr.LedgerCloseMeta) error {
return nil
}

cancel()

datastoreFactory = func(_ context.Context, _ datastore.DataStoreConfig) (datastore.DataStore, error) {
return mockDataStore, nil
}
Expand Down

0 comments on commit 6555e4d

Please sign in to comment.