Skip to content

Commit

Permalink
stellar#5412: fixed producer test for caller ctx cancel to be consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
sreuland committed Oct 7, 2024
1 parent ba11f09 commit 9d06613
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ingest/cdp/producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ func TestBSBProducerCallerCancelsCtx(t *testing.T) {
BufferedStorageConfig: DefaultBufferedStorageBackendConfig(1),
}

// prevent the ledgerbuffer from being eagerly async loaded initially up to
// buffer-size ledgers and the requested test range, forces new load attempt
// during GetLedger which is when ctx is checked, test asks for 3 ledger range
// since 2 ledgers are by default eagerly loaded.
pubConfig.BufferedStorageConfig.BufferSize = 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 @@ -218,7 +225,7 @@ func TestBSBProducerCallerCancelsCtx(t *testing.T) {
return mockDataStore, nil
}
assert.ErrorIs(t,
ApplyLedgerMetadata(ledgerbackend.BoundedRange(uint32(2), uint32(3)), pubConfig, ctx, appCallback),
ApplyLedgerMetadata(ledgerbackend.BoundedRange(uint32(2), uint32(4)), pubConfig, ctx, appCallback),
context.Canceled)
}

Expand Down

0 comments on commit 9d06613

Please sign in to comment.