Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,18 +283,15 @@ func TestStreamingChunker_FullChunkCachedAfterPartialRequest(t *testing.T) {
require.NoError(t, err)

// The background goroutine should continue fetching the remaining data.
// Wait for it to complete.
require.Eventually(t, func() bool {
// Try reading the LAST block — if the full chunk is cached this
// will succeed without opening another range reader.
lastOff := int64(storage.MemoryChunkSize) - testBlockSize
slice, err := chunker.Slice(t.Context(), lastOff, testBlockSize)
if err != nil {
return false
}
// Use a blocking Slice call (with timeout) instead of require.Eventually
// to avoid racing condition goroutines against defer chunker.Close().
lastOff := int64(storage.MemoryChunkSize) - testBlockSize
ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)
defer cancel()

return bytes.Equal(data[lastOff:], slice)
}, 5*time.Second, 10*time.Millisecond)
slice, err := chunker.Slice(ctx, lastOff, testBlockSize)
require.NoError(t, err)
require.True(t, bytes.Equal(data[lastOff:], slice))

// Exactly one OpenRangeReader call should have been made for the entire
// chunk, not one per requested block.
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/pkg/storage/storage_cache_seekable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ func TestCachedSeekable_ReadAt_PreservesEOF(t *testing.T) {
n, err := c.ReadAt(t.Context(), buff, 0)
assert.Equal(t, 3, n)
require.ErrorIs(t, err, io.EOF, "cachedSeekable must not swallow io.EOF")

c.wg.Wait()
})

t.Run("nil error from inner is returned to caller unchanged", func(t *testing.T) {
Expand Down
Loading