aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2021-12-22 16:05:08 -0800
committerchrislu <chris.lu@gmail.com>2021-12-22 16:05:08 -0800
commit4c1368d621d452232d5d9e0cad466760353ac443 (patch)
tree9261613c64b951480e5e133a7755cd9f362be9a3
parent7b78fc72b04e1ebdd4a4a2496c341b83c53938ad (diff)
downloadseaweedfs-4c1368d621d452232d5d9e0cad466760353ac443.tar.xz
seaweedfs-4c1368d621d452232d5d9e0cad466760353ac443.zip
fix test
-rw-r--r--weed/filer/reader_at.go3
-rw-r--r--weed/filer/reader_at_test.go35
2 files changed, 22 insertions, 16 deletions
diff --git a/weed/filer/reader_at.go b/weed/filer/reader_at.go
index 5f58b870c..35e0012c8 100644
--- a/weed/filer/reader_at.go
+++ b/weed/filer/reader_at.go
@@ -186,6 +186,9 @@ func (c *ChunkReadAt) readChunkSlice(chunkView *ChunkView, nextChunkViews *Chunk
if len(chunkSlice) > 0 {
return chunkSlice, nil
}
+ if c.lookupFileId == nil {
+ return nil, nil
+ }
chunkData, err := c.readFromWholeChunkData(chunkView, nextChunkViews)
if err != nil {
return nil, err
diff --git a/weed/filer/reader_at_test.go b/weed/filer/reader_at_test.go
index f8e4727ce..411d7eb3b 100644
--- a/weed/filer/reader_at_test.go
+++ b/weed/filer/reader_at_test.go
@@ -22,7 +22,7 @@ func (m *mockChunkCache) GetChunk(fileId string, minSize uint64) (data []byte) {
}
func (m *mockChunkCache) GetChunkSlice(fileId string, offset, length uint64) []byte {
- return nil
+ return m.GetChunk(fileId, length)
}
func (m *mockChunkCache) SetChunk(fileId string, data []byte) {
@@ -64,11 +64,12 @@ func TestReaderAt(t *testing.T) {
}
readerAt := &ChunkReadAt{
- chunkViews: ViewFromVisibleIntervals(visibles, 0, math.MaxInt64),
- lookupFileId: nil,
- readerLock: sync.Mutex{},
- fileSize: 10,
- chunkCache: &mockChunkCache{},
+ chunkViews: ViewFromVisibleIntervals(visibles, 0, math.MaxInt64),
+ lookupFileId: nil,
+ readerLock: sync.Mutex{},
+ fileSize: 10,
+ chunkCache: &mockChunkCache{},
+ readerPattern: NewReaderPattern(),
}
testReadAt(t, readerAt, 0, 10, 10, io.EOF)
@@ -114,11 +115,12 @@ func TestReaderAt0(t *testing.T) {
}
readerAt := &ChunkReadAt{
- chunkViews: ViewFromVisibleIntervals(visibles, 0, math.MaxInt64),
- lookupFileId: nil,
- readerLock: sync.Mutex{},
- fileSize: 10,
- chunkCache: &mockChunkCache{},
+ chunkViews: ViewFromVisibleIntervals(visibles, 0, math.MaxInt64),
+ lookupFileId: nil,
+ readerLock: sync.Mutex{},
+ fileSize: 10,
+ chunkCache: &mockChunkCache{},
+ readerPattern: NewReaderPattern(),
}
testReadAt(t, readerAt, 0, 10, 10, io.EOF)
@@ -142,11 +144,12 @@ func TestReaderAt1(t *testing.T) {
}
readerAt := &ChunkReadAt{
- chunkViews: ViewFromVisibleIntervals(visibles, 0, math.MaxInt64),
- lookupFileId: nil,
- readerLock: sync.Mutex{},
- fileSize: 20,
- chunkCache: &mockChunkCache{},
+ chunkViews: ViewFromVisibleIntervals(visibles, 0, math.MaxInt64),
+ lookupFileId: nil,
+ readerLock: sync.Mutex{},
+ fileSize: 20,
+ chunkCache: &mockChunkCache{},
+ readerPattern: NewReaderPattern(),
}
testReadAt(t, readerAt, 0, 20, 20, io.EOF)